// 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);
	}
	
// 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));
}
}

// resize a div to 100%
function resize(){  
var frame = document.getElementById("frame1");  
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"; }  
} 

// 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','100px','300px','25px',13px','myClass').
leaving the html blank will display a 'no content message.
leaving the width,height,left,top blank ( blank= '') will default*/
function creatediv(id, html, width, height, left, top, style) {

// get the window size
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 newdiv = document.createElement('div');
	newdiv.setAttribute('id', id);
	newdiv.className=style;
	newdiv.style.zIndex=3;
	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 = halfheight+"px";
	newdiv.style.left = halfwidth+"px";
   }
   
   if (html) {
       // newdiv.innerHTML = html;
	   document.body.appendChild(newdiv);
       makerequest(html,id);
   } else {
       newdiv.innerHTML = "no content specified";
	   document.body.appendChild(newdiv);
   }

}  else {
	removeElement(id);
}
}

var c = queryString('c');

//Popup DIV open/close

function closeFW(xyz) {
  document.getElementById(xyz).style.display = 'none';
  document.getElementById('newdivBlack').style.display = 'none';
}
function showFW(xyz) {
  document.getElementById(xyz).style.display = 'block';
  document.getElementById('newdivBlack').style.display = 'block';
}

//onload popup of binary download
function popup(url)
{ this.location=url;}
