﻿// JScript File
    
    //Regular Function Library
		function findPosX(obj)
        {
            var curleft = 0;
            if(obj.offsetParent)
                while(1) 
                {
                curleft += obj.offsetLeft;
                if(!obj.offsetParent)
                    break;
                obj = obj.offsetParent;
                }
            else if(obj.x)
                curleft += obj.x;
            return curleft;
        }
        
        function findPosY(obj)
        {
            var curtop = 0;
            if(obj.offsetParent)
                while(1)
                {
                curtop += obj.offsetTop;
                if(!obj.offsetParent)
                    break;
                obj = obj.offsetParent;
                }
            else if(obj.y)
                curtop += obj.y;
            return curtop;
        }
        
        
    //Ajax Function Library
    function CreateXmlHttp()
    {
        var xmlRequest;
        //Creating object of XMLHTTP in IE
        try
        {
            xmlRequest = new ActiveXObject("Msxml2.XMLHTTP");
        }
        catch(e)
        {
            try
            {
                xmlRequest = new ActiveXObject("Microsoft.XMLHTTP");
            }
            catch(e1)
            {
                xmlRequest = null;
            }
        }
        //Creating object of XMLHTTP in Mozilla and Safari
        if(!xmlRequest && typeof XMLHttpRequest != "undefined")
        {
            xmlRequest = new XMLHttpRequest();
        }
        return xmlRequest;
    }

    function DoCallback(url,DataToSend)
    {
		var pageUrl = url;
		xmlRequest =CreateXmlHttp(); 
		xmlRequest.open("POST", pageUrl, false);
        xmlRequest.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
        xmlRequest.send(DataToSend);
        return xmlRequest;
    }
    
//    //Function to bind DDl
//    function GetDDLData(comboBoxId, arrayName, showBlankItem, selectedValue)
//    {
//	    var codeArray, descArray;
//	    var opt;
//	    var cb = document.getElementById(comboBoxId);
//	    var separator = '~'; // this is hardcoded for control to differenciate the Value and Text
//	    var emptyString = '';
//	    	    
//	    try
//	    {
//		    eval("codeArray=" + arrayName + "_cd");
//		    eval("descArray=" + arrayName + "_cd");
//	    }
//	    catch (e)
//	    {
//	    alert(e);
//		    // skip to generate js droplist
//		    return;
//	    }

//	    if (showBlankItem)
//	    {
//		    opt = document.createElement("OPTION");
//		    opt.text = emptyString;
//		    opt.value = emptyString + separator;
//		    cb.options.add(opt);
//	    }

//	    if (codeArray != null && codeArray.length != null)
//	    {
//		    for (index = 0; index < codeArray.length; index++)
//		    {
//			    if (selectedValue != '' && selectedValue == codeArray[index])
//			    {
//				    opt = document.createElement("OPTION");
//				    opt.selected = true;
//			    }
//			    else
//			    {
//				    opt = document.createElement("OPTION");
//			    }
//			    opt.value = codeArray[index] + separator + descArray[index];
//			    opt.text = descArray[index];
//			    cb.options.add(opt);
//		    }
//	    }

//    	var self = this;
//		
//		// public members
//		this.hiddenId = "__" + comboBoxId;
//		
//        if ((oSelect = document.getElementById(comboBoxId)))
//		{
//			// create hidden field to store dropdownlist content
//			if (!(hidden = document.getElementById(self.hiddenId)))
//			{
//				hidden = document.createElement("input");
//				hidden.id = self.hiddenId;
//				hidden.name = self.hiddenId;
//				hidden.type = "hidden";
//				oSelect.form.appendChild(hidden);
//			}				

//			// load source data if dropdownlist is empty,
//			// otherwise persist existing content
//			if (oSelect.options.length == 0)
//			{
//				this.load();
//			}
//			else
//			{
//				this.persist(oSelect,self.hiddenId);
//			}
//		}
//    }
//    
//	function persist(oSelect,hiddenCtrl)
//	{
//		var content = "";
//		for(var i=0; i<oSelect.options.length; i++)
//		{
//			content += oSelect.options[i].value + '~';
//		}
//		
//		if (content.substr(content.length-1,1) == '~')
//		{
//			content = content.substr(0, content.length-1);
//		}

//		if ((hidden = document.getElementById(hiddenCtrl)))
//		{
//			hidden.value = content;
//		}
//	}