﻿var applicationPath='http://localhost:5451/';


function SwtichTab(dvId, btn, hfAllPanels, hfAllBtns, hfSelectedPanelId, hfSelectedButtonId) {

    var allBnt = new Array();
    var allPnl = new Array();
    
    allPnl = $get(hfAllPanels).value.split(',');
    allBnt = $get(hfAllBtns).value.split(',');

    for (var i = 0; i < allBnt.length; i++) 
    {
        $get(allBnt[i]).className = '';
    }

    for (var j = 0; j < allPnl.length; j++) {
        $get(allPnl[j]).style.display = 'none';
    }
       
    $get(btn).className = 'current';
    $get(dvId).style.display = 'block';

    $get(hfSelectedButtonId).value = btn;
    $get(hfSelectedPanelId).value = dvId;

    return false;
}


// Show and hide left menu.
function ShowHideLeftMenu(TDid, imgID){

    var LeftCol = this.document.getElementById(TDid);
    var ShowHideImg = this.document.getElementById(imgID);

    if(LeftCol != null && ShowHideImg != null)
    {
	    if(LeftCol.style.display=='none'){
		    LeftCol.style.display='inline';

		    Set_Cookie('ShowHideLeftCol','true',30,'/','','');
		    var show = Get_Cookie('ShowHideLeftCol');
		    ShowHideImg.src = applicationPath + 'images/hide_leftcol.gif';
	    }else{
		    LeftCol.style.display='none';

		    Set_Cookie('ShowHideLeftCol','false',30,'/','','');
		    var show = Get_Cookie('ShowHideLeftCol');
		    ShowHideImg.src = applicationPath + 'images/show_leftcol.gif';
	    }
	 }
}

// Sets left menu last settings.
function setLeftMenu(TDid, imgID)
{
    var LeftCol = this.document.getElementById(TDid);
    var ShowHideImg = this.document.getElementById(imgID);

    if(LeftCol != null && ShowHideImg != null)
    {
        if (!Get_Cookie("ShowHideLeftCol")) {
	        Set_Cookie('ShowHideLeftCol','true',30,'/','','');
        }

        var show = Get_Cookie('ShowHideLeftCol');

        if (show == "true") {
	        LeftCol.style.display='inline';
	        ShowHideImg.src = applicationPath + 'images/hide_leftcol.gif';
        } else {
	        LeftCol.style.display='none';
	        ShowHideImg.src = applicationPath + 'images/show_leftcol.gif';
        }
    }
}

//set default postback button

function AnyInput_KeyDown ( e, target ) 
	{ 
		if ((e.which && e.which == 13) || (e.keyCode && e.keyCode == 13)) 
		{ 
			document.getElementById(target).focus();
			return false; 
		} 
			return true; 
	} 

function CheckAllDataGridCheckBoxes(checkVal,expression) {

        re = new RegExp(expression)  

        for(i = 0; i < document.forms[0].elements.length; i++) {

            elm = document.forms[0].elements[i]

            if (elm.type == 'checkbox') {

                if (re.test(elm.name)) {

                    elm.checked = checkVal

                }
            }
        }
    }
    function ChangeParentCheckboxState(parentID, expression) {

        re = new RegExp(expression)

        for (i = 0; i < document.forms[0].elements.length; i++) {

            elm = document.forms[0].elements[i]

            if (elm.type == 'checkbox') {

                if (re.test(elm.name)) {

                    if (elm.checked) {
                        document.getElementById(parentID).checked = true;
                        return true;
                    }
                }
            }
        }

        document.getElementById(parentID).checked = false;
    }
    function doNothing() {
        return false;
    }

    function SetUniqueRadioButton(name, current) {
        for (i = 0; i < document.forms[0].elements.length; i++) {
            elm = document.forms[0].elements[i]
            if (elm.type == 'radio') {
                if (elm.name.indexOf(name) != -1 && elm.id !=current.id) 
                {
                
                    elm.checked = false;
                    elm.value = '';
                }
            }
        }
        current.checked = true;
        
    }
    
    
    function toggleCheckboxWithTick(chk,img) {
    var chkbox = document.getElementById(chk);
    var imgtick= document.getElementById(img);

    if (chkbox.checked) {
        chkbox.checked = false;
        imgtick.style.display = 'none';
    }
    else {
        chkbox.checked = true;
        imgtick.style.display = '';
    }
}


var _ContentFrame = '';
function LoadUrl(_ContentFrame, url) {

    alert("hello how are you");
    _ContentFrame.src = url;
}


function SetDropDownListRadioButton(name) {
    document.getElementById(name).checked = true;
 }
