// JavaScript Document
//Create a boolean variable to check for a valid Internet Explorer instance.
	var xmlhttp = false;
	
	//Check if we are using IE.
	try {
		//If the Javascript version is greater than 5.
		xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
		// alert ("You are using Microsoft Internet Explorer.");
	} catch (e) {
		//If not, then use the older active x object.
		try {
			//If we are using Internet Explorer.
			xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
			// alert ("You are using Microsoft Internet Explorder");
		} catch (E) {
			//Else we must be using a non-IE browser.
			xmlhttp = false;
		}
	}
	
	//If we are using a non-IE browser, create a javascript instance of the object.
	if (!xmlhttp && typeof XMLHttpRequest != 'undefined') {
		xmlhttp = new XMLHttpRequest();
		// alert ("You are not using Microsoft Internet Explorer");
	}
	
	// ---------- load content into a div ----------
	function makerequest(serverPage, objID) {
		
		var obj = document.getElementById(objID);
		xmlhttp.open("GET", serverPage);
		xmlhttp.onreadystatechange = function() {
			if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
				obj.innerHTML = xmlhttp.responseText;
			}
		}
		xmlhttp.send(null);
	}

// ---------- resize a div to 100% height ----------
function resizeItem(id) {  
var frame = document.getElementById(id);
var htmlheight = document.body.parentNode.scrollHeight; 
var windowheight = window.innerHeight;  
if ( htmlheight < windowheight ) {
	document.body.style.height = windowheight + "px";
	frame.style.height = windowheight + "px";
	} else {
		document.body.style.height = htmlheight + "px";
		frame.style.height = htmlheight + "px";
	}
}

// ---------- show a hidden div	----------
function show(id,showText,hideText)
{
	el = document.getElementById(id);
	if (el.style.display == 'none')
	{
		el.style.display = '';
		el = document.getElementById('more' + id);
		el.innerHTML = hideText;
	} else {
		el.style.display = 'none';
		el = document.getElementById('more' + id);
		el.innerHTML = showText;
	}
}

// ---------- get name/value pairs from url ----------
function PageQuery(q) {
	if(q.length > 1) this.q = q.substring(1, q.length);
	else this.q = null;
	this.keyValuePairs = new Array();
	if(q) {
		for(var i=0; i < this.q.split("&").length; i++) {
			this.keyValuePairs[i] = this.q.split("&")[i];
		}
	}
	this.getKeyValuePairs = function() { return this.keyValuePairs; }
	this.getValue = function(s) {
		for(var j=0; j < this.keyValuePairs.length; j++) {
			if(this.keyValuePairs[j].split("=")[0] == s)
				return this.keyValuePairs[j].split("=")[1];
		}
		return false;
	}
	this.getParameters = function() {
		var a = new Array(this.getLength());
		for(var j=0; j < this.keyValuePairs.length; j++) {
			a[j] = this.keyValuePairs[j].split("=")[0];
		}
		return a;
	}
	this.getLength = function() { return this.keyValuePairs.length; }	
}
function queryString(key){
var page = new PageQuery(window.location.search); 
return unescape(page.getValue(key)); 
}

// ---------- alert the name/value pairs ----------
function displayItem(key){
if(queryString(key)=='false') 
{
alert("you didn't enter a ?name=value querystring item.");
}else{
alert(queryString(key));
}
}

// ---------- remove a div by name ----------
function removeElement(divNum) {
  // var d = document.getElementById('myDiv');
  var olddiv = document.getElementById(divNum);
  document.body.removeChild(olddiv);
}

// ---------- create a div by name ----------
/* Sample usage: creatediv('myDivName','content.html','100','300','25','13','myClass','fade').
leaving the html blank will display a 'no content message'.
leaving the width,height,left,top blank ( blank= '') will default to middle of the page */
function creatediv(id, html, width, height, left, top, style, fade) {

// get the window size for centering
if (parseInt(navigator.appVersion)>3) {
 if (navigator.appName=="Netscape") {
  winW = window.innerWidth-16;
  winH = window.innerHeight-16;
 }
 if (navigator.appName.indexOf("Microsoft")!=-1) {
  winW = document.body.offsetWidth-20;
  winH = document.body.offsetHeight-20;
 }
}

var state = document.getElementById(id);
if  (state==null) { // this line prevents duplicates
   var newdivWhite = document.createElement('div');
   newdivWhite.setAttribute('id', 'newdivWhite');
   newdivWhite.className='newdivWhite';
   
   var newdiv = document.createElement('div');
	newdiv.setAttribute('id', id);
	newdiv.className=style;
	newdiv.style.zIndex=5;
	newdiv.style.overflow="hidden";
	newdiv.style.position = "absolute";
		
   if (width) {
       newdiv.style.width = width+"px";
   } else {
	   newdiv.style.width = "100%";
   }
   
   if (height) {
       newdiv.style.height = height+"px";
    } else {
	   newdiv.style.height = "100%";
   }
   
   if ((left || top) || (left && top)) {
       if (left) {
           newdiv.style.left = left+"px";
       }
       if (top) {
           newdiv.style.top = top+"px";
       }
   } else {
	halfheight = (winH / 2) - (height / 2);
	halfwidth = (winW / 2) - (width / 2);
	newdiv.style.top = "50px";
	newdiv.style.left = halfwidth+"px";
   }
   
   if (html) {
       // newdiv.innerHTML = html;
	   if (fade) {
	   document.body.appendChild(newdivWhite);
	   }
	   document.body.appendChild(newdiv);
       makerequest(html,id);
   } else {
       newdiv.innerHTML = "no content specified";
	   if (fade) {
	   document.body.appendChild(newdivWhite);
	   }
	   document.body.appendChild(newdiv);
   }
   
   resizeItem('newdivWhite');

}  else {
	removeElement(id);
	removeElement('newdivWhite');
}
}

function MM_jumpMenu(targ,selObj,restore){ //v3.0
  eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
  if (restore) selObj.selectedIndex=0;
}

// open product modules in a small window
function openProductInfo (url) {
	window.open(url,'product_info','toolbar=no,width=780,height=600,left=100,top=100,status=no,scrollbars=yes,resize=yes');
	return false;
}

// popup div on the page
function toggleBox(szDivID, iState) // 1 visible, 0 hidden
{
    if(document.layers)	   //NN4+
    {
       document.layers[szDivID].display = iState ? "show" : "hide";
    }
    else if(document.getElementById)	  //gecko(NN6) + IE 5+
    {
        var obj = document.getElementById(szDivID);
        obj.style.display = iState ? "block" : "none";
    }
    else if(document.all)	// IE 4
    {
        document.all[szDivID].style.display = iState ? "block" : "none";
    }
}
function toggleLayerDisplay (whichLayer, isDisplay) {
  var elem, vis;
  if(document.getElementById) // this is the way the standards work
    elem = document.getElementById(whichLayer);
  else if(document.all) // this is the way old msie versions work
      elem = document.all[whichLayer];
  else if(document.layers) // this is the way nn4 works
    elem = document.layers[whichLayer];
  vis = elem.style;

  vis.display = (isDisplay)?'block':'none';
}
function toggleLayer(whichLayer) {
  var elem, vis;
  if(document.getElementById) // this is the way the standards work
    elem = document.getElementById(whichLayer);
  else if(document.all) // this is the way old msie versions work
      elem = document.all[whichLayer];
  else if(document.layers) // this is the way nn4 works
    elem = document.layers[whichLayer];
  vis = elem.style;
  // if the style.display value is blank we try to figure it out here
  if(vis.display==''&&elem.offsetWidth!=undefined&&elem.offsetHeight!=undefined)
    vis.display = (elem.offsetWidth!=0&&elem.offsetHeight!=0)?'block':'none';
  vis.display = (vis.display==''||vis.display=='block')?'none':'block';
}
function togglePopup(whichLayer) {
	toggleLayer(whichLayer);
	toggleLayer('newdivWhite');	
}
function toggleUpsellPopup(whichLayer) {
	toggleLayer(whichLayer);
	toggleLayer('newdivWhite');
	toggleLayer(whichLayer);	
}
function showShortList (show) {	
	if (show) { 
		toggleLayerDisplay ('priceListLong', false);
		toggleLayerDisplay ('priceListShort', true);
		document.getElementById("shortList").selectedIndex = 0; 
	}
	else { 
		toggleLayerDisplay ('priceListLong', true);
		toggleLayerDisplay ('priceListShort', false);
		document.getElementById("shortList").selectedIndex = -1; 
	}
}