// **************************************************************************
// find out what browser we're using
if (document.getElementById)
{
	DOMtype = "std";
}
else if (document.all)
{
	DOMtype = "ie4";
}
else if (document.layers)
{
	DOMtype = "ns4";
}

// **************************************************************************
// grab object by ID on page
function grabobj(objname) // v1.0
{

var ret = null;
	switch (DOMtype)
	{
		case "std":
		{
			ret = document.getElementById(objname);
		}
		break;

		case "ie4":
		{
			ret = document.all[objname];
		}
		break;
		case "ns4":
		{
			ret = document.layers[objname];
		}
		break;
	}
return ret;
}
function $(objname)
{
	return grabobj(objname);
}
var fastorder=false;
function outofstock(stno,type)
{
//	13-05-10; LJB; returned value from ajax check is a string not a boolean value so no equal
//	if (validajax==true)
	if (validajax)
	{
		var ajax = new ajaxObject('/stockmessage/',evalAjax);
		ajax.update('STNO='+stno+'&type='+type+'&fastorder='+fastorder,'GET');
	} else {
		//window.location='/stockmessage/?STNO='+stno+'&type='+type+'&fastorder='+fastorder+'&viewmode=1&ret='+window.location;
	}
		
}
function evalAjax (t,s)
{	
	displayBox('stock',unescape(t));
}
function ajaxObject(url, callbackFunction)
{

  var that=this;      
  this.updating = false;
  this.abort = function() {
    if (that.updating) {
      that.updating=false;
      that.AJAX.abort();
      that.AJAX=null;
    }
  }
  this.update = function(passData,postMethod) { 
    if (that.updating) { return false; }
    that.AJAX = null;                          
    if (window.XMLHttpRequest) {
      that.AJAX=new XMLHttpRequest();
    } else {
		try {
			that.AJAX=new ActiveXObject("Microsoft.XMLHTTP");
		} catch(e) {
			that.AJAX=new IFrameXMLHttpRequest();
		}
    }
    if (that.AJAX==null) {                             
      return false;                               
    } else {
      that.AJAX.onreadystatechange = function() {  
        if (that.AJAX.readyState==4) {             
          that.updating=false;
          that.callback(that.AJAX.responseText,that.AJAX.status,that.AJAX.responseXML);        
          that.AJAX=null;                                         
        }                                                      
      }                                                        
      that.updating = new Date();        
	  
	  if ($('ajaxcall')) $('ajaxcall').innerHTML=new Date();
      if (/post/i.test(postMethod)) {
        var uri=urlCall+'?'+that.updating.getTime();
        that.AJAX.open("POST", uri, true);
        that.AJAX.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
        that.AJAX.send(passData);
      } else {
        var uri=urlCall+'?'+passData+'&stamp='+(that.updating.getTime()); 
        that.AJAX.open("GET", uri, true);                             
        that.AJAX.send(null);                                         
      }              
      return true;                                             
    }
  }
  var urlCall = url;
  this.callback = callbackFunction || function () { };
}
/*
coded by Kae - http://verens.com/
use this code as you wish, but retain this notice
*/

var kXHR_instances=0;
var kXHR_objs=[];


IFrameXMLHttpRequest=function()
{
	var i=0;
	var url='';
	var responseText='';
	var iframe='';
	this.onreadystatechange=function(){
		return false;
	}
	this.open=function(method,url)
	{
		//TODO: POST methods
		this.i=++kXHR_instances; // id number of this request
		this.url=url;
		iFrame	=	document.createElement('iframe');
		iFrame.id	=	"kXHR_iframe_"+this.i;
		iFrame.style.display = 'none';
		iFrame.style.width = '1px';
		iFrame.style.height = '1px';
		document.body.appendChild(iFrame);
	}
	this.send=function(postdata)
	{
		//TODO: use the postdata
		document.getElementById('kXHR_iframe_'+this.i).src=this.url;
		kXHR_objs[this.i]=this;
		setTimeout('XMLHttpRequest_checkState('+this.i+',2)',2);
	}
	return true;
}
XMLHttpRequest_checkState=function(inst,delay)
{
	var el=document.getElementById('kXHR_iframe_'+inst);
	if(el.readyState=='complete')
	{
		var responseText=document.frames['kXHR_iframe_'+inst].document.body.innerText;
		kXHR_objs[inst].responseText=responseText;
		kXHR_objs[inst].readyState=4;
		kXHR_objs[inst].status=200;
		kXHR_objs[inst].onreadystatechange();
		el.parentNode.removeChild(el);
	}else{
		delay*=1.5;
		setTimeout('XMLHttpRequest_checkState('+inst+','+delay+')',delay);
	}
}




function openImgZoom (FS)
{
	var b=displayBox('imgzoom','<iframe id="imgZoomIFrame" style="width:740px;height:585px; #height:595px;" src="/amoimagezoom/?FS='+FS+'" frameborder="0"></iframe>');
}