You're using EditText_SetCurSel in the wrong way. The function takes 2 numbers, and you are passing 2 strings. You should do:
code:
function OnEvent_MenuClicked(MenuItemId,Location,OriginWnd) 
{
var currenttext = OriginWnd.EditText;
switch(MenuItemId) 
{
         case "PHP":
         OriginWnd.EditText_SetCurSel (0, currenttext.length - 1);
         OriginWnd.EditText_ReplaceSel ("[ code=php] [/code ]");
         break;
    }
}
That will replace all text in the edit box with [ code=php][/code ]. To replace it with: [ code=php]oldtext[/code ] use:
code:
function OnEvent_MenuClicked(MenuItemId,Location,OriginWnd) 
{
var currenttext = OriginWnd.EditText;
switch(MenuItemId) 
{
         case "PHP":
         OriginWnd.EditText_SetCurSel (0, currenttext.length - 1);
         OriginWnd.EditText_ReplaceSel ("[ code=php]"+currenttext+"[/code ]");
         break;
    }
}