function ValidateEmail(email){
		var atCharPresent = false;
		var dotPresent = false;
		
		for ( var Idx = 0; Idx < email.value.length; Idx++ ){
			if ( email.value.charAt ( Idx ) == '@' )
				atCharPresent = true;
			if ( email.value.charAt ( Idx ) == '.' )
				dotPresent = true;
		}
		if ( !atCharPresent || !dotPresent ){
			return false;
			}
	return true;
}

function changeCountry(selectObj){
	// get the index of the selected option 
	var idx = selectObj.selectedIndex; 
	// get the value of the selected option 
	var which = selectObj.options[idx].value;
	if(which != ""){
	document.selectCountry.myCountry.value = which;
	//alert(which);
	document.selectCountry.submit();
	} else {
		//alert("Please select your Country.");
	}
}



function getCookie(c_name){
	if (document.cookie.length>0){
		c_start=document.cookie.indexOf(c_name + "=");
		if (c_start!=-1){
			c_start=c_start + c_name.length+1;
			c_end=document.cookie.indexOf(";",c_start);
			if (c_end==-1) c_end=document.cookie.length;
			return unescape(document.cookie.substring(c_start,c_end));
		}
	}
	return "";
}

function setCookie(c_name,value,expiredays){
	var exdate=new Date();
	exdate.setDate(exdate.getDate()+expiredays);
	document.cookie=c_name+ "=" +escape(value)+((expiredays==null) ? "" : ";expires="+exdate.toGMTString());
}

function checkCookie(){
	username=getCookie('username');
	if (username!=null && username!=""){
		//alert('Welcome again '+username+'!');
	} else {
		//username=prompt('Please enter your name:',"");
		if (username!=null && username!=""){
			setCookie('username','PLAY',365);
		}
	}
}


function homeVideo(){
}

//var url = 'http://motiliti.net/LiveOnPageClient.ashx?ci=7588&pi=home';var tt= new Date().getTime();document.write('<sc'+'ript type="text/javascript" ');document.write('src="'+url+'&t'+tt+'='+tt+'">');document.write('</sc'+'ript>');


function validateSignUpForm(){
	check = document.signUpForm;
	
	if(check.full_name.value == ""){
		alert("Please fill in Full Name.");
		check.full_name.focus();
		return false;
	}
	if(check.email.value == ""){
		alert("Please fill in Email.");
		check.email.focus();
		return false;
	}
	if (!ValidateEmail(check.email)){
		alert("Please fill in valid eMail address.");
		check.email.focus();
		return false;
	}

	if(check.password.value == ""){
		alert("Please fill in Password.");
		check.password.focus();
		return false;
	}
	if(check.confirm_password.value != check.password.value){
		alert("Your Password did not match. Please fill again.");
		check.confirm_password.focus();
		return false;
	}
	if(check.date.options[check.date.selectedIndex].value == ""){
		alert("Please select your BirthDate.");
		check.date.focus();
		return false;
	}
	if(check.month.options[check.month.selectedIndex].value == ""){
		alert("Please select your BirthDate.");
		check.month.focus();
		return false;
	}
	if(check.year.options[check.year.selectedIndex].value == ""){
		alert("Please select your BirthDate.");
		check.year.focus();
		return false;
	}
	if(check.address_1.value == ""){
		alert("Please fill in your Address.");
		check.address_1.focus();
		return false;
	}
	if(check.city.value == ""){
		alert("Please fill in City.");
		check.city.focus();
		return false;
	}
	if(check.province.value == ""){
		alert("Please fill in Province/State.");
		check.province.focus();
		return false;
	}
	if(check.zip.value == ""){
		alert("Please fill in ZIP Code.");
		check.zip.focus();
		return false;
	}
	if(check.country.options[check.country.selectedIndex].value == ""){
		alert("Please select your Country.");
		check.country.focus();
		return false;
	}
	if(check.recaptcha_response_field.value == ""){
		alert("Please fill in Security Image.");
		check.recaptcha_response_field.focus();
		return false;
	}
	if(check.accept_terms.checked == false){
		alert("You have to agree to the EcoMart Terms of Use and Privacy Policy.");
		check.accept_terms.focus();
		return false;
	}
}

function trim(strValue, field){
	if(strValue.replace(/ /g, "") == ""){
		alert("Please enter valid "+ field);
		return false;
	} else {
		return true;
	}
}

function validateAccountForm(){
	check = document.accountForm;
	if(check.full_name.value == ""){
		alert("Please fill in Full Name.");
		check.full_name.focus();
		return false;
	} else {
		if(! trim(check.full_name.value, 'Full Name')) return false;
	}

	if(check.email.value == ""){
		alert("Please fill in Email.");
		check.email.focus();
		return false;
	}
	if (!ValidateEmail(check.email)){
		alert("Please fill in valid eMail address.");
		check.email.focus();
		return false;
	}
	if(check.date.options[check.date.selectedIndex].value == ""){
		alert("Please select your BirthDate.");
		check.date.focus();
		return false;
	}
	if(check.month.options[check.month.selectedIndex].value == ""){
		alert("Please select your BirthDate.");
		check.month.focus();
		return false;
	}
	if(check.year.options[check.year.selectedIndex].value == ""){
		alert("Please select your BirthDate.");
		check.year.focus();
		return false;
	}
	if(check.address_1.value == ""){
		alert("Please fill in your Address.");
		check.address_1.focus();
		return false;
	} else {
		if(! trim(check.address_1.value, 'Address')) return false;
	}
	if(check.city.value == ""){
		alert("Please fill in City.");
		check.city.focus();
		return false;
	} else {
		if(! trim(check.city.value, 'City')) return false;
	}
	if(check.province.value == ""){
		alert("Please fill in Province/State.");
		check.province.focus();
		return false;
	} else {
		if(! trim(check.province.value, 'Province / State')) return false;
	}
	if(check.zip.value == ""){
		alert("Please fill in ZIP Code.");
		check.zip.focus();
		return false;
	} else {
		if(! trim(check.zip.value, 'ZIP Code')) return false;
	}
	if(check.country.options[check.country.selectedIndex].value == ""){
		alert("Please select your Country.");
		check.country.focus();
		return false;
	}
}

function validateactivateAccount(){
	check = document.activationCode;
	if(check.actCode.value == ""){
		alert("Please fill in your Activation Code.");
		check.actCode.focus();
		return false;
	}
	if(check.password.value == ""){
		alert("Please fill in your Password.");
		check.password.focus();
		return false;
	}
}

function validateforgotPassword(){
	check = document.forgotPasswordFrm;
	if(check.email.value == ""){
		alert("Please enter your Registered eMail.");
		check.email.focus();
		return false;
	}
}

function validatePasswordUpdateForm(){
	check = document.passwordUpdateForm;
	if(check.old_password.value == ""){
		alert("Please fill in your Existing Password.");
		check.old_password.focus();
		return false;
	}
	if(check.password.value == ""){
		alert("Please fill in New Password.");
		check.password.focus();
		return false;
	}
	if(check.confirm_password.value != check.password.value){
		alert("Your New Password did not match. Please fill again.");
		check.confirm_password.focus();
		return false;
	}
}

function validateaccountLogin(){
	check = document.accountLoginFrm;
	if(check.email.value == ""){
		alert("Please enter your Registered eMail.");
		check.email.focus();
		return false;
	}
	if (!ValidateEmail(check.email)){
		alert("Please fill in valid eMail address.");
		check.email.focus();
		return false;
	}
	if(check.password.value == ""){
		alert("Please enter your Password.");
		check.password.focus();
		return false;
	}
}

function validateaccountLogin1(){
	check = document.accountLoginFrm1;
	if(check.email.value == ""){
		alert("Please enter your Registered eMail.");
		check.email.focus();
		return false;
	}
	if (!ValidateEmail(check.email)){
		alert("Please fill in valid eMail address.");
		check.email.focus();
		return false;
	}
	if(check.password.value == ""){
		alert("Please enter your Password.");
		check.password.focus();
		return false;
	}
}

function resetReferer(){
	document.signUpForm.referral.value="";
	document.signUpForm.namedoesnotmatter.value="";
}