//Search Related Scripts--------------------------------------------------------------------//

	String.prototype.ltrim = function () {
		return this.replace(/^\s*/, "");
	}
		
	String.prototype.rtrim = function () {
		return this.replace(/\s*$/, "");
	} 
		
	String.prototype.trim  = function () {
		return this.ltrim().rtrim(); 
	}

	function ValidateFormSubmit2() {
		document.frmSearch2.qt.value = document.frmSearch2.qt.value.trim();

		if (document.frmSearch2.qt.value == '') {
			alert('Please enter search text.');
			return false;
		}
		else {
			document.frmSearch2.action = 'enter.htm';
			document.frmSearch2.target = 'content';
			document.frmSearch2.submit();
		}
	}
	
	
	function SetFocus() {
		document.frmSearch2.qt.focus();
	}

//Popup Script-------------------------------------------------------------------------------//
	function popNewWindow(PopURL,PopHeight,PopWidth,ScrollBar)
		{
	        modalX = (screen.width-PopWidth) / 2
	        modalY = (screen.height-PopHeight) / 2

	        //Open New Window
	        var WinPlace = '"resizable=yes,scrollbars=' + ScrollBar + ',height=' + PopHeight + ',width=' + PopWidth + ',screenx=' + modalX + ',screenY=' + modalY + ',left=' + modalX + ',top=' + modalY + '"'
			var OpenStr = window.open(PopURL, "SonicPopup", WinPlace)
        	OpenStr.focus()
	    }  

		
	function popUnderWindow(PopURL,PopHeight,PopWidth,ScrollBar)
		{
	        modalX = (screen.width-PopWidth) / 2
	        modalY = (screen.height-PopHeight) / 2

	        //Open New Window
	        var WinPlace = '"resizable=yes,scrollbars=' + ScrollBar + ',height=' + PopHeight + ',width=' + PopWidth + ',screenx=' + modalX + ',screenY=' + modalY + ',left=' + modalX + ',top=' + modalY + '"'
			var OpenStr = window.open(PopURL, "SonicPopup", WinPlace)
        	window.focus();
	    }  

//Image swap script - no preloader-----------------------------------------------------------//
	function changeImage(btn, img)
	    {
	        var objBtn = eval("document." + btn);
	        objBtn.src = img;
	    }

//Navigation Script-------------------------------------------------------------------------//

	//let the script know when the subnavs are loaded and ready for popup
	var SubNavReady = 0
	
	function SubNavLoaded(){
		SubNavReady = 1
	}

	function MakeArray(n){
	   this.length = n;
	   for (var i = 1; i<=n; i++)
	      this[i] = new Image();
	   return this;
	}
	
	//array of image names for items that have subnavs under them
	var imgName = new
	Array("News","Community","Jfamily","Multimedia","Shop1","Shop2","Support");
	
	if (document.images) {
		nav_on = new MakeArray(7);
		nav_off = new MakeArray(7);
		for (x=0;x<7;x++){
			nav_off[x] = new Image(); 
			nav_off[x].src = "images/" + imgName[x] + ".jpg";
			nav_on[x] = new Image();
			nav_on[x].src = "images/" +imgName[x] + "_on.jpg";
		}
	}
	

	function navOn(num){ 
		eval ("document." + imgName[num] + ".src ='" + nav_on[num].src +"'");
	}

	function navOff(num){ 
		eval ("document." + imgName[num] + ".src ='" + nav_off[num].src +"'");
	}

	//browser detection
	var NS = (navigator.appName == "Netscape");
	mac = navigator.appVersion.indexOf("Mac");
	if (mac>=0) {mac=1} else {mac=0}
	IE = (document.all) ? true : false; 
	NS4 = (document.layers) ?  true : false;
	eID = document.getElementById;
	if(eID && NS) {NS6=true} else {NS6=false}
	if ((IE) || (NS4) || (NS6)) {dhtml=1;}
	
	//reload the page when a Netscape 4.0 window is resized
	if(NS4){origWidth = innerWidth; origHeight = innerHeight;}
	function resizeNS() {
		if (NS4)
			if (innerWidth != origWidth || innerHeight != origHeight) 
				location.reload(true);
	}
	window.onResize = resizeNS;
	if (NS4){origWidth = innerWidth;origHeight = innerHeight;}
		
	px = ""; 
	menuOn = -1; 
	menuTop = 1; 
	ext = 5;
	layerLeft = 0;
//		aryLayerX = new Array;
	aryLayerY = new Array(262,200,152,246,218,218);// submenu heights
	menuLeft = new Array(1,101,201,301,401,501,629);// submenu left edge
	 
	function makeRef(refElement) {
		if (NS6) {var prefix = "document.getElementById('" + refElement + "')"}
		if (IE) {var prefix = "document.all." + refElement}
		if (NS4) {var prefix = "document." + refElement}
		return prefix;
	}


	function menuInit() { 
		for (m=0; m<7; m++) {
			layerRef =  makeRef("menu" + m);
//				aryLayerX[m]  = (IE || NS6) ? eval(layerRef + ".offsetWidth + 5") : eval(layerRef + ".clip.width + 5");
		}
	}
	 
	function eventYell(menuEvents) {
		mouseY  	=	(IE) ? event.y + menuTop : menuEvents.pageY + menuTop
		mouseX  	=	(IE) ? event.x : menuEvents.pageX
		minmouseY 	=	(IE) ? (menuTop - document.body.scrollTop - 20) : (menuTop+20);
		var menuRef 	=	makeRef("menuHead" + menuOn)
	  	if(
			(mouseY >(aryLayerY[menuOn] + menuTop + ext)) || 
			((mouseY - menuTop) < minmouseY ) || 
			(mouseX < (layerLeft - 10)) || 
//				(mouseX > (aryLayerX[menuOn] + layerLeft))
			(mouseX > (174 + layerLeft))
		){ 
			(IE || NS6) ? eval(layerRef + ".style.visibility = 'hidden'") : eval(layerRef + ".visibility = 'hidden'");
			navOff(menuOn);
	 		if (IE || NS6) { document.onmousemove = null }
			else{ document.releaseEvents(Event.MOUSEMOVE) }
		}
	}
	
	function navMenu(mID) {
		if(SubNavReady == 1){
			navOn(mID);
			layerRef =  makeRef("menu" + menuOn);
			
			if (menuOn != mID && menuOn != -1){
				(IE || NS6) ? eval(layerRef + ".style.visibility = 'hidden'") : eval(layerRef + ".visibility = 'hidden'");
				if (menuOn>=0) { navOff(menuOn) }
			}
			menuOn = mID;
			if(dhtml = 1){
				browserwidth = (IE || (NS6 &! mac)) ? (document.body.clientWidth) : (self.innerWidth)
				if (browserwidth > 800)
					{layerLeft = ((browserwidth - 800)/2  + menuLeft[menuOn] - NSoffset);}
				else{layerLeft = (menuLeft[menuOn]);}
				var layerLeftFix = (IE && mac) ? (menuLeft[menuOn]) : (layerLeft)
				layerRef =  makeRef("menu" + menuOn);
				(IE || NS6) ? eval(layerRef + ".style.left =" + layerLeftFix) : eval(layerRef + ".left =" + layerLeftFix);
				(IE || NS6) ? eval(layerRef + ".style.visibility = 'visible'") : eval(layerRef + ".visibility = 'visible'");
				if(document.layers) {document.captureEvents(Event.MOUSEMOVE)}
				document.onmousemove = eventYell;
				if (IE) 	{ document.onmouseover = null }
				else		{ document.releaseEvents(Event.MOUSEOVER)};
			}
		}
	} 
	
	window.onload = menuInit;

