﻿// JScript File
    //Fires when page opens - Hidden variable is created if JavaScript is enabled.  
    //Check for value in other JS functions.    if (document.all.hidJSEnabled != null)
    document.write('<input type="hidden" id="hidJSEnabled" name="hidJSEnabled" value="true">');


    function ValidateSearch() {
        
		var hidJS;
		hidJS = document.getElementById("hidJSEnabled");
		 
		if (hidJS != null) {
			var hidAction;
			hidAction = document.getElementById("hidAction");
			
			//Doesn't work in FireFox
			//if user pressed enter key, reset hidAction to blank
//			var e;
//			e = window.event;
//			alert("after e");
//			alert(e.type);
//			 
//			if (e.type == "submit") {
//			    document.forms[0].hidAction.value = "";
//			}
			
		 
			if (document.forms[0].hidAction.value != "Y") {
				//NOT FY change
				var pstrSearchText, hidSearchText;
				var pintSearchTextLen;
				//get Search text
				hidSearchText = document.getElementById("hidSearchText");
				//trim leading & trailing blanks
				pstrSearchText = trim(document.getElementById("txtSearch").value);
				//display text search with blanks removed
				document.forms[0].txtSearch.value = pstrSearchText;
				//get the length of the trimmed search text
				pintSearchTextLen = pstrSearchText.length;
				
				if (pintSearchTextLen < 3) {
					//Minimum of 3 characters for search
					//clear hidden value
					hidSearchText.value = "";
					document.forms[0].txtSearch.focus();
					alert("Search text must be at least 3 characters");
					return false;
				}
				else {
					if (pintSearchTextLen > 81) {
						//Maximum of 81 characters for search
						//clear hidden value
						hidSearchText.value = "";
						document.forms[0].txtSearch.focus();
						alert("Search text must be less than 82 characters");
						return false;
					}
					else {
						//Valid length of search  
						//Check for   "<" 
						var pstrScript2 = "<";
						var re2 = new RegExp(pstrScript2, "g");
						var result2 = pstrSearchText.match(re2);
						if (result2) {
							//clear hidden value
							hidSearchText.value = "";
							document.forms[0].txtSearch.focus();
							alert("Invalid character '<' entered in search.  Please remove this character and try again.");
							return false;
						}
						else {
							//Valid search, submit request
							hidSearchText.value = pstrSearchText;
							document.forms[0].txtSearch.focus();
							//document.forms[0].submit();
							return true;
						}
					}
				}
			}
		}
	}
	
	
//    function window.onbeforeprint() { >> only works for IE
	function window_onbeforeprint() {
		var hidJS;
		hidJS = document.getElementById("hidJSEnabled");
     	var strLogo, strFund, strExport, strPrint;
		strLogo = document.getElementById("divFixedMenu");
		strFund = document.getElementById("tblFund");
		strExport = document.getElementById("btnExport1");
		strPrint = document.getElementById("btnPrint");
		if (hidJS != null) {
			var hidValue;
			hidValue = document.getElementById("hidBrowser");
			if (hidValue.value.substr(0,1) == "I") {
				//Make sure the browser is IE
				//Before printing document, hide Menu and other objects
				//divMenuOB.style.display = "none";
				if (strLogo != null) {
					//divLogo.style.display = "none";	
					divFixedMenu.className = "fixed_menu2_print";
					divFixedMenu.style.display = "none";
					divScrollable.className = "scrollareaPrint";
					tblBC.style.display = "none";
					tblTabs.style.paddingTop = "5px";
					tblSearch.style.display = "none";
					divSearch.style.display = "none";
					if (strExport != null) {
						document.all.btnExport1.style.display = "none";	
					}
					if (strPrint != null) {
						document.all.btnPrint.style.display = "none";			
					}
					//divBI.className = "divBISrchPrint";
				}
			}
        }
    }

//    function window.onafterprint() { >> only works for IE
    function window_onafterprint() {
		var hidJS;
		hidJS = document.getElementById("hidJSEnabled");
     	var strLogo, strFund, strExport, strPrint;
		strLogo = document.getElementById("divFixedMenu");
		strFund = document.getElementById("tblFund");
		strExport = document.getElementById("btnExport1");
		strPrint = document.getElementById("btnPrint");
        if (hidJS != null) {
			var hidValue;
			hidValue = document.getElementById("hidBrowser");
			if (hidValue.value.substr(0,1) == "I") {
				//Make sure the browser is IE
				//After printing document, redisplay Menu and other objects
				//divMenuOB.style.display = "";
				if (strLogo != null) {
					//divLogo.style.display = "";				
					divFixedMenu.style.display = "";
					divFixedMenu.className = "fixed_menu_New";
					divScrollable.className = "scrollarea";
					tblBC.style.display = "";
					tblTabs.style.paddingTop = "";
					tblSearch.style.display = "";
					divSearch.style.display = "";
				if (strExport != null) {
						document.all.btnExport1.style.display = "";
					}
					if (strPrint != null) {
						document.all.btnPrint.style.display = "";
					}
					//divBI.className = "divBISrchDisplay";
				}
			}   
       }
    }
