  var theDIV; // we will set this to an id that actually exists in the page


//==================================== new to solve back button prob ===========================
function pagenavdonenews(x,y)
{
    var urlparams = {month: x, year: y};
    AJAX.execute("ajx.php", urlparams, displayresult);
}

function pagenavdoneprimenews(pagename)
{
    var urlparams = {news_main: pagename};

    AJAX.execute("ajx.php", urlparams, displayresult);
}

function pagenavdoneprime(pagename)
{
    var urlparams = {prime: pagename};
    
    AJAX.execute("ajx.php", urlparams, displayresult);
}

function pagenavdonecat(pagename)
{
    var urlparams = {category: pagename};
    AJAX.execute("ajx.php", urlparams, displayresult);
}

function pagenavdoneprod(pagename)
{
    var urlparams = {prod_id: pagename};
    AJAX.execute("ajx.php", urlparams, displayresult);
}

function displayresult(ajaxRequest)
{
    var myString = ajaxRequest.responseText;
		//alert(theDIV+" "+ajaxRequest.responseText);

        var myStringArray = myString.split("###WML###");


		var myDivArray = theDIV.split(";;---DIV---;;");
		var i=0;
		while(i<myDivArray.length) {
			e = document.getElementById(myDivArray[i]);
        	e.innerHTML = myStringArray[i];

			i++;
		}
     //document.getElementById('products').innerHTML=ajaxRequest.responseText;
}

//==============================================================================================
  
  var http_request = false;
  function fromServer()
  {
  	//alert(theDIV);
    if( http_request.readyState==4 )
    {
      if( http_request.status==200 )
      {
		// results from call to the sql appear here
		// in http_request.responseText;

		//alert(theDIV+" "+http_request.responseText);
        
        e = document.getElementById(theDIV);
        if(e != null)        e.innerHTML = http_request.responseText;
		
      }
      else
      {
		// uncomment next line if you want to show any error messages
        alert('error: ' + http_request.responseText);
      }
    }
  }

  function fromServer3()
  {
  	//alert(theDIV);
    if( http_request.readyState==4 )
    {
      if( http_request.status==200 )
      {
		// results from call to the sql appear here
		// in http_request.responseText;

		//alert(theDIV+" "+http_request.responseText);
        
        window.location = http_request.responseText;

      }
      else
      {
		// uncomment next line if you want to show any error messages
        alert('error: ' + http_request.responseText);
      }
    }
  }
  
  function fromServerSpecial()
  {
    if( http_request.readyState==4 )
    {
      if( http_request.status==200 )
      {
		// results from call to the sql appear here
		// in http_request.responseText;
		var myString = http_request.responseText;  
		//alert(http_request.responseText);  
        var myStringArray = myString.split("###WML###");  
		
		
		var myDivArray = theDIV.split(";;---DIV---;;");
		var i=0;
		while(i<myDivArray.length) {
			e = document.getElementById(myDivArray[i]); 
        	e.innerHTML = myStringArray[i];

			i++;
		}
      }
      else
      {
		// uncomment next line if you want to show any error messages
        //alert('error: ' + http_request.responseText);
      }
    }
  }

  //=====================================================================================  

  function makeRequest(url, parameters) 
  {

    http_request = false;

    if( window.XMLHttpRequest ) 
    { 
      // Mozilla, Safari,...
      http_request = new XMLHttpRequest();
      if (http_request.overrideMimeType) 
      { http_request.overrideMimeType('text/html');
      }
    } 
    else if (window.ActiveXObject) 
    { // IE
      try 
      { http_request = new ActiveXObject("Msxml2.XMLHTTP");
      } 
      catch (e) 
      { try
        { http_request = new ActiveXObject("Microsoft.XMLHTTP");
        } catch (e) {}
      }
    }
    if (!http_request) 
    {
	// uncomment next line if you want to show any error messages
      alert('Cannot create XMLHTTP instance');
      
	  return false;
	  
    }

    http_request.onreadystatechange = fromServer;
    http_request.open('GET', url + parameters, true);
    http_request.send(null);
  }

  function makeRequest3(url, parameters)
  {

    http_request = false;

    if( window.XMLHttpRequest )
    {
      // Mozilla, Safari,...
      http_request = new XMLHttpRequest();
      if (http_request.overrideMimeType)
      { http_request.overrideMimeType('text/html');
      }
    }
    else if (window.ActiveXObject)
    { // IE
      try
      { http_request = new ActiveXObject("Msxml2.XMLHTTP");
      }
      catch (e)
      { try
        { http_request = new ActiveXObject("Microsoft.XMLHTTP");
        } catch (e) {}
      }
    }
    if (!http_request)
    {
	// uncomment next line if you want to show any error messages
      alert('Cannot create XMLHTTP instance');

	  return false;

    }

    http_request.onreadystatechange = fromServer3;
    http_request.open('GET', url + parameters, true);
    http_request.send(null);
  }

  function makeRequestSpecial(url, parameters)
  {
    http_request = false;
    if( window.XMLHttpRequest ) 
    { 
      // Mozilla, Safari,...
      http_request = new XMLHttpRequest();
      if (http_request.overrideMimeType) 
      { http_request.overrideMimeType('text/html');
      }
    } 
    else if (window.ActiveXObject) 
    { // IE
      try 
      { http_request = new ActiveXObject("Msxml2.XMLHTTP");
      } 
      catch (e) 
      { try
        { http_request = new ActiveXObject("Microsoft.XMLHTTP");
        } catch (e) {}
      }
    }
    if (!http_request) 
    {
// uncomment next line if you want to show any error messages
      alert('Cannot create XMLHTTP instance');
      
	  return false;
	  
    }
	
    http_request.onreadystatechange = fromServerSpecial;
    http_request.open('GET', url + parameters, true);
    http_request.send(null);
  }

//=========================================================================================================
 
  function getNews(id)
  {
    var url = "ajx.php"

    theDIV='newsThumb';
    qry = "?getNews="+id;
	makeRequest(url,qry);
    return false;
  }

  function getChildCat(parent){
	var url = "ajx.php"
//alert('1');
    theDIV='productFunct;;---DIV---;;breadcrumb';
    qry = "?parent="+parent;
	makeRequestSpecial(url,qry);
    return false;
  }

  function getProductlist(category){
	theDIV='products;;---DIV---;;leftProduct';
    //alert('2');
    top.frames["historyframe"].location.href = "page_hist.php?c="+category;
    var url = "ajx.php"

    //theDIV='products;;---DIV---;;leftProduct;;---DIV---;;paging;;---DIV---;;breadcrumb';
    qry = "?category="+category;
	//makeRequest(url,qry);
    return false;
  }
 
  function getProdDetail(prod_id){
    theDIV='products;;---DIV---;;leftProduct';
    top.frames["historyframe"].location.href = "page_hist.php?p="+prod_id;

    var url = "ajx.php"
   
    qry = "?prod_id="+prod_id;
	//makeRequestSpecial(url,qry);
    return false;
  }
  
  function pagingRandProd(page,arr) {
	var url = "ajx.php"
	
	var str = "";
	
	for(i=0;i<3;i++){
		if(str == "") str = arr[(page-1)*3 + i];
		else str = str + "," + arr[(page-1)*3 + i];
	}

    theDIV='leftProduct';
    qry = "?left_prod_id="+str;
	makeRequest(url,qry);
    return false;
  }
  
  function pagingCategorizedProd(category,page) {
	var url = "ajx.php"

    theDIV='leftProduct';
    qry = "?categorizedPage="+page+"&cat="+category;
	makeRequest(url,qry);
    return false;
  }
  
  function getNewsFromPeriode(month,year) {
	var url = "ajx.php"

    theDIV='newsList';

    top.frames["historyframe"].location.href = "page_hist_news.php?m="+month+"&y="+year;
    //qry = "?month="+month+"&year="+year;
	//makeRequest(url,qry);
    return false;
  }
  
  function getSpecificNews(news_id) {
	var url = "ajx.php"

    theDIV='news';
    qry = "?news_id="+news_id;
	makeRequest(url,qry);
    return false;
  }

  function vendorHit(vendor_id) {
	var url = "ajx.php"

    theDIV='products';
    qry = "?vendor_id="+vendor_id; 
	makeRequest3(url,qry);
    return false;
  }
  
  function getEvent(event_id) {
	var url = "ajx.php"

    theDIV='event';
    qry = "?event_id="+event_id;
	makeRequest3(url,qry);
    return false;
  }
  
  function newPagingBlock(cat,startPage) {
	var url = "ajx.php"

    theDIV='leftProduct;;---DIV---;;paging';
    qry = "?cat="+cat+"&startpage="+startPage;
	makeRequestSpecial(url,qry);
    return false;
  }
  