// JavaScript Document

function checklistingtype(type) {
	if(type==2) {
		document.getElementById('desc').style.display = '';
	} else {
		document.getElementById('desc').style.display = 'none';
	}
}

function usernamecheck(e, decimal) {
	var key;
	var keychar;

	if (window.event) {
	   key = window.event.keyCode;
	}
	else if (e) {
	   key = e.which;
	}
	else {
	   return true;
	}
	if ((key==32)) {
	   return false;
	}
}

function RestValidation()
{
	    if(document.myform.restaurant_username.value=='')
		{
			alert("Please enter a username.");
			document.myform.restaurant_username.focus();
			return false;
		}
		var user = document.myform.restaurant_username.value;
		if(user.length<6||user.length>25)
		{
			alert("Username should be 6-25 characters in length.");
			document.myform.restaurant_username.focus();
			return false;
		}
		if(document.myform.restaurant_password.value=='')
		{
			alert("Please fill password.");
			document.myform.restaurant_password.focus();
			return false;
		}
		var pass = document.myform.restaurant_password.value;
		if(pass.length<6||pass.length>10)
		{
			alert("Password should be 6-10 characters in length.");
			document.myform.restaurant_password.focus();
			return false;
		}
		if(document.myform.restaurant_password2.value=='')
		{
			alert("Please fill confirm password.");
			document.myform.restaurant_password2.focus();
			return false;
		}
	   if(document.myform.restaurant_password.value!=document.myform.restaurant_password2.value)
	   {
		   alert("Password and confirm password not match");
		   document.myform.restaurant_password2.focus();
		   return false;
	   }
	   if(!document.myform.restaurant_type[0].checked && !document.myform.restaurant_type[1].checked)
		{
			alert("Please select Restaurant listing offer.");
			return false;
		}
		if(document.myform.restaurant_name.value=='')
		{
			alert("Please fill restaurant name.");
			document.myform.restaurant_name.focus();
			return false;
		}
		if(document.myform.restaurant_city.value=='')
		{
			alert("Please fill city name.");
			document.myform.restaurant_city.focus();
			return false;
		}
		if(document.myform.restaurant_state.value=='')
		{
			alert("Please choose state.");
			document.myform.restaurant_state.focus();
			return false;
		}
		if(document.myform.restaurant_zip.value=='')
		{
			alert("Please fill zip.");
			document.myform.restaurant_zip.focus();
			return false;
		}
		if(document.myform.restaurant_contact_person.value=='')
		{
			alert("Please fill restaurant contact.");
			document.myform.restaurant_contact_person.focus();
			return false;
		}
		if(document.myform.restaurant_phone.value=='')
		{
			alert("Please fill restaurant phone.");
			document.myform.restaurant_phone.focus();
			return false;
		}
		if(document.myform.restaurant_email.value=='')
		{
			alert("Please fill your email.");
			document.myform.restaurant_email.focus();
			return false;
		}
	   var email=document.myform.restaurant_email.value;
	   if(!email.match(/^[A-Za-z0-9\._\-+]+@[A-Za-z0-9_\-+]+(\.[A-Za-z0-9_\-+]+)+$/))
	   {
			alert("The e-mail format is not correct.");
			document.myform.restaurant_email.focus();
			return false;
	   }
}

function BackStep2() {
		document.myform.restaurant_val.value = '1';
}

function step2()
{
	    if(document.myform.restaurant_val.value == '1') {
			return true;
		}
		if(document.myform.restaurant_hotel1_name.value=='')
		{
			alert("Please enter Nearby hotel 1 Name.");
			document.myform.restaurant_hotel1_name.focus();
			return false;
		}
		if(document.myform.restaurant_hotel1_address.value=='')
		{
			alert("Please enter Nearby hotel 1 Address.");
			document.myform.restaurant_hotel1_address.focus();
			return false;
		}
		if(document.myform.restaurant_hotel1_phone.value=='')
		{
			alert("Please enter Nearby hotel 1 Phone.");
			document.myform.restaurant_hotel1_phone.focus();
			return false;
		}
		if(document.myform.restaurant_hotel1_distance1.value=='' || document.myform.restaurant_hotel1_distance2.value=='')
		{
			alert("Please enter Nearby hotel 1 Distance.");
			document.myform.restaurant_hotel1_distance1.focus();
			return false;
		}
		if(document.myform.restaurant_hotel1_time1.value=='' || document.myform.restaurant_hotel1_time2.value=='')
		{
			alert("Please enter Nearby hotel 1 Time.");
			document.myform.restaurant_hotel1_time1.focus();
			return false;
		}
		
		
}

function BackStep3() {
		document.myform.restaurant_val.value = '1';
}

function step3() {
		if(document.myform.restaurant_val.value == '1') {
			return true;
		}
		if(document.myform.restaurant_college1_name.value=='')
		{
			alert("Please enter Nearest (College or University).");
			document.myform.restaurant_college1_name.focus();
			return false;
		}
		if(document.myform.restaurant_college1_distance1.value=='' || document.myform.restaurant_college1_distance2.value=='')
		{
			alert("Please enter Nearby (College or University) Distance.");
			document.myform.restaurant_college1_distance1.focus();
			return false;
		}
		if(document.myform.restaurant_college1_time1.value=='' || document.myform.restaurant_college1_time2.value=='')
		{
			alert("Please enter Nearby (College or University) Time.");
			document.myform.restaurant_college1_time1.focus();
			return false;
		}
}


function BackStep4() {
		document.myform.restaurant_val.value = '1';
}

function step4() {
		if(document.myform.restaurant_val.value == '1') {
			return true;
		}
		if(document.myform.restaurant_venue4_name.value=='')
		{
			alert("Please enter Theater or Performing Arts Venue 1.");
			document.myform.restaurant_venue4_name.focus();
			return false;
		}
		if(document.myform.restaurant_venue4_distance1.value=='' || document.myform.restaurant_venue4_distance2.value=='')
		{
			alert("Please enter Theater or Performing Arts Venue 1 Distance.");
			document.myform.restaurant_venue4_distance1.focus();
			return false;
		}
		if(document.myform.restaurant_venue4_time1.value=='' || document.myform.restaurant_venue4_time2.value=='')
		{
			alert("Please enter Theater or Performing Arts Venue 1 Time.");
			document.myform.restaurant_venue4_time1.focus();
			return false;
		}
}


function Step5 () {
	if(document.myform.restaurant_val.value == '1') {
			return true;
	}
	if(!document.myform.user_terms.checked)
    {
		alert("Please check terms & conditions.");
		return false;
	}
	return true;
}
function BackStep5 () {
	document.myform.restaurant_val.value = '1';
}


function updateaction() {
	document.myform.restaurant_val.value = '1';
	//document.myform.image.value = count;
	document.myform.action.value = 'upload';
}

function promoaction(count) {
	document.myform.restaurant_val.value = '1';
	document.myform.action.value = 'promocode';
}

function adddeleteimage(count) {
	if(confirm("Are you sure to delete this image"+count)) {
		window.location.href = "cre_res_profile5.php?img="+count;
	}
}

function editdeleteimage(count) {
	if(confirm("Are you sure to delete this image"+count)) {
		window.location.href = "update_res_profile5.php?img="+count;
	}
}




function EditRestValidation()
{
	    
	  	if(document.myform.restaurant_name.value=='')
		{
			alert("Please fill restaurant name.");
			document.myform.restaurant_name.focus();
			return false;
		}
		 if(!document.myform.restaurant_type[0].checked && !document.myform.restaurant_type[1].checked)
		{
			alert("Please select Restaurant listing offer.");
			return false;
		}
		if(document.myform.restaurant_city.value=='')
		{
			alert("Please fill city name.");
			document.myform.restaurant_city.focus();
			return false;
		}
		if(document.myform.restaurant_state.value=='')
		{
			alert("Please choose state.");
			document.myform.restaurant_state.focus();
			return false;
		}
		if(document.myform.restaurant_zip.value=='')
		{
			alert("Please fill zip.");
			document.myform.restaurant_zip.focus();
			return false;
		}
		if(document.myform.restaurant_contact_person.value=='')
		{
			alert("Please fill restaurant contact.");
			document.myform.restaurant_contact_person.focus();
			return false;
		}
		if(document.myform.restaurant_phone.value=='')
		{
			alert("Please fill restaurant phone.");
			document.myform.restaurant_phone.focus();
			return false;
		}
		if(document.myform.restaurant_email.value=='')
		{
			alert("Please fill your email.");
			document.myform.restaurant_email.focus();
			return false;
		}
	   var email=document.myform.restaurant_email.value;
	   if(!email.match(/^[A-Za-z0-9\._\-+]+@[A-Za-z0-9_\-+]+(\.[A-Za-z0-9_\-+]+)+$/))
	   {
			alert("The e-mail format is not correct.");
			document.myform.restaurant_email.focus();
			return false;
	   }
}