// Mark Fesco - March 2009
var xmlhttp;

// Global Search Values ------------------------------------------------------------------

var searchp
var litrep
var purposep


//-----------------------------------------------------------------------------------------

function GetXmlHttpObject()
{
var xmlHttp=null;
try
  {
  xmlHttp=new XMLHttpRequest();
  }
catch (e)
  {
  try
    {
    xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
    }
  catch (e)
    {
    xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
    }
  }
return xmlHttp;
}

function searchChange() {
document.getElementById("drillMe").innerHTML="<br/><br/><br/><br/><center><img src=/graphics/common/loader.gif></center>";
      if (xmlHttp.readyState == 4) {        
		 if (xmlHttp.status == 200) {	
		 if(xmlHttp.responseText=="goToFinal"){
		 finishUp();
		 }
		 else{
		 if(xmlHttp.responseText=="goToTempType"){
		tempUp();
		 }
		 		 else{
		 if(xmlHttp.responseText=="goToCapacity"){
		capacUp();
		 }
		 else{	 
           document.getElementById("drillMe").innerHTML=xmlHttp.responseText;    
		   }
		   }
		   }     
         } else {
            alert('There was a problem with the request.');
         }
      }  
} 

//-------------------------------------------------------------------------------------------

function resetMe(){
document.location.href="/Foster-productSearch.asp";
}

function DrillQ1(obj){
var url;
if(obj=="y"){
url="/search/mkii/q1yes.asp";
}
else
{
url="/search/mkii/q1no.asp";
}

url=url+"?r="+new Date().getTime();

var thisLot;
thisLot="$=1";

xmlHttp=GetXmlHttpObject();
if (xmlHttp==null) {
  alert ("Your browser does not support AJAX!");
  return;
  } 
  // // // alert(thisLot);
xmlHttp.onreadystatechange = searchChange;
xmlHttp.open("POST",url,true);
xmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
xmlHttp.setRequestHeader("Content-length", thisLot.length);
xmlHttp.setRequestHeader("Connection", "close");
xmlHttp.send(thisLot);
}

function jumpMe(){
var url;

// // alert(obj);

url="/search/mkii/setPrevious.asp?r="+new Date().getTime();
var thisLot;
thisLot="priCategory=1" 

xmlHttp=GetXmlHttpObject();
if (xmlHttp==null) {
  alert ("Your browser does not support AJAX!");
  return;
  } 
  // // // alert(thisLot);
xmlHttp.onreadystatechange = searchChange;
xmlHttp.open("POST",url,true);
xmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
xmlHttp.setRequestHeader("Content-length", thisLot.length);
xmlHttp.setRequestHeader("Connection", "close");
xmlHttp.send(thisLot);	
	
}

function gotRange(obj){
var url;

// // alert(obj);

url="/search/mkii/setPriCategory.asp?r="+new Date().getTime();
var thisLot;
thisLot="priCategory=" + encodeURIComponent(obj);

xmlHttp=GetXmlHttpObject();
if (xmlHttp==null) {
  alert ("Your browser does not support AJAX!");
  return;
  } 
  // // // alert(thisLot);
xmlHttp.onreadystatechange = searchChange;
xmlHttp.open("POST",url,true);
xmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
xmlHttp.setRequestHeader("Content-length", thisLot.length);
xmlHttp.setRequestHeader("Connection", "close");
xmlHttp.send(thisLot);
}

function gotPri(obj){
var url;

// // alert(obj);

url="/search/mkii/setPriCategory2.asp?r="+new Date().getTime();
var thisLot;
thisLot="priCategory=" + encodeURIComponent(obj);

xmlHttp=GetXmlHttpObject();
if (xmlHttp==null) {
  alert ("Your browser does not support AJAX!");
  return;
  } 
  // // // alert(thisLot);
xmlHttp.onreadystatechange = searchChange;
xmlHttp.open("POST",url,true);
xmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
xmlHttp.setRequestHeader("Content-length", thisLot.length);
xmlHttp.setRequestHeader("Connection", "close");
xmlHttp.send(thisLot);
}

function gotSec(obj){
var url;

//// // alert(obj);

url="/search/mkii/setSecCategory.asp?r="+new Date().getTime();
var thisLot;
thisLot="secCategory=" + encodeURIComponent(obj);

xmlHttp=GetXmlHttpObject();
if (xmlHttp==null) {
  alert ("Your browser does not support AJAX!");
  return;
  } 
// alert(thisLot);
xmlHttp.onreadystatechange = searchChange;
xmlHttp.open("POST",url,true);
xmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
xmlHttp.setRequestHeader("Content-length", thisLot.length);
xmlHttp.setRequestHeader("Connection", "close");
xmlHttp.send(thisLot);
}

function gotTemp(obj){
var url;

// // alert(obj);

url="/search/mkii/setTempType.asp?r="+new Date().getTime();
var thisLot;
thisLot="tempType=" + encodeURIComponent(obj);

xmlHttp=GetXmlHttpObject();
if (xmlHttp==null) {
  alert ("Your browser does not support AJAX!");
  return;
  } 
  // // // alert(thisLot);
xmlHttp.onreadystatechange = searchChange;
xmlHttp.open("POST",url,true);
xmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
xmlHttp.setRequestHeader("Content-length", thisLot.length);
xmlHttp.setRequestHeader("Connection", "close");
xmlHttp.send(thisLot);
}

function getCapacity(obj){
var url;

// // alert(obj);

url="/search/mkii/setCapacity.asp?r="+new Date().getTime();
var thisLot;
thisLot="capacity=" + encodeURIComponent(obj);

xmlHttp=GetXmlHttpObject();
if (xmlHttp==null) {
  alert ("Your browser does not support AJAX!");
  return;
  } 
  // // // alert(thisLot);
xmlHttp.onreadystatechange = searchChange;
xmlHttp.open("POST",url,true);
xmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
xmlHttp.setRequestHeader("Content-length", thisLot.length);
xmlHttp.setRequestHeader("Connection", "close");
xmlHttp.send(thisLot);
}



function finishUp(){
var url;
url="/search/q5.asp"
url=url+"?r="+new Date().getTime();
var thisLot;
thisLot="99=99";
xmlHttp=GetXmlHttpObject();
if (xmlHttp==null) {
  alert ("Your browser does not support AJAX!");
  return;
  } 
  //document.location.href=url;
xmlHttp.onreadystatechange = searchChange;
xmlHttp.open("POST",url,true);
xmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
xmlHttp.setRequestHeader("Content-length", thisLot.length);
xmlHttp.setRequestHeader("Connection", "close");
xmlHttp.send(thisLot);
}

function tempUp(){
var url;
url="/search/mkii/drillTempOption.asp"
url=url+"?r="+new Date().getTime();
var thisLot;
thisLot="99=99";
xmlHttp=GetXmlHttpObject();
if (xmlHttp==null) {
  alert ("Your browser does not support AJAX!");
  return;
  } 
xmlHttp.onreadystatechange = searchChange;
xmlHttp.open("POST",url,true);
xmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
xmlHttp.setRequestHeader("Content-length", thisLot.length);
xmlHttp.setRequestHeader("Connection", "close");
xmlHttp.send(thisLot);
}

function capacUp(){
var url;
url="/search/mkii/drillCapacityOption.asp"
url=url+"?r="+new Date().getTime();
var thisLot;
thisLot="99=99";
xmlHttp=GetXmlHttpObject();
if (xmlHttp==null) {
  alert ("Your browser does not support AJAX!");
  return;
  } 
xmlHttp.onreadystatechange = searchChange;
xmlHttp.open("POST",url,true);
xmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
xmlHttp.setRequestHeader("Content-length", thisLot.length);
xmlHttp.setRequestHeader("Connection", "close");
xmlHttp.send(thisLot);
}



function drillRange(obj){
var url;
url="/search/q5.asp"
url=url+"?r="+new Date().getTime();
var thisLot;
thisLot="cat="+encodeURIComponent(obj);
//alert(thisLot)
xmlHttp=GetXmlHttpObject();
if (xmlHttp==null) {
  alert ("Your browser does not support AJAX!");
  return;
  } 
xmlHttp.onreadystatechange = searchChange;
xmlHttp.open("POST",url,true);
xmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
xmlHttp.setRequestHeader("Content-length", thisLot.length);
xmlHttp.setRequestHeader("Connection", "close");
xmlHttp.send(thisLot);
}

function drillRangeOption(obj){

var url;
url="/search/mkii/drillRangeOption.asp"
url=url+"?r="+new Date().getTime();
var thisLot;
thisLot="purpose="+encodeURIComponent(obj);
//alert(thisLot)
xmlHttp=GetXmlHttpObject();
if (xmlHttp==null) {
  alert ("Your browser does not support AJAX!");
  return;
  } 
xmlHttp.onreadystatechange = searchChange;
xmlHttp.open("POST",url,true);
xmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
xmlHttp.setRequestHeader("Content-length", thisLot.length);
xmlHttp.setRequestHeader("Connection", "close");
xmlHttp.send(thisLot);
}

function drillCabinetOption(obj){

var url;
url="/search/mkii/drillCabinetOption.asp"
url=url+"?r="+new Date().getTime();
var thisLot;
thisLot="purpose="+encodeURIComponent(obj);
//alert(thisLot)
xmlHttp=GetXmlHttpObject();
if (xmlHttp==null) {
  alert ("Your browser does not support AJAX!");
  return;
  } 
xmlHttp.onreadystatechange = searchChange;
xmlHttp.open("POST",url,true);
xmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
xmlHttp.setRequestHeader("Content-length", thisLot.length);
xmlHttp.setRequestHeader("Connection", "close");
xmlHttp.send(thisLot);
}


function drillTempOption(obj){

var url;
url="/search/mkii/drillTempOption.asp"
url=url+"?r="+new Date().getTime();
var thisLot;
thisLot="purpose="+encodeURIComponent(obj);
//alert(thisLot)
xmlHttp=GetXmlHttpObject();
if (xmlHttp==null) {
  alert ("Your browser does not support AJAX!");
  return;
  } 
xmlHttp.onreadystatechange = searchChange;
xmlHttp.open("POST",url,true);
xmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
xmlHttp.setRequestHeader("Content-length", thisLot.length);
xmlHttp.setRequestHeader("Connection", "close");
xmlHttp.send(thisLot);
}



/////////////////////////////////////////////////////////////////////////////////////////////////////////////

function productMe(id){
document.getElementById('divThis').style.display='';
document.getElementById('apDiv1').style.display='';
document.body.scroll="no";
returnProduct(id);
}


function coldroomMe(id){
document.getElementById('divThis').style.display='';
document.getElementById('apDiv1').style.display='';
document.body.scroll="no";

xmlHttp=GetXmlHttpObject();
if (xmlHttp==null)
  {
  alert ("Your browser does not support AJAX!");
  return;
  } 
var url="/coldroomPop.asp";
url=url+"?mid="+id;
//url=url+"&sid="+Math.random();
xmlHttp.onreadystatechange=displayNews;
xmlHttp.open("GET",url,true);
xmlHttp.send(null);
}

function returnProduct(str)
{ 
xmlHttp=GetXmlHttpObject();
if (xmlHttp==null)
  {
  alert ("Your browser does not support AJAX!");
  return;
  } 
  if(str=="coldroom"){
var url="/Coldroom-spec-" + globPage + ".asp";
  } else {
var url="/search/returnProduct.asp";
url=url+"?id="+str;
}
//url=url+"&sid="+Math.random();
xmlHttp.onreadystatechange=displayNews;
xmlHttp.open("GET",url,true);
xmlHttp.send(null);
}



function fireText(obj)
{ 

var heading;

if(obj==1){
heading=2;
}
if(obj==2){
heading=3;
}
if(obj==3){
heading=1;
}
if(obj==4){
heading=4;
}
if(obj==5){
heading=9;
}
if(obj==6){
heading=8;
}
if(obj==7){
heading=7;
}
if(obj==8){
heading=6;
}
if(obj==9){
heading=5;
}
var url="/Coldroom-spec-" + heading + ".asp";

if(obj==15){
//heading=5;
document.location.href="/Foster-products.asp?id=398";
return;
}

xmlHttp=GetXmlHttpObject();
if (xmlHttp==null)
  {
  alert ("Your browser does not support AJAX!");
  return;
  } 

//url=url+"&sid="+Math.random();
xmlHttp.onreadystatechange=fireChange;
xmlHttp.open("GET",url,true);
xmlHttp.send(null);
}

function fireChange() {
document.getElementById("getText").innerHTML="<br/><br/><br/><br/><center><img src=/graphics/common/loader.gif></center>";
      if (xmlHttp.readyState == 4) {        
		 if (xmlHttp.status == 200) {		 
           document.getElementById("getText").innerHTML=xmlHttp.responseText;         
         } else {
            alert('There was a problem with the request.');
         }
      }  
}

///////////////////////////////////////////////////////////////////////////////////////////////////////////////

function goWord(obj){
var oktogo="";//document.sun1.sun.value;
if(oktogo==""){
if(document.getElementById('wordAlert')){
document.getElementById('wordAlert').innerHTML = "<img src=/fosterPDF/loader.gif>";
}
if (confirm('When prompted, please select [ OPEN ].\n\nThen, using MS Word, save as an HTM page. This will ensure that all images are retained.\n\nNOTE: Versions of MS Word ealrier than Office 2007 may not display or print specification sheets exactly as intended. For best results, please select Save as PDF from the previous Product Document Downloads area')) {
document.location.href="/search/word.asp?id=" + obj;
}
document.getElementById('wordAlert').innerHTML = "";
}else{
alert("You must be a registered user and logged in to use this funtion\n\nTo register, click the link at the top of this page");
}
}

function goWordR(obj){
if(getCookie('fosterRefrigerator')){
if(document.getElementById('wordAlert')){
document.getElementById('wordAlert').innerHTML = "<img src=/fosterPDF/loader.gif>";
}
if (confirm('When prompted, please select [ OPEN ].\n\nThen, using MS Word, save as an HTM page. This will ensure that all images are retained.\n\nNOTE: Versions of MS Word ealrier than Office 2007 may not display or print specification sheets exactly as intended. For best results, please select Save as PDF from the previous Refrigeration Systems Document Downloads area')) {
document.location.href="/search/wordR.asp?id=" + obj;
}
document.getElementById('wordAlert').innerHTML = "";
}else{
alert("You must be a registered user and logged in to use this funtion\n\nTo register, click the link at the top of this page");
}
}

///////////////////////////////////////////////////////////////////////////////////////////////////////////////


function dh(e,obj){
globX = mouseX(e);
globY = mouseY(e);
var heading;
var texting;

if(obj==1){
heading="Ceiling Joints";
}
if(obj==2){
heading="Partition joints";
}
if(obj==3){
heading="Ceilings";
}
if(obj==4){
heading="Corner Joints";
}
if(obj==5){
heading="Walls";
}
if(obj==6){
heading="Panel Joints";
}
if(obj==7){
heading="Doors";
}
if(obj==8){
heading="Floors";
}
if(obj==9){
heading="Optional Extras";
}

texting="For more information about coldroom " + heading + ", click now";

//document.getElementById('popHead').innerHTML=heading;
//document.getElementById('popText').innerHTML=texting;


	//document.getElementById('popDiv').style.left = parseFloat(globX-125) + "px";
	//document.getElementById('popDiv').style.top = parseFloat(globY-200) + "px";
	//document.getElementById('popDiv').style.display='';


}

var globX;
var globY;
var globPage;

function mouseX(evt) {
if (evt.pageX) return evt.pageX;
else if (evt.clientX)
   return evt.clientX + (document.documentElement.scrollLeft ?
   document.documentElement.scrollLeft :
   document.body.scrollLeft);
else return null;
}
function mouseY(evt) {
if (evt.pageY) return evt.pageY;
else if (evt.clientY)
   return evt.clientY + (document.documentElement.scrollTop ?
   document.documentElement.scrollTop :
   document.body.scrollTop);
else return null;
}

function db(obj){
document.getElementById('popDiv').style.display='none';

}

function dc(obj){

globPage=obj;
productMe('coldroom');
}

function saveProduct(obj){

var thisLot;
thisLot =  "productId=" + obj;

//// // alert(thisLot);
myTitle=window.favTitle;


xmlHttp=GetXmlHttpObject();
if (xmlHttp==null) {
  alert ("Your browser does not support AJAX!");
  return;
  } 
  
var url="/search/saveProduct.asp";
xmlHttp.onreadystatechange = goSaved;
xmlHttp.open("POST",url,true);
xmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
xmlHttp.setRequestHeader("Content-length", thisLot.length);
xmlHttp.setRequestHeader("Connection", "close");
xmlHttp.send(thisLot);
}

function saveProductR(obj){

var thisLot;
thisLot =  "productId=" + obj;

//// // alert(thisLot);
myTitle=window.favTitle;


xmlHttp=GetXmlHttpObject();
if (xmlHttp==null) {
  alert ("Your browser does not support AJAX!");
  return;
  } 
  
var url="/search/saveProductR.asp";
xmlHttp.onreadystatechange = goSaved;
xmlHttp.open("POST",url,true);
xmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
xmlHttp.setRequestHeader("Content-length", thisLot.length);
xmlHttp.setRequestHeader("Connection", "close");
xmlHttp.send(thisLot);
}

function goSaved() {
      if (xmlHttp.readyState == 4) {
         if (xmlHttp.status == 200) {
            if(xmlHttp.responseText=="1"){
            alert("You must be a registered user and logged in to use this funtion\n\nTo register, click the link at the top of this page");
			}
			if(xmlHttp.responseText=="2"){
           alert("This product has been added to 'My Area'.\n\nTo view at any time, click on the [ My Area ] button at the top of this page.")
			}           
         } else {
            alert('There was a problem with the request.');
         }
      }     
   }
   
   function popImage(obj){
   // // alert(obj);
   }
   
   function popImageClose(){
   }
   
   function openDivRel(obj){
   openDiv('dropper'+obj);
   var x="closeButton" + obj;
   if(document.getElementById(x).innerHTML=="Product Document Downloads"){  
   document.getElementById(x).innerHTML="Close Product Document Downloads";
   document.getElementById(x).style.color="#0000FF";
   }else{
    document.getElementById(x).innerHTML="Product Document Downloads";
	document.getElementById(x).style.color="#000000";
   }
   }
   
function getRange(obj){
document.location.href="/products.asp?range=" + obj;
}

