
 var branch,type,bed,pmin,StockNum,page;

function fetchdata()
{
/*
  branch=document.getElementById('branch').value;
  if(branch=="No Preference")
*/

  StockNum=document.getElementById('StockNum').value;
  
  document.getElementById('reason').innerHTML="";
     document.getElementById('branchhold').innerHTML="";
     document.getElementById('main').innerHTML="";
     
/*      document.getElementById('topnews').innerHTML=""; */
  document.getElementById('searchresults').innerHTML="<p style=\"width:100%; text-align:center\"align=\"center\"><img style=\"float:none; margin:auto\" src=\"images/loading.gif\"><br/><br/><font class=\"commontext\">Searching database,please wait</font></p>";
//window.location = "#searchresults";  
  setTimeout('postrequest()',100);
 
}
function createRequestObject() { 
    var ro; 
    var browser = navigator.appName; 
    if(browser == "Microsoft Internet Explorer"){ 
        ro = new ActiveXObject("Microsoft.XMLHTTP"); 
    }else{ 
        ro = new XMLHttpRequest(); 
    } 
    return ro; 
} 
var http = createRequestObject(); 

function postrequest()
{
  var url ="http://richardgardnerantiques.co.uk/fetchdata.php?type="+type+"&bed="+bed+"&pmin="+pmin+"&StockNum="+StockNum+"&page="+page;

//alert(url);
    http.open('get', url,true); 

    http.onreadystatechange = handleResponse; 
	 
    http.send(null); 
}

function showpage(mypage)
{
 document.getElementById('tim').innerHTML="<img src=\"images/inner_img.jpg\">";
  document.getElementById('reason').innerHTML="";
    document.getElementById('branchhold').innerHTML="";
    document.getElementById('main').innerHTML="";
page=mypage;
 document.getElementById('searchresults').innerHTML="<p style=\"width:100%; text-align:center\"align=\"center\"><img style=\"float:none; margin:auto\" src=\"images/loading.gif\"><br/><br/><font class=\"commontext\">Loading page,please wait</font></p>";
//window.location = "#searchresults"; 
    setTimeout('postrequest()',100);

}


function handleResponse()
{ 
  
    if(http.readyState == 4)
	{ 
	  
        var response = http.responseText;
		response="<h2><a href=\"\">Start New Search ></a></h2><h1 style=\"margin-top:10px\">Search Results</h1>"+response;
		
	document.getElementById('searchresults').innerHTML=response;
	
	}
}

function winopen(url)
{
window.open(url,"mywin","height=525,width=700,resizeable=1");
}

function winopen2(url)
{
window.open(url,"mywin","height=600,width=750,resizeable=1,scrollbars=1");
}

function showlisting()
{

  document.getElementById('reason').innerHTML="";
      document.getElementById('branchhold').innerHTML="";
      document.getElementById('main').innerHTML="";
document.getElementById('searchresults').innerHTML="<p style=\"width:100%; text-align:center\" align=\"center\"><img src=\"loading.gif\"><br><font class=\"commontext\">Loading page,please wait</font></p>";
 
    setTimeout('postrequest()',1000);
	
}



function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}



var nn4 = (navigator.appName.indexOf("Netscape") > -1 && navigator.appVersion.indexOf("4") > -1) ? true : false


//function for forcing form submission
function checkEnter(e){
var characterCode
	 if(e && e.which){
	 e = e
	 characterCode = e.which
	 }
	 else{
	 e = event
	 characterCode = e.keyCode
	 }
	 if(characterCode == 13){
 	 javascript:fetchdata()
 	  	 return false
	 }
return true

}

