// This creates a XMLRequest (ActiveXObject) to be sent to the server
var XmlReq;
// This page returns the XML Response for the selected choice
var AjaxServerPageName = "AjaxServer.aspx";

function CreateXmlReq()
{
	try
	{
		XmlReq = new ActiveXObject("Msxml2.XMLHTTP");
	}
	catch(e)
	{
		try
		{
			XmlReq = new ActiveXObject("Microsoft.XMLHTTP");
		} 
		catch(oc)
		{
			XmlReq = null;
		}
	}
	if(!XmlReq && typeof XMLHttpRequest != "undefined") 
	{
		XmlReq = new XMLHttpRequest();
	}
}
function getPageInfo(fileName)
{

	//imgtbl.style.visibility = 'visible';
	
	var requestUrl = AjaxServerPageName + "?filename=" + fileName;
	CreateXmlReq();
	
	if(XmlReq)
	{
		XmlReq.onreadystatechange = HandleResponse;
		XmlReq.open("GET", requestUrl,  true);
		XmlReq.send("");		
	}
}

function HandleResponse()
{
    if(XmlReq.readyState == 4)
	{
		if(XmlReq.status == 200)
		{			
			// Before filling new contents into the DataGrid, clear the cotents by calling this function
			//ClearTable();
			// Fill the cleared Datagrid with new XML Reponse
			result = XmlReq.responseText;
			document.getElementById('myspan').innerHTML = result; 
			// Hides the Process Image Table after displaying the contents
			//imgtbl.style.visibility = 'hidden';
		}
		else
		{
			alert("There was a problem retrieving data from the server." );
		}
	}
}
function funToggle(v)
        {
        v=v.split('&id');
        
        var txtHidden = document.getElementById("ctl00_txtHidden")
            var obj = document.getElementById("ctl00_pnl_" + v[0])
            obj.style.display=( (obj.style.display=='none') ? '' : 'none');
        if(obj.style.display=='')
        {
                set_cookie( "hiddenmenu", v, 7 );
        }
        else
        {
             set_cookie( "hiddenmenu", '', 7 );
        }
        
        var selectedCount = 0;
  var element;
   var coo = '';
coo = get_cookie("hiddenmenu");
  for (var i = 0; i < document.forms[0].elements.length; i++)
  {
    element = document.forms[0].elements[i];

    switch (element.type)
    {
      case 'text':
        if (element.value.length > 0)
        {
          selectedCount++;
        }
        break;
      case 'select-one':
        if (element.selectedIndex > 0)
        {
          selectedCount++;
        }
        break;
      case 'button':
        
        var pn = 'ctl00_pnl_' + element.value;
        var pnl = document.getElementById(pn);
       
        try
        {
        
        if(coo == element.value)
        {
        
        }
        else
        {
            pnl.style.display='none';
        }
        }
        catch(e)
        {
        //coo = '';
        }
        
        if (element.selectedIndex > 0)
        {
          selectedCount++;
        }
        break;
       default:
       
       break;
    }
  }

            
    
        }
        
     function get_cookie ( cookie_name )
        {
            var cookie_string = document.cookie ;
        if (cookie_string.length != 0) 
        {
            var cookie_value = cookie_string.match('(^|;)[\s]*' + cookie_name + '=([^;]*)' );
            return decodeURIComponent ( cookie_value[2] ) ;
        }
        return '' ;
        }
        
        function set_cookie ( cookie_name, cookie_value,lifespan_in_days, valid_domain )
        {
            var domain_string = valid_domain ?
                       ("; domain=" + valid_domain) : '' ;
    document.cookie = cookie_name +
                       "=" + encodeURIComponent( cookie_value ) +
                       "; max-age=" + 60 * 60 *
                       24 * lifespan_in_days +
                       "; path=/" + domain_string ;
        }




//////////search code///////////


function SearchSiteSubmit(myfield, e)  //kayaguru search code
{
    
        var keycode;
        if (window.event)
                keycode = window.event.keyCode;
        else if (e)
                keycode = e.which;
        else 
                return true;
         if (keycode == 13)
        {
                SearchSite();
                return false;
        }
        else 
                return true;

}

    
    function SearchSite()   //kayaguru search site code top menu
  {
    
    var q = document.getElementById('ctl00_ControlTopMenu1_q');
    var sa = document.getElementById('ctl00_ControlTopMenu1_sa');
    document.location.href='Kayagurusearch.aspx?cx=001314527110842220634:zz-xawmizcm&cof=FORID:11&ie=UTF-8&q='+URLEncode(q.value) + '&sa=Search';
    return false; 
  }
function URLEncode (clearString) {
  var output = '';
  var x = 0;
  clearString = clearString.toString();
  var regex = /(^[a-zA-Z0-9_.]*)/;
  while (x < clearString.length) {
    var match = regex.exec(clearString.substr(x));
    if (match != null && match.length > 1 && match[1] != '') {
    	output += match[1];
      x += match[1].length;
    } else {
      if (clearString[x] == ' ')
        output += '+';
      else {
        var charCode = clearString.charCodeAt(x);
        var hexVal = charCode.toString(16);
        output += '%' + ( hexVal.length < 2 ? '0' : '' ) + hexVal.toUpperCase();
      }
      x++;
    }
  }
  return output;
}


//open new window
function modelesswin(url,mwidth,mheight){
    mwidth=="1024";
    mheight=="768";
if (document.all&&window.print) //if ie5
eval('window.open(url,"","toolbar,menubar,resizable,dialogWidth:'+mwidth+'px,dialogHeight:'+mheight+'px,scrollbars")')
else
eval('window.open(url,"","toolbar,menubar,resizable,width='+mwidth+'px,height='+mheight+'px,scrollbars")')
//menubar, toolbar, location, directories, status, scrollbars, resizable, dependent, width=640, height=480, left=0, top=0'
}
