function getXMLHTTP(){

	try{
		var A=null;
		try{
			A=new ActiveXObject("Msxml2.XMLHTTP")
		}catch(e){
			try{
			A=new ActiveXObject("Microsoft.XMLHTTP")
			} catch(oc){
			A=null
			}
		}
		if(!A && typeof XMLHttpRequest != "undefined") {
			A=new XMLHttpRequest()
		}
		return A
	}catch(e){
	
	}
}

function resetServerPageTracking(){

	//breakhere();
	try{
		_xmlHttp=getXMLHTTP();
		if(_xmlHttp){
			_xmlHttp.open("GET",document.location.href,true);
			_xmlHttp.send(null);
		}
	}catch(e){
		// just ignore
	}	
}



var Content;
function Shrink(oElements){
		var item;
		var oldWidth;
		var newWidth;
	try{		
		
		for (item=0;item < oElements.length ; item++){
			if ((oElements[item] != null) && (oElements[item] != undefined)){
				oldWidth = oElements[item].getAttribute("width");
				
				if ((oldWidth != null) && (oldWidth != undefined)){
					if (isNaN(oldWidth)) {
						//newWidth = parseInt(parseInt(oldWidth) * .82);
					}else{
						newWidth = parseInt(parseInt(oldWidth) * .82);
						oElements[item].setAttribute("width", newWidth );
					}
				}
			}
		}
	}catch(e){
		
	}
}

function SetupPageForPrint(){
	try{
		Content = window.document.body.innerHTML;
		var oPrintContent = window.document.getElementById('PrintContent')
		if ( oPrintContent != null){
			var sReturn ;
			sReturn = "<a href='#' onclick='javascript:ReturnPageAfterPrint()'>Return To Normal View</a><BR><BR>"
			//sReturn = "<a href='" + document.location.toString() + "#a'>Return To Normal View</a><BR><BR>"
			window.document.body.innerHTML = sReturn + oPrintContent.innerHTML; 
			
			setTimeout("StartShrinkingStuff()",50);
		}
	}catch(e){
	
	}
}


function StartShrinkingStuff(){
	if (document.readyState == "complete"){
		var oTables = window.document.getElementsByTagName("table");
		var oTDs = window.document.getElementsByTagName("td");
		var oImages = window.document.getElementsByTagName("img");			
		
		Shrink(oTables);
		Shrink(oTDs);
		Shrink(oImages);
	}else{
		setTimeout("StartShrinkingStuff()",50);
	}
}

function ReturnPageAfterPrint(){
	try{
		/*
		var sURL = unescape(window.location.pathname);
		window.location.replace( sURL );
		*/
		
		window.location.reload(true);
		//window.document.body.innerHTML = Content;
	}catch(e){
	
	}
}


try{
	window.onbeforeprint = SetupPageForPrint;

	window.onafterprint = ReturnPageAfterPrint;
}catch(e){

}