// by DA studio - http://www.dastudio.biz

function checkNews() {
	var form=document.getElementById('news-form');
	
	var mail=form.email.value;
	
	email = /^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*\.(\w{2}|(ad|ae|aero|af|ag|ai|al|am|an|ao|aq|ar|arpa|as|at|au|aw|az|ba|bb|bd|be|bf|bg|bh|bi|biz|bj|bm|bn|bo|br|bs|bt|bv|bw|by|bz|ca|cc|cd|cf|cg|ch|ci|ck|cl|cm|cn|co|com|coop|cr|cs|cu|cv|cx|cy|cz|de|dj|dk|dm|do|dz|ec|edu|ee|eg|eh|er|es|et|eu|fi|fj|fk|fm|fo|fr|ga|gb|gd|ge|gf|gh|gi|gl|gm|gn|gov|gp|gq|gr|gs|gt|gu|gw|gy|hk|hm|hn|hr|ht|hu|id|ie|il|in|info|int|io|iq|ir|is|it|jm|jo|jp|ke|kg|kh|ki|km|kn|kp|kr|kw|ky|kz|la|lb|lc|li|lk|lr|ls|lt|lu|lv|ly|ma|mc|md|mg|mh|mil|mk|ml|mm|mn|mo|mp|mq|mr|ms|mt|mu|museum|mv|mw|mx|my|mz|na|name|nc|ne|net|nf|ng|ni|nl|no|np|nr|nt|nu|nz|om|org|pa|pe|pf|pg|ph|pk|pl|pm|pn|pr|pro|ps|pt|pw|py|qa|re|ro|ru|rw|sa|sb|sc|sd|se|sg|sh|si|sj|sk|sl|sm|sn|so|sr|st|su|sv|sy|sz|tc|td|tf|tg|th|tj|tk|tm|tn|to|tp|tr|tt|tv|tw|tz|ua|ug|uk|um|us|uy|uz|va|vc|ve|vg|vi|vn|vu|wf|ws|ye|yt|yu|za|zm|zw))$/;
	 
	if (mail.length==0 || !email.test(mail)) {
		document.getElementById('email').className='text';
		var alertmsg='';
		
		if(mail.length==0 || !email.test(mail)) {
			document.getElementById('email').className='text Error';
			alertmsg=alertmsg+'- please enter a valid email address\n';
		}
		
		alert(alertmsg);
	}		
	else {
		
		OpenWindow('aemail.php?email='+mail,'','email');
		form.email.value="";
		//form.submit();
	}
	
}

function contactCheck() {
	var form=document.getElementById('formcontact');
	
	var Name=form.Name.value;
	var Email=form.Email.value;
	var Comment=form.Comment.value;	
	var Security=form.Security.value;	
	
	email = /^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*\.(\w{2}|(ad|ae|aero|af|ag|ai|al|am|an|ao|aq|ar|arpa|as|at|au|aw|az|ba|bb|bd|be|bf|bg|bh|bi|biz|bj|bm|bn|bo|br|bs|bt|bv|bw|by|bz|ca|cc|cd|cf|cg|ch|ci|ck|cl|cm|cn|co|com|coop|cr|cs|cu|cv|cx|cy|cz|de|dj|dk|dm|do|dz|ec|edu|ee|eg|eh|er|es|et|eu|fi|fj|fk|fm|fo|fr|ga|gb|gd|ge|gf|gh|gi|gl|gm|gn|gov|gp|gq|gr|gs|gt|gu|gw|gy|hk|hm|hn|hr|ht|hu|id|ie|il|in|info|int|io|iq|ir|is|it|jm|jo|jp|ke|kg|kh|ki|km|kn|kp|kr|kw|ky|kz|la|lb|lc|li|lk|lr|ls|lt|lu|lv|ly|ma|mc|md|mg|mh|mil|mk|ml|mm|mn|mo|mp|mq|mr|ms|mt|mu|museum|mv|mw|mx|my|mz|na|name|nc|ne|net|nf|ng|ni|nl|no|np|nr|nt|nu|nz|om|org|pa|pe|pf|pg|ph|pk|pl|pm|pn|pr|pro|ps|pt|pw|py|qa|re|ro|ru|rw|sa|sb|sc|sd|se|sg|sh|si|sj|sk|sl|sm|sn|so|sr|st|su|sv|sy|sz|tc|td|tf|tg|th|tj|tk|tm|tn|to|tp|tr|tt|tv|tw|tz|ua|ug|uk|um|us|uy|uz|va|vc|ve|vg|vi|vn|vu|wf|ws|ye|yt|yu|za|zm|zw))$/;

	if (Email.length==0 || !email.test(Email) || Name.length==0 || Comment.length==0 || Security.length==0) {
		document.getElementById('Email').className='';
		document.getElementById('Name').className='';
		document.getElementById('Comment').className='';
		document.getElementById('Security').className='';
		var alertmsg='';
		
		if (Name.length==0) {
			document.getElementById('Name').className='Error';
			alertmsg=alertmsg+'- please enter your name\n';
		}
		if(Email.length==0 || !email.test(Email)) {
			document.getElementById('Email').className='Error';
			alertmsg=alertmsg+'- please enter a valid email address\n';
		}		
		if (Comment.length==0) {
			document.getElementById('Comment').className='Error';
			alertmsg=alertmsg+'- please enter your comment\n';
		}
		if (Security.length==0) {
			document.getElementById('Security').className='Error';
			alertmsg=alertmsg+'- please enter the security code\n';
		}
		alert(alertmsg);
	}		
	else {
		form.submit();
	}
}

function checkInfo() {
	var form=document.getElementById('form_info');
	
	var quantity=form.quantity.value;
	var name=form.name.value;
	var mail=form.email.value;
	var phone=form.phone.value;	
	
	var afirstname=form.afirstname.value;	
	var alastname=form.alastname.value;	
	var acity=form.acity.value;	
	var astate=form.astate.value;	
	
	email = /^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*\.(\w{2}|(ad|ae|aero|af|ag|ai|al|am|an|ao|aq|ar|arpa|as|at|au|aw|az|ba|bb|bd|be|bf|bg|bh|bi|biz|bj|bm|bn|bo|br|bs|bt|bv|bw|by|bz|ca|cc|cd|cf|cg|ch|ci|ck|cl|cm|cn|co|com|coop|cr|cs|cu|cv|cx|cy|cz|de|dj|dk|dm|do|dz|ec|edu|ee|eg|eh|er|es|et|eu|fi|fj|fk|fm|fo|fr|ga|gb|gd|ge|gf|gh|gi|gl|gm|gn|gov|gp|gq|gr|gs|gt|gu|gw|gy|hk|hm|hn|hr|ht|hu|id|ie|il|in|info|int|io|iq|ir|is|it|jm|jo|jp|ke|kg|kh|ki|km|kn|kp|kr|kw|ky|kz|la|lb|lc|li|lk|lr|ls|lt|lu|lv|ly|ma|mc|md|mg|mh|mil|mk|ml|mm|mn|mo|mp|mq|mr|ms|mt|mu|museum|mv|mw|mx|my|mz|na|name|nc|ne|net|nf|ng|ni|nl|no|np|nr|nt|nu|nz|om|org|pa|pe|pf|pg|ph|pk|pl|pm|pn|pr|pro|ps|pt|pw|py|qa|re|ro|ru|rw|sa|sb|sc|sd|se|sg|sh|si|sj|sk|sl|sm|sn|so|sr|st|su|sv|sy|sz|tc|td|tf|tg|th|tj|tk|tm|tn|to|tp|tr|tt|tv|tw|tz|ua|ug|uk|um|us|uy|uz|va|vc|ve|vg|vi|vn|vu|wf|ws|ye|yt|yu|za|zm|zw))$/;

	if (mail.length==0 || !email.test(mail) || quantity.length==0 || name.length==0 || phone.length==0 || afirstname.length==0 || alastname.length==0 || acity.length==0 || astate.length==0) {
		document.getElementById('f0').className='';
		document.getElementById('f1').className='';
		document.getElementById('f2').className='';
		document.getElementById('f3').className='';
		document.getElementById('f4').className='';
		document.getElementById('f5').className='';
		document.getElementById('f6').className='';
		document.getElementById('f7').className='';

		var alertmsg='';
		if (quantity.length==0) {
			document.getElementById('f0').className='Error';
			alertmsg=alertmsg+'- please enter the number desired\n';
		}
		if (name.length==0) {
			document.getElementById('f1').className='Error';
			alertmsg=alertmsg+'- please enter your name\n';
		}
		if(mail.length==0 || !email.test(mail)) {
			document.getElementById('f2').className='Error';
			alertmsg=alertmsg+'- please enter a valid email address\n';
		}		
		if (phone.length==0) {
			document.getElementById('f3').className='Error';
			alertmsg=alertmsg+'- please enter your phone number\n';
		}
		if (afirstname.length==0) {
			document.getElementById('f4').className='Error';
			alertmsg=alertmsg+'- please enter the awardee first name\n';
		}
		if (alastname.length==0) {
			document.getElementById('f5').className='Error';
			alertmsg=alertmsg+'- please enter the awardee last name\n';
		}
		if (acity.length==0) {
			document.getElementById('f6').className='Error';
			alertmsg=alertmsg+'- please enter the awardee city\n';
		}
		if (astate.length==0) {
			document.getElementById('f7').className='Error';
			alertmsg=alertmsg+'- please enter the awardee state\n';
		}
		alert(alertmsg);
	}		
	else {
		form.submit();
	}
}
function checkShipping() {
	var form=document.getElementById('form_shipping');
	
	var name=form.name.value;
	var address=form.address.value;
	var city=form.city.value;		
	var state=form.state.value;	
	var zip=form.zip.value;	

	if (name.length==0 || address.length==0 || city.length==0 || state.length==0 || zip.length==0) {
		document.getElementById('f1').className='';
		document.getElementById('f2').className='';
		document.getElementById('f3').className='';
		document.getElementById('f4').className='';
		document.getElementById('f5').className='';

		var alertmsg='';
		if (name.length==0) {
			document.getElementById('f1').className='Error';
			alertmsg=alertmsg+'- please enter the name\n';
		}
		if (address.length==0) {
			document.getElementById('f2').className='Error';
			alertmsg=alertmsg+'- please enter the address\n';
		}
		if(city.length==0) {
			document.getElementById('f3').className='Error';
			alertmsg=alertmsg+'- please enter the city\n';
		}		
		if (state.length==0) {
			document.getElementById('f4').className='Error';
			alertmsg=alertmsg+'- please enter the state\n';
		}
		if (zip.length==0) {
			document.getElementById('f5').className='Error';
			alertmsg=alertmsg+'- please enter the zip / postal code\n';
		}
		alert(alertmsg);
	}		
	else {
		form.submit();
	}
}

function checkBilling() {
	var form=document.getElementById('form_billing');
	var cardnumber=form.cardnumber.value;
	var expiration=form.expiration.value;
	var securitycode=form.securitycode.value;
	
	var name=form.name.value;
	var address=form.address.value;
	var city=form.city.value;		
	var state=form.state.value;	
	var zip=form.zip.value;	

	if (cardnumber.length==0 || expiration.length==0 || securitycode.length==0 || name.length==0 || address.length==0 || city.length==0 || state.length==0 || zip.length==0) {
		document.getElementById('c2').className='';
		document.getElementById('c3').className='';
		document.getElementById('c4').className='';
		
		document.getElementById('f1').className='';
		document.getElementById('f2').className='';
		document.getElementById('f3').className='';
		document.getElementById('f4').className='';
		document.getElementById('f5').className='';

		var alertmsg='';
		if (cardnumber.length==0) {
			document.getElementById('c2').className='Error';
			alertmsg=alertmsg+'- please enter the card number\n';
		}
		if (expiration.length==0) {
			document.getElementById('c3').className='Error';
			alertmsg=alertmsg+'- please enter the expiration date (MMYY)\n';
		}
		if (securitycode.length==0) {
			document.getElementById('c4').className='Error';
			alertmsg=alertmsg+'- please enter the security code\n';
		}
		
	
		if (name.length==0) {
			document.getElementById('f1').className='Error';
			alertmsg=alertmsg+'- please enter the name\n';
		}
		if (address.length==0) {
			document.getElementById('f2').className='Error';
			alertmsg=alertmsg+'- please enter the address\n';
		}
		if(city.length==0) {
			document.getElementById('f3').className='Error';
			alertmsg=alertmsg+'- please enter the city\n';
		}		
		if (state.length==0) {
			document.getElementById('f4').className='Error';
			alertmsg=alertmsg+'- please enter the state\n';
		}
		if (zip.length==0) {
			document.getElementById('f5').className='Error';
			alertmsg=alertmsg+'- please enter the zip / postal code\n';
		}
		alert(alertmsg);
	}		
	else {
		form.submit();
	}
}


function OpenWindow(URL,windowName,features) {  
	if (features == 'who') {
		features='dependent=yes, top='+(screen.availHeight-240)/2+', left='+(screen.availWidth-375)/2+', width=375, height=240, scrollbars=0, locationbar=no, menubar=no, resizable=no, status=no';  
	}
	if (features == 'what') {
		features='dependent=yes, top='+(screen.availHeight-270)/2+', left='+(screen.availWidth-375)/2+', width=375, height=270, scrollbars=0, locationbar=no, menubar=no, resizable=no, status=no';
	}
	if (features == 'why') {
		features='dependent=yes, top='+(screen.availHeight-375)/2+', left='+(screen.availWidth-375)/2+', width=375, height=375, scrollbars=0, locationbar=no, menubar=no, resizable=no, status=no';  
	}
	if (features == 'how') {
		features='dependent=yes, top='+(screen.availHeight-350)/2+', left='+(screen.availWidth-465)/2+', width=465, height=350, scrollbars=0, locationbar=no, menubar=no, resizable=no, status=no';  
	}
	if (features == 'email') {
		features='dependent=yes, top='+(screen.availHeight-310)+', left='+(screen.availWidth-50)/2+', width=350, height=150, scrollbars=0, locationbar=no, menubar=no, resizable=no, status=no,titlebar=no';  
	}
//alert(screen.availWidth-150);
  newwin=window.open(URL,windowName,features);
  newwin.focus();
}
 
