<!--
function DoSubmit(){
}

function CheckRadio(formEle)
{
	bCont = false;
	for(x = 0;x<formEle.length;x++)
	{
			if(formEle[x].checked == true) 
				bCont = true;
	}
	if(bCont == false)
	{
		//	formEle.focus();
	}
	return bCont;
}

function CheckS()
{
	var noError = true;
	var strErr = "Please answer the following questions:";
	if (document.forms.form1.t_gender.value == 0) 
	{
		alert("Please select your gender.");
		return false;
	}
	if (document.forms.form1.t_age.value == 0) 
	{
		alert("Please select your age.");
		return false;
	}
/*if (CheckRadio(document.forms.form1.question_1) == false) 
{
	sErr = "Please Answer: 1. Of your last 5 beer purchases (not including beer purchased at a restaurant or bar), how many were made at The Beer Store?";
	strErr = strErr + '\n' + sErr
	noError = false;
}
if (CheckRadio(document.forms.form1.question_2) == false) 
{
	sErr = "Please Answer: 2. In the past week, how many beers have you drank at home?";
	strErr = strErr + '\n' + sErr
	noError = false;
}
if (CheckRadio(document.forms.form1.question_3) == false) 
{
	sErr = "Please Answer: 3. Has The Beer Store in your neighbourhood been recently renovated";
	strErr = strErr + '\n' + sErr
	noError = false;
}
00 Stuff[z++] = 'question_2|1. Of your last 5 beer purchases (not including beer purchased at a restaurant or bar), how many were made at The Beer Store?';
01 Stuff[z++] = 'question_1|2. In general, how often do you drink beer at home?';
18 Stuff[z++] = 'question_5|6. Would you like to hear about special offers and promotions from The Beer Store?';

*/
	var str4;
	var Stuff = Array(20);
	z=0;
/*
	Stuff[z++] = 'question_1|1. In the past week, how many beers have you drank at home or elsewhere (not including those drank at a bar or restaurant)?';
	Stuff[z++] = 'question_2|2. In general, how often do you drink beer at home?';
	Stuff[z++] = 'question_3|3. In the past month, have you purchased beer?';
	Stuff[z++] = 'question_5|5. Would you like to hear about special offers and promotions from The Beer Store?';
*/
/*
	Stuff[z++] = 'question_1|1. Have you purchased beer in the past 12 months at either the Beer Store or the LCBO?';
	Stuff[z++] = 'question_2|2. As best as you can remember, out of your past 5 purchases of beer for consumption at your home or at somebody else's home, how many of the 5 purchases were made from The Beer Store, The LCBO or somewhere else? Total must equal 5.?';
	Stuff[z++] = 'question_3|3. On average, how often do purchase beer from The Beer Store? (Read List)?';
	Stuff[z++] = 'question_5|4. If The Beer Store were to introduce a loyalty program featuring rewards that were of interest to you, how likely would you be to shop at The Beer Store more often? Would you be¡­ (Read list)?';
	Stuff[z++] = 'question_8|5. The Beer Store could offer a number of different types of rewards as part of a customer loyalty program. Please indicate below how interested you are in a particular reward on a 10 point scale, with a score of "10" being very interested and a score of "1" being not at all interested. You can use any number between 1-10. How interested would you be in rewards such as... ?';
	Stuff[z++] = 'question_6|6. Are you currently a member of any loyalty programs that you actively participate in (i.e. purchase specific products or services regularly to collect points in that program)?';
	Stuff[z++] = 'question_10|7. Would you like to hear about special offers and promotions from The Beer Store?';
	Stuff[z++] = 'question_11|8. In which format would you prefer to receive promotional email from The Beer Store?';
	Stuff[z++] = "question_2|2. As best as you can remember, out of your past 5 purchases of beer for consumption at your home or at somebody else's home, how many of the 5 purchases were made from The Beer Store, The LCBO or somewhere else? If you choose to answer this question, please have your numbers total 5.";
*/

	Stuff[z++] = 'question_10|7. Would you like to hear about special offers and promotions from The Beer Store?';

	for(ele=0;ele<z;ele++){
		a = Stuff[ele].split("|");
		strCheck = 'document.forms.form1.' + a[0];
		/*
		if(ele==0){
			//check text
			if(CheckData()==false){
				strErr = strErr + '\n' + a[1];
				noError = false;
			}
		}
		*/
		if(ele==0){
			if(CheckRadio(eval(strCheck)) == false){
				strErr = strErr + '\n' + a[1];
				noError = false;
			}
		}
		/*
		if(ele==2){
			str4 = CheckMathAlert();
			if(str4.length > 0){
				strErr = strErr + '\n' + str4;
			}
		}
		*/
	}
	
	if(noError == false)
	{
		alert(strErr);
	}
	
	return noError;
}

function CheckMathAlert(){
var i;
var thechar;
var iValid;
//	if(document.form1.question_4.value.length<1){
//		return '4. Skill-Testing Question 18 x 3 ?6 + 48 - 33 = ? ';
//	}
//	else{
//		return '';
//	}
}


function CheckMath(){
//var i;
//var thechar;
//var iValid;
//	if(document.form1.question_4.value.length<1){
//		alert('Please answer the following questions. Skill-Testing Question 18 x 3 ?6 + 48 - 33 = ? ');
//		document.form1.question_4.focus();
//		return false;
//	}
//	else{
//		if(CheckNumbers(document.form1.question_4.value)==true){
//			return true;
//		}
//		else{
//			alert("invalid answer!");
//			document.form1.question_4.focus();
//			return false;
//		}
//	}
}


function OnConfirm(){
	if(checkinfo()==true){
		//alert('submit');
		document.form1.submit();
	}
	//alert('false');
	return false;
}

function checkinfo(){
	if(document.form1.t_fname.value.length<1){
		alert("Please enter a valid First Name!");
		document.form1.t_fname.focus();
		return false;
	}
	if(document.form1.t_lname.value.length<1){
		alert("Please enter a valid Last Name!");
		document.form1.t_lname.focus();
		return false;
	}
	//if(document.form1.t_email.value.length<1){
	//	alert("Invalid email!");
	//	document.form1.t_email.focus();
	//	return false;
	//}

	//if(document.form1.t_email.value.length < 1){
	//	alert("Please enter a valid Email Address!");
	//	document.form1.t_email.focus();
	//	return false;
	//}
	//else{
	//	if((document.form1.t_email.value.indexOf("@") < 1)||(document.form1.t_email.value.indexOf("@") + 4 > document.form1.t_email.value.length)){
	//		alert("Please enter a valid Email Address!");
	//		document.form1.t_email.focus();
	//		return false;
	//	}
	//	if(echeck(document.form1.t_email.value)==false){
	//		alert("Please enter a valid Email Address!");
	//		document.form1.t_email.focus();
	//		return false;
	//	}
	//}
	//
	if(document.form1.t_addr1.value.length<1){
		alert("Please enter a valid Address!");
		document.form1.t_addr1.focus();
		return false;
	}
	if(document.form1.t_city.value.length<1){
		alert("Please enter a valid City!");
		document.form1.t_city.focus();
		return false;
	}
	if(document.form1.t_postal.value.length<1){
		alert("Please enter a valid Postal Code!");
		document.form1.t_postal.focus();
		return false;
	}
	
	//check number
	if(!CheckHTel()){
		return false;
	}
	//if(!CheckMTel()){
	//	return false;
	//}
	//if(!CheckWTel()){
	//	return false;
	//}
	//
	//document.form1.t_country.value = document.form1.s_country.value;
	//document.form1.t_state.value = document.form1.s_state.value;
	document.form1.t_prefix.value = document.form1.s_prefix.value;
	//if(document.form1.c_confirm.checked==true){
		document.form1.t_confirm.value = 1;
	//}
	//else{
	//	document.form1.t_confirm.value = 0;
	//}
	if(CheckData()==false){
		return false;
	}
	return true;
}

function echeck(str) {
		var at="@"
		var dot="."
		var lat=str.indexOf(at)
		var lstr=str.length
		var ldot=str.indexOf(dot)
		if (str.indexOf(at)==-1){
		   //alert("Invalid E-mail address!");
		   return false;
		}

		if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
		   //alert("Invalid E-mail address!");
		   return false;
		}

		if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
		   //alert("Invalid E-mail address!");
		   return false;
		}

		 if (str.indexOf(at,(lat+1))!=-1){
		   //alert("Invalid E-mail address!");
		   return false;
		 }

		 if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
			//alert("Invalid E-mail address!");
			return false;
		 }

		 if (str.indexOf(dot,(lat+2))==-1){
			//alert("Invalid E-mail address!");
			return false;
		 }
		
		 if (str.indexOf(" ")!=-1){
			//alert("Invalid E-mail address!");
			return false;
		 }
 		 return true;
}

function CheckHTel(){
	if((document.form1.t_phone1.value.length==3)&&(document.form1.t_phone2.value.length==3)&&(document.form1.t_phone3.value.length==4)){
		if(!CheckNumber(document.form1.t_phone1.value)){
			alert("invalid Home Phone number!");
			return false;
		}
		if(!CheckNumber(document.form1.t_phone2.value)){
			alert("invalid Home Phone number!");
			return false;
		}
		if(!CheckNumber(document.form1.t_phone3.value)){
			alert("invalid Home Phone number!");
			return false;
		}
		else{
			return true;
		}
	}
	else{
		if((document.form1.t_phone1.value.length==0)&&(document.form1.t_phone2.value.length==0)&&(document.form1.t_phone3.value.length==0)){
			return true;
		}
		else{
			alert("Home Phone length is invalid!");
			return false;
		}
	}
}


function CheckMTel(){
	if((document.form1.t_mphone1.value.length==3)&&(document.form1.t_mphone2.value.length==3)&&(document.form1.t_mphone3.value.length==4)){
		if(!CheckNumber(document.form1.t_mphone1.value)){
			alert("invalid Mobile Phone number!");
			return false;
		}
		if(!CheckNumber(document.form1.t_mphone2.value)){
			alert("invalid Mobile Phone number!");
			return false;
		}
		if(!CheckNumber(document.form1.t_mphone3.value)){
			alert("invalid Mobile Phone number!");
			return false;
		}
		else{
			return true;
		}
	}
	else{
		if((document.form1.t_mphone1.value.length==0)&&(document.form1.t_mphone2.value.length==0)&&(document.form1.t_mphone3.value.length==0)){
			return true;
		}
		else{
			alert("Mobile Phone length is invalid!");
			return false;
		}
	}
}

function CheckWTel(){
	if((document.form1.t_wphone1.value.length==3)&&(document.form1.t_wphone2.value.length==3)&&(document.form1.t_wphone3.value.length==4)){
		if(!CheckNumber(document.form1.t_wphone1.value)){
			alert("invalid Work Phone number!");
			return false;
		}
		if(!CheckNumber(document.form1.t_wphone2.value)){
			alert("invalid Work Phone number!");
			return false;
		}
		if(!CheckNumber(document.form1.t_wphone3.value)){
			alert("invalid Work Phone number!");
			return false;
		}
		else{
			return true;
		}
	}
	else{
		if((document.form1.t_wphone1.value.length==0)&&(document.form1.t_wphone2.value.length==0)&&(document.form1.t_wphone3.value.length==0)){
			return true;
		}
		else{
			alert("Work Phone length is invalid!");
			return false;
		}
	}
}

function CheckNumbers(items){
	var sTest;
	var i = 0;
	sText = items;
	for(i=0;i<sText.length;i++){
		if((sText.charAt(i)<'0')||(sText.charAt(i)>'9')){
			return false;
		}
	}
	return true;
}


function CheckNumber(items){
	var sTest;
	var i = 0;
	sText = items;
	//alert("CheckNumber:" + sText);
	for(i=0;i<sText.length;i++){
		if((sText.charAt(i)<'0')||(sText.charAt(i)>'9')){
			return false;
		}
	}
	return true;
	/*if(isNaN(parseInt(items))){
		return false;
	}	
	else{
		return true;
	}*/
}


//************added by yang*****************

function CheckData(){
	return true;
//	if(document.form1.question_4){
//		if(!CheckNumber(document.form1.question_4.value)){
//			alert("Please enter the number of beers you have consumed in the past week (only numeric entries accepted)");
//			document.form1.question_4.focus();
//			return false;
//		}
//	}
	//question_2_1 
//	var item1,item2,item3;
	//Has data
//	if((document.form1.question_2.length)>0){
//		if((document.form1.question_2[0].value.length>0)||(document.form1.question_2[1].value.length>0)||(document.form1.question_2[2].value.length>0)){
//			//Has value there and invalid
//			if((document.form1.question_2[0].value.length>0)&&(!CheckNumber(document.form1.question_2[0].value))){
//				alert("Data is invalid!");
//				document.form1.question_2[0].focus();
//				return false;
//			}
//			if((document.form1.question_2[1].value.length>0)&&(!CheckNumber(document.form1.question_2[1].value))){
//				alert("Data is invalid!");
//				document.form1.question_2[1].focus();
//				return false;
//			}
//			if((document.form1.question_2[2].value.length>0)&&(!CheckNumber(document.form1.question_2[2].value))){
//				alert("Data is invalid!");
//				document.form1.question_2[2].focus();
//				return false;
//			}
//			//
//			item1 = document.form1.question_2[0].value;		
//			if(item1.length==0){
//				item1=0;
//			}
//			item2 = document.form1.question_2[1].value;
//			if(item2.length==0){
//				item2=0;
//			}
//			item3 = document.form1.question_2[2].value;
//			if(item3.length==0){
//				item3=0;
//			}
//			if(parseInt(item3,10)+parseInt(item2,10)+parseInt(item1,10)!=5){
//				alert("Please have your beer purchases total 5")
//				return false;
//			}
//			document.form1.question_2.value = item1 + ',' + item2 + ',' + item3 + ',';
//			return true;
//		}
//		else{
//			//alert('Please answer the qyestion: As best as you can remember, out of your past 5 purchases of beer for consumption at your home or at somebody else¡¯s home, how many of the 5 purchases were made from The Beer Store, The LCBO or somewhere else? Total must equal 5.');
//			//document.form1.question_2_1.focus();
//			document.form1.question_2.value = '';
//			return true;
//		}
//	} else {
//		return true;
//	}
}	
function ConfirmAddition() {
	if(CheckData()==true){
		//alert('submit');
		document.form1.submit();
	}
	return false;
}
// -->