// JavaScript Document
function closeWindow() {
	parent.window.opener.window.focus();
	parent.window.close();
}

function printWindow() 
{
	window.print();
}
function valid_email(eml)
{
	//declare the required variables
	var mint_len;
	var mstr_eml=eml;
	var mint_at=0;
	var mint_atnum=0;
	var mint_dot=0;
	var mint_dotnum=0;
	
	mint_len=eml.length; //takes the length of the email address entered
	
	//checking for the symbol single quote. If found replace it with its html code
	if (mstr_eml.indexOf("'")!=-1)
	{
		mstr_eml=mstr_eml.replace("'","&#39;");
	}
	
	//checking for the (@) & (.) symbol
	for(var iloop=0;iloop<mint_len;iloop++)
	{
		if(mstr_eml.charAt(iloop)=="@")
		{
			mint_at=iloop+1;
			mint_atnum=mint_atnum+1;
		}
		if(mstr_eml.charAt(iloop)==".")
		{
			mint_dot=iloop+1;
			mint_dotnum=mint_dotnum+1;
		}
	}
	
	//if nothing entered in the field
	if (mstr_eml=="")
	{
		return true;
	}
	
	//if @ entered more than once & dot (.) entered more than 4 times
	else if((mint_atnum!=1)||(mint_dotnum>4)||((mint_dot-mint_at)<2)||((mint_len-mint_dot)<2)||(mint_at<3))
	{
		return true;
	}
	
	//if any blank space is entered in the email address
	else if (mstr_eml.indexOf(" ")!=-1)
	{
		return true;
	}
	return false;
}

function showCalendar(frmElement, dispElement) {
	sWidth = screen.availWidth;
	sHeight = screen.availHeight;
	
	winWidth = 375;
	winHeight = 300;
	
	sLeft = (sWidth - winWidth) / 2;
	sTop = (sHeight - winHeight) / 2;

	window.open("showCalendar.php?frmElement=" + frmElement + "&dispElement=" + dispElement, "Calendar", "width=" + winWidth + ",height=" + winHeight + ",top=" + sTop + ",left=" + sLeft + ",toolbar=0,menubar=0,status=0,scrollbars=0,resizable=0");
	return;
}

function checkFeedBack() {
	document.forms[0].visitorName.value = trimSpaces(document.forms[0].visitorName.value);
	if(document.forms[0].visitorName.value.length <= 0) {
		alert("Please enter your name");
		document.forms[0].visitorName.focus();
		return false;
	}

	document.forms[0].emailAddress.value = trimSpaces(document.forms[0].emailAddress.value);
	if(document.forms[0].emailAddress.value.length <= 0) {
		alert("Please enter your email address");
		document.forms[0].emailAddress.focus();
		return false;
	}
	if(!checkEmail(document.forms[0].emailAddress.value)) {
		document.forms[0].emailAddress.focus();
		document.forms[0].emailAddress.select();
		return false;
	}

	document.forms[0].visitorComments.value = trimSpaces(document.forms[0].visitorComments.value);
	if(document.forms[0].visitorComments.value.length <= 0) {
		alert("Please enter your comments");
		document.forms[0].visitorComments.focus();
		return false;
	}
	document.forms[0].frmAction.value = "update";
}

function checkContactus() {
	document.feedback.firstName.value = trimSpaces(document.feedback.firstName.value);
	if(document.feedback.firstName.value.length <= 0) {
		alert("Please enter your first name");
		document.feedback.firstName.focus();
		return false;
	}
	document.feedback.lastName.value = trimSpaces(document.feedback.lastName.value);
	if(document.feedback.lastName.value.length <= 0) {
		alert("Please enter your last name");
		document.feedback.lastName.focus();
		return false;
	}

	document.feedback.email.value = trimSpaces(document.feedback.email.value);
	if(document.feedback.email.value.length <= 0) {
		alert("Please enter your email address");
		document.feedback.email.focus();
		return false;
	}
	if(!checkEmail(document.feedback.email.value)) {
		document.feedback.email.focus();
		document.feedback.email.select();
		return false;
	}
	document.feedback.frmAction.value = "update";
}
function showPhoto(photoUrl) {
	//photoUrl="../"+photoUrl;
	sWidth = screen.availWidth;
	sHeight = screen.availHeight;
	
	winWidth = 600;
	winHeight = 500;
	
	sLeft = (sWidth - winWidth) / 2;
	sTop = (sHeight - winHeight) / 2;
	
	window.open("showIcon.php?iconUrl=" + photoUrl,"photoURL","width=" + winWidth + ",height=" + winHeight + ",top=" + sTop + ",left=" + sLeft + ",toolbar=0,menubar=0,status=0,scrollbars=1,resizable=0");
}
/*function removeBannerPhoto(photoUrl) {
	if(photoUrl.length > 0) {
		if(confirm("Do you really want to delete this posting photo?")) {
			document.form1.frmAction.value = "removePhoto";
			document.form1.photoURL.value = photoUrl;
			document.form1.submit();
		}
		else {
			return;
		}
	}
}*/
function openNewWindow(pagepath) {
	sWidth = screen.availWidth;
	sHeight = screen.availHeight;
	
	winWidth = 550;
	winHeight = 400;
	
	sLeft = (sWidth - winWidth) / 2;
	sTop = (sHeight - winHeight) / 2;
	window.open(pagepath,"Details","width=" + winWidth + ",height=" + winHeight + ",top=" + sTop + ",left=" + sLeft + ",toolbar=0,menubar=0,status=0,scrollbars=1,resizable=0");
}

function printCoupon(couponid){
	sWidth = screen.availWidth;
	sHeight = screen.availHeight;
	
	winWidth = 600;
	winHeight = 500;
	
	sLeft = (sWidth - winWidth) / 2;
	sTop = (sHeight - winHeight) / 2;

	window.open("showCouponFrame.php?couponid=" + couponid, "printCoupon", "width=" + winWidth + ",height=" + winHeight + ",top=" + sTop + ",left=" + sLeft + ",toolbar=0,menubar=0,status=0,scrollbars=1,resizable=0");
	return;
}

function openDynWindow(url,width,height) {
	sWidth = screen.availWidth;
	sHeight = screen.availHeight;
	
	winWidth = width;
	winHeight = height;
	
	sLeft = (sWidth - winWidth) / 2;
	sTop = (sHeight - winHeight) / 2;
	window.open(url, "win", "width=" + winWidth + ",height=" + winHeight + ",top=" + sTop + ",left=" + sLeft + ",toolbar=0,menubar=0,status=0,scrollbars=1,resizable=0");
}
function showReservationDate(frmElement, dispElement) {
	sWidth = screen.availWidth;
	sHeight = screen.availHeight;
	
	winWidth = 375;
	winHeight = 300;
	
	sLeft = (sWidth - winWidth) / 2;
	sTop = (sHeight - winHeight) / 2;

	window.open("showCalendar.php?frmElement=" + frmElement + "&dispElement=" + dispElement + "&laterdate=1", "laviolaCalendar", "width=" + winWidth + ",height=" + winHeight + ",top=" + sTop + ",left=" + sLeft + ",toolbar=0,menubar=0,status=0,scrollbars=0,resizable=0");
	return;
}

function valSignUp()
{
	name = trimSpaces(document.forms[0].name.value);
	email = trimSpaces(document.forms[0].email.value);

	if(name.length <= 0) {
		alert("Please enter your name");
		document.forms[0].name.focus();
		return false;
	}
	if(email.length <= 0) {
		alert("Please enter your email address.");
		document.forms[0].email.focus();
		return false;
	}
	if(!checkEmail(email)) {
		document.forms[0].email.focus();
		return false;
	}

document.forms[0].frmAction.value = "update";
}

function getCalDate(frmElement, dispElement, dateValue, dispValue) {
	frmObject = eval("window.opener.document.forms[0]." + frmElement);
	frmObject.value = dateValue;
	frmObject = eval("window.opener.document.forms[0]." + dispElement);
	frmObject.value = dispValue;
	closeWindow();
}
function validateDiscussion()
{
name=trimSpaces(document.discForm.name.value);
if(name.length<=0)
{
  alert("Please enter your name");
  document.discForm.name.focus();
   return false;
}

email=trimSpaces(document.discForm.email.value);
if(email.length<=0)
 {
  alert("Please enter your email");
  document.discForm.email.focus();
  return false;
 }
 else
 {
	 if(email.length>0)
	 {
		 if(!checkEmail(email))
		 {
		  document.discForm.email.focus();
		  return false;
		 }
	 }
  }
  
if(document.discForm.description.value.length<=0)
{
  alert("Please Enter your comments");
  document.discForm.description.focus();
   return false;
}
document.discForm.frmAction.value = "discussion";  
}

function markAsObjecction(forum_id)
{
	if (!confirm("Do you really want to mark this entry \n as objectionable?"))
	return;
	else
	{
		document.discForm.frmAction.value ="objection";
		document.discForm.forum_id.value = forum_id ;
		document.discForm.submit();
	}
		
}
function checkGuestBook() {
	document.feedback.visitorName.value = trimSpaces(document.feedback.visitorName.value);
	if(document.feedback.visitorName.value.length <= 0) {
		alert("Please enter your name");
		document.feedback.visitorName.focus();
		return false;
	}

	document.feedback.emailAddress.value = trimSpaces(document.feedback.emailAddress.value);
	if(document.feedback.emailAddress.value.length <= 0) {
		alert("Please enter your email address");
		document.feedback.emailAddress.focus();
		return false;
	}
	if(!checkEmail(document.feedback.emailAddress.value)) {
		document.feedback.emailAddress.focus();
		return false;
	}

	if(document.feedback.visitorComments.value.length <= 0) {
		alert("Please enter your comments");
		document.feedback.visitorComments.focus();
		return false;
	}
	document.feedback.frmAction.value = "update";
}

function doEmbSearch()
{
	document.forms[0].frmAction.value='hc';
	document.forms[0].submit();
}

function doEmbSearch_spl(hostcountry)
{
	document.forms[0].frmAction.value='hc';
	document.forms[0].hostcountry.value=hostcountry;
	document.forms[0].submit();
}

function doEmbSearch1()
{
	document.forms[0].frmAction.value='eh';
	document.forms[0].submit();
}
function chkUserLogin()
{	
		if(document.userlogin.email.value=="")
		{
		alert("Enter Email address");
		document.userlogin.email.focus();
		return false;
		}
		if(!checkEmail(document.userlogin.email.value)){
		document.userlogin.email.focus();
		 return false;
	    }
	
		if(document.userlogin.password.value=="")
		{
		alert("Enter password");
		document.userlogin.password.focus();
		return false;
		
   		}
		
	document.userlogin.frmAction.value = "login";
	document.userlogin.submit();	
}

function ChkUserRegn(){
	
	userreg.first_name.value = trimSpaces(userreg.first_name.value);
	if(userreg.first_name.value.length <= 0) {
		alert("Please enter your first name");
		userreg.first_name.focus();
		return false;
	}
	userreg.last_name.value = trimSpaces(userreg.last_name.value);
	if(userreg.last_name.value.length <= 0) {
		alert("Please enter your last name");
		userreg.last_name.focus();
		return false;
	}
	userreg.email.value = trimSpaces(userreg.email.value);
	if(!checkEmail(userreg.email.value)) {
		userreg.email.focus();
		return false;
	}
	
	userreg.city.value = trimSpaces(userreg.city.value);
	if(userreg.city.value.length <= 0) {
		alert("Please enter your city");
		userreg.city.focus();
		return false;
	}
	
	if(trimSpaces(userreg.birth_year.options[userreg.birth_year.selectedIndex].value).length <= 0) 
	{
		alert("Please select the birth year");
		userreg.birth_year.focus();
		return false;
	}
	
	if(trimSpaces(userreg.birth_mon.options[userreg.birth_mon.selectedIndex].value).length <= 0) 
	{
		alert("Please select the birth month");
		userreg.birth_mon.focus();
		return false;
	}	

	document.userreg.frmAction.value = "join";
	document.userreg.submit();
}
function chkSendCommentsandLogin()
{ 

 name = trimSpaces(document.sendcomments.name.value);
	if(name.length <= 0)
	{
		alert("Please enter the name");
		sendcomments.name.focus();
		return false;
	}
    
	country = trimSpaces(document.sendcomments.country.value);
    if(country.length <= 0)
	{
		alert("Please select country");
		document.sendcomments.country.focus();
		return false;
	}
	city = trimSpaces(document.sendcomments.city.value);
    if(city.length <= 0)
	{
		alert("Please enter city");
		document.sendcomments.city.focus();
		return false;
	}
	
   
	document.sendcomments.comments.value = trimSpaces(document.sendcomments.comments.value);	
	if(document.sendcomments.comments.value.length <= 0) {
		alert("Please enter comments");
		document.sendcomments.comments.focus();
		return false;
	}
	
	
	
	
	thecode = trimSpaces(document.sendcomments.thecode.value);
	if(thecode.length <= 0) 
	{
		alert("Please enter the number");
		sendcomments.thecode.focus();
		return false;
	}	
	document.sendcomments.emailAddress.value = trimSpaces(document.sendcomments.emailAddress.value);
	
	
	
	if(document.sendcomments.emailAddress.value.length <= 0) {
		alert("Please enter your email address");
		document.sendcomments.emailAddress.focus();
		return false;
	}
	if(!checkEmail(document.sendcomments.emailAddress.value)) {
		document.sendcomments.emailAddress.focus();
		document.sendcomments.emailAddress.select();
		return false;
	}
	document.sendcomments.password.value = trimSpaces(document.sendcomments.password.value);	
	if(document.sendcomments.password.value.length <= 0) {
		alert("Please enter Password");
		document.sendcomments.password.focus();
		return false;
	}
	
	
		
		
	document.sendcomments.frmAction.value = "loginpost";	
}
function showForgotPass()
{
	sWidth = screen.availWidth;
	sHeight = screen.availHeight;
	winWidth = 400;
	winHeight = 220;
	sLeft = (sWidth - winWidth) / 2;
	sTop = (sHeight - winHeight) / 2;
	window.open("../php/forgotPasswordTwo.php","Details","width=" + winWidth + ",height=" + winHeight + ",top=" + sTop + ",left=" + sLeft + ",toolbar=0,menubar=0,status=0,scrollbars=1,resizable=0");
}
function chkEditAccount(f)
{
		f.firstname.value = trimSpaces(f.firstname.value);
		if(f.firstname.value.length <= 0) {
			alert("Please enter your first name");
			f.firstname.focus();
			return false;
		}
		
		f.lastname.value = trimSpaces(f.lastname.value);
		if(f.lastname.value.length <= 0) {
			alert("Please enter your last name");
			f.lastname.focus();
			return false;
		}
		document.account.frmAction.value = "update";
}
function checkPassword()
{
	document.changePassword.password.value = trimSpaces(document.changePassword.password.value);
	if(document.changePassword.password.value.length <= 0){
		alert("Please enter the current password");
		document.changePassword.password.focus();
		return false;
	}
	document.changePassword.newPassword.value = trimSpaces(document.changePassword.newPassword.value);
	if(document.changePassword.newPassword.value.length <= 0){
		alert("Please enter the new password");
		document.changePassword.newPassword.focus();
		return false;
	}
	document.changePassword.retypePassword.value = trimSpaces(document.changePassword.retypePassword.value);
	if(document.changePassword.newPassword.value != document.changePassword.retypePassword.value){
		alert("Passwords does not match");
		document.changePassword.retypePassword.focus();
		return false;
	}
}


function chkGustCommentsandLogin()
{ 

 name = trimSpaces(document.sendcomments.name.value);
	if(name.length <= 0)
	{
		alert("Please enter the name");
		sendcomments.name.focus();
		return false;
	}
 
   
	document.sendcomments.comments.value = trimSpaces(document.sendcomments.comments.value);	
	if(document.sendcomments.comments.value.length <= 0) {
		alert("Please enter comments");
		document.sendcomments.comments.focus();
		return false;
	}
	
	
	
	
	thecode = trimSpaces(document.sendcomments.thecode.value);
	if(thecode.length <= 0) 
	{
		alert("Please enter the number");
		sendcomments.thecode.focus();
		return false;
	}	
	document.sendcomments.emailAddress.value = trimSpaces(document.sendcomments.emailAddress.value);
	
	
	
	if(document.sendcomments.emailAddress.value.length <= 0) {
		alert("Please enter your email address");
		document.sendcomments.emailAddress.focus();
		return false;
	}
	if(!checkEmail(document.sendcomments.emailAddress.value)) {
		document.sendcomments.emailAddress.focus();
		document.sendcomments.emailAddress.select();
		return false;
	}
	document.sendcomments.password.value = trimSpaces(document.sendcomments.password.value);	
	if(document.sendcomments.password.value.length <= 0) {
		alert("Please enter Password");
		document.sendcomments.password.focus();
		return false;
	}
	
	
		
		
	document.sendcomments.frmAction.value = "loginpost";	
}function ChkActivateEmail(f)
{
	if(trimSpaces(f.email.value).length <= 0) 
	{
		alert("Please enter your email");
		f.email.focus();
		return false;
	}
f.frmAction.value = "activate";	
}
