// Compiled by: Burnz ^_^
//updated by Ramir/hehe
function bookmarksite(){
var myloc = location.href;
var title = "Pazzo Pazzo Restaurant - Morristown New Jersey";
// check if active
// alert (title+"\r\n"+myloc);
if (document.all)
window.external.AddFavorite(myloc,title);
if (window.sidebar)
window.sidebar.addPanel(title, myloc,"");
}

function sendtofriend() {
	// alert (URL);
	var URL;
	URL = location.href;
	window.open('sendtofriend.htm?page='+URL, 'EmailWindow', 'scrollbars=yes,width=730,height=363');
}

//################################################
//Newsletter Sign-up Form
//################################################

function sendnews()
{
	var themessage = "Please fill-up the required fields: \r\n";
	if (document.fnews.txtemail2.value=="") {
	themessage = themessage + "E-mail \r\n";
	}
	// Checking if email address is valid
	if (document.fnews.txtemail2.value!="") {
		text=document.fnews.txtemail2.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 required fields: \r\n")
	{
//	 	window.open('', "SignUp", 'top=50,left=50,height=150,width=300');
//		document.fnews.target="SignUp"; 
		document.fnews.action = "html_sendmail.php"; 
		document.fnews.submit(); 
//		document.fnews.reset();
	}
	else {
	alert(themessage);
	return false;
   }
}


//################################################
// Student Sign - up Form
//################################################

/*
 Original:  Ronnie T. Moore 
 Web Site:  The JavaScript Source 

 Dynamic 'fix' by: Nannette Thacker 
 Web Site: http://www.shiningstar.net 

 This script and many more are available free online at 
 The JavaScript Source!! http://javascript.internet.com 
*/
//<!-- Begin
function textCounter(field, countfield, maxlimit) {
if (field.value.length > maxlimit) // if too long...trim it!
field.value = field.value.substring(0, maxlimit);
// otherwise, update 'characters left' counter
else 
countfield.value = maxlimit - field.value.length;
}
// End -->


function nextbox(fldobj,nbox)
{
if(fldobj.value.length>2)
{document.formsign.elements[nbox].focus()}
}

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 sendsign()
{
	var themessage = "Please fill-up the following fields: \r\n";
	if (document.formsign.txtname.value=="") {
	themessage = themessage + "Name \r\n"; 
	}
	if (document.formsign.txtmm.value=="") {
	themessage = themessage + "Date of Birth (Month) \r\n";
	}
	if (document.formsign.txtdd.value=="") {
	themessage = themessage + "Date of Birth (Day) \r\n";
	}
	if (document.formsign.txtyy.value=="") {
	themessage = themessage + "Date of Birth (Year) \r\n";
	}
	
	var mydate = new Date();
	myyear = mydate.getFullYear();
	xyear = document.formsign.txtyy.value;
	totyear = eval(myyear)-eval(xyear);

	if(totyear<=18)
	{
		if (document.formsign.txtpname.value=="") {
			themessage = themessage + "Parent's Name \r\n";
		}
	}

	if (document.formsign.txtphone.value=="") {
		themessage = themessage + "Phone \r\n";
	}
	if (document.formsign.txtemail2.value=="") {
		themessage = themessage + "E-mail \r\n";
	}
	
	// Checking if email address is valid
	if (document.formsign.txtemail2.value!="") {
		text=document.formsign.txtemail2.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
		}
	}
	if (document.formsign.drp_interest.value=="") {
		themessage = themessage + "Class of Interest \r\n";
	}
	if (document.formsign.drp_month.value=="") {
		themessage = themessage + "(Month) When would you like to come in for the Free Trial Program? \r\n";
	}
	if (document.formsign.drp_day.value=="") {
		themessage = themessage + "(Day) When would you like to come in for the Free Trial Program? \r\n";
	}
	if (document.formsign.drp_year.value=="") {
		themessage = themessage + "(Year) When would you like to come in for the Free Trial Program? \r\n";
	}
	if (document.formsign.txtRefer.value=="") {
		themessage = themessage + "Who Referred You to Our School?/Other \r\n";
	}
	if (document.formsign.chkExpother.checked==true) {
		if (document.formsign.txtExpother.value=="") {
		themessage = themessage + "What benefits would you like to experience from Martial Arts / Fitness Training? Other \r\n";
		}
	}
	if (document.formsign.txtmartial.value=="") {
		themessage = themessage + "Why would you like to take martial arts lessons? \r\n";
	}
	if((document.formsign.chkadver.checked==false)&&(document.formsign.chkinter.checked==false)&&(document.formsign.chkyello.checked==false)&&(document.formsign.chkdirec.checked==false)&&(document.formsign.chkdrive.checked==false)&&(document.formsign.chkref.checked==false)&&(document.formsign.chkother.checked==false)){
		themessage = themessage + "How did you hear about us \r\n";
	}	
	if (document.formsign.chkref.checked==true) {
		if (document.formsign.txtref.value=="") {
		themessage = themessage + "How did you hear about Pazzo Pazzo Restaurant? Referral \r\n";
		}
	}
	if (document.formsign.chkother.checked==true) {
		if (document.formsign.txtother.value=="") {
		themessage = themessage + "How did you hear about Pazzo Pazzo Restaurant Other \r\n";
		}
	}
	
	//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.formsign.target='Volunteer'; 
*/		//document.formsign.action = "signup.php"; 
		document.formsign.submit(); 
//		document.formsign.reset();
	}
	else
	{
		alert(themessage);
		/*return false;*/
	}
}


//################################################
// Contact Form
//################################################

function sendcontact()
{
	var themessage = "Please fill-up the following fields: \r\n";
	if (document.contactform.txtname.value=="") {
	themessage = themessage + "Name \r\n";
	}
	if (document.contactform.txtphone.value=="") {
	themessage = themessage + "Phone \r\n";
	}
	if (document.contactform.txtemail5.value=="") {
	themessage = themessage + "E-mail \r\n";
	}
	if (document.contactform.txtmsg.value=="") {
	themessage = themessage + "Comments \r\n";
	}
	// Checking if email address is valid
	if (document.contactform.txtemail5.value!="") {
		text=document.contactform.txtemail5.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.contactform.target='Volunteer'; 
*/		document.contactform.action = "contact_us.html"; 
		document.contactform.submit(); 
//		document.contactform.reset();
	}
	else
	{
		alert(themessage);
		/*return false;*/
	}
}

function validate_form(){
	if (document.getElementById("txtstuduser").value == null || document.getElementById("txtstuduser").value == ""){
  		document.getElementById("txtstuduser").focus()
  		alert("Please enter your username.")
  	}
	else if (document.getElementById("txtstudpass").value == null || document.getElementById("txtstudpass").value == ""){
  		document.getElementById("txtstudpass").focus()
  		alert("Please enter your password.")
    }
}


//<script language="javascript" type="text/javascript">
/*
###########################################################
Begin - Scripts for Seminar Section
###########################################################
*/
function seminar(){
	var themessage = "Please fill-up the following fields: \r\n";
	if (document.formsign.txtname.value=="") {
	themessage = themessage + "Name \r\n";
	}
	if (document.formsign.bmon.value=="") {
	themessage = themessage + "Date of Birth (Month) \r\n";
	}
	if (document.formsign.xmyday.value=="") {
	themessage = themessage + "Date of Birth (Day) \r\n";
	}
	if (document.formsign.byear.value=="") {
	themessage = themessage + "Date of Birth (Year) \r\n";
	}
	//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.contactform.target='Volunteer'; 
*/		document.contactform.action = "html_sendmail.php"; 
		document.contactform.submit(); 
//		document.contactform.reset();
	}
	else
	{
		alert(themessage);
		return false;
	}
}
/*Seminar cart (recal  remove and clear)
*/
/*
Shop Cart Section
*/

function myrem(mysem, myid,day) {
	var submitOK = confirm("Are you sure you want to remove \n" + mysem + "?")
	if ( submitOK ){
		location.href = "seminars_cart.php?action=remove&sem_id=" + myid +"&day=" + day;
	}
}


function recal() {
	document.cart_form.action = "seminars_cart.php?action=recal";
	document.cart_form.submit();
}

function cartclear() {
	var submitOK = confirm("Are you sure you want to clear all the items in your cart?")
	if ( submitOK ){
		location.href = 'seminars_cart.php?action=clear';
	}
}

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();
}


function submitForm() {
	eForm = document.emailForm;
	
	if (eForm.txtname.value=="") {
		alert("Please type in your name.");
		eForm.txtname.focus();
		return;
	}
	
	else if (eForm.email.value=="") {
		alert("Please enter your email address.");
		eForm.email.focus();
		return;
	}

	else if (eForm.ddlMonth.value=="") {
		alert("Please enter month.");
		eForm.ddlMonth.focus();
		return;
	}
	
	else if (eForm.ddlDay.value=="") {
		alert("Please enter day.");
		eForm.ddlDay.focus();
		return;
	}
	
	else if (eForm.ddlYear.value=="") {
		alert("Please enter year.");
		eForm.ddlYear.focus();
		return;
	}
	
	
	else if(eForm.street.value=="") {
		alert("Please type in your street");
		eForm.street.focus();
		return;
	}
	
	else if (eForm.city.value=="") {
		alert("Please enter your city.");
		eForm.city.focus();
		return;
	}
	
	else if (eForm.state.value=="") {
		alert("Please enter your state.");
		eForm.state.focus();
		return;
	}

	
	document.emailForm.action="career-opportunities.php";
	document.emailForm.submit();
	eForm.formAction.value = "Submit";
	eForm.submit();
	}


