// JavaScript Document

function getValue()
{
   var pName = location.pathname;
   if (pName.indexOf("OnlineFeedbackForm.aspx")>0)
   {
        return;
   }
   var previousAddress = window.location.toString();
   var heading = "Home Page";
   location.href = "contactus/OnlineFeedbackForm.aspx?pT=" + heading + "&url="+previousAddress ;
}

//This set of functions are used for CURRENT NAV


function GetXmlHttpObject(handler)
{ 
  
    var objXmlHttp = null;
    if (!window.XMLHttpRequest)
    {
        
        objXmlHttp = GetMSXmlHttp();

        if (objXmlHttp != null)
        {
            objXmlHttp.onreadystatechange = handler;
        }
    } 
    else
    {
        // Mozilla | Netscape | Safari
       // alert("entered for mozilla")
        objXmlHttp = new XMLHttpRequest();
       //alert("object created")
        if (objXmlHttp != null)
        {
            if(document.all)
            {
                objXmlHttp.onreadystatechange = handler;
                //alert("handler registered")
            }
            else
            {
            objXmlHttp.onload = handler;
            objXmlHttp.onerror = handler;
            }
        }
    } 
    return objXmlHttp; 
} 

function GetMSXmlHttp() {
    var xmlHttp = null;
    var clsids = ["Msxml2.XMLHTTP.6.0",
                  "Msxml2.XMLHTTP.4.0",
                  "Msxml2.XMLHTTP.3.0",
                  "Msxml2.XMLHTTP",
                  "Microsoft.XMLHTTP"];
                  

    for(var i=0; i<clsids.length && xmlHttp == null; i++) {
        xmlHttp = CreateXmlHttp(clsids[i]);
    }
    return xmlHttp;
}
function CreateXmlHttp(clsid) {
    var xmlHttp = null;
    try {
        xmlHttp = new ActiveXObject(clsid);
        lastclsid = clsid;
        return xmlHttp;
    }
    catch(e) {}
}

function SendXmlHttpRequest(xmlhttp, url) { 
    xmlhttp.open('GET', url, true); 
    //alert("open");
    xmlhttp.send(null); 
}

var xmlHttp; 

function ExecuteCall(url)
{ 
    try 
    { 
        xmlHttp = GetXmlHttpObject(CallbackMethod); 
        SendXmlHttpRequest(xmlHttp, url); 
       //alert("no exception")
    }
    catch(e){
    //alert(e.toString());
    } 
} 
    
//CallbackMethod1 will fire when the state 

//has changed, i.e. data is received back 

function CallbackMethod() 
{ 
    try
    {
     
        //readyState of 4 or 'complete' represents 

        //that data has been returned 
        //alert("coming to the event")
        if (xmlHttp.readyState == 4 || 
            xmlHttp.readyState == 'complete')
        {
            var response = xmlHttp.responseText; 
           
            if (response.length > 0)
            {
                 //update page
          
                document.getElementById("tmessage").innerHTML 
                                                   = response; 
                window.setTimeout("ShowRecords1(0,2)",1000);   
                                       
            } 
        }
    }
    catch(e){
        //alert(e.toString())
    }
}
function voteNAV()
{
    ExecuteCall("Test2.aspx");
}


var currentRecord =-2;

function ShowRecords1(startIndex,recordsCount)
{
    
    var table = document.getElementById("navList");
   
    if(table != null)
    {
    
    var dateLastUpdated = table.title;
    document.getElementById("navLastUpdDate").innerHTML=dateLastUpdated;
    document.getElementById("txtMoreHome").innerHTML="More";
    var totalRecords = table.rows.length;
    currentRecord = currentRecord + recordsCount;
    
    // This is used to hide all the records
    for (i=0;i<totalRecords;i++)
    {
        table.rows[i].style.display = 'none';
    }
    
    // This is used to set the currentRecord
    if (currentRecord > table.rows.length-1)
    {
        currentRecord = 0;
    }                
    // This is used to show only two records at a time (onr record and one line)
    for(i=currentRecord;i<(currentRecord + recordsCount);i++)
    {
        table.rows[i].style.display = '';
    }
    
    //Recursively call this function to continue the cycle
    window.setTimeout("ShowRecords1("+startIndex+","+recordsCount+")",2000);
    }
    else
    {
        
    }
}



//These CURRENT NAV functions ends here





//This set of functions are used for Dynamic dropdown BranchLocator



var Ispopulated = "false";

function Objecthandling(handeldata)
{ 
    var objXml = null;
    if (!window.XMLHttpRequest)
    {
        objXml = GetHttp();
        
        if (objXml != null)
        {
            objXml.onreadystatechange = handeldata;
           
        }
    } 
    else
    {
        // Mozilla | Netscape | Safari
       // alert("entered for mozilla")
        objXml = new XMLHttpRequest();
      
        if (objXml != null)
        {
            if(document.all)
            {
                objXml.onreadystatechange = handeldata;
              
            }
            else
            {
            objXml.onload = handeldata;
            objXml.onerror = handeldata;
            }
        }
    } 
    return objXml; 
}



function GetHttp()
 {
    var getData = null;
    var clsids = ["Msxml2.XMLHTTP.6.0",
                  "Msxml2.XMLHTTP.4.0",
                  "Msxml2.XMLHTTP.3.0",
                  "Msxml2.XMLHTTP",
                  "Microsoft.XMLHTTP"];
    for(var i=0; i<clsids.length && getData == null; i++) {
        getData = CreateHttp(clsids[i]);
    }
    return getData;
}
function CreateHttp(clsid) 
{
    var createData = null;
    try {
       createData = new ActiveXObject(clsid);
        lastclsid = clsid;
        return createData;
    }
    catch(e) {}
}

function SendRequest(SendXML, url)
 { 
    SendXML.open('GET', url, true); 
    SendXML.send(null); 
}





var DataExecute; 

function ExecutethisCall(url)
{ 
    try 
    { 
       DataExecute = Objecthandling(CallbackthisMethod); 
        SendRequest(DataExecute, url); 
       
    }
    catch(e){
    //alert(e.toString());
    } 
} 


//CallbackthisMethod will fire when the state 

//has changed, i.e. data is received back 

function CallbackthisMethod() 
{ 
    try
    {
        //readyState of 4 or 'complete' represents 

        
        if (DataExecute.readyState == 4 || 			 //xmlHttp
            DataExecute.readyState == 'complete')     //xmlHttp
        {
           
            var myresponse = DataExecute.responseText; 
           // alert(myresponse);
            
            if (myresponse.length > 0)
            {

				if(Ispopulated == "false")
                {
				    var my_column = myresponse;
				    var col_array=my_column.split(";");
				    var part_num=0;
				    
			        var optionObject = new Option('----Select----','0');
			        var optionObject1 = new Option('City','City');
			        optionObject1.style.color="#CCCCCC";
                    var optionRank;
                    var optionRank1;
                    //document.getElementById('select4').options[0]=optionObject;
                    
				    if(col_array[0] != "Database Error")
                    {
                        document.getElementById('select4').options[0]=optionObject;
                        document.getElementById('emailqueryCity').options[0]=optionObject1;
				    }
				    while (part_num < col_array.length - 1)
			        {
			            if(col_array[part_num] != '')
				        {
                            optionObject = new Option(col_array[part_num],col_array[part_num]);
                            optionObject1 = new Option(col_array[part_num],col_array[part_num]);
                            optionRank = document.getElementById('select4').options.length;
                            optionRank1 = document.getElementById('emailqueryCity').options.length;
                            document.getElementById('select4').options[optionRank]=optionObject;
                            document.getElementById('emailqueryCity').options[optionRank]=optionObject1;
                            part_num += 1;
                        }
                        
                    }
                    var optionOthers = new Option('Others','Others');
                    document.getElementById('emailqueryCity').options[part_num+1] = optionOthers;
                    document.getElementById('select4').selectedIndex = 0;
                    document.getElementById('emailqueryCity').selectedIndex = 0;
                    Ispopulated = "true";   
                } 
    	                                            
            } 
        }
    }
    catch(e)
	{
        //alert(e.toString())
    }
}

function voteme()
{  
   ExecutethisCall("GetDropDown.aspx");
}



//Dynamic dropdown BranchLocator ends here.




function Dynamicdata()
{   
    voteNAV();    
    voteme();
}


window.setTimeout("Dynamicdata()",1000);