var tCss;
var loc;
var divs;
var op;
var n;
var iA;
var c;

function brwsr(){
  var brwsr='error'
  if(document.getElementById){
    if(document.all){
      if(document.compatMode){brwsr='ie6'}
      else if(navigator.appVersion.indexOf('5.5')!=-1){brwsr='ie5.5'}
      else{brwsr='ie5'}
      }
    else{brwsr='nn6'}
    }
  else if(document.all){brwsr='ie4'}
  else if(document.layers){brwsr='nn4'}
  }

function headingtxtOnimgPrdct(){
//	alert("heading text function:")
	if(getElement("txtHdng") && getElement("headingtxt") && getElement("imgPrdct_2")){
		//alert("bp1")
		if(getTopOfObj(getElement("txtHdng"))+getTopOfObj(getElement("headingtxt"))+getHeightOfObj(getElement("headingtxt"))>getTopOfObj(getElement("imgPrdct_2"))){
			setTopOfObj(getElement("imgPrdct_2"),getTopOfObj(getElement("txtHdng"))+getTopOfObj(getElement("headingtxt"))+getHeightOfObj(getElement("headingtxt")))
			}
		}
	if(getElement("txtHdng") && getElement("headingtxt") && getElement("multi1")){
//	alert("bp2")
		var bit_CheckMe;
		if(getElement("multi1").parentElement) {
			bit_CheckMe = getTopOfObj(getElement("txtHdng"))+getTopOfObj(getElement("headingtxt"))+getHeightOfObj(getElement("headingtxt"))>getTopOfObj(getElement("multi1").parentElement)
		} else {
			bit_CheckMe = getTopOfObj(getElement("txtHdng"))+getTopOfObj(getElement("headingtxt"))+getHeightOfObj(getElement("headingtxt"))>getTopOfObj(getElement("multi1").parentNode)
		}
		if(bit_CheckMe){
//		alert("bp3")
			if(getElement("multi1").parentElement){
				setTopOfObj(getElement("multi1").parentElement,getTopOfObj(getElement("txtHdng"))+getTopOfObj(getElement("headingtxt"))+getHeightOfObj(getElement("headingtxt")))
			} else {
				setTopOfObj(getElement("multi1").parentNode,20+getTopOfObj(getElement("txtHdng"))+getTopOfObj(getElement("headingtxt"))+getHeightOfObj(getElement("headingtxt")))
			}
			}
		}
	}

function brokenImgCheck(){
	if(document.getElementById("intTbl") && document.getElementById("imgClose")){
		if(parseInt(getWidthOfObj(getElement("intTbl"))+getLeftOfObj(getElement("tblPrdcts")))>540){
			document.getElementById("imgClose").style.left=parseInt(getWidthOfObj(getElement("intTbl"))+getLeftOfObj(getElement("tblPrdcts")))
			document.getElementById("list").style.left=parseInt(getLeftOfObj(getElement("list")))
			if(parseInt(getWidthOfObj(getElement("list")))<100){
				document.getElementById("list").style.width="100px"
				}
//			document.getElementById("imgClose").style.left=parseInt(getWidthOfObj(getElement("intTbl"))+getLeftOfObj(getElement("tblPrdcts")))
			}
		}
	iA=document.images
	for(n=0;n<iA.length;n++){
		if(iA[n].getAttribute("key")!=null){
			iA[n].onmouseover=key_over
			}
		if(iA[n].readyState){
			if(iA[n].readyState!="complete"){
				//iA[n].style.visibility="hidden"
			}
		}
	}
}

function nada(){
	return true
	}

function key_over(){
  if(!document.getElementById("key_tip")){
		makeElement("div","key_tip","",document.body)
		}
	this.onmouseover=nada
	this.onmouseout=key_out
	key_tipObj=getElement("key_tip")
	key_tipRef=this.getAttribute("key")
	cnt="<img src='" + this.getAttribute("src") + "' style='float:left;border:1px solid #000000; padding:1px;'>"
	if(key_tipRef=="domestic"){
		cnt+="Domestic"
		}
	if(key_tipRef=="commercial"){
		cnt+="Commercial"
		}
	if(key_tipRef=="price_1"){
		cnt+="Price 1: Most economical"
		}
	if(key_tipRef=="price_2"){
		cnt+="Price 2: Economy"
		}
	if(key_tipRef=="price_3"){
		cnt+="Price 3: Median"
		}
	if(key_tipRef=="price_4"){
		cnt+="Price 4: Luxury"
		}
	if(key_tipRef=="price_5"){
		cnt+="Price 5: Most luxurious"
		}
	if(key_tipRef=="anti_vandal"){
		cnt+="Anti vandal"
		}
	if(key_tipRef=="healthcare"){
		cnt+="Healthcare"
		}
	if(key_tipRef=="HTM64"){
		cnt+="Conforms to DoH HTM64"
		}
	if(key_tipRef=="Defra"){
		cnt+="Defra Approved"
		}
	key_tipObj.innerHTML=cnt
	key_tipObj.style.top=mp_y-24
	key_tipObj.style.left=mp_x+4
	key_tipObj.style.display="block"
	}
function key_out(){
	key_tipObj.style.display="none"
	this.onmouseover=key_over
	}

function ftr(){
//alert("ftr function called");
  loc=0
  //alert(document.getElementById("main"));
  if(document.getElementById("main")){
	divs=document.getElementById("main").getElementsByTagName("div")
  } else {
	divs=document.getElementById("mainText").getElementsByTagName("div");
  }
  
  op=""
  
  for(n=0;n<divs.length;n++){
    c=parseInt(getTopOfObj(divs[n])+getHeightOfObj(divs[n]))
    c>loc?loc=c:null
    }
  
  if(loc<150){
	loc=1250
  } else {
	null
  }
  
 // alert(getWinSizeY())
  //640
  
  if(loc<getWinSizeY()-19){
	loc=getWinSizeY()-18
  } else {
	null
  }
  
  if(document.getElementById('ftr')){
	document.getElementById('ftr').style.top=parseInt(loc-5)
    document.getElementById('ftr').style.visibility="visible"
	  if(document.getElementById('imgMvUp')){
//	    document.getElementById('imgMvUp').style.position="absolute"
//	    document.getElementById('imgMvUp').style.left="700px"
	    document.getElementById('imgMvUp').style.top=parseInt(loc-10)
	    document.getElementById('imgMvUp').style.visibility="visible"
			}
	  if(document.getElementById('nextfooter')){
	    document.getElementById('nextfooter').style.top=parseInt(loc-10)
	    document.getElementById('nextfooter').style.visibility="visible"
			}
	  if(document.getElementById('previousfooter')){
	    document.getElementById('previousfooter').style.top=parseInt(loc-10)
	    document.getElementById('previousfooter').style.visibility="visible"
	    }
	  }
  else{
    if(document.all('ftr')){
      document.all('ftr').style.top = parseInt(loc+20)
      document.all('ftr').style.visibility="visible"
	    if(document.all('imgMvUp')){
	      document.all('imgMvUp').style.top = parseInt(loc-10)
	      document.all('imgMvUp').style.visibility="visible"
				}
	    if(document.all('nextfooter')){
	      document.all('nextfooter').style.top = parseInt(loc-10)
	      document.all('nextfooter').style.visibility="visible"
				}
	    if(document.all('previousfooter')){
	      document.all('previousfooter').style.top = parseInt(loc-10)
	      document.all('previousfooter').style.visibility="visible"
	      }
			}
    }
    //alert("Usable Height:" + loc);
  return loc
  }

function rcM(){
  if(!event.ctrlKey){
		if(event.altKey && document.getElementById('cntxtMnu2')){
	 	  hideOtherMenus()
	    cObj=eval("document.getElementById('cntxtMnu2')")
	    cSt=cObj.currentStyle.visibility
			shwM2();
	    if(document.getElementById('cntxtMnu')){
		    document.getElementById('cntxtMnu').style.visibility="hidden"
		    }
			return false;
			}
		else{
	 	  hideOtherMenus()
	    cObj=eval("document.getElementById('cntxtMnu')")
	    cSt=cObj.currentStyle.visibility
	    shwM();
	    if(document.getElementById('cntxtMnu2')){
		    document.getElementById('cntxtMnu2').style.visibility="hidden"
		    }
	    return false;
			}
    }
  else{
		hdM()
		return true;
    }
    return false;
  }

function shwM(){
  shwThsDv('cntxtMnu',0,0)
  }
function shwM2(){
  shwThsDv('cntxtMnu2',0,0)
  }


function shwThsDv(whch,xM,yM){
  if(document.getElementById){
    document.getElementById(whch).style.visibility='visible'
    var srl = parseInt(document.body.scrollTop)
    var newY = parseInt(event.clientY+srl);
    var objH=document.getElementById(whch).clientHeight
    var winH=document.body.clientHeight
    var objBtm =parseInt(newY+objH-srl)
    var objN = parseInt(winH-objH+srl-6)
    if(objBtm>winH){newY=objN}

    var newX = parseInt(event.clientX);
    var objW=document.getElementById(whch).clientWidth
    var winW=document.body.clientWidth
    var objRgh =parseInt(newX+objW)
    var objNx = parseInt(winW-objW-6)
    if(objRgh>winW){newX=objNx}

    if(yM==0){document.getElementById(whch).style.top=newY;}
    if(xM==0){document.getElementById(whch).style.left=newX;}

    }
  }

function shM(){
  cObj=eval("document.getElementById('cntxtMnu')")
  cObj.style.visibility = "visible"
  return false
  }

function hdM(){
  if(window.event.srcElement.tagName!="INPUT"){
	cObj=eval("document.getElementById('cntxtMnu')")
	cObj.style.visibility = "hidden"
	}
  }


function ovr(n,m){
  cObj=eval("document.getElementById('"+m+''+n+"')")
  cObj.style.backgroundColor="#000080"
  cObj.style.color="#ffffff"
  }

function out(n,m){
  cObj=eval("document.getElementById('"+m+''+n+"')")
  //cObj.style.backgroundColor="transparent"
  cObj.style.color="#000000"
  }

function clk(n,m){
  if(n==101){history.back()}
  else if(n==102){history.forward()}
  else if(n==103){window.print()}
  else if(n==104){location.reload()}
  else if(n==105){location.href='mailto:info@thebluebook.co.uk'}
  else if(n==106){document.frm_Search.submit()}
  else if(n==107){}
  else {
	goH=z+'static/index_'+n+'.asp'
    }
  location.href=goH
  }

tCss='#cntxtMnu  { cursor: default; position: absolute; visibility: hidden; top: 100px; left: 100px; border: 2px outset #ffffff; background-color: #C0C0C0; }'
tCss+='#cntxtMnu hr { width: 150px; }'

tCss+='.optn form  { padding: 1px 3px; padding-left: 12px; display: inline; }'
tCss+='.optn form input { padding: 0px ; margin:0px; display: inline; }'

tCss+='.optn  { font-family: arial; height: auto; width: 170px; font-size: 11px; letter-spacing: 1px;padding: 1px 3px; color:#000000;padding-left: 12px; }'
tCss+='.toptn  { font-family: arial; height: auto; width: 170px; font-size: 12px; font-weight: bold; margin-top: 1px; margin-bottom: 1px; padding: 1px 3px; color:#ffffff; background-color: #000080; padding-left: 6px; }'
tCss+='@media print { #cntxtMnu { display: none } }'
document.write('<style>'+tCss+'</style>')



function popUp(sURL, sName, sWidth, sHeight)
{
	var win = null;
	var sProperties = 'scrollbars=yes,status=no,location=no,menubar=no,toolbar=no,resizable=no,width=' + sWidth + ',height=' + sHeight;
	if(win)
	{
		if (!win.closed)
		{
			win.focus()
			win.location = sURL;
		}
		else
			{
				win = window.open(sURL,sName,sProperties);
				win.focus()
			}
	}
	else
		{
			win = window.open(sURL,sName,sProperties);
			win.focus()
		}
}

function popUp2(sURL, sName, sWidth, sHeight)
{
	var win = null;
	var sProperties = 'scrollbars=yes,status=yes,location=no,menubar=no,toolbar=yes,resizable=yes,width=' + sWidth + ',height=' + sHeight;
	if(win)
	{
		if (!win.closed)
		{
			win.focus()
			win.location = sURL;
		}
		else
			{
				win = window.open(sURL,sName,sProperties);
				win.focus()
			}
	}
	else
		{
			win = window.open(sURL,sName,sProperties);
			win.focus()
		}
}
	
function CloseWin()
{
	if(win!=null) 
		win.close()
}

function create(){
  var mnu=document.createElement("div")
  mnu.id='cntxtMnu'
  moTxt = new Array()
  moTxt[1]="General"
  moTxt[2]="Colours"
  moTxt[3]="Suites"
  moTxt[4]="WCs"
  moTxt[5]="Washbasins"
  moTxt[6]="Baths"
  moTxt[7]="Showers"
  moTxt[8]="Brassware"
  moTxt[9]="Bidets"
  moTxt[10]="Urinals"
  moTxt[11]="Sinks"
  moTxt[12]="Fountains"
  moTxt[13]="Accessories"
  moTxt[14]="Bathroom Furniture"
  moTxt[15]="Washroom Systems"
  moTxt[16]="Space Saving"
  moTxt[17]="Special Care"
  moTxt[18]="Healthcare"
  moTxt[19]="Education"
  moTxt[20]="Hotel &amp; Leasure "
  moTxt[21]="Anti Vandal"
  moTxt[22]="Water Saving"
  moTxt[23]="Index"
//  mnu.innerHTML+='<div class="toptn">Controls</div>'
  mnu.innerHTML+='<div class="optn" id="m101" onmouseover="ovr(101,\'m\')" onmouseout="out(101,\'m\')" onclick="clk(101,\'m\')">Back</div>'
  mnu.innerHTML+='<div class="optn" id="m102" onmouseover="ovr(102,\'m\')" onmouseout="out(102,\'m\')" onclick="clk(102,\'m\')">Forward</div>'
  mnu.innerHTML+='<div class="optn" id="m103" onmouseover="ovr(103,\'m\')" onmouseout="out(103,\'m\')" onclick="clk(103,\'m\')">Print</div>'
  mnu.innerHTML+='<div class="optn" id="m104" onmouseover="ovr(104,\'m\')" onmouseout="out(104,\'m\')" onclick="clk(104,\'m\')">Refresh</div>'
//  mnu.innerHTML+='<div><hr></div>'
  mnu.innerHTML+='<div class="toptn">Bluebook</div>'
  for(biac=1;biac<moTxt.length;biac++){
    mnu.innerHTML+='<div class=\"optn\" id=\"m'+biac+'\" onmouseover=\"ovr('+biac+',\'m\')\" onmouseout=\"out('+biac+',\'m\')\" onclick=\"clk('+biac+',\'m\')\">'+moTxt[biac]+'</div>'  
    }
  mnu.innerHTML+='<div class="toptn">Contact</div>'
  mnu.innerHTML+='<div class="optn" id="m105" onmouseover="ovr(105,\'m\')" onmouseout="out(105,\'m\')" onclick="clk(105,\'m\')">arm-idealinfo@aseur.com</div>'  
  document.body.appendChild(mnu)
  document.oncontextmenu=rcM
  document.onclick=hdM
  }
//  See loaded statment
// if (document.getElementById){onload=create}

tCss='#cntxtMnu  { cursor: default; position: absolute; visibility: hidden; top: 100px; left: 100px; border: 2px outset #ffffff; background-color: #C0C0C0; }'
tCss+='#cntxtMnu hr { width: 150px; }'
tCss+='.optn  { font-family: arial; height: auto; width: 170px; font-size: 11px; letter-spacing: 1px;padding: 1px 3px; color:#000000;padding-left: 12px; }'
tCss+='.toptn  { font-family: arial; height: auto; width: 170px; font-size: 12px; font-weight: bold; margin-top: 1px; margin-bottom: 1px; padding: 1px 3px; color:#ffffff; background-color: #000080; padding-left: 6px; }'
tCss+='@media print { #cntxtMnu { display: none } }'
document.write('<style>'+tCss+'</style>')
