// Compiled by: Burnz ^_^

function nextbox(fldobj,nbox)
{
if(fldobj.value.length>2)
{document.vipform.elements[nbox].focus()}
}

function ship(){
	document.chk_credit.target="_self";
	document.chk_credit.action="checkout_creditinfo.php";
	document.chk_credit.submit();
}

function getKeyCode(e)
{
	if (window.event)
	   return window.event.keyCode;
	else if (e)
	   return e.which;
	else
	   return null;
}
function keyRestrict(e, validchars) { 
	var key='', keychar='';
	key = getKeyCode(e);
	if (key == null) return true;
	keychar = String.fromCharCode(key);
	keychar = keychar.toLowerCase();
	validchars = validchars.toLowerCase();
	if (validchars.indexOf(keychar) != -1)
		return true;
	if ( key==null || key==0 || key==8 || key==9 || key==13 || key==27 )
		return true;
	return false;
}

function addme()
{
/*	var themessage = "Please Enter a ";
	if (document.form1.txtqty.value=="") {
		themessage = themessage + "Quantity \r\n";
	}
	
	if (themessage == "Please Enter a ")
	{
/*	 	window.open('', 'Volunteer', 'top=50,left=50,height=150,width=300');
		document.form1.target='Volunteer'; 
		document.form1.action = "sendmail.php"; 
*/		document.form1.submit(); 
//		document.form1.reset();
/*	}
	else
	{
		alert(themessage);
		return false;
	}
	*/
}


/*
Shop Cart Section
*/

function myrem(mypro, myid) {
	var submitOK = confirm("Are you sure to remove \n" + mypro + "?")
	if ( submitOK ){
		location.href = "view_cart.html?action=remove&id=" + myid;
	}
}


function recal() {
	document.cart_form.target="_self";
	document.cart_form.action = "view_cart.html?action=recal";
	document.cart_form.submit();
}

function cartclear() {
	var submitOK = confirm("Are you sure clear all the items in your cart?")
	if ( submitOK ){
		document.cart_form.target="_self";
		location.href = 'view_cart.html?action=clear';
	}
	return false; 
}

function checkmeout() {
//		document.cart_form.target="_blank";
//		document.cart_form.action = "https://www.paypal.com/cgi-bin/webscr";

		document.cart_form.action = "checkout.php";
		document.cart_form.submit();
}

/*
#############################
Begin - Checkout
#############################
*/

function chkstate(){
	if(document.chkbill.b_txtcountry.selectedIndex != 208)
		document.chkbill.b_txtstate.disabled = true;
	else
		document.chkbill.b_txtstate.disabled = false;


	if(document.chkbill.txtcountry.selectedIndex != 208)
		document.chkbill.txtstate.disabled = true;
	else
		document.chkbill.txtstate.disabled = false;
}






function fillup2(){
	document.chk_credit.CreditCardNumber.value = '4977849400587060';
	document.chk_credit.CVV2.value = '268';
	document.chk_credit.ExpMonth.selectedIndex = 1;
	document.chk_credit.ExpYear.selectedIndex = 10;
}

function fillup(){
	//document.chkoutform.txtstate.selectedIndex = 0;
	
	
	document.chkbill.b_txtfname.value = 'WSMD';
	document.chkbill.b_txtlname.value = 'Development Team';
	document.chkbill.b_txtadd1.value = '1 Main St';
	document.chkbill.b_txtadd2.value = '2 Main St';
	document.chkbill.b_txtcity.value = 'San Jose';
	document.chkbill.b_txtzip.value = '95131';
	document.chkbill.b_txtstate.selectedIndex = 3;
	document.chkbill.b_txtcountry.selectedIndex = 208;
	//document.chkbill.b_txtprov.value = 'Bulacan';
	document.chkbill.b_txtphone.value = '123456789';
	//document.chkbill.b_txtemail.value = 'testin_1199329707_per@wsmdusa.com';
	document.chkbill.b_txtemail.value = 'jhayzie_frenchkiss@yahoo.com';
}

function binfo(){
	if(document.chkbill.chksame.checked==true){
		document.chkbill.txtfname.value=document.chkbill.b_txtfname.value;
		document.chkbill.txtlname.value=document.chkbill.b_txtlname.value;
		document.chkbill.txtadd1.value=document.chkbill.b_txtadd1.value;
		document.chkbill.txtadd2.value=document.chkbill.b_txtadd2.value;
		document.chkbill.txtcity.value=document.chkbill.b_txtcity.value;
		document.chkbill.txtzip.value=document.chkbill.b_txtzip.value;
		document.chkbill.txtstate.selectedIndex=document.chkbill.b_txtstate.selectedIndex;
		document.chkbill.txtcountry.selectedIndex=document.chkbill.b_txtcountry.selectedIndex;
		
		if(document.chkbill.b_txtcountry.selectedIndex != 208){
			document.chkbill.txtstate.disabled = true;
		}

		document.chkbill.txtprov.value=document.chkbill.b_txtprov.value;
		document.chkbill.txtphone.value=document.chkbill.b_txtphone.value;
		document.chkbill.txtemail.value=document.chkbill.b_txtemail.value;
	}
}

function paystand1(){
	document.getElementById("paypro").style.visibility = 'visible';
	document.getElementById("paypro").style.display = 'block';
}
function paystand2(){
	document.getElementById("paypro").style.visibility = 'hidden';	
	document.getElementById("paypro").style.display = 'none';
}

function chk_credit_on(){
	var msg = "Please check your: \r\n";

	if(document.getElementById("paypro").style.visibility == 'hidden'){// Paypal Standard
		document.chk_credit.chkmeout.value = 'on';
		document.chk_credit.action="checkout_creditinfo.php?action=checkout";
		document.chk_credit.submit();
	}
	else{  
			if(document.chk_credit.CreditCardNumber.value=="")
				msg = msg + "Credit number\r\n";
			if(document.chk_credit.CVV2.value=="")
				msg = msg + "Security Code\r\n";
			if(msg=="Please check your: \r\n"){
				document.chk_credit.chkmeout.value = 'on';
				document.chk_credit.action="checkout_creditinfo.php?action=checkout";
				document.chk_credit.submit();
			}
			else{
				alert(msg);
				return false;
			}
	}
	
}

function send_chkbill(){
	
	
		var themessage = "Please fill-up the following fields: \r\n";
	// Billing Info
		if (document.chkbill.b_txtfname.value=="") {
		themessage = themessage + "Billing First Name \r\n";
		}
		if (document.chkbill.b_txtlname.value=="") {
		themessage = themessage + "Billing Last Name \r\n";
		}
		if (document.chkbill.b_txtadd1.value=="") {
		themessage = themessage + "Billing Address 1\r\n";
		}
		if (document.chkbill.b_txtcity.value=="") {
		themessage = themessage + "Billing City \r\n";
		}
		if (document.chkbill.b_txtzip.value=="") {
		themessage = themessage + "Billing ZIP / Postal Code \r\n";
		}
/*		UNcomment this to enable Province field required

		if(document.chkbill.b_txtcountry.selectedIndex != 208){
			if (document.chkbill.b_txtprov.value=="") {
				themessage = themessage + "Billing Province \r\n";
			}
		}
*/
		if (document.chkbill.b_txtphone.value=="") {
		themessage = themessage + "Billing Phone \r\n";
		}
		if (document.chkbill.b_txtemail.value=="") {
		themessage = themessage + "Billing Email \r\n";
		}
		
		
		
	//Shipping info
		if (document.chkbill.txtfname.value=="") {
		themessage = themessage + "Shipping First Name \r\n";
		}
		if (document.chkbill.txtlname.value=="") {
		themessage = themessage + "Shipping Last Name \r\n";
		}
		if (document.chkbill.txtadd1.value=="") {
		themessage = themessage + "Shipping Address 1\r\n";
		}
		if (document.chkbill.txtcity.value=="") {
		themessage = themessage + "Shipping City \r\n";
		}
		if (document.chkbill.txtzip.value=="") {
		themessage = themessage + "Shipping ZIP / Postal Code \r\n";
		}
/*		UNcomment this to enable Province field required

		if(document.chkbill.txtcountry.selectedIndex != 208){
			if (document.chkbill.txtprov.value=="") {
				themessage = themessage + "Shipping Province \r\n";
			}
		}
*/
		if (document.chkbill.txtphone.value=="") {
		themessage = themessage + "Shipping Phone \r\n";
		}
		if (document.chkbill.txtemail.value=="") {
		themessage = themessage + "Shipping Email \r\n";
		}

	
		// Checking if email address is valid
		if (document.chkbill.txtemail.value!="") {
			text=document.chkbill.txtemail.value
			// Check For Bad Chars
			badchar = " ()<>\/[]{}+-*|;,'"
			for (i=0;i<text.length;i++) {
				for (j=0;j<badchar.length;j++) {
					if (text.charAt(i) == badchar.charAt(j)) {
						alert("Please enter a valid e-mail address.")				
		//				alert("Your Email Address May Has Some Bad Character or there is some space between letters")
						return false
					}
				}
			}
			// There Should Be a dot (.) Symbol
			if (text.indexOf(".") == -1) {
				alert("Please enter a valid e-mail address.")				
		//		alert("Your Email Address Doesnot have any dot(.) symbol")
				return false
			}
			// There Should Be an @ Symbol
			if (text.indexOf("@") == -1) {
				alert("Please enter a valid e-mail address.")				
		//		alert("Your Email Address Doesnot have any @ symbol")
				return false
			}
			else {
			// Only one @ symbol should be found
				symbolfound = 0
				for (i=0;i<text.length;i++) {
					if (text.charAt(i) == "@") {
						symbolfound++
					}
					else {
						continue
					}
				}
				if (symbolfound != 1) {
					alert("Please enter a valid e-mail address.")		
		//			alert("Ooops  Your Email Address Has More Than One @ Symbol")
					return false
				}
			}
			// Check For Syntax Errors Such as .@  or   @.  or  ..
			if (text.indexOf("@.") != -1 || text.indexOf(".@") != -1 || text.indexOf("..") != -1) {
				alert("Please enter a valid e-mail address.")		
		//		alert("Sorry Your Email Address has two symbol side by side and it is wrong")
				return false
			}
			// The first character shouldn't be @ or .
			if (text.charAt(0) == "@" || text.charAt(0) == ".") {
				alert("Please enter a valid e-mail address.")		
		//		alert("E-mail: Your first character seem to be . or @ and it is wrong")
				return false
			}
			// The last character shouldn't be @ or .
			if (text.charAt(text.length-1) == "@" || text.charAt(text.length-1) == ".") {
				alert("Please enter a valid e-mail address.")		
		//		alert("E-mail: Your last character seem to be . or @ and it is wrong")
		
				return false
			}
			// The @ Symbol should be found before .
			foundchar1 = text.indexOf("@")
			foundchar2 = text.indexOf(".")
			if (foundchar1 > foundchar2) {
				alert("Please enter a valid e-mail address.")		
		//		alert("E-mail: Sorry The @ Symbol should be found before dot(.)symbol but it isnt in yours")
				return false
			}
		}
		//alert if fields are empty and cancel form submit
		if (themessage == "Please fill-up the following fields: \r\n")
		{
	//	 	window.open('', 'Volunteer', 'top=50,left=50,height=150,width=300');
	//		document.chkbill.target='Volunteer'; 
	//		document.chkbill.action = location.href; 
	//		document.chkbill.action = 'checkout_process.php'; 
	
			document.chkbill.action = 'checkout_creditinfo.php'; 
			document.chkbill.submit(); 
	//		document.chkbill.reset();
		}
		else
		{
			alert(themessage);
			return false;
		}
	
}

/*
#############################
End - Checkout
#############################
*/









/*
#############################
Begin - Newsletter
#############################
*/


function sendnews(){
var themessage = "Please fill-up your ";

	if (document.newsform.txtemail.value=="") {
	themessage = themessage + "E-mail Address \n";
	}

// Checking if email address is valid
if (document.newsform.txtemail.value!="") {
	text=document.newsform.txtemail.value
	// Check For Bad Chars
	badchar = " ()<>\/[]{}+-*|;,'"
	for (i=0;i<text.length;i++) {
		for (j=0;j<badchar.length;j++) {
			if (text.charAt(i) == badchar.charAt(j)) {
				alert("Please enter a valid e-mail address.")				
//				alert("Your Email Address May Has Some Bad Character or there is some space between letters")
				return false
			}
		}
	}
	// There Should Be a dot (.) Symbol
	if (text.indexOf(".") == -1) {
		alert("Please enter a valid e-mail address.")				
//		alert("Your Email Address Doesnot have any dot(.) symbol")
		return false
	}
	// There Should Be an @ Symbol
	if (text.indexOf("@") == -1) {
		alert("Please enter a valid e-mail address.")				
//		alert("Your Email Address Doesnot have any @ symbol")
		return false
	}
	else {
	// Only one @ symbol should be found
		symbolfound = 0
		for (i=0;i<text.length;i++) {
			if (text.charAt(i) == "@") {
				symbolfound++
			}
			else {
				continue
			}
		}
		if (symbolfound != 1) {
			alert("Please enter a valid e-mail address.")		
//			alert("Ooops  Your Email Address Has More Than One @ Symbol")
			return false
		}
	}
	// Check For Syntax Errors Such as .@  or   @.  or  ..
	if (text.indexOf("@.") != -1 || text.indexOf(".@") != -1 || text.indexOf("..") != -1) {
		alert("Please enter a valid e-mail address.")		
//		alert("Sorry Your Email Address has two symbol side by side and it is wrong")
		return false
	}
	// The first character shouldn't be @ or .
	if (text.charAt(0) == "@" || text.charAt(0) == ".") {
		alert("Please enter a valid e-mail address.")		
//		alert("E-mail: Your first character seem to be . or @ and it is wrong")
		return false
	}
	// The last character shouldn't be @ or .
	if (text.charAt(text.length-1) == "@" || text.charAt(text.length-1) == ".") {
		alert("Please enter a valid e-mail address.")		
//		alert("E-mail: Your last character seem to be . or @ and it is wrong")

		return false
	}
	// The @ Symbol should be found before .
	foundchar1 = text.indexOf("@")
	foundchar2 = text.indexOf(".")
	if (foundchar1 > foundchar2) {
		alert("Please enter a valid e-mail address.")		
//		alert("E-mail: Sorry The @ Symbol should be found before dot(.)symbol but it isnt in yours")
		return false
	}

}


//alert if fields are empty and cancel newsform submit
if (themessage == "Please fill-up your ")
{
	document.newsform.action = "index.html"; 
	document.newsform.submit(); 
//	document.newsform.reset();
}
else {
alert(themessage);
return false;
   }
   
}


/*
#############################
End - Newsletter
#############################
*/




