// JavaScript Document
function checking(name)
		{
			var extension = name.split(".");
			if(extension[1]=="jpg")
			{
			return(0);
			}
			else if(extension[1]=="gif")
			{
			return(0);
			}
			else if(extension[1]=="png")
			{
			return(0);
			}
			else if(extension[1]=="bmp")
			{
			return(0);
			}
		}
		
function checkEmail(emailString) {
	splitVal = emailString.split('@');
	
	if(splitVal.length <= 1) {
		alert("Please enter a valid email address");
		return false;
	}
	if(splitVal[0].length <= 0 || splitVal[1].length <= 0) {
		alert("Please enter a valid email address");
		return false;
	}
	
	splitDomain = splitVal[1].split('.');
	if(splitDomain.length <= 1) {
		alert("Please enter a valid email address");
		return false;
	}
	if(splitDomain[0].length <= 0 || splitDomain[1].length <= 1) {
		alert("Please enter a valid email address");
		return false;
	}
	return true;
}
function trimSpaces(stringValue) {
	// Checks the first occurance of spaces and removes them
	for(i = 0; i < stringValue.length; i++) {
		if(stringValue.charAt(i) != " ") {
			break;
		}
	}
	if(i > 0) {
		stringValue = stringValue.substring(i);
	}
	
	// Checks the last occurance of spaces and removes them
	strLength = stringValue.length - 1;
	for(i = strLength; i >= 0; i--) {
		if(stringValue.charAt(i) != " ") {
			break;
		}
	}
	if(i < strLength) {
		stringValue = stringValue.substring(0, i + 1);
	}
	
	// Returns the string after removing leading and trailing spaces.
	return stringValue;
}
function chksub() {
   pername= trimSpaces(document.forms[0].pername.value);
   email=trimSpaces(document.forms[0].email.value);
	address = trimSpaces(document.forms[0].address.value);
	picker = trimSpaces(document.forms[0].picker.value);
	phone = trimSpaces(document.forms[0].phone.value);
	pkgCount=trimSpaces(document.forms[0].pkgCount.value);
	numPeop=trimSpaces(document.forms[0].numPeop.value);
	packagerange=trimSpaces(document.forms[0].packagerange.value);
	
	
	
	if(pername.length <= 0) {
		alert("Plese Enter Your Name");
		document.forms[0].pername.focus();
		return false;
	}
	if(email.length<=0)
	{
		alert("Plese Enter your E-mail Address");
		document.forms[0].email.focus();
		return false;
	}
	if(email.length>0)
	 {
	if(!checkEmail(email)) 
	{
		document.forms[0].email.focus();
		return false;
	} 
	 }
	 
	 if(phone.length <= 0) 
	{
		alert("Plese Enter Your phone number");
		document.forms[0].phone.focus();
		return false;
	}
	 
	if(address.length <= 0) 
	{
		alert("Plese Enter Your Address");
		document.forms[0].address.focus();
		return false;
	}
	if(picker.length <= 0) 
	{
		alert("Plese Pick your date from the Date picker on right side");
		document.forms[0].picker.focus();
		return false;
	}
	if(pkgCount.length <= 0) 
	{
		alert("Plese Specify your package");
		document.forms[0].pkgCount.focus();
		return false;
	}
	if(numPeop.length <= 0) 
	{
		alert("Please specify the number of people");
		document.forms[0].numPeop.focus();
		return false;
	}
	if(packagerange.length <= 0) 
	{
		alert("Please specify your budget cost");
		document.forms[0].packagerange.focus();
		return false;
	}
	return true;
}
function chkhotel()
{
	 hotel= trimSpaces(document.forms[0].hotel.value);
   address=trimSpaces(document.forms[0].address.value);
   
	description = trimSpaces(document.forms[0].description.value);
	gradehotel = trimSpaces(document.forms[0].gradehotel.value);
	
	
	if(hotel.length <= 0) {
		alert("Plese Enter The Hotel Name");
		document.forms[0].hotel.focus();
		return false;
	}
	
	if(address.length <= 0) {
		alert("Plese Enter The Hotel Address");
		document.forms[0].address.focus();
		return false;
	}
	if(document.forms[0].district.value.length <= 0) {
		alert("Plese Select your District");
		document.forms[0].district.focus();
		return false;
	}
	if(description.length <= 0) {
		alert("Plese Enter About the Hotel");
		document.forms[0].description.focus();
		return false;
	}
	
	if(gradehotel.length <= 0) {
		alert("Plese select your Hoteltype");
		document.forms[0].gradehotel.focus();
		return false;
	}
	if(document.forms[0].photograph.value.length>0)
		{
			var photovalue=checking(document.forms[0].photograph.value)
			if(photovalue!=0)
			{
			
			alert("Invalid photo file extension. You must select a .jpg or .gif or .png or bmp");
			return false;
			}
		}
		
		function checking(name)
		{
			var extension = name.split(".");
			if(extension[1]=="jpg")
			{
			return(0);
			}
			else if(extension[1]=="gif")
			{
			return(0);
			}
			else if(extension[1]=="png")
			{
			return(0);
			}
			else if(extension[1]=="bmp")
			{
			return(0);
			}
		}
		if(document.forms[0].logo.value.length>0)
		{
			var logo=checking(document.forms[0].logo.value)
			if(logo!=0)
			{
			
			alert("Invalid photo file extension. You must select a .jpg or .gif or .png or bmp");
			return false;
			}
		}
	document.forms[0].frmAction.value = "submit";
	return true;
	
	
}




function showRoomTariff(linkid) {
	sWidth = screen.availWidth;
	sHeight = screen.availHeight;
	
	winWidth = 600;
	winHeight = 600;
	
	sLeft = (sWidth - winWidth) / 2;
	sTop = (sHeight - winHeight) / 2;
	
	window.open("addRoomtariff.php?id=" + linkid,"photoCategory","width=" + winWidth + ",height=" + winHeight + ",top=" + sTop + ",left=" + sLeft + ",toolbar=0,menubar=0,status=0,scrollbars=1,resizable=0");
}
function showDistrict(linkid) {
	sWidth = screen.availWidth;
	sHeight = screen.availHeight;
	
	winWidth = 600;
	winHeight = 600;
	
	sLeft = (sWidth - winWidth) / 2;
	sTop = (sHeight - winHeight) / 2;
	
	window.open("districtDetails.php?distId=" + linkid,"photoCategory","width=" + winWidth + ",height=" + winHeight + ",top=" + sTop + ",left=" + sLeft + ",toolbar=0,menubar=0,status=0,scrollbars=1,resizable=0");
}



function showPhotos(linkid,width,height) {
	sWidth = screen.availWidth;
	sHeight = screen.availHeight;
	
	winWidth = width;
	winHeight = height;
	
	//sLeft = (sWidth - winWidth) / 2;
	//sTop = (sHeight - winHeight) / 2;
	
	sLeft = (sWidth - winWidth) / 2;
	sTop = (sHeight - winHeight) / 2;

	
	
	window.open("showPhotos.php?id=" + linkid,"photoCategory","width=" + winWidth + ",height=" + winHeight + ",top=" + sTop + ",left=" + sLeft + ",toolbar=0,menubar=0,status=0,scrollbars=1,resizable=0");
}
function goto()
{
	airport=trimSpaces(document.forms[0].airport.value);
	railway=trimSpaces(document.forms[0].railway.value);
	loc=trimSpaces(document.forms[0].loc.value);
	attra=trimSpaces(document.forms[0].attra.value);
 
  if(airport.length <=0)
  {
	  alert("Please Enter About The Nearest Airport");
	  document.forms[0].airport.focus();
	  return false;
  }
  if(railway.length <=0)
  {
	  alert("Please Enter About The Nearest Railwaystation");
	  document.forms[0].railway.focus();
	  return false;
  }
  if(loc.length <=0)
  {

	  alert("Please Enter About The Location");
	  document.forms[0].loc.focus();
	  return false;
  }
  if(attra.length <=0)
  {
	  alert("Please Enter The Major Attractions");
	  document.forms[0].attra.focus();
	  return false;
  }
  document.forms[0].frmAction.value = "submit";
	return true;
}


<!-- For Real Estate-->




function chkProp() 
{
   name=trimSpaces(document.forms[0].name.value);
   address=trimSpaces(document.forms[0].address.value);
   code = trimSpaces(document.forms[0].code.value);
	ph = trimSpaces(document.forms[0].ph.value);
	email=trimSpaces(document.forms[0].email.value);
	title=trimSpaces(document.forms[0].title.value);
	district=trimSpaces(document.forms[0].district.value);
	loc=trimSpaces(document.forms[0].loc.value);
	propArea=trimSpaces(document.forms[0].propArea.value);
	bed=trimSpaces(document.forms[0].bed.value);
	bath=trimSpaces(document.forms[0].bath.value);
	if(name.length <= 0) {
		alert("Plese Enter Your Name");
		document.forms[0].name.focus();
		return false;
	}


	if(address.length <= 0) 
	{
		alert("Plese Enter Your Address");
		document.forms[0].address.focus();
		return false;
	}
	
	if(code.length <= 0) 
	{
		alert("Plese Enter the STD Code");
		document.forms[0].code.focus();
		return false;
	}
	if(code=='STD Code')
	{
		alert("Please Enter a valid Digit");
		document.forms[0].code.focus();
		return false;
	}
	if(ph.length <= 0) 
	{
		alert("Plese Enter your Number");
		document.forms[0].ph.focus();
		return false;
	}
	
	if(email.length>0)
	 {
	if(!checkEmail(email)) 
	{
		document.forms[0].email.focus();
		return false;
	} 
	 }
	 if(title.length <= 0) 
	{
		alert("Plese Enter The Caption About the Property");
		document.forms[0].title.focus();
		return false;
	}
	 
	  if(district.length <= 0) 
	{
		alert("Plese Select The District");
		document.forms[0].district.focus();
		return false;
	}
	  if(loc.length <= 0) 
	{
		alert("Plese Enter About The Location");
		document.forms[0].loc.focus();
		return false;
	}
	  if(propArea.length <= 0) 
	{
		alert("Plese Enter The Property Area in Square Feet");
		document.forms[0].propArea.focus();
		return false;
	}
	
	for (i=0, n=document.forms[0].Suballocator.length; i<n; i++) 
	{
		if (document.forms[0].Suballocator[i].checked) 
		{
				Suballocator = document.forms[0].Suballocator[i].value;
				if(Suballocator==2 || Suballocator==3 || Suballocator==4 || Suballocator==5)
				{
					
					  if(bed.length <= 0) 
					{
						alert("Plese Enter The Number of Bed Rooms");
						document.forms[0].bed.focus();
						return false;
					}
					
					
					  if(bath.length <= 0) 
					{
						alert("Plese Enter The Number of Bath Rooms");
						document.forms[0].bath.focus();
						return false;
					}
		        }


          } 


   }
	document.forms[0].frmAction.value = "put";
	return true;
}

function pkgBooking()
{
persons=trimSpaces(document.myform.persons.value);
picker=trimSpaces(document.myform.picker.value);
name=trimSpaces(document.myform.name.value);
address=trimSpaces(document.myform.address.value);
email=trimSpaces(document.myform.email.value);

if(persons.length<=0)
{
alert("Please Enter the Number of Persons");
	document.myform.persons.focus();
	return false;
}

if(picker.length<=0)
{
alert("Please pick the date");
	document.myform.picker.focus();
	return false;
}

if(name.length<=0)
{
alert("Please enter your name");
	document.myform.name.focus();
	return false;
}


if(address.length<=0)
{
alert("Please enter the address");
	document.myform.address.focus();
	return false;
}

if(email.length<=0)
{
alert("Please enter the email address");
	document.myform.email.focus();
	return false;
}


if(email.length>0)
	 {
	if(!checkEmail(email)) 
	{
		document.myform.email.focus();
		return false;
	} 
	 }

return true;

}
function zs()
{
	name= trimSpaces(document.forms[0].name.value);
	address = trimSpaces(document.forms[0].address.value);

	code = trimSpaces(document.forms[0].code.value);
	ph = trimSpaces(document.forms[0].ph.value);
	email=trimSpaces(document.forms[0].email.value);
	
	title=trimSpaces(document.forms[0].title.value);
	district=trimSpaces(document.forms[0].district.value);
	
	propArea=trimSpaces(document.forms[0].propArea.value);
	bed=trimSpaces(document.forms[0].bed.value);
	bath=trimSpaces(document.forms[0].bath.value);
	if(document.forms[0].name.value.length <= 0) {
		alert("Plese Enter Your Name");
		document.forms[0].name.focus();
		return false;
	}


	if(address.length <= 0) 
	{
		alert("Plese Enter Your Address");
		document.forms[0].address.focus();
		return false;
	}
	
	if(code.length <= 0) 
	{
		alert("Plese Enter the STD Code");
		document.forms[0].code.focus();
		return false;
	}
	
	if(ph.length <= 0) 
	{
		alert("Plese Enter your Number");
		document.forms[0].ph.focus();
		return false;
	}
	
	if(email.length>0)
	 {
	if(!checkEmail(email)) 
	{
		document.forms[0].email.focus();
		return false;
	} 
	 }
	 
	 
	 
		
	document.forms[0].frmAction.value = "put";
	return true;
}




function valbutton(thisform) 
{
	


// place any other field validations that you require here
// validate myradiobuttons


myOption = -1;
for (i=thisform.rate.length-1; i > -1; i--) {
if (thisform.rate[i].checked) {
myOption = i;
}
}
if (myOption == -1) {
alert("Please Select the Category");
return false;
}
if(thisform.persons.value.length<=0)
{
	alert("Please Enter the Number of Persons");
	thisform.persons.focus();
	return false;
}
if(thisform.picker.value.length<=0)
{
	alert("Please Pick The Date from Datepicker");
	thisform.picker.focus();
	return false;
}
if(thisform.name.value.length<=0)
{
	alert("Please Enter Your Name");
	thisform.name.focus();
	return false;
}
if(thisform.address.value.length<=0)
{
	alert("Please Enter Your Address");
	thisform.address.focus();
	return false;
}
if(thisform.phone.value.length<=0)
{
	alert("Please Enter Your Mobile/Phone Number");
	thisform.phone.focus();
	return false;
}
if(thisform.email.value.length<=0)
{
	alert("Please Enter Your E-mail Address");
	thisform.email.focus();
	return false;
}
if(thisform.email.value.length>0)
{
	if(!checkEmail(thisform.email.value)) 
	{
		thisform.email.focus();
		return false;
	} 
}
if(thisform.feed.value.length<=0)
{
	alert("Please Enter Your Feedback");
	thisform.feed.focus();
	return false;
}
//alert("You selected button number " + myOption
//+ " which has a value of "
//+ thisform.myradiobutton[myOption].value);




// place any other field validations that you require here
thisform.frmAction.value = "booked";
return true;// this line submits the form after validation
}
//contact
function chkContact()
{
	name=trimSpaces(document.forms[0].name.value);
	email=trimSpaces(document.forms[0].email.value);
	addr=trimSpaces(document.forms[0].addr.value);

	if(name.length<=0)
	{
		alert("Plese Enter your Name");
		document.forms[0].name.focus();
		return false;
	}
	if(email.length<=0)
	{
		alert("Plese Enter your E-mail Address");
		document.forms[0].email.focus();
		return false;
	}
	if(email.length>0)
	 {
	if(!checkEmail(email)) 
	{
		document.forms[0].email.focus();
		return false;
	} 

	 }
	 if(addr.length<=0)
	{
		alert("Plese Enter your Address");
		document.forms[0].addr.focus();
		return false;
	}
	return true;
	 //document.forms[0].frmAction.value = "put";
}


function chktariff()
{
	var frm=document.forms[0];
	//Room Categories
	//nonac=frm.nonac.value;
	acdel=frm.acdel.value;
	sut=frm.sut.value;
	//Room Type(Non A/C)
	//non_single=frm.non_single.value;
	//non_double=frm.non_double.value
	//non_suite=frm.non_suite.value
	
//Non A/C Delux	
	//Mealplan Non A/c
	    //single
	non_ep_single=trimSpaces(frm.non_ep_single.value);
	non_cp_single=trimSpaces(frm.non_cp_single.value);
	non_ap_single=trimSpaces(frm.non_ap_single.value);
	non_map_single=trimSpaces(frm.non_map_single.value);
	 //Mealplan Non A/c
	    //double
	non_ep_double=trimSpaces(frm.non_ep_double.value);
	non_cp_double=trimSpaces(frm.non_cp_double.value);
	non_ap_double=trimSpaces(frm.non_ap_double.value);
	non_map_double=trimSpaces(frm.non_map_double.value);
	//Mealplan Non A/C
	   //suite
	non_ep_suite=trimSpaces(frm.non_ep_suite.value);
	non_cp_suite=trimSpaces(frm.non_cp_suite.value);
	non_ap_suite=trimSpaces(frm.non_ap_suite.value);
	non_map_suite=trimSpaces(frm.non_map_suite.value);
	
	
	
	
	
	if(frm.nonac.checked)
	{
		
		//single bed non a/c deluxe
	if((frm.non_single.checked==false && non_ep_single.length >0) || (frm.non_single.checked==false && non_cp_single.length >0) || (frm.non_single.checked==false && non_ap_single.length >0) || (frm.non_single.checked==false && non_map_single.length >0))
		{
			alert("Please Select Single Bed"+'\n'+"From Non A/C Delux Category");
			return false;
		}
		//double bed non a/c deluxe
	if((frm.non_double.checked==false && non_ep_double.length>0) || (frm.non_double.checked==false && non_cp_double.length>0) || (frm.non_double.checked==false && non_ap_double.length>0) || (frm.non_double.checked==false && non_map_double.length>0))
	{
		alert("Please Select Double Bed"+'\n'+"From Non A/C Delux Category");
			return false;
	}
	//suite non a/c deluxe
	if((frm.non_suite.checked==false && non_ep_suite.length>0) || (frm.non_suite.checked==false && non_cp_suite.length>0) || (frm.non_suite.checked==false && non_ap_suite.length>0) || (frm.non_suite.checked==false && non_map_suite.length>0))
	{
		alert("Please Select Suite"+'\n'+"From Non A/C Delux Category");
			return false;
	}
	
	}
	
	
	
	
//A/C Deluxe
	//Meal plan single
	ac_ep_single=trimSpaces(frm.ac_ep_single.value);
	ac_cp_single=trimSpaces(frm.ac_cp_single.value);
	ac_ap_single=trimSpaces(frm.ac_ap_single.value);
	ac_map_single=trimSpaces(frm.ac_map_single.value);
	//meal plan double
	ac_ep_double=trimSpaces(frm.ac_ep_double.value);
	ac_cp_double=trimSpaces(frm.ac_cp_double.value);
	ac_ap_double=trimSpaces(frm.ac_ap_double.value);
	ac_map_double=trimSpaces(frm.ac_map_double.value);
	//meal plan suite
	ac_ep_suite=trimSpaces(frm.ac_ep_suite.value);
	ac_cp_suite=trimSpaces(frm.ac_cp_suite.value);
	ac_ap_suite=trimSpaces(frm.ac_ap_suite.value);
	ac_map_suite=trimSpaces(frm.ac_map_suite.value);


    if(frm.acdel.checked)
	{
		//single bed a/c deluxe
		if((frm.ac_single.checked==false && ac_ep_single.length>0) || (frm.ac_single.checked==false && ac_cp_single.length>0) || (frm.ac_single.checked==false && ac_ap_single.length>0) || (frm.ac_single.checked==false && ac_map_single.length>0))
		{
			alert("Please Select Single Bed"+'\n'+"From A/C Delux Category");
			return false;
		}
		//double bed a/c deluxe
		if((frm.ac_double.checked==false && ac_ep_double.length>0) || (frm.ac_double.checked==false && ac_cp_double.length>0) || (frm.ac_double.checked==false && ac_ap_double.length>0) || (frm.ac_double.checked==false && ac_map_double.length>0))
		{
			alert("Please Select Double Bed"+'\n'+"From A/C Delux Category");
			return false;
		}
		//suite a/c deluxe
		if((frm.ac_suite.checked==false && ac_ep_suite.length>0) || (frm.ac_suite.checked==false && ac_cp_suite.length>0) || (frm.ac_suite.checked==false && ac_ap_suite.length>0) || (frm.ac_suite.checked==false && ac_map_suite.length>0))
		{
			alert("Please Select Suite"+'\n'+"From A/C Delux Category");
			return false;
		}
		
	}
	
	
//Suite
	//Meal plan single bed
	suite_ep_single=trimSpaces(frm.suite_ep_single.value);
	suite_cp_single=trimSpaces(frm.suite_cp_single.value);
	suite_ap_single=trimSpaces(frm.suite_ap_single.value);
	suite_map_single=trimSpaces(frm.suite_map_single.value);
	//meal plan double
	suite_ep_double=trimSpaces(frm.suite_ep_double.value);
	suite_cp_double=trimSpaces(frm.suite_cp_double.value);
	suite_ap_double=trimSpaces(frm.suite_ap_double.value);
	suite_map_double=trimSpaces(frm.suite_map_double.value);
	//meal plan suite
	suite_ep_suite=trimSpaces(frm.suite_ep_suite.value);
	suite_cp_suite=trimSpaces(frm.suite_cp_suite.value);
	suite_ap_suite=trimSpaces(frm.suite_ap_suite.value);
	suite_map_suite=trimSpaces(frm.suite_map_suite.value);
	
	if(frm.sut.checked)
	{
		//suite single bed
	if((frm.suite_single.checked==false && suite_ep_single.length>0) || (frm.suite_single.checked==false && suite_cp_single.length>0) || (frm.suite_single.checked==false && suite_ap_single.length>0) || (frm.suite_single.checked==false && suite_map_single.length>0))
	{
		alert("Please Select Single Bed"+'\n'+"From Suite Category");
			return false;

	}
	}
	// suite double bed
  if((frm.suite_double.checked==false && suite_ep_double.length>0) || (frm.suite_double.checked==false && suite_cp_double.length>0) || (frm.suite_double.checked==false && suite_ap_double.length>0) || (frm.suite_double.checked==false && suite_map_double.length>0))
  {
	  alert("Please Select Double Bed"+'\n'+"From Suite Category");
			return false;
  }
  // suite suite
  if((frm.suite_suite.checked==false && suite_ep_suite.length>0) || (frm.suite_suite.checked==false && suite_cp_suite.length>0) || (frm.suite_suite.checked==false && suite_ap_suite.length>0) || (frm.suite_suite.checked==false && suite_map_suite.length>0))
  {
	  alert("Please Select Suite"+'\n'+"From Suite Category");
			return false;
  }


document.forms[0].frmAction.value = "add";
return true;
}


function showAllHotels(linkid) {
	sWidth = screen.availWidth;
	sHeight = screen.availHeight;
	
	winWidth = 1000;
	winHeight = 800;
	
	sLeft = (sWidth - winWidth) / 2;
	sTop = (sHeight - winHeight) / 2;
	
	var win = null;


  win = window.open("showallHotels.php?id=" + linkid,"photoCategory","width=" + winWidth + ",height=" + winHeight + ",top=" + sTop + ",left=" + sLeft + ",toolbar=0,menubar=0,status=0,scrollbars=1,resizable=0");
  // statements that refer to the new window go here

	if (win) 
	win.focus();
	//window.open("showallHotels.php?id=" + linkid,"photoCategory","width=" + winWidth + ",height=" + winHeight + ",top=" + sTop + ",left=" + sLeft + ",toolbar=0,menubar=0,status=0,scrollbars=1,resizable=0");
}