function add_Restaurant(frm){
	frm.theAction.value="add_Restaurant";
	frm.submit();
}
function search_again(frm){
	frm.theAction.value="search_again";
	frm.submit();
}
function do_Cancel(frm){
	frm.theAction.value="Cancel";
	frm.submit();
}
function do_Search(frm){
	frm.theAction.value="search";
	frm.submit();
}
function do_Reset(frm){
	frm.price_range.value = "Any";
	frm.ambience.value = "Any";
	frm.cuisine.value = "Any";
	frm.county.value = "Any";
	frm.special_offers.checked = false;
}
function do_Submit(frm){
	frm.submit();
}

function add_Register(frm){
	var thefields = new Array("first_name","surname","email_address","confirm_email_address","password1","password2","phone_number","screen_name","userdigit");

	var thetext = new Array("your firstname","your surname","your email address","your confirmed email address","your password","your confirmed your password","your contact number","your bookit.ie screen name","the 5 digit number displayed in the image");	
	
	for (var i=0; i<thefields.length; i++){
		if (!frm[thefields[i]].value){
			alert("Please enter "+ thetext[i] + ".");
			frm[thefields[i]].focus();
			return;
		}
	}

	if ((frm.email_address.value)!=(frm.confirm_email_address.value)){
		alert("Your email address and confirmation email address do not match!");
		return;
	}
	if ((frm.password1.value)!=(frm.password2.value)){
		alert("Your Password and Confirmation Password do not match!");
		return;
	}
	if (frm.terms_and_conditions.checked == false){
		alert("You must indicate that you have read and accept the sites Terms & Conditions");
		return;
	}
	if (frm.privacy_policy.checked == false){
		alert("You must indicate that you have read and accept the sites Privacy Policy");
		return;
	}
	frm.theAction.value = "add_Register";
	frm.submit();
}

function add_Register_owner(frm){
	var thefields = new Array("first_name","surname","job_title","email_address","confirm_email_address","password1","password2","phone_number","userdigit");

	var thetext = new Array("your firstname","your surname","your job title","your email address","your confirmed email address","your password","your confirmed your password","your contact number","the 5 digit number displayed in the image");	
	
	for (var i=0; i<thefields.length; i++){
		if (!frm[thefields[i]].value){
			alert("Please enter "+ thetext[i] + ".");
			frm[thefields[i]].focus();
			return;
		}
	}

	if ((frm.email_address.value)!=(frm.confirm_email_address.value)){
		alert("Your email address and confirmation email address do not match!");
		return;
	}
	if ((frm.password1.value)!=(frm.password2.value)){
		alert("Your Password and Confirmation Password do not match!");
		return;
	}
	if (frm.terms_and_conditions.checked == false){
		alert("You must indicate that you have read and accept the sites Terms & Conditions");
		return;
	}
	if (frm.privacy_policy.checked == false){
		alert("You must indicate that you have read and accept the sites Privacy Policy");
		return;
	}
	frm.theAction.value = "add_Register";
	frm.submit();
}


function do_Booking(frm,date1,date2){
	if (date1 == ""){
		alert("Please select a date");
		frm.booking_date.focus();
		return false;
	}else{
		tmp = date1.split("-")
		xDate = tmp[1]+"-"+tmp[0]+"-"+tmp[2];
		refDate = calcJulian(xDate);
		tmp = date2.split("-")
		xDate = tmp[1]+"-"+tmp[0]+"-"+tmp[2];
		fwdDate = calcJulian(xDate);
	
		if (fwdDate > refDate){
			alert('Booking date must not be in the past!');
			frm.booking_date.value = "";
			frm.booking_date.focus();
			return false;
		}
	}
	if (frm.time.value==""){
		alert("Please select a sitting time!");
		frm.time.focus();
		return false;
	}
	frm.theAction.value="do_Booking";
	frm.submit();
}
function do_Booking_best(frm){

	if ((!document.bookit.sitting[0].checked)&&(!document.bookit.sitting[1].checked)&&(!document.bookit.sitting[2].checked)){
		alert("Please select a sitting");
		return false;
	}
	if (frm.number_of_people.value == ""){
		alert("Please enter the number of people");
		frm.number_of_people.focus();
		return false;
	}
	if (frm.time.value==""){
		alert("Please select a sitting time!");
		frm.time.focus();
		return false;
	}
	frm.theAction.value="do_Booking";
	frm.submit();
}

function check_loginform(frm){
	if ((frm.username.value == "USERNAME") || (frm.password.value == "PASSWORD")){
		alert("Please enter your Username and Password");
	}else{
		frm.submit();
	}
}

function logout(frm){
	frm.submit();
}

function update_User(frm){
	var thefields = new Array("first_name","surname","email_address","confirm_email_address","password1","password2","phone_number");

	var thetext = new Array("your firstname","your surname","your email address","your confirmed email address","your password","confirm your password","your contact number");	
	
	for (var i=0; i<thefields.length; i++){
		if (!frm[thefields[i]].value){
			alert("Please enter "+ thetext[i] + ".");
			frm[thefields[i]].focus();
			return;
		}
	}

	if ((frm.email_address.value)!=(frm.confirm_email_address.value)){
		alert("Your email address and confirmation email address do not match!");
		return;
	}
	if ((frm.password1.value)!=(frm.password2.value)){
		alert("Your Password and Confirmation Password do not match!");
		return;
	}
	frm.theAction.value = "update_User";
	frm.submit();
}

function forgotten_password(frm){
	if (frm.email_address.value == ""){
		alert("Please enter your email address");
		frm.email_address.focus();
		return false;
	}else{
		frm.theAction.value="gogetit";
		frm.submit();
	}
}
function add_Review(frm){
	if (frm.restaurant.value == ""){
		alert("You must select a restaurant!");
		return;
	}
	if (frm.review.value == ""){
		alert("You must review this restaurant!");
		return;
	}
	if ((frm.food_rating.value == "")||(frm.service_rating.value == "")||(frm.wine_list_rating.value == "")||(frm.ambience_rating.value == "")||(frm.value_for_money_rating.value == "")||(frm.washrooms_rating.value == "")||(frm.overall_rating.value == "")){
		alert("Rating not complete!");
		return;
	}
	frm.restaurant_object_id.value = frm.restaurant.value;
	frm.theAction.value = "add_Review";
	frm.submit();
}

function resfreshImg1(frm){
	if (frm.ImgFeature_upld1.value!=""){
		frm.ImgFeature1.src=frm.ImgFeature_upld1.value;
	}

}
function resfreshImg2(frm){
	if (frm.ImgFeature_upld2.value!=""){
		frm.ImgFeature2.src=frm.ImgFeature_upld2.value;
	}

}
function resfreshImg3(frm){
	if (frm.ImgFeature_upld3.value!=""){
		frm.ImgFeature3.src=frm.ImgFeature_upld3.value;
	}

}
function resfreshImg4(frm){
	if (frm.ImgFeature_upld4.value!=""){
		frm.ImgFeature4.src=frm.ImgFeature_upld4.value;
	}

}
function resfreshImg5(frm){
	if (frm.ImgFeature_upld5.value!=""){
		frm.ImgFeature5.src=frm.ImgFeature_upld5.value;
	}

}
function resfreshImg6(frm){
	if (frm.ImgFeature_upld6.value!=""){
		frm.ImgFeature6.src=frm.ImgFeature_upld6.value;
	}

}
function resfreshLogo(frm){
	if (frm.restaurant_logo.value!=""){
		frm.restaurant_logo1.src=frm.restaurant_logo.value;
	}
}
function popUp(url) {
SMWin = window.open(url,"win",'toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=1,resizable=0,width=400,height=400,left='+(screen.width-400)/2+',top='+(screen.height-400)/2+'');
}
function popUp2(url) {
SMWin = window.open(url,"win",'toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=1,resizable=1,width=600,height=200,left='+(screen.width-600)/2+',top='+(screen.height-200)/2+'');
}
function popUp3(url) {
SMWin = window.open(url,"win",'toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=1,resizable=1,width=600,height=300,left='+(screen.width-600)/2+',top='+(screen.height-300)/2+'');
}

function best_for_again(frm){
	frm.theAction.value="best_for_again";
	frm.submit();
}

function do_best_for(frm){
	if (frm.best_for.value == ""){
		alert("Please select a 'Best for...'");
		frm.best_for.focus();
		return false;
	}else{
		frm.submit();
	}
}
function checkit(frm){
	var thefields = new Array("name","email","teleno","comments");
	var thetext = new Array("your name","your full email address","your telephone number","your comments");	
	for (var i=0; i<thefields.length; i++){
		if (i==1){
			if (frm[thefields[i]].value.indexOf('@') == -1){
				alert("Please enter "+ thetext[i] + ".");
				frm.email.focus();
				return false;
			}
		}
		if (!frm[thefields[i]].value){
		alert("Please enter "+ thetext[i] + ".");
		frm[thefields[i]].focus();
		return false;
		}
	}
	frm.submit();
}



function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}
function do_suitable_for1(frm){
	if (frm.suitable_for.value == ""){
		alert("Please select the Type of Event");
		frm.suitable_for.focus();
		return false;
	}
	if (frm.type_of_entertainment.value == 1){
		alert("Please select the type of DJ");
		frm.type_of_entertainment.focus();
		return false;
	}
	if (frm.type_of_entertainment.value == 11){
		alert("Please select the type of Live Music");
		frm.type_of_entertainment.focus();
		return false;
	}
	if (frm.type_of_entertainment.value == 31){
		alert("Please select the type of Childrens Entertainment");
		frm.type_of_entertainment.focus();
		return false;
	}
	if (frm.type_of_entertainment.value == 41){
		alert("Please select the type of Entertainers");
		frm.type_of_entertainment.focus();
		return false;
	}
	if (frm.type_of_entertainment.value == 61){
		alert("Please select the type of Dancers");
		frm.type_of_entertainment.focus();
		return false;
	}
	frm.submit();
}
function do_suitable_for(frm){
	if (frm.suitable_for.value == ""){
		alert("Please select the Type of Event");
		frm.suitable_for.focus();
		return false;
	}
	frm.submit();
}

function do_Booking_entertainer(frm,date1,date2){
	if (date1 == ""){
		alert("Please select a date");
		frm.booking_date.focus();
		return false;
	}else{
		tmp = date1.split("-")
		xDate = tmp[1]+"-"+tmp[0]+"-"+tmp[2];
		refDate = calcJulian(xDate);
		tmp = date2.split("-")
		xDate = tmp[1]+"-"+tmp[0]+"-"+tmp[2];
		fwdDate = calcJulian(xDate);
	
		if (fwdDate > refDate){
			alert('Booking date must not be in the past!');
			frm.booking_date.value = "";
			frm.booking_date.focus();
			return false;
		}
	}
	if (frm.address_line1.value == ""){
		alert("Please enter the venue address");
		frm.address_line1.focus();
		return false;
	}
	if (frm.address_line2.value == ""){
		alert("Please enter the venue address");
		frm.address_line2.focus();
		return false;
	}

	if (frm.address_line3.value == ""){
		alert("Please enter the venue address");
		frm.address_line3.focus();
		return false;
	}

	if (frm.address_line4.value == ""){
		alert("Please enter the venue address");
		frm.address_line4.focus();
		return false;
	}
	frm.theAction.value="do_Booking";
	frm.submit();
}
function do_return_url(frm){
	frm.theAction.value="return_url";
	frm.submit();
}
function calcJulian(isDate){

gregDate = new Date(isDate);
year = gregDate.getFullYear();
month = gregDate.getMonth()+1;
day = gregDate.getDate();
A = Math.floor((7*(year+Math.floor((month+9)/12)))/4);
B = day+Math.floor((275*month)/9)
isJulian = (367*year)-A+B+1721014;
return isJulian;
}

function validate(frm,date1,date2){

	if (date1 == ""){
		alert("Please select a date");
		frm.booking_date.focus();
		return;
	}else{
		tmp = date1.split("-")
		xDate = tmp[1]+"-"+tmp[0]+"-"+tmp[2];
		refDate = calcJulian(xDate);
		tmp = date2.split("-")
		xDate = tmp[1]+"-"+tmp[0]+"-"+tmp[2];
		fwdDate = calcJulian(xDate);
	
		if (fwdDate > refDate){
			alert('Booking date must not be in the past!');
			frm.booking_date.value = "";
			frm.booking_date.focus();
			return;
		}
	}
	if ((!document.bookit.sitting[0].checked)&&(!document.bookit.sitting[1].checked)&&(!document.bookit.sitting[2].checked)){
		alert("Please select a sitting");
		return;
	}
	if (frm.number_of_people.value == ""){
		alert("Please enter the number of people");
		frm.number_of_people.focus();
		return;
	}
	if (frm.time.value==""){
		alert("Please select a sitting time!");
		frm.time.focus();
		return;
	}
	frm.theAction.value="do_Booking";
	frm.submit();
}
function add_Link(frm){
	var thefields = new Array("title","description","link");

	var thetext = new Array("the title","the description","the link");	
	
	for (var i=0; i<thefields.length; i++){
		if (!frm[thefields[i]].value){
			alert("Please enter "+ thetext[i] + ".");
			frm[thefields[i]].focus();
			return false;
		}
	}
	frm.theAction.value = "add_Link";
	frm.submit();
}
function update_Link(frm){
	var thefields = new Array("title","description","link");

	var thetext = new Array("the title","the description","the link");	
	
	for (var i=0; i<thefields.length; i++){
		if (!frm[thefields[i]].value){
			alert("Please enter "+ thetext[i] + ".");
			frm[thefields[i]].focus();
			return false;
		}
	}
	frm.theAction.value = "update_Link";
	frm.submit();
}
function add_Request(frm){
	var thefields = new Array("title","description","assign_to");

	var thetext = new Array("the title","the description","who you are assigning this request to");	
	
	for (var i=0; i<thefields.length; i++){
		if (!frm[thefields[i]].value){
			alert("Please enter "+ thetext[i] + ".");
			frm[thefields[i]].focus();
			return false;
		}
	}
	frm.theAction.value = "add_Request";
	frm.submit();
}
function update_Request(frm){
	var thefields = new Array("title","description","assign_to");

	var thetext = new Array("the title","the description","who you are assigning this request to");	
	
	for (var i=0; i<thefields.length; i++){
		if (!frm[thefields[i]].value){
			alert("Please enter "+ thetext[i] + ".");
			frm[thefields[i]].focus();
			return false;
		}
	}
	frm.theAction.value = "update_Request";
	frm.submit();
}
function add_Reply(frm){
	var thefields = new Array("reply","assign_to");

	var thetext = new Array("the reply","who you are assigning this request to");	
	
	for (var i=0; i<thefields.length; i++){
		if (!frm[thefields[i]].value){
			alert("Please enter "+ thetext[i] + ".");
			frm[thefields[i]].focus();
			return false;
		}
	}
	frm.theAction.value = "update_Request";
	frm.submit();
}
function do_Booking_venue(frm,date1,date2){
	if (date1 == ""){
		alert("Please select a date");
		frm.booking_date.focus();
		return;
	}else{
		tmp = date1.split("-")
		xDate = tmp[1]+"-"+tmp[0]+"-"+tmp[2];
		refDate = calcJulian(xDate);
		tmp = date2.split("-")
		xDate = tmp[1]+"-"+tmp[0]+"-"+tmp[2];
		fwdDate = calcJulian(xDate);
	
		if (fwdDate > refDate){
			alert('Booking date must not be in the past!');
			frm.booking_date.value = "";
			frm.booking_date.focus();
			return;
		}
	}
	frm.theAction.value="do_Booking";
	frm.submit();
}

function do_passback(section,image_name){
	//alert(image_name);
	opener.document.newsletter[section].value = image_name;
	opener.document.newsletter[section].focus();
	close();
}

function add_test_email(frm){
	if (frm.email_address.value == ""){
		alert("Enter an email address");
		return false;
	}else{
		frm.theAction.value = "add_test_email";
		frm.submit();
	}
}
function do_Delete_test_email(frm,object_id){
	if (confirm("Are you sure you want to delete this test email address?")){
		frm.theAction.value="do_delete";
		frm.object_id.value=object_id;
		frm.submit();
	}
}
function save_featured(frm){
	if (frm.featured.value == ""){
		alert("Select a restaurant");
		return false;
	}
	if (frm.comment.value == ""){
		alert("Enter a comment");
		return false;
	}
	frm.theAction.value = "SAVE";
	frm.submit();
}
function delete_featured(frm,object_id){
	if (confirm("Are you sure you want to delete this featured restaurant?")){
		frm.theAction.value="do_delete";
		frm.featured_object_id.value=object_id;
		frm.submit();
	}
}
function edit_featured(frm,object_id){
	frm.theAction.value="do_edit";
	frm.featured_object_id.value=object_id;
	frm.submit();
}
function do_simple_search_old(frm){   
	if ((!document.simple_search.anoption[0].checked)&&(!document.simple_search.anoption[1].checked)&&(!document.simple_search.anoption[2].checked)&&(!document.simple_search.anoption[3].checked)){
		alert("Please select one of the options");
		return false;
	}
	if (!document.simple_search.anoption[0].checked){
		if (frm.astring.value == ""){
			alert("Please enter a search string");
			frm.astring.focus();
			return false;
		}
	}
	frm.submit();
}
function do_submit_20(frm){
	if (frm.name.value==""){
		alert("Please enter your name");
		frm.name.focus();
		return;
	}
	if (frm.contactno.value==""){
		alert("Please enter a contact number");
		frm.contactno.focus();
		return;
	}
	if (frm.emailaddress.value==""){
		alert("Please enter your email address");
		frm.emailaddress.focus();
		return;
	}
	if ((frm.date1.value=="")&&(frm.date2.value=="")){
		alert("Please enter at least 1 choice date");
		frm.date1.focus();
		return;
	}
	if (frm.county.value==""){
		alert("Please enter a county/area");
		frm.county.focus();
		return;
	}
	frm.theAction.value="do_twenty";
	frm.submit();
}