$(document).ready(function(){
	$(".swrapimg li img").hover(
		function(){
			$(this).attr("src",$(this).attr("src").replace("images/","images/r"));
			$("#simg").attr("src",$(this).attr("src").replace("images/r","images/b"));
		},
		function(){
			$(this).attr("src",$(this).attr("src").replace("images/r","images/"));
		}
	);
	
	$("form#subscr").submit(function(){
		if(!isValidEmail($("form#subscr input[name='emailAddr']").val()))
		{alert("Please enter a valid email address."); $("form#subscr input[name='emailAddr']").focus(); return false;}
	});
	
});

function checkreg()
{
	if(document.regform.firstname.value=="")
		{
			alert("Please fill in the Firstname!");
			document.regform.firstname.focus();
			return false;
		}
	if(document.regform.lastname.value=="")
		{
			alert("Please fill in the Lastname!");
			document.regform.lastname.focus();
			return false;
		}
	if(document.regform.address1.value=="")
		{
			alert("Please fill in the Address1!");
			document.regform.address1.focus();
			return false;
		}
	if(document.regform.phone.value=="")
		{
			alert("Please fill in the Phone!");
			document.regform.phone.focus();
			return false;
		}
	if(document.regform.state.value=="")
		{
			alert("Please fill in the State!");
			document.regform.state.focus();
			return false;
		}
	if(document.regform.city.value=="")
		{
			alert("Please fill in the City!");
			document.regform.city.focus();
			return false;
		}
	if(document.regform.zip.value=="")
		{
			alert("Please fill in the Zip!");
			document.regform.zip.focus();
			return false;
		}
	if(document.regform.email.value=="")
		{
			alert("Please fill in the Email!");
			document.regform.email.focus();
			return false;
		}
	if(document.regform.email.value.indexOf("@")<0)
		{
			alert("Please check the Email!");
			document.regform.email.focus();
			return false;
		}
	if(document.regform.password.value=="")
		{
			alert("Please fill in the Password!");
			document.regform.password.focus();
			return false;
		}
	if(!(document.regform.repassword.value==document.regform.password.value))
		{
			alert("Please check the Repassword!");
			document.regform.repassword.focus();
			return false;
		}
}


var str = "";
var str_check = "";
var str_text = "";

function popUp(URL) 
{
	day = new Date();
	id = day.getTime();
	
	eval("page" + id + " = window.open(URL, '" + id + "', 'toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=0,width=640,height=640,left = 300,top = 200');");
}

function getAddInfo()
{
	for(i = 0; i < total_option; i++)
	{
		var getVal = eval("window.document.productform.txtOption" + i + ".options[window.document.productform.txtOption" + i + ".selectedIndex].value");

		if(getVal)
		{
			str += getVal + ",";
		}
	}
	
	
	for(i = 0; i < total_check; i++)
	{
		if(window.document.productform.txtCheck[i].checked==true)
		{
			str_check += window.document.productform.txtCheck[i].value + ",";
		}
	}
	
	for(j = 0; j < total_text; j++)
	{
		var val = eval("window.document.productform.txtText" + j + ".value");
		
		str_text += val + "|";
	}

	window.document.productform.addInfo.value = str;
	window.document.productform.addCheckInfo.value = str_check;
	window.document.productform.addTextInfo.value = str_text;
	
}

function isValidEmail(e) {
	return /^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(e);
}

$(document).ready(function(){
	$("#logo #subscribeform").submit(function(){
		if ($("input#subscribeemail").val()=="")
		{alert("Please enter your email address.");$("input#subscribeemail").focus();return false;}
		if (!isValidEmail($("input#subscribeemail").val()))
		{alert("Please enter a valid email address.");$("input#subscribeemail").focus();return false;}
	});
	
	$("#subscribe_fm").submit(function(){
		if ($("input#Email").val()=="")
		{alert("Please enter your email address.");$("input#Email").focus();return false;}
		if (!isValidEmail($("input#Email").val()))
		{alert("Please enter a valid email address.");$("input#Email").focus();return false;}
		
		if($("input[name='Action'][checked]").val()=="Subscribe")
		{$("#subscribe_fm").attr("action","/list_new.asp");}

	});
	
	$("#searchform").submit(function(){
		if ($("input#searchkeyword").val()=="")
		{alert("Please enter a value for \"Keyword\" field.");$("input#searchkeyword").focus();return false;}
	});
});

function killErrors() {
return true;
}
window.onerror = killErrors;
