function SendToSearchField(searchfor, tid) {
	window.document.forms['form1'].q.value = searchfor;
	goSearch(tid);
}

function goSearch(tid){
	var q = window.document.forms['form1'].q.value;
	qCheck = q.replace(/ /g,"");
	if(qCheck != ""){	
		q = q.replace(/ /g,"+");
		location.href = '/index.php?tid=' + tid + '&q=' + q;
	}	
}

 function SelectTab(tabid){
 	if(document.getElementById("infodiv1")){
 		//reset tabs
      	document.getElementById("infodiv1").style.visibility ="hidden";
      	document.getElementById("infodiv2").style.visibility ="hidden";
      	document.getElementById("infodiv3").style.visibility ="hidden";
      	document.getElementById("infodiv1").style.position ="absolute";
      	document.getElementById("infodiv2").style.position ="absolute";
      	document.getElementById("infodiv3").style.position ="absolute";

  	  	//reset background images.
      	newImage = "url(/images/basic/products_tab_clear.gif)";
      	if (document.getElementById("infotab1")){ document.getElementById("infotab1").style.backgroundImage = newImage; }
      	if (document.getElementById("infotab2")){ document.getElementById("infotab2").style.backgroundImage = newImage; }
      	if (document.getElementById("infotab3")){ document.getElementById("infotab3").style.backgroundImage = newImage; }

      	//set tab
      	newImage = "url(/images/basic/products_tab_selected.gif)";
      	document.getElementById("infotab"+tabid).style.backgroundImage = newImage;
      	document.getElementById("infodiv"+tabid).style.position ="relative";
      	document.getElementById("infodiv"+tabid).style.visibility ="visible";
		document.getElementById("infodiv"+tabid).style.top ="0px";
    }
 }
 
 function formSubscribeActivationLengthCheck(e, current, next){
	if(((document.getElementById(current).value.length)) >= 5){
		if(window.event)	keynum = e.keyCode;
  		else if(e.which)	keynum = e.which;
		if((keynum > 47 && keynum<58) || (keynum > 64 && keynum<91) || (keynum > 96 && keynum<123)){
	 		document.getElementById(next).focus();
	 	}
 	}
 }
 
//function to add a product to the shopchart
if (!(typeof AddToChart == "function") && !(typeof document.AddToChart == "function")){
		function AddToChart(postbackmoduleid, handlemoduleid, productid, amountfield){
		    amount = eval("document.getElementById('form1')." + amountfield + ".value")

		    setFormField("form1", "hidden", "order_chart", "add");
			setFormField("form1", "hidden", "order_amount", amount);
		    setFormField("form1", "hidden", "order_product", productid);
		    postModule(postbackmoduleid, handlemoduleid);
		}
}

//add all shown products to chart
if (!(typeof AddAllToChart == "function") && !(typeof document.AddAllToChart == "function")){
		function AddAllToChart(postbackmoduleid, handlemoduleid, orderid){
		    setFormField("form1", "hidden", "order_chart", "addall");
		    setFormField("form1", "hidden", "order_id", orderid);
			postModule(postbackmoduleid, handlemoduleid);
		}
}

//function to add a product to the favorite list.
if (!(typeof AddToFavorite == "function") && !(typeof document.AddToFavorite == "function")){
		function AddToFavorite(postbackmoduleid, handlemoduleid, productid){
		    setFormField("form1", "hidden", "as_favorite", productid);
		    postModule(postbackmoduleid, handlemoduleid);
		}
}
//function to add a product to the wanted list.
if (!(typeof AddToDesires == "function") && !(typeof document.AddToDesires == "function")){
		function AddToDesires(postbackmoduleid, handlemoduleid, productid){
		    setFormField("form1", "hidden", "as_desired", productid);
		    postModule(postbackmoduleid, handlemoduleid);
		}
}


