function opnWin(pagename, wid, hght)
{
	var myRef ;
	myRef = window.open(pagename,'mywin', 'left=20,top=20,width=' + wid + ',height=' + hght + ',toolbar=no, location=no,directories=no,status=no,menubar=no,scrollbars=yes,copyhistory=no, resizable=no');
	myRef.focus();
}
function alltrim(str) {
	return str.replace(/^\s+|\s+$/g, '');
}
function isEmail(mailvalue) {
	if (/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(mailvalue))
	{
		return (true);
	}
	return (false);
}
function IsNumeric(sText)
{
	var i = 0;
	var ValidChars = "0123456789";
	var IsNumber=true;
	var Char;
	for (i = 0; i < sText.length && IsNumber == true; i++) 
	{ 
		Char = sText.charAt(i); 
		if (ValidChars.indexOf(Char) == -1) 
		{
			IsNumber = false;
        }
	}
	return IsNumber;
}
function isEmpty(str)
{	var strTrim

	if (alltrim(str) == "")	{
		return true;
	}	
	else {
		return false;
	}
}
/* kitbuilder scripts */
function showdetails(item) {
	show = "show_"+item;
	item = "info_"+item;	
	if(document.getElementById(item).style.display == "none") {
		document.getElementById(item).style.display = "block";
		document.getElementById(show).innerHTML = "Hide Details";
	}
	else {
		document.getElementById(item).style.display = "none";
		document.getElementById(show).innerHTML = "Show More Info";
	}
}
function GetXmlHttpObject()
{
	var xmlHttp=null;
	try
	{
		// Firefox, Opera 8.0+, Safari
		xmlHttp=new XMLHttpRequest();
	}
	catch (e)
	{
		// Internet Explorer
		try
	    {
			xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
	    }
		catch (e)
	    {
			xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
	    }
	}
	return xmlHttp;
}
var xmlHttp = GetXmlHttpObject();
function addtokit(i) {
	document.getElementById("loading_"+i).style.display = "inline";
	var sku = document.getElementById("addkit"+i).sku.value;
	var xcatid = document.getElementById("addkit"+i).xcatid.value;
	var params = "";
	var url = "/addtokit.asp";
	params += "sku="+ encodeURI(sku);
	params += "&xcatid="+encodeURI(xcatid);
	timestamp = new Date();
	tim1 = (timestamp.getTime());
	sec1 = timestamp.getSeconds();
	ms1 = timestamp.getMilliseconds();
	thetime = tim1+sec1+ms1;
	params += "&rand="+thetime;
	//alert(params);
	xmlHttp.open('post',url,true);	
	xmlHttp.onreadystatechange = function(){ 
		if (xmlHttp.readyState == 4) {
			if (xmlHttp.status == 200) {			
				result = xmlHttp.responseText;					
				document.getElementById("kititems").innerHTML = result;			
				document.getElementById("loading_"+i).style.display = "none";
			}
			else {			
				alert("error with request");
				document.getElementById("loading_"+i).style.display = "none";
			}
		}
	};
	xmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
	xmlHttp.setRequestHeader('If-Modified-Since','Tue, 04 Apr 2006 00:00:00 GMT');
	xmlHttp.setRequestHeader("Content-length", params.length);
	xmlHttp.setRequestHeader("Connection", "close");
	xmlHttp.send(params);
}
function removekit(xtype,xaccessories)
{
	var params = "";
	var url = "/removekit.asp";
	var xcatid = document.getElementById("addkit1").xcatid.value;
	params += "type="+ encodeURI(xtype);
	params += "&xcatid="+encodeURI(xcatid);
	params += "&sku="+ encodeURI(xaccessories);
	timestamp = new Date();
	tim1 = (timestamp.getTime());
	sec1 = timestamp.getSeconds();
	ms1 = timestamp.getMilliseconds();
	thetime = tim1+sec1+ms1;
	params += "&rand="+thetime;
	xmlHttp.open('post',url,true);	
	xmlHttp.onreadystatechange = function(){ 
		if (xmlHttp.readyState == 4) {
			if (xmlHttp.status == 200) {			
				result = xmlHttp.responseText;					
				document.getElementById("kititems").innerHTML = result;							
			}
			else {			
				alert("error with request");				
			}
		}
	};
	xmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
	xmlHttp.setRequestHeader('If-Modified-Since','Tue, 04 Apr 2006 00:00:00 GMT');
	xmlHttp.setRequestHeader("Content-length", params.length);
	xmlHttp.setRequestHeader("Connection", "close");
	xmlHttp.send(params);
}
function kitpop(sku, cartid) {
	window.open('/kitpop.asp?sku='+sku, "mywindow","menubar=0,status=0,resizable=1,scrollbars=1,width=450,height=375");
}
function kblk(catid) {
	if (catid != -1)
	{
		document.getElementById("kittocart").action= "category.asp?cat="+catid+"&sub=sub34";
		document.getElementById("kittocart").method = "post";
		document.getElementById("kittocart").submit();
	}
}
function checkSearchform(frm) {
	if (isEmpty(frm.keyword.value))
	{
		alert("Please enter search keyword.")
		frm.keyword.focus()
		return false
	}
}
function checkSignNewsLetter(f) {
	if (isEmpty(f.email.value))
	{
		alert("Please enter your email address.")
		f.email.focus()
		f.email.select()
		return false
	}
	if (isEmail(f.email.value)  != true)
	{
		alert("Your email is invalid.");
		f.email.focus()
		f.email.select()
		return false;
	}
	return true
}
function showSubCat(CatID) {
	if (document.getElementById(CatID).style.display == "none")
	{
		document.getElementById(CatID).style.display = "block";
	}
	else
	{
		document.getElementById(CatID).style.display = "none";
	}
}
var toptimeout	= 500;
var topclosetimer = 0;
var topddmenuitem = 0;
var topddsubmenuitem = 0;
function hideTopDropDowns() {
	if(topddmenuitem) topddmenuitem.style.visibility = 'hidden';
}
function showTopDropDown(tab) {
	topmcancelclosetime();
	if(topddmenuitem) topddmenuitem.style.visibility = 'hidden';
	if (document.getElementById('topdropdown' + tab))
	{
		topddmenuitem = document.getElementById('topdropdown' + tab);
		topddmenuitem.style.visibility = 'visible';
	}
}
function topmclosetime()
{
	topclosetimer = window.setTimeout(topmclose, toptimeout);
}
function topmcancelclosetime()
{
	if(topclosetimer)
	{
		window.clearTimeout(topclosetimer);
		topclosetimer = null;
	}
}
var timeout	= 500;
var closetimer	= 0;
var ddmenuitem	= 0;
var ddsubmenuitem = 0;
function hideDropDowns() {
	if(ddmenuitem) ddmenuitem.style.visibility = 'hidden';
}
function showDropDown(tab) {
	mcancelclosetime();
	if(ddmenuitem) ddmenuitem.style.visibility = 'hidden';
	if (document.getElementById('dropdown' + tab))
	{
		ddmenuitem = document.getElementById('dropdown' + tab);
		ddmenuitem.style.visibility = 'visible';
	}
}
function hideSubDropDowns() {
	if(ddsubmenuitem) ddsubmenuitem.style.visibility = 'hidden';
}
function showSubDropDown(tab) {
	mcancelclosetime();
	if(ddsubmenuitem) ddsubmenuitem.style.visibility = 'hidden';
	if (document.getElementById('subdropdown' + tab))
	{
		ddsubmenuitem = document.getElementById('subdropdown' + tab);
		ddsubmenuitem.style.visibility = 'visible';
	}
}
function mclosetime()
{
	closetimer = window.setTimeout(mclose, timeout);
}
function mcancelclosetime()
{
	if(closetimer)
	{
		window.clearTimeout(closetimer);
		closetimer = null;
	}
}
function view(n)
{
	document.getElementById("page").value = n;
	document.ViewPage.submit();
}
function checkFromEmail(f)
{
	if (isEmpty(f.yourname.value))
	{
		alert("Please enter your name.")
		f.yourname.focus()
		return false
	}
	if (isEmpty(f.youremail.value))
	{
		alert("Please enter your email address.")
		f.youremail.focus()
		return false
	} else
	{	if (isEmail(f.youremail.value)  != true)
		{
			alert("Please enter a valid email address.");
			f.youremail.focus()
			return false;
		}
	}
	if (isEmpty(f.friendname.value))
	{
		alert("Please enter your friend's name.")
		f.friendname.focus()
		return false
	}
	
	if (isEmpty(f.friendemail.value))
	{
		alert("Please enter your friend email address.")
		f.friendemail.focus()
		return false
	} else
	{	if (isEmail(f.friendemail.value)  != true)
		{
			alert("Your friend email is invalid.");
			f.friendemail.focus()
			return false;
		}
	}
	return true
}
function popModels(parentCat)
{
	var catID = "206" + parentCat
	var url = "/ajax/popModels.asp?catid=" + catID;
	xmlHttp.open('GET',url,true);
	xmlHttp.onreadystatechange=function() {
		if(xmlHttp.readyState == 4 && xmlHttp.status == 200) {
			document.getElementById("modelopts").innerHTML = xmlHttp.responseText;
		}
	}
	xmlHttp.send(null);
}
function seeCategory(catID)
{
	cururl = '/category.asp?cat=' + catID; 
	window.location.assign( cururl ); 
}
function clearMsg()
{
	if (document.getElementById('sli_search_2')) {
		if (document.getElementById('sli_search_2').value == '-Enter Search Term Here-')
		{
			document.getElementById('sli_search_2').value = '';
			document.getElementById('sli_search_2').style.textAlign = 'left';
			document.getElementById('sli_search_2').style.color = '#000';
			document.getElementById('sli_search_2').style.fontStyle = 'normal';
		}
	}
}
function checkMsg()
{
	if (document.getElementById('sli_search_2')) {
		if (document.getElementById('sli_search_2').value == '')
		{
			document.getElementById('sli_search_2').value = '-Enter Search Term Here-';
			document.getElementById('sli_search_2').style.textAlign = 'center';
			document.getElementById('sli_search_2').style.color = '#ccc';
			document.getElementById('sli_search_2').style.fontStyle = 'italic';
		}
	}
}