//Declare common vars

var iLookupBt = 1
function setLookupBt(iVal){
	iLookupBt = iVal
}


// Use Code below for fixed positioning
if (parseInt(navigator.appVersion)>3) {
 if (navigator.appName=="Netscape") {
  winW = window.innerWidth;
  winH = window.innerHeight;
 }
 if (navigator.appName.indexOf("Microsoft")!=-1) {
  winW = document.body.offsetWidth;
  winH = document.body.offsetHeight;
 }
}

var DH = 0;
var an = 0;
var al = 0;
var ai = 0;
if (document.getElementById) {
	ai = 1;
	DH = 1;
}else {
	if (document.all) {
		al = 1; DH = 1;
	}else {
		browserVersion = parseInt(navigator.appVersion); 
		if ((navigator.appName.indexOf('Netscape') != -1) && (browserVersion == 4)) {
			an = 1; DH = 1;
		}
	}
}
function fd(oi, wS) {
	if (ai) return wS ? document.getElementById(oi).style:document.getElementById(oi);
	if (al) return wS ? document.all[oi].style: document.all[oi];
	if (an) return document.layers[oi];
}
function pw() {
	return window.innerWidth != null? window.innerWidth: document.body.clientWidth != null? document.body.clientWidth:null;
}
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 openItem(evt,oi,sPage,sTopPos) {
	bFixPos = String(sTopPos) != "undefined"
	sBtVal = "Look Up"
	sBtValOff = "Close Look Up"
	
	if(sPage.indexOf("FileUpload") != -1){
		sBtVal = "Upload New File"
		sBtValOff = "Close"
	}
	if (DH) {var wp = pw(); ds = fd(oi,1); dm = fd(oi,0); st = ds.visibility; 
	if (dm.offsetWidth) ew = dm.offsetWidth; 
	else if (dm.clip.width) ew = dm.clip.width; 
	if (st == "visible" || st == "show") { 
		closeAjax()
		document.getElementById('Look_UpBt'+iLookupBt).value = sBtVal
		try{document.getElementById('Save').style.visibility = "visible"}catch(err){}
	}else {
		tv = mouseY(evt) + 10; lv = mouseX(evt) - (ew/50); 
		if (lv < 2) lv = 2; 
		else if (lv + ew > wp) lv -= ew/2; 
		if (!an) {
			lv += 'px';tv += 'px';
		}
		ds.left = lv; ds.top = tv;
		
		//Use Below for fixed position
		if(bFixPos){
			ds.left = (winW-((winW-958)/2))-958+"px" 
			ds.top = sTopPos+"px";
		}
		ajaxFunction(sPage)
		ds.visibility = "visible";
		document.getElementById('Look_UpBt'+iLookupBt).value = sBtValOff
		try{document.getElementById('Save').style.visibility = "hidden"}catch(err){}
		}
	}
}

function refreshMenu(sPage){
var xmlHttp;
	sPage += "?menu=refresh"
	//alert(sPage)
  	try{    
	// Firefox, Opera 8.0+, Safari    
		xmlHttp=new XMLHttpRequest();
		xmlHttp.overrideMimeType('text/xml')   
	}catch (e){
	// Internet Explorer
		try{
			xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
		}catch (e){
			try{
				xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
			}catch (e){
				alert("Your browser does not support AJAX!");
				return false;        
			}      
		}    
	}
	xmlHttp.onreadystatechange=function(){
		//alert(xmlHttp.status)
		if(xmlHttp.readyState==4){
			try{
				document.getElementById("LeftMenu").innerHTML=xmlHttp.responseText;
			}catch(err){
				document.getElementById("LeftMenu").innerHTML="Error: " + err.description
			}
		}
	}

	xmlHttp.open("GET",sPage,true);
	xmlHttp.send(null);
}

function showItem(sPage,sCallingPage){
	var xmlHttp;
	sDivId = 'look'
	// Uncomment line below to make every call unique and bypass cache
	if(sCallingPage!="undefined"){
		if(sCallingPage=="look2"){
			sDivId = 'look2'
		}else{
			sPage += "&CallingPage="+sCallingPage
		}
	}
	sPage += "&"+String(new Date().getTime())+"="+String(new Date().getTime())
	
  	try{    
	// Firefox, Opera 8.0+, Safari    
		xmlHttp=new XMLHttpRequest();
		xmlHttp.overrideMimeType('text/xml')   
	}catch (e){
	// Internet Explorer
		try{
			xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
		}catch (e){
			try{
				xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
			}catch (e){
				alert("Your browser does not support AJAX!");
				return false;        
			}      
		}    
	}
	xmlHttp.onreadystatechange=function(){
		//alert(xmlHttp.status)
		if(xmlHttp.readyState==4){
			try{
				//Use Below to show outputted html as code
				//document.getElementById("look").innerText=xmlHttp.responseText;
				
				//Use Below to show outputted HTML
				//document.getElementById("MainContentTable").style.top = '0px'
				//prompt('',xmlHttp.responseText)
				document.getElementById(sDivId).innerHTML=xmlHttp.responseText;
				
				document.getElementById(sDivId).style.display="inline"
			}catch(err){
				document.getElementById(sDivId).innerHTML="Error: " + err.description
			}
		}
	}

	xmlHttp.open("GET",sPage,true);
	xmlHttp.send(null);
	location.href = "#ProductDisplay"
}
function Hilight(oObj, bState)
{
	
  if (bState)
  { 
    oObj.className="Hilite"; 
  }
  else 
  {
    oObj.className="Data"; 
  }
}

function closeAjax(){
	document.getElementById('look').style.height = "10px"
	document.getElementById('look').innerHTML = ""
	ds.visibility = "hidden";
	try{document.getElementById('Save').style.visibility = "visible"}catch(err){}	
}
function changeHREF(id,sHref){
	document.getElementById(id).href=sHref
}

