var url 		= document.URL;
url 			= url.substring(0,url.indexOf('?'));


String.prototype.trim = function() {
	a = this.replace(/^\s+/, '');
	return a.replace(/\s+$/, '');
	};

function fnChangeMenu(label, docLink, popup, rootLevel, type) {
	if(popup == true || type != "HTML") {
		window.open(docLink); 
	} 
	else if(label.trim() == "Home"){
		window.location.href="/"+docLink.trim();
	}
	else {
		fnOpenContent(docLink, label, rootLevel);
	}
}
 
function fnOpenContent(docLink, label, rootIndex) {
	var newURL = url+"?content_path="+docLink+"&label="+label+"&rootLevel="+rootIndex;
	window.location.href=newURL;
}
function fnOpenFooterContent(docLink) {
	var newURL = url+"?"+docLink;
	window.location.href=newURL;
}

function fnOpenGrantees(label, rootIndex){
	var state = document.getElementById("states").options[document.getElementById("states").selectedIndex].value;
	var newURL = url+"?content_path=&label="+label+"&rootLevel="+rootIndex+"&state="+state;
	window.location.href=newURL;
}

function fnPrint(){
	var printHTML = document.getElementById("pageCopy").innerHTML;
	var newWindow =  window.open("","printwindow","status=0,toolbar=0,scrollbars=1");
	newWindow.document.write(printHTML);
	newWindow.document.getElementById("idPrintDocument").innerHTML="";
	
	if(null != newWindow.document.getElementById("backToPressReleases") && undefined != newWindow.document.getElementById("backToPressReleases")){
		var backToPressReleases = newWindow.document.getElementById("backToPressReleases");
		var divOutsideAnchor = newWindow.document.createElement("div");
		divOutsideAnchor.onclick = function(){newWindow.close(); return false;}
		divOutsideAnchor.innerHTML= "<div style='text-decoration:underline;'>close</div>";
		divOutsideAnchor.style.cursor="pointer";
		backToPressReleases.innerHTML="";
		backToPressReleases.onclick=null;
		backToPressReleases.appendChild(divOutsideAnchor);
	}
	
	
	newWindow.document.close();
	newWindow.focus();
	newWindow.print();
	

}