bAllowCaching = false;

// JavaScript Document

function addListener(element, type, expression, bubbling){
	bubbling = bubbling || false;
	if(window.addEventListener)	{// Standard
		element.addEventListener(type, expression, bubbling);
		return true;
	} else if(window.attachEvent) {// IE
		element.attachEvent('on' + type, expression);
		return true;
	} else {
          return false;
        }
}


function CheckIsIE() { 
	if (navigator.appName.toUpperCase() == 'MICROSOFT INTERNET EXPLORER') { return true;} 
	else { return false; } 
}
function getPDF(sFile){
	if(CheckIsIE()){
		location.href = '?access=true&file='+sFile;
	}else{
		window.open('documents/'+sFile);
	}
}
function setHeight() {
  var myWidth = 0, myHeight = 0, contentHeight = 0;
  if( typeof( window.innerWidth ) == 'number' ) {
    //Non-IE
    myWidth = window.innerWidth;
    myHeight = window.innerHeight;
  } else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
    //IE 6+ in 'standards compliant mode'
    myWidth = document.documentElement.clientWidth;
    myHeight = document.documentElement.clientHeight;
	contentHeight = myHeight-183;
  } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
    //IE 4 compatible
    myWidth = document.body.clientWidth;
    myHeight = document.body.clientHeight;
	contentHeight = myHeight-183;
  }
  document.getElementById('MainTable').style.height = myHeight+"px";
  document.getElementById('MainContentCell').style.height = contentHeight+"px";
  //document.getElementById('MainContent').style.height = (contentHeight-20)+"px"
  try{document.getElementById('PDF').style.height = contentHeight-3+"px";}catch(err){}
}

function showPage(sPage,sCallingPage){

	var xmlHttp;
  	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{
				if(sPage=='openPDF.asp'){
					document.getElementById("MainContent").style.padding = "0px"
					document.getElementById("MainContentRight").style.borderLeft = "solid 1px #858487"
				}
				//Use Below to show outputted HTML

				document.getElementById("MainContent").innerHTML = xmlHttp.responseText;

				//Appending the SubTitle for Top20

				if(sPage.indexOf('corporate.asp?section=4')!=-1){
					document.getElementById("SubTitleTD").innerHTML = document.getElementById("EquityInfo").value
				}


			}catch(err){
				document.getElementById("MainContent").innerHTML="Error: " + err.description
			}
		}
	}

	sPage = cacheControl(sPage)
	xmlHttp.open("GET",sPage,true);
	xmlHttp.send(null);


}

function PrintIt(sPage){
	window.open(sPage);
}

	var sImageFolder = "images/";
	bPreload = false;
	menu01_on = new Image();
	menu01_on.src = sImageFolder+"menu01_on.gif";
	menu01_off = new Image();
	menu01_off.src = sImageFolder+"menu01_off.gif";
	menu02_on = new Image();
	menu02_on.src = sImageFolder+"menu02_on.gif";
	menu02_off = new Image();
	menu02_off.src = sImageFolder+"menu02_off.gif";
	menu03_on = new Image();
	menu03_on.src = sImageFolder+"menu03_on.gif";
	menu03_off = new Image();
	menu03_off.src = sImageFolder+"menu03_off.gif";
	menu04_on = new Image();
	menu04_on.src = sImageFolder+"menu04_on.gif";
	menu04_off = new Image();
	menu04_off.src = sImageFolder+"menu04_off.gif" ;
	bPreload = true;
	function swapImg(id,which){
		if(bPreload){
			document.getElementById(id).src = eval(id+"_"+which+".src");
		}
	}
	function getPage(sVal,bExternal){
		if(bExternal){
			sPage = sVal.split('?page=');
			sPage = sPage[1];
			sPage = sPage.split('&');
			sPage = sPage[0];
			showPage(sPage);
		}else{
			sPage = "home.asp";
			sVal = sVal.split("?");
			sVal = sVal[1];
			if(sVal!=""){
				sVal = sVal.split("&");
				iValCount = parseInt(sVal.length);
				if(iValCount==1){
					sVal = sVal[0].split("=");
					sVal = sVal[1]+".asp";
					showPage(sVal);
					return;
				}else{
					sPage = sVal[0].split("=");
					sPage = sPage[1]+".asp?";
					for(i=1;i<iValCount;i++){
						sPage += sVal[i];
						if(i<iValCount-1) {sPage += "&"};
					}
					showPage(sPage);
					return;
				}
			}else{
				showPage(sPage);
			}
			/*aVal = sVal.split("&")
			page = aVal[0].split("=")
			page = page[1]
			if(String(page)!="undefined"){
				sPage = page+'.asp'
				if(String(aVal[1])!="undefined"){
					sVal = aVal[1].split("=")
					sVal = sVal[1]
					sPage += "?section=" + sVal
				}
				if(String(aVal[2])!="undefined"){
					sVal = aVal[2].split("=")
					sVal = sVal[1]
					sPage += "&subsection=" + sVal
				}
			}*/
		}
		
	}


function setBorderLeft(sID){
	document.getElementById(sID).style.borderLeft = 'dashed 1px #858487'
}
function OpenDoc(sDoc,sName,sType){
	iWidth = (screen.availWidth/100)*90;
	iHeight = (screen.availHeight/100)*90;
	iLeft = (screen.availWidth - iWidth)/2;
	iTop = ((screen.availHeight - iHeight)/2)-8;
	if(sType=="Pres"){
		iWidth = screen.availWidth;
		iHeight = screen.availHeight;
	}

	window.open(sDoc, sName.replace(/-|\./g, ''), "toolbar=no,menubar=no,location=no,scrollbars=yes,resize=yes,width="+iWidth+",height="+iHeight+",left="+iLeft+",top="+iTop);
}
//Make unique - non IIS cache bypass
function cacheControl(sPage){
	if(bAllowCaching) return sPage
	var d = new Date()
	if(sPage.indexOf('?')==-1){
		sUTC = "?"
		}else{
		sUTC = "&"
	}
	sUTC += "key="
	sUTC += String(d.getUTCHours())
	sUTC += String(d.getUTCMinutes())
	sUTC += String(d.getUTCSeconds())
	sUTC += String(d.getUTCMilliseconds())
	sPage += sUTC
	return sPage
}

function SendIt(){
	if(document.getElementById("First_Name").value.length<3){
		alert('Please provide your first name')
		return
	}
	if(document.getElementById("Last_Name").value.length<3){
		alert('Please provide your last name')
		return
	}
	if(document.getElementById("Email").value.indexOf('@')==-1){
		alert('Please provide a valid email address')
		return
	}
	ContactForm.submit()
}

addListener(window,'resize',setHeight);
addListener(window,'load',setHeight);
//addListener(window,'load',setPDFHeight)