
function ClearSearch() {
	try {
		var element = window.document.getElementById('SearchKeywords');
		if(element.value=='Search'){
			element.value='';
		}else{}
	} catch(e) {}
}

function WriteSearch() {
	try {
		var element = window.document.getElementById('SearchKeywords');
		if(element.value==''){
			element.value='Search';
		}else{}
	} catch(e) {}
}


ReplaceSearch = function() {
	try {
		var elements = window.document.getElementById('SearchKeywords');
		if(window.addEventListener){	
			window.addEventListener('focus', ClearSearch, true);
			window.addEventListener('blur', WriteSearch, true);	
		}else{
			elements.attachEvent("onfocus",ClearSearch);
			elements.attachEvent("onblur",WriteSearch);
		}
	} catch(e) {}
}


if(window.addEventListener) window.addEventListener('load', ReplaceSearch, false); // gecko, safari, konqueror and standard
else if(document.addEventListener) document.addEventListener('load', ReplaceSearch, false); // opera 7
else if(window.attachEvent) { // win/ie
	window.attachEvent('onload', ReplaceSearch);
} else { // mac/ie5
	if(typeof window.onload == 'function') {
		var existing = onload;
		window.onload = function() {
			existing();
			ReplaceSearch();
		}
	} else {
		window.onload = function() {
			ReplaceSearch();
		}
	}
}



var newWindow = null;

// Generic Pop-up window
function PopWin(url,strName,strWidth,strHeight) {

	if(strHeight == '') {
		strHeight = document.body.clientHeight;
		//strHeight = document.body.offsetHeight;
	}
	if(strWidth == '') {
		strWidth = document.body.clientWidth;
		//strWidth = document.body.offsetWidth;
	}

	//alert(strHeight + 'x' + strWidth);

	if (newWindow && newWindow.open && !newWindow.closed){
		//alert(newWindow.name + ' is open');
		newWindow.location = url;
		newWindow.focus();
	}else{
		newWindow = window.open(url,strName,"status=yes,scrollbars=yes,toolbar=no,location=no,menubar=no,resizable=yes,width="+strWidth+",height="+strHeight);
	}
}






// ====================================================================
// Original post: Unkown person - I lost my notes on who did this first
//                Unkown source
// Modified by:   Walter Torres <walter@torres.ws> [www.torres.ws]
//                2001/04/29
//                I found the secret to remove the prompt!
//                Original post did not have this gem to it.
//
// This accesses a built-in Windows command that can perform Magic!
// And yes, this is a Windows ONLY solution.
// In fact, it only works in IE. :(
//
// This still doesn't work with Frames!  :(
//
//          INPUT: intOLEcmd   = integer between 1 and 37, only a few are of use
//                 intOLEparam = parameter integer for function - optional
//         OUTPUT: none
//   DEPENDANCIES: none
//
//           NOTE: intOLEparam is not optional in the Object call,
//                 I just made it optional here to make life easier.
//                 All command values use '1' execept print, thus my reasoning.
//
//        EXAMPLE: // This prints given window/frame WITHOUT prompt!
//                 objWinName.ieExecWB(6, -1)
//
//                 // This prints given window/frame WITH prompt!
//                 objWinName.ieExecWB(6)

// 	               // This will display the Print Preview window
//                 objWinName.ieExecWB(7)
//
//         VALUES: intOLEcmd has these possible values
//                 OLECMDID_OPEN         = 1
//                 OLECMDID_NEW          = 2    warning, this kills IE windows!
//                 OLECMDID_SAVE         = 3
//                 OLECMDID_SAVEAS       = 4
//                 OLECMDID_SAVECOPYAS   = 5    note: does nothing in IE
//                 OLECMDID_PRINT        = 6    note: give '-1' as param - no prompt!
//                 OLECMDID_PRINTPREVIEW = 7
//                 OLECMDID_PAGESETUP    = 8
//                          Others have no use in IE

function ieExecWB( intOLEcmd, intOLEparam )
{
	try{
		// Gathering browser name and version
		strUAName = 'msie';
		strUA = navigator.userAgent.toLowerCase();
		strNamePos = strUA.indexOf(strUAName) + 1;
		strUAVer = strUA.substr(strNamePos + strUAName.length,3);

		// If the name matches (IE), then proceed
		if (strNamePos > 0) {

			// Create OLE Object
			var WebBrowser = '<OBJECT ID="WebBrowser1" WIDTH=0 HEIGHT=0 CLASSID="CLSID:8856F961-340A-11D0-A96B-00C04FD705A2"></OBJECT>';

			// Place Object on page
			document.body.insertAdjacentHTML('beforeEnd', WebBrowser);

			// if intOLEparam is not defined, set it
			if ( ( ! intOLEparam ) || ( intOLEparam < -1 )  || ( intOLEparam > 1 ) )
				intOLEparam = 1;

			// Execute Object
			WebBrowser1.ExecWB( intOLEcmd, intOLEparam );

			// Destroy Object
			WebBrowser1.outerHTML = "";
		}
	}
	catch(e){}
}









function ShowHideItems(MenuElementID,ForceOpen){
	try{
		var obj = document.getElementById(MenuElementID);
		if(obj.style.display == "none" || obj.style.display == ""){
			obj.style.display="block";
		}else{
			obj.style.display="none";
		}
		if(ForceOpen == true){
			obj.style.display="block";
		}
	}
	catch(e){}
}


function MenuToggle(AnchorElementID,ForceOpen){
	try{
		var obj = document.getElementById(AnchorElementID);
		if(obj.className == "Close"){
			obj.className="Open";
		}else{
			obj.className="Close";
		}
		if(ForceOpen == true){
			obj.className="Open";
		}
	}
	catch(e){}

}


function ToggleView(MenuIdent,AnchorIdent,Force){
	ShowHideItems(MenuIdent,Force);
	MenuToggle(AnchorIdent,Force);
}


function InsertImg(ImgID,ImgSrc){
	try{
		var obj = document.getElementById(ImgID);
		obj.src=ImgSrc;
	}
	catch(e){}
}



function ResizeToPrint(ImgID){
	try{
		var obj = document.getElementById(ImgID);

		ImgWidth = obj.width;
		ImgHeight = obj.height;

		divFactor = 300 / ImgWidth;
		//alert(ImgWidth+"x"+ImgHeight);

		if(divFactor < 1){
			obj.width = 300;
			obj.height = ImgHeight * divFactor;
		}
	}
	catch(e){}
}



function CheckIE(){
	try{
		// Gathering browser name and version
		strUAName = 'msie';
		strUA = navigator.userAgent.toLowerCase();
		strNamePos = strUA.indexOf(strUAName) + 1;
		strUAVer = strUA.substr(strNamePos + strUAName.length,3);

		// If the name matches (IE), then proceed
		if (strNamePos > 0) {
			// If the version is greater than 6, proceed
			if (strUAVer > 5) {
				return true;
			}
		}
	}
	catch(e){}
}
