﻿// ***************** START OF CONVERSTION OF "common_js_function.js" FILE FROM  ASP **DATE: 5/26/2009 2:30PM******************

//Function to retrieve cookie
function GetCookie(name)
{
    var cname = name + "=";
    var dc = document.cookie;
    if (dc.length > 0) 
    {
        begin = dc.indexOf(cname);
	    if (begin != -1)
	    {
	       begin += cname.length;
	       end = dc.indexOf(";", begin);
		    if (end == -1) 
		    {
		        end = dc.length;
		    }
	        return unescape(dc.substring(begin, end));
	    }
    }
    return null;
}

//Function to save cookie
function SetCookie(name, value, expires)
{
	document.cookie = name + "=" + escape(value) + ";path=/" + ((expires==null)?"":";expires=" + expires.toGMTString());
}

//Function to delete a cookie
function delCookie(name)
{
    document.cookie = name + "=; expires=Thu, 01-Jan-70 00:00:01 GMT" + ";path=/";
}

//Split data string 
function poparray(nelements, lc,delimit) 
{
    var arrname = new Array(nelements); 
    var newstring = lc 
    var start_loc = 0 
    var end_loc = newstring.indexOf(delimit) 
	if (nelements == 1) 
    { 
		arrname[0] = newstring 
    } 
	else
	{ 
		for (i=0; i<=nelements-1; i++) 
		{ 
			if (end_loc > 0) 
			{ 
				arrname[i] = newstring.substring(0, end_loc) 
			} 
			else 
			{ 
				arrname[i] = newstring.substring(0) 
			} 		
			newstring = newstring.substring(end_loc+1) 
			end_loc = newstring.indexOf(delimit) 		
		} 
	} 
    return arrname 
}

// ***************** END OF CONVERSTION OF "common_js_function.js" FILE FROM  ASP **DATE: 5/26/2009 2:30PM******************


// This function displays any web page as a popup page, and since it is pretends as a popup page 
// it can avoid the blocking done by the popup blockers on the browsers.
function DisplayPageAsPopup(path,width,height)
{
    if (width > 0 && height > 0)
    {
        GB_showCenter('',path,width,height);
    }
    else
    {
        GB_showCenter('',path,50,50);
    }
    return;
}

//  DIV TAG MOVING CODE -- TAK 7/27/2009 4 PM

    //Global Var   
    //Default Height for Parent Container
    var header_height = 148; //Height of parent header
    //Default Height for Control Center
    var TitleDivTag_Height = 20;
    var TitleBarDivTag_Height = 20;
    var SearchDivTag_Height = 230;
    //Default Height for Gridview - this value will be overwritten
    var GridDivTag_Height = 1;
    	
    function setDivSize() 
    {	
	    //Find IFRAME container width & height 
	    var h = checkHeight();
	    document.getElementById('SearchDivTag').style.height = SearchDivTag_Height + "px";
	    GridDivTag_Height = (h - header_height - TitleDivTag_Height - TitleBarDivTag_Height - SearchDivTag_Height - 20);//15
	    document.getElementById('GridDivTag').style.height = GridDivTag_Height + "px";
    }
    
    function setDivSizeJLG() 
    {	
	    //Find IFRAME container width & height 
	    var h = checkHeight();
	    document.getElementById('SearchDivTag').style.height = SearchDivTag_Height + "px";
	    GridDivTag_Height = (h - header_height - TitleDivTag_Height - TitleBarDivTag_Height - SearchDivTag_Height - 60);//50
	    document.getElementById('GridDivTag').style.height = GridDivTag_Height + "px";
    }

    function checkHeight() 
    {
          var myHeight = 0;
          if( typeof( parent.window.innerWidth ) == 'number' ) {
            //Non-IE
            myHeight = parent.window.innerHeight + 115;
          } else if( parent.document.documentElement && ( parent.document.documentElement.clientWidth || parent.document.documentElement.clientHeight ) ) {
            //IE 6+ in 'standards compliant mode'
            myHeight = parent.document.documentElement.clientHeight + 115;
          } else if( parent.document.body && ( parent.document.body.clientWidth || parent.document.body.clientHeight ) ) {
            //IE 4 compatible
            myHeight = parent.document.body.clientHeight;
          }
          return myHeight;
    }

    function hideSearchOption() {
	    document.getElementById('SearchDivTag').style.display = "none";
	    var h = checkHeight();
	    GridDivTag_Height =  (h - header_height - TitleDivTag_Height - TitleBarDivTag_Height - 35);//30
	    document.getElementById('GridDivTag').style.height = GridDivTag_Height + "px";
    }

    function showSearchOption() {
	    document.getElementById('SearchDivTag').style.display = "";
	    setDivSize();
    }
    
    function recheckDivSize()
    {
        var corporateName = document.getElementById('corporateNameVal');
        
        if (null != corporateName)
        {
            if (corporateName.value == "JLG")
            {
                var t=setInterval("setDivSizeJLG()",1000);
            }
            else
            {
                var t=setInterval("setDivSize()",1000);
            }
        }
        else
        {
            var t=setInterval("setDivSize()",1000);
        }
    }
    
    function toggleSearch(height) {
        document.getElementById('pnlSearchOptions').style.display = "none";
        if (SearchDivTag_Height !=0) { 
            SearchDivTag_Height = 0;
            var h = checkHeight();
            GridDivTag_Height = (h - header_height - TitleDivTag_Height - TitleBarDivTag_Height - SearchDivTag_Height - 15); //10
            document.getElementById('GridDivTag').style.height = GridDivTag_Height + SearchDivTag_Height + "px";
            
        }
        else{
            if(typeof(height) != 'undefined')
            {
                SearchDivTag_Height = height;
            }
            else
            {
                SearchDivTag_Height = 230;
            }
            var h = checkHeight();
            GridDivTag_Height = (h - header_height - TitleDivTag_Height - TitleBarDivTag_Height - SearchDivTag_Height - 15);//10
            document.getElementById('GridDivTag').style.height = GridDivTag_Height + SearchDivTag_Height + "px";
            document.getElementById('pnlSearchOptions').style.display = "block";
        }
    }
