/*
    (c) Copyright Mobile Bridges Ltd 2005. All Rights Reserved.

    Project: Project independent
    Version: 1.0
    Date:    04-03-2006

    Description: Eventhandler for ActionForm, generated by Code Generator
*/

function OnFilter()
{
    OnAction("Filter");
}

function OnSelect()
{
    OnAction("Select");
}

function OnEdit()
{
    OnAction("Load");
}

function OnInsert()
{
    OnAction("Add");
}

function OnRemove(inConfirmation)
{
    var isConfirmed = true;

    if (inConfirmation.length)
        isConfirmed = confirm(inConfirmation);

    if (isConfirmed)
        OnAction("Remove");
}

function OnCancel()
{
    OnAction("Load");
}

function OnSave()
{
    OnAction("Save");
}

function OnAction(inAction)
{
    var theForm = document.getElementById("ActionForm");

    theForm.theAction.value = inAction;
    theForm.submit();
}

function OnBack(inPage, inAction)
{
    var theForm = document.getElementById("ActionForm");

    theForm.Page.value = inPage;
    theForm.theAction.value = inAction;

    theForm.action = "";
    theForm.submit();
}

function OnConfirm(inConfirmation, inPage, inAction)
{
    var isConfirmed = true;

    if (inConfirmation.length)
        isConfirmed = confirm(inConfirmation);

    if (isConfirmed)
    {
        var theForm = document.getElementById("ActionForm");

        theForm.Page.value = inPage;
        theForm.theAction.value = inAction;

        theForm.action = "";
        theForm.submit();
    }
}

function RestoreSelectBox(inName, inValue)
{
    var theSelectBox = document.getElementById(inName);
    if (theSelectBox)
    {
        var theOptions = theSelectBox.options;
        for (i=0;i<theOptions.length;i++)
        {
            if (theOptions[i].value == inValue)
            {
                theOptions[i].selected = true;
                return true;
            }
        }
    }
}

function RestoreCheckBox(inName)
{
    var theCheckBox = document.getElementById(inName);
    if (theCheckBox)
        theCheckBox.checked = !theCheckBox.checked;
}
function OnChangeLanguage(inLanguageCode){
    var theForm = document.getElementById("ActionForm");
    theForm.Code.value = inLanguageCode;
    theForm.theAction.value = "ChangeLanguage"; 
    theForm.Location.value = document.location.href; 
    theForm.submit();
}

function RestoreRadioButtonGroup(inName, inValue)
{
    var theChildNodes = document.getElementsByTagName("input");
    for (i=0;i<theChildNodes.length;i++)
    {
        var theChildNode = theChildNodes.item(i);
        if (theChildNode.getAttribute("id") == inName) {
            theChildNode.checked = true;
            return;
        }
    }
}
function OnLoadLanguage(inAction, language)
{
    var theForm = document.getElementById("ActionForm");
    theForm.theAction.value = inAction;
    theForm.Language.value = language;
    theForm.submit();
}

function AcceptNum()
{
    $("#Msisdn").keypress(function (e) {
        var charCode = (e.which) ? e.which : e.keyCode
        return (charCode == 45 || charCode == 13 || charCode == 8 || charCode == 9 || charCode== 189 || (charCode >= 48 && charCode <= 58) ) ;        

    })  
}