﻿function getCookie(NameOfCookie)
{
 try
 {     
    if (document.cookie.length > 0) 
    { 
        begin = document.cookie.indexOf(NameOfCookie+"="); 
        if (begin != -1) 
        { 
        begin += NameOfCookie.length+1; 
        end = document.cookie.indexOf(";", begin);
        if (end == -1) end = document.cookie.length;     
        return unescape(document.cookie.substring(begin, end));
        } 
    }
    return null; 
   }
   catch(ex)
   {
   errMessage('FNC502:'+ex.description)
   } 
}

function setCookie(NameOfCookie, value, expiredays) 
{
    try
    {       
        var ExpireDate = new Date ();
        ExpireDate.setTime(ExpireDate.getTime() + (expiredays * 24 * 3600 * 1000));
        document.cookie = NameOfCookie + "=" + escape(value) +        
        ((expiredays == null) ? "" : "; expires=" + ExpireDate.toGMTString());
     
    }
    catch(ex)
    {
        errMessage('FNC503:'+ex.description)
    } 
}

function delCookie(NameOfCookie) 
{
    try
    {      
        if (getCookie(NameOfCookie)) 
        {
            document.cookie = NameOfCookie + "=" +"; expires=Thu, 01-Jan-70 00:00:01 GMT";
        }
    }
    catch(ex)
    {
    errMessage('FNC504:'+ex.description)
    } 
}

var objXmlHttp;
function GetXmlHttpObject()
{
    /*Below two ActiveXObject depending on the version of MSXML installed.
     It is for internet explorer.
    */
    try 
    {
    objXmlHttp = new ActiveXObject("Msxml2.XMLHTTP");
    } 
    catch (e)
    {
        try
        {
        objXmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
        } 
        catch (E)
        {
        objXmlHttp = false;
        }
    }
//Mozilla and Safari

if (!objXmlHttp && typeof XMLHttpRequest!='undefined')
 {
	try
	{
		objXmlHttp = new XMLHttpRequest();
	}
	 catch (e) 
	{
		objXmlHttp=false;
	}	
}

//IceBrowser
if (!objXmlHttp && window.createRequest) 
   {
	try
	{
		objXmlHttp = window.createRequest();
	} 
	catch (e) 
	{
		objXmlHttp=false;
	}
}
return objXmlHttp;
}

function stateChanged()
{
 if(objXmlHttp.readyState==4 || objXmlHttp.readyState=='complete')
   {       
       if (objXmlHttp.status == 200) 
       {
          
           FillChdPwd(objXmlHttp.responseXML.documentElement)
       }
   }
}

function GetinnerHTML(node)
{
 return(node.innerHTML || node.textContent || node.text);
}


function isNumeric(e,objId) {
try{
    var ch;   
    
    if (navigator.appName == "Microsoft Internet Explorer") {
        ch = event.keyCode;
        if (!((ch >= 48 && ch <= 57) || ch == 0 || ch == 8)) {
            //document.getElementById(msgId).innerHTML = "Enter only numeric values(0-9)."
            event.keyCode = 0;
        }   
    }
    else {
        ch = e.which;
        
        var otxtTT ='ctl00_ContentPlaceHolder1_'+objId;
       
         otxtTT=document.getElementById(otxtTT); 
          alert(otxtTT)
        if (!((ch >= 48 && ch <= 57) || ch == 0 || ch == 8)) {            
            //document.getElementById(msgId).innerHTML = "Enter only numeric values(0-9)."            
            $(otxtTT).val("");
        }   
    }
    }
            catch(ex){
              alert(ex.description)
            }
}


// Numeric only control handler
jQuery.fn.ForceNumericOnly =
function()
{
    return this.each(function()
    {
        $(this).keydown(function(e)
        {
            var key = e.charCode || e.keyCode || 0;
            // allow backspace, tab, delete, arrows, numbers and keypad numbers ONLY
            return (
                key == 8 || 
                key == 9 ||
                key == 46 ||
                (key >= 37 && key <= 40) ||
                (key >= 48 && key <= 57) ||
                (key >= 96 && key <= 105));
        })
    })
};


function maskInput() {
        var key_code = window.event.keyCode;
        var oElement = window.event.srcElement;
        if (!window.event.shiftKey && !window.event.ctrlKey && !window.event.altKey) {
                if ((key_code > 47 && key_code < 58) ||
                          (key_code > 95 && key_code < 106)) {
                                if (key_code > 95) 
                                        key_code -= (95-47);
                           oElement.value = oElement.value;
                } else if(key_code == 8) {
                        oElement.value = oElement.value;
                } else if(key_code != 9) {
                        event.returnValue = false;
                }    
        }
    }
    
    function queryStringValue(findName){
var name = new String();
var value = new String();
var querystring = document.location.href;
if(querystring.indexOf("?")==-1){
return "null";
}
querystring = querystring.split("?");
querystring = querystring[1].split("&");
for(q=0;q<querystring.length;q++){
var pair = querystring[q].split("=");
name = pair[0].toLowerCase();
value = pair[1].toLowerCase();
if(findName.toLowerCase() == name){
return value;
}
}
}

function getPageName()
{
    var path=window.location.pathname;
    var pageName;            
    pageName=path.substring(path.lastIndexOf('/')+1);
    return pageName;
}
