/* RegEx Constants */
var RegExes=new Array();

/* Cookie Utility */
var CookieUtil={
	getValue: function(name){
	  if(!name)return document.cookie;
		var exp = new RegExp (escape(name) + "=([^;]+)");
		var ck=document.cookie + ";";
		if (exp.test(ck)){
			exp.exec(ck);
			return unescape(RegExp.$1);
		}
		return null;
	}
}

// Generic create window function
function CreateWindow(URL,Target,Width,Height) {
	window.open(URL, Target,'toolbar=0,menubar=0,location=0,width=' + Width + ',height=' + Height + ',resizable=1,scrollbars=1');
}

function BrowserClient(){
	this.userAgent=navigator.userAgent.toLowerCase();
	this.isIE=this.userAgent.indexOf("msie")>=0;
	this.isWin=this.userAgent.indexOf("win")>=0;

// http://msdn.microsoft.com/library/default.asp?url=/workshop/author/dhtml/overview/browserdetection.asp
	this.ver = -1; // Return value assumes failure
	this.isBad=false;
	if (navigator.appName == 'Microsoft Internet Explorer'){
		var re  = new RegExp("msie ([0-9]{1,}[\.0-9]{0,})");
		if (re.exec(this.userAgent) != null){
			this.ver = parseFloat( RegExp.$1 );
			this.isBad=this.ver<7.0;
		}
	}
	this.getHeight=function(){
		if( typeof( window.innerHeight ) == 'number' ) 
			return window.innerHeight;
		else if (document.documentElement &&  document.documentElement.clientHeight) 
			return document.documentElement.clientHeight;
		else if(document.body && document.body.clientHeight) 
			return document.body.clientHeight;	 
		return 0;
	}
	this.getScrollTop=function(){
		if (document.documentElement &&  document.documentElement.scrollTop) 
			return document.documentElement.scrollTop;
		else if(document.body && document.body.scrollTop) 
			return document.body.scrollTop;
		return 0;
	}
	this.createShim=function(){
		var shim=document.createElement('iframe');
		if(document.location.protocol == "https:")shim.src="javascript:false;document.write('');";
		else shim.src="javascript:false	";
		shim.scrolling="no"; shim.frameBorder="1"; shim.style.zIndex="98";
		shim.style.position="absolute";
		return shim;
	}
	this.showShim=function(shim, elem){
		if(!elem)return null;
		if(!elem.insertAdjacentElement)return null;
		if(!WebSiteVars.client.isWin)return null;
		if(!WebSiteVars.client.isBad)return null;
		if(!shim){
			shim=this.createShim();
			elem.insertAdjacentElement("beforeBegin",shim);
		}
		shim.style.width = elem.offsetWidth;
		shim.style.height = elem.offsetHeight;
		shim.style.top = elem.style.top;
		shim.style.left = elem.style.left;
		shim.style.display="block";
		elem.shim=shim;
		return shim;
	}
}

var WebSiteVars = {
	client: new BrowserClient()	
}

function AddUrlHistory(){
	var url=window.location+"";
	if(url.toLowerCase().indexOf("/quickorder.aspx")>=0)return false;
	if(url.toLowerCase().indexOf("/cart.aspx")>=0)return false;
	if(url.length<9)return false;
	if(url.indexOf("https://")==0)return false;
	document.cookie="URLHIST="+escape(url)+"; path=/";
}

function GoToURL(URL,UseAbsolute) {
	var mainForm = document.forms["aspnetForm"];
	if (mainForm) {
		var userID = mainForm["id"].value;		
		if (userID)URL = URL + "?id=" + userID;
		if (UseAbsolute>0)URL = "http://" + WebSiteVars.Server + URL;
		document.location = URL;
	}	
}

function getObj(name){
	if (document.getElementById)return document.getElementById(name);
	else if (document.all)return document.all[name];
	else if (document.layers)return document.layers[name];
	return null;
}

// image on/off
function changeOn (Reference) {	
	var image = Reference.firstChild
	if (image) {
		if (image.nodeName == "IMG") {
			var name = image.name;
			image.src = eval(name + "on.src");
		}
	}
}

function changeOff (Reference) {
	var image = Reference.firstChild
	if (image) {
		if (image.nodeName == "IMG") {
			var name = image.name;
			image.src = eval(name + "off.src");
		}
	}
}

function changeImages() {
  if (document.images) {
    for (var i = 0; i < changeImages.arguments.length; i += 2) {
      document[changeImages.arguments[i]].src = eval(changeImages.arguments[i + 1] + ".src");
    }
  }
}

// swap contents of droplist with array
function loadSelectOptions(objSelect, arrList) {
  if (!objSelect) return;
  if (!objSelect.tagName) return;
  if (objSelect.tagName != 'SELECT') return;
  objSelect.options.length = 0;
  objSelect.options.length = arrList.length;
  for (x = 0; x < arrList.length; x++) {
    objSelect.options[x] = arrList[x]
  }
}

function findPosX(obj){
	var curleft = 0;
	if (obj.offsetParent)	{
		while (obj.offsetParent)		{
			curleft += obj.offsetLeft
			obj = obj.offsetParent;
		}
	}
	else if (obj.x) curleft += obj.x;
	return curleft;
}

function findPosY(obj){
	var curtop = 0;
	if (obj.offsetParent)	{
		while (obj.offsetParent)		{
			curtop += obj.offsetTop
			obj = obj.offsetParent;
		}
	}
	else if (obj.y)	curtop += obj.y;
	return curtop;
}

var HttpReq={
	values : new Array,
	_setup : function() {
		try {HttpReq.HR = new ActiveXObject("Msxml2.XMLHTTP");} catch (e) {
  		try {HttpReq.HR = new ActiveXObject("Microsoft.XMLHTTP");} catch (E) {
   			HttpReq.HR = false;}}
		if (typeof XMLHttpRequest!='undefined')
			try {HttpReq.HR = new XMLHttpRequest();} catch (e) {HttpReq.HR=false;}
		if (!HttpReq.HR && window.createRequest)
			try {HttpReq.HR = window.createRequest();} catch (e) {HttpReq.HR=false;}
	},
	clear : function(){
		HttpReq.values=new Array();
		HttpReq.callBack=null;
	},
  get : function(url){
		if(!HttpReq.HR)HttpReq._setup();
		var data="";
		for(key in HttpReq.values){
			var val=HttpReq.values[key];
			if(!val)continue;
			data+=((data.length>0)?"&":"")+key+"="+escape(val);
		}
		if(data!="")url+="?"+data;
		HttpReq.HR.open("GET",url,false);
		HttpReq.HR.send(null);
		return HttpReq.HR.responseText;
	},
  getUrl : function(url,callBack){
		if(callBack)HttpReq.callBack=callBack;
		if(!HttpReq.HR)HttpReq._setup();
		if(!HttpReq.HR)return;
		if(HttpReq.callBack){
			HttpReq.HR.open("GET",url,true);
			HttpReq.HR.onreadystatechange=HttpReq.stateChg;
			HttpReq.HR.send(null);
		}else{
			HttpReq.HR.open("GET",url,false);
			HttpReq.HR.send(null);
			return HttpReq.HR.responseText;
		}
	},
  post : function(url,callBack){
		if(callBack)HttpReq.callBack=callBack;
		if(!HttpReq.HR)HttpReq._setup();
		if(!HttpReq.HR)return;
		try{
			var data="";
			for(key in HttpReq.values){
				var val=HttpReq.values[key];
				if(!val)continue;
				data+=((data.length>0)?"&":"")+key+"="+escape(val);
			}
			if(HttpReq.callBack){
				HttpReq.HR.open("POST",url,true);
				HttpReq.HR.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
				HttpReq.HR.onreadystatechange=HttpReq.stateChg;
				HttpReq.HR.send(data);
			}else{
				HttpReq.HR.open("POST",url,false);
				HttpReq.HR.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
				HttpReq.HR.send(data);
				return HttpReq.HR.responseText;
			}
		}catch(e){alert("HttpReq: "+e.message);}
	},
	stateChg : function(){
		try{
			var hr=HttpReq.HR;
			if(hr.readyState != 4) return;
			if (hr.status != 200)HttpReq.callBack(hr.responseText, hr.status, hr.statusText);
			else HttpReq.callBack(hr.responseText);
		}catch(e){alert("StateChg: "+e.message);}
	}
}

var SSMenu={
	init: function() {
		var sfEls = getObj("ssmenu");
		if(!sfEls)return;
		sfEls=sfEls.getElementsByTagName("LI");
		if(!sfEls)return;
		for (var i=0; i<sfEls.length; i++) {
			if((sfEls[i].className) && (sfEls[i].className=="endMnu")){
				sfEls[i].onmouseover=function(){SSMenu.show(this,"emhover");}
				sfEls[i].onmouseout=function(){SSMenu.hide(this,"endMnu");}
			}else{
				sfEls[i].onmouseover=function(){SSMenu.show(this,"sfhover");}
				sfEls[i].onmouseout=function(){SSMenu.hide(this);}
			}
			sfEls[i].ulElem=sfEls[i].getElementsByTagName("UL")[0];
		}
	},
	show: function(elem,hn){
		if(SSMenu.curMenu)SSMenu.curMenu.className=SSMenu.curClass;
		SSMenu.curClass=elem.className;
		SSMenu.curMenu=elem;
		elem.className=hn;
		if(elem.ulElem)SSMenu.showShim(elem.ulElem);
		if(SSMenu.ahTimer)window.clearTimeout(SSMenu.ahTimer);
		SSMenu.ahTimer=null;
	},
	hide: function(elem,cn){
		if(SSMenu.curMenu){
			if(SSMenu.ahTimer)window.clearTimeout(SSMenu.ahTimer);
			SSMenu.ahTimer=window.setTimeout("SSMenu.autohide();",300);
		}
	},
	autohide:function(){
		if(SSMenu.curMenu){
			var elem=SSMenu.curMenu;
			elem.className=SSMenu.curClass;
			if((elem.ulElem) && (elem.ulElem.shim))elem.ulElem.shim.style.display="none";
		}
		SSMenu.curMenu=null;
		if(SSMenu.ahTimer)window.clearTimeout(SSMenu.ahTimer);
		SSMenu.ahTimer=null;
	},
	showShim:function(elem){
		var shim=SSMenu.getShim(elem); if(!shim)return;
		shim.style.width = elem.offsetWidth;
		shim.style.height = elem.offsetHeight;
		shim.style.top = elem.offsetTop;
		shim.style.left = elem.offsetLeft;
		shim.style.display="block";
		elem.shim=shim;
	},
	getShim:function(elem){
		if(SSMenu.shim)return SSMenu.shim;
		if(!WebSiteVars.client.isWin)return null;
		if(!WebSiteVars.client.isBad)return null;
		var shim=document.createElement('iframe');
		if(document.location.protocol == "https:")shim.src="javascript:false;document.write('');";
		else shim.src="javascript:false";
		shim.scrolling="no"; shim.frameBorder="0"; shim.style.zIndex="99";
		shim.style.position="absolute";
		elem.insertAdjacentElement("beforeBegin",shim);
		return SSMenu.shim=shim;
	}
}

var PopBuy={
	init: function(){
		if(!(PopBuy.DlgBox=getObj("BUYPOPUP"))){
			if(document.body.insertAdjacentHTML)
				document.body.insertAdjacentHTML("afterBegin","");
			else if(document.createRange)
				document.body.AppendChild(document.createRange().createContextualFragment("<div id='BUYPOPUP' style='left:300px;display:none;'></div>"));
			PopBuy.DlgBox=getObj("BUYPOPUP");
		}
		if(!WebSiteVars.client.isBad && (PopBuy.DlgBox)){
			PopBuy.DlgBox.style.position="fixed";
			PopBuy.DlgBox.style.top=(WebSiteVars.client.getHeight()/2-150) + "px";
		}
	},
	buy: function(elem,skuID,vid){
		var smsg=null;
		try{
		  if(!CookieUtil.getValue()){
		    window.location="/policies/CookieHelp.aspx";
		    return false;
		  }
			if(PopBuy.popupBuried())return true;
			if(!skuID)return false;
			if(!PopBuy.DlgBox){
				PopBuy.init();
				if(!PopBuy.DlgBox)return true;
			}
			var qid="QTY_" + (vid?vid:skuID);
			var qty=NaN;
			if(elem && elem.form){
				if(elem.form[qid])qty=parseInt(elem.form[qid].value);
				if(vid && elem.form["itemNo_"+vid])skuID=elem.form["itemNo_"+vid].value;
			}
			if(!qty){
				alert("Item quantity is invalid. Please re-enter.");
				return false;
			}
			PopBuy.showWait();
			HttpReq.clear();
			HttpReq.values["qty"]=qty;
			HttpReq.values["sku"]=skuID;
			HttpReq.post("/cartadd.aspx",PopBuy.display);
			return false;
		}catch(e){alert("PopBuy: "+e.message);}
		return true;
	},
	buyKP: function(e, elem, sid, qid){
		var kn;
		if(window.event)kn = e.keyCode;
		else if(e.which)kn = e.which;
		if(kn!=13)return true;
		return PopBuy.buyEx(elem,sid,qid);
	},
	buyEx: function(elem,sid,qid){
		try{
			if(PopBuy.popupBuried())return true;
			if(!qid)return false;
			if(!PopBuy.DlgBox)PopBuy.init();
			var qty=NaN;
			if(elem && elem.form){
				if(elem.form[qid])qty=parseInt(elem.form[qid].value);
				if(elem.form[sid])skuID=elem.form[sid].value;
			}
			if(!qty){
				alert("Item quantity is invalid. Please re-enter.");
				return false;
			}
			if((!skuID)||(skuID=='Enter item number')){
				alert("Item No is invalid. Please re-enter.");
				return false;
			}
			PopBuy.showWait();
			HttpReq.clear();
			HttpReq.values["qty"]=qty;
			HttpReq.values["sku"]=skuID;
			HttpReq.post("/cartadd.aspx",PopBuy.display);
			return false;
		}catch(e){alert("PopBuy: "+e.message);}
		return true;
	},
	showWait:function(){
		var pop=PopBuy.DlgBox;
		pop.innerHTML="<table class=\"wait\" cellpadding=\"0\" cellspacing=\"0\"><tr class=\"hdr\"><th colspan=\"2\">Please Wait...</th></tr><tr class=\"sku\"><td colspan=\"2\"><img src=\"/images/myaccount/ProgIndicator.gif\" alt=\"Please wait\"/></td></tr><tr class=\"ftr ftr2\"><td colspan=\"2\">&#160;</td></tr></table>";
		PopBuy.showShim(pop);
		pop.style.display="block";
		if(WebSiteVars.client.isBad)
			pop.style.top=WebSiteVars.client.getHeight()/2-150+WebSiteVars.client.getScrollTop();
		return pop;
	},
	display:function(resp){
		var pop=PopBuy.DlgBox;
		pop.innerHTML=resp;
		pop.style.display="block";
		PopBuy.showShim(pop);
		var bury=PopBuy.popupBuried();
		var elem=getObj("POPCHK");
		if(elem)elem.checked=bury;
		if(PopBuy.ahTimer)window.clearTimeout(PopBuy.ahTimer);
		if(bury)
			PopBuy.ahTimer=window.setTimeout("PopBuy.autohide();",5000);
		var elem=getObj("CARTSUMTOTALTMP");
		if(elem){
			var sumText=elem.innerHTML;
			elem=getObj("CARTSUMTOTAL");
			if(elem)elem.innerHTML=sumText;
		}
	},
	autohide: function(){
		var pop=PopBuy.DlgBox;
		pop.style.display="none";
		if(pop.shim)pop.shim.style.display="none";
		if(PopBuy.ahTimer)window.clearTimeout(PopBuy.ahTimer);
	},
	buryPopup: function(bury){
		if(bury)document.cookie="POPUPBURY=T; path=/";
		else document.cookie="POPUPBURY=F; path=/";
	},
	popupBuried: function(){return CookieUtil.getValue("POPUPBURY")=='T';},
	showShim:function(elem){
		var shim=PopBuy.getShim(elem); if(!shim)return;
		shim.style.width = elem.offsetWidth;
		shim.style.height = elem.offsetHeight;
		shim.style.top = elem.style.top;
		shim.style.left = elem.style.left;
		shim.style.display="block";
	},
	getShim:function(elem){
		if(PopBuy.shim)return PopBuy.shim;
		if(!WebSiteVars.client.isWin)return null;
		if(!WebSiteVars.client.isBad)return null;
		var shim=document.createElement('iframe');
		if(document.location.protocol == "https:")shim.src="javascript:false;document.write('');";
		else shim.src="javascript:false	";
		shim.scrolling="no"; shim.frameBorder="0"; shim.style.zIndex="98";
		shim.style.position="absolute";
		elem.insertAdjacentElement("beforeBegin",shim);
		return PopBuy.shim=elem.shim=shim;
	}
}

// BEGIN fixlinks
// manages user state for visitors without cookies
//
function fixLinks() {
	if (CookieUtil.getValue("ASP.NET_SessionId"))return;
	var vardocloc = document.location.toString();

	if (!WebSiteVars.userID) {
		// Retrieve the userID from the querystring
		
		var doclocparts = vardocloc.split("?");

		if (doclocparts[1]) {

			// Check for both ?usr= and ?id=
			if (doclocparts[1].match(/^id=([^&#]*)/i)) {
				WebSiteVars.userID=RegExp.$1;
			} else if (doclocparts[1].match(/&id=([^&#]*)/i)) {
				WebSiteVars.userID=RegExp.$1;
			}

			if (doclocparts[1].match(/^usr=([^&#]*)/i)) {
				WebSiteVars.userID=RegExp.$1;
			} else if (doclocparts[1].match(/&usr=([^&#]*)/i)) {
				WebSiteVars.userID=RegExp.$1;
			}
		}
	}
		
	var doclocparts = vardocloc.split("#");
			
	// If strUserID was passed to this page...
	if (WebSiteVars.userID) {
			
		// Loop through all links...
		for (i=0; i < document.links.length; i++) {
			//alert ("Checking " + document.links[i].href);
					
			var anchorInLink = (document.links[i].href.indexOf("#")>0);
			var baseUrlInLink = (document.links[i].href.indexOf(doclocparts[0]) == 0);
			
			if (!anchorInLink || !baseUrlInLink) {
				if (document.links[i].href.indexOf("?")>0) {
					if (document.links[i].href.match(/(.*)[?&]+id=/i) ) 
						document.links[i].href = document.links[i].href.replace(/id=([^&#]*)/i,"ID=" + WebSiteVars.userID);
					else document.links[i].href = document.links[i].href.replace(/(.*)\?(.*)/,"$1" + "?ID=" + WebSiteVars.userID + "&$2");
				}  else document.links[i].href = document.links[i].href.replace(/^http([^#]*)/,"http$1?ID=" + WebSiteVars.userID );

			} 
		}
	}
	fixForms();          
}

//OnLoadEvent.add(fixLinks);

// Fix form elements
function fixForms () {
	if (!WebSiteVars.userID) return;
	for (i=0; i< document.forms.length; i++) {
		if (objEl=document.forms[i].id) objEl.value=WebSiteVars.userID;
		if (objEl=document.forms[i].ID) objEl.value=WebSiteVars.userID;				
		if (objEl=document.forms[i].p_UserID)objEl.value=WebSiteVars.userID;
		if (objEl=document.forms[i].p_userid)objEl.value=WebSiteVars.userID;
		if (objEl=document.forms[i].p_id)objEl.value=WebSiteVars.userID;
	} 
}

function LoadUser(){
	var st=CookieUtil.getValue("CARTSUMTOTAL");
	if(st)$("#CARTSUMTOTAL").html(st);
  st = CookieUtil.getValue("PROMO");
  if (st) {
    var elem = $("#promoMsg");
    if (st == "OLMXHC9A") {
      elem.html('Mr. Olympia Promotion - Save 25%');
      elem.show();
      $("#promoPopup").html('<div class="box"><div class="title">Thank you for visiting us<br /> at Mr. Olympia 2009!</div>To show our appreciation, we&#x2019;ll take <b>25% OFF</b> all products ordered. Your discount will be automatically applied to your shopping cart.<br /><b>Hurry!</b> This offer expires Monday, October 12, 2009 at midnight PST.<br /> <div class="fine">25% OFF offer on all products applies to everyone - new and existing customers. Offer valid for web orders only. Quantity limit of 5 for each unique product purchased.<br/><br/>If you are a new customer, you will also get Free Shipping ($5.95 value) when placing an order for over $50 that is shipped to the continental United States (48 states). This $5.95 Free Shipping credit will be shown on the last page of checkout.</div></div>');
    }
  }
	st = CookieUtil.getValue("MYACCT_NAME");
	if (st) {
	  $("#MYACCT_NAME").html(st);
	  $("#MYACCT_LOGIN_LINK").html("Log Out");
	}
}

function CheckCookie(){
  if(!CookieUtil.getValue()){
    window.location="/policies/CookieHelp.aspx";
    return false;
  }
}

function viewXLImg(){
	var elem=getObj('prodLargeImg');
	elem.style.zIndex="100";
	elem.style.display='block';	
	WebSiteVars.client.showShim(elem.shim,elem);
}
function hideXLImg(){
	var elem=getObj('prodLargeImg');
	elem.style.display='none';	
	if(elem.shim)elem.shim.style.display='none';
}

function LoadImages () {
	if (document.images) {

	  image1on = new Image();
	  image1on.src = WebSiteVars.BasePath + "/images/topnav/tab_home_on.gif";
	  
	  image1off = new Image();
	  image1off.src = WebSiteVars.BasePath + "/images/topnav/tab_home.gif"; 
	  
	  image2on = new Image();
	  image2on.src = WebSiteVars.BasePath + "/images/topnav/tab_categories_on.gif";
	  
	  image2off = new Image();
	  image2off.src = WebSiteVars.BasePath + "/images/topnav/tab_categories.gif";  
	  
	  image3on = new Image();
	  image3on.src = WebSiteVars.BasePath + "/images/topnav/tab_brands_on.gif";
	  
	  image3off = new Image();
	  image3off.src = WebSiteVars.BasePath + "/images/topnav/tab_brands.gif";
	  
	  image4on = new Image();
	  image4on.src = WebSiteVars.BasePath + "/images/topnav/tab_specials_on.gif";
	  
	  image4off = new Image();
	  image4off.src = WebSiteVars.BasePath + "/images/topnav/tab_specials.gif";  
	  
	  image5on = new Image();
	  image5on.src = WebSiteVars.BasePath + "/images/topnav/tab_articles_on.gif";
	  
	  image5off = new Image();
	  image5off.src = WebSiteVars.BasePath + "/images/topnav/tab_articles.gif"; 
	}
}

function PreSelectTab() {
	//alert("tabName=" + tabName);

	if (!window.tabName) return
	if (tabName=="Home") {
		image1off.src = image1on.src;
	}else if (tabName=="Categories") {
		image2off.src = image2on.src;
	}else if (tabName=="Brands") {
		image3off.src = image3on.src;
	}else if (tabName=="Specials") {
		image4off.src = image4on.src;
	}else if (tabName=="Articles") {
		image5off.src = image5on.src;
	}
}

// build footer text
function BuildFooter() {

  var footertext = "";
  footertext += "<p class=\"footer\">Information provided on this site is solely for informational purposes only. It \n";
  footertext += "is not a substitute for professional medical advice. Do not use this \n";
  footertext += "information for diagnosing or treating a health problem or disease, or \n";
  footertext += "prescribing of any medications or supplements. Only your healthcare provider \n";
  footertext += "should diagnose your healthcare problems and prescribe treatment.\n";
  footertext += "None of our statements or information, including health claims, articles, \n";
  footertext += "advertising or product information have been evaluated or approved by the \n";
  footertext += "United States Food and Drug Administration (FDA). The products or ingredients \n";
  footertext += "referred to on this site are not intended to diagnose, treat, cure or prevent \n";
  footertext += "any disease. Please consult your healthcare provider before starting any \n";
  footertext += "supplement, diet or exercise program, before taking any medications or \n";
  footertext += "receiving treatment, particularly if you are currently under medical care. Make \n";
  footertext += "sure you carefully read all product labeling and packaging prior to use. If you \n";
  footertext += "have or suspect you may have a health problem, do not take any supplements \n";
  footertext += "without first consulting and obtaining the approval of your healthcare provider. </p> \n";
  footertext += "<p class=\"footer\">*These statements have not been evaluated by the Food and Drug Administration. \n"
  footertext += "These products are not intended to diagnose, treat, cure or prevent any disease.</p> \n";
  footertext += "<p class=\"footer\">Copyright 2000-2009 Nutrition Express Corporation. All rights reserved.</p> \n";
  
  $("#footertext").html(footertext);
}

function submitSearch() {
  var elemSearch = document.forms[0]["topNavSearch"];
  var query = elemSearch.value;

  var form = document.forms["searchForm"];

  if (form) {
    form["query"].value = query;
    form.submit();
  } else {
    alert("I'm sorry. An error has occurred.");
    return false;
  }
}

$(document).ready(function(){
  SSMenu.init();
  LoadUser();
  LoadImages();
  PreSelectTab();
  BuildFooter();
  $("#promoMsg").hoverIntent({
    sensitivity: 3,
    interval: 100,
    over: function() {$("#promoPopup").fadeIn("fast");},
    timeout: 500,
    out: function() {$("#promoPopup").fadeOut("slow");}
  });
  $("#promoDisc").hoverIntent({
    sensitivity: 3,
    interval: 100,
    over: function() { $("#promoPopup").fadeIn("fast"); },
    timeout: 500,
    out: function() { $("#promoPopup").fadeOut("slow"); }
  });
});
