﻿//---------------------------------------------------------
//This function will call the StateSaver.aspx page using ajax 
//and saves a value in the session.
oXmlhttp = null;

function PersistState(key,value)
{  
  // code for Mozilla, etc.
  if (window.XMLHttpRequest)
  {
    oXmlhttp = new XMLHttpRequest()
  }
  //code for IE
  else if(window.ActiveXObject)
  {
    oXmlhttp = new ActiveXObject("Microsoft.XMLHTTP")
  }
  
  if(oXmlhttp!=null)
  { 
    //Get the url for the request
    var sURL = "http://" + location.hostname + "/AB/Common/StateSaver.aspx?key=" + key + "&value=" + value;         
    oXmlhttp.onreadystatechange = StateChangeCallBack;
    oXmlhttp.open("GET",sURL,true);
    oXmlhttp.send(null);
  }
}

//This is the callback function for the PersistState PersistState
function StateChangeCallBack()
{
  // if xmlhttp shows "loaded"
  if (oXmlhttp.readyState==4)
  {
    // if "OK"
    if (oXmlhttp.status==200)
    {
      
    }
    else
    {
      alert("Problem retrieving XML data")
    }
  }
}

//This Function will check in the session for the right url to return 2
//It will do it using ajax and the Get 
function GetPrevAddress()
{
 //New feature - if we are in the units pages redirect back to a speific page: 
	if ((location.href.indexOf("units") != -1) && (location.href.indexOf("unit100") != -1))
 {
  
	return  "http://" + location.hostname + "/AB/Lashon/kesem/TextMenu.aspx";
 }
  
 // code for Mozilla, etc.
  if (window.XMLHttpRequest)
  {
    oXmlhttp = new XMLHttpRequest();
  }
  //code for IE
  else if(window.ActiveXObject)
  {
    oXmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
  }
  
  if(oXmlhttp!=null)
  { 
    //Get the url for the request
    var sURL = "http://" + location.hostname + "/AB/Common/GetNavigationHelperURL.aspx";             
    oXmlhttp.open("GET",sURL,false);
    oXmlhttp.send(null);
   // alert(oXmlhttp.responseText);
    return oXmlhttp.responseText;
  }
}




