// JavaScript Document



 

function reservation_form(form1)

{

	if(document.form1.name.value == "")

	{

		alert("Please enter your 'Name'")

		document.form1.name.focus();

		return(false)

	}

	if(document.form1.city.value == "")

	{

		alert("Please enter your 'City'")

		document.form1.city.focus();

		return(false)

	}	


	if(document.form1.contact.value == "")

	{

		alert("Please enter your 'Contact No'")

		document.form1.contact.focus();

		return(false)

	}	

	if(document.form1.phone.value == "")

	{

		alert("Please enter your 'Contact No'")

		document.form1.phone.focus();

		return(false)

	}


	if(document.form1.mobile.value == "")

	{

		alert("Please enter your 'Mobile No'")

		document.form1.mobile.focus();

		return(false)

	}	

	if(!checkmailid(document.form1.email.value))

	{	

	alert("Please enter a valid 'email id'");

	document.form1.email.select();

	document.form1.email.focus(); 

	return(false)

	}

	if(document.form1.type.value=="0")

	{

		alert("Please mention your '-- Please select your Type -- '")

		document.form1.type.focus();

		return(false)

	}

	if(document.form1.type.value=="1")

	{

		if(document.form1.room1.value=="")

	{

		alert("Please mention your '-- Please select a room type -- '")

		document.form1.room1.focus();

		return(false)

	}

	}

	if(document.form1.type.value=="2")

	{

		if(document.form1.room2.value=="")

	{

		alert("Please mention your '-- Please select a room type -- '")

		document.form1.room2.focus();

		return(false)

	}

	}

}





function checkmailid(mailid)

{

       if (mailid!="" )

         {   

            var b = mailid;

			var c = b.length;				//  to find thelength of the email id

 			var d = b.indexOf("@");         //  to check for the occurance of "@"

 			var e = b.indexOf("@",d+1); 	//  to confirm "@" occurs only once

			var f = b.indexOf(".");			//  to check for the occurance of "."

 			var g = b.lastIndexOf(".");		//  to Check for the last occurance of "." in the string 					

			var h = b.indexOf(".",d+1);		//  to Check for the last occurance of "." in the string after "@"

			var i = b.indexOf(",");			//  To check for the Occurance Of "," in the string

			var j = b.indexOf(" ");       	//  to check for the occurance of tho sace

                                             //**small modification in below line to avoid the successive occurance of the "." using h==g-1



			if(d==-1 || g==c-1 || d==0 || f==0 || h==d+1 ||  h==c-1 || d==c-1 || e!=-1 || h==-1 ||  i!=-1 || j!=-1 || h==g-1)

  				{ 

   					return(false);

   				}

			else

			{

			return(true);

			}

   			}

 }

 

 function change(){

	 if(document.form1.type.selectedIndex=="0") 

	 {

		 document.getElementById("div1").style.display = "none";

		 document.getElementById("div2").style.display = "none";

		 document.getElementById("div3").style.display = "none";
   document.getElementById("div4").style.display = "none";
document.getElementById("div5").style.display = "none";

	 }

	 if(document.form1.type.selectedIndex=="1") 

	 {

		 document.getElementById("div1").style.display = "block";

		 document.getElementById("div2").style.display = "none";

		 document.getElementById("div3").style.display = "none";
document.getElementById("div4").style.display = "none";
document.getElementById("div5").style.display = "none";

	 }

	 if(document.form1.type.selectedIndex=="2") 

	 {

		 document.getElementById("div1").style.display = "none";

		 document.getElementById("div2").style.display = "block";

		 document.getElementById("div3").style.display = "none";
document.getElementById("div4").style.display = "none";
document.getElementById("div5").style.display = "none";

	 }

	 if(document.form1.type.selectedIndex=="3") 

	 {

		 document.getElementById("div1").style.display = "none";

		 document.getElementById("div2").style.display = "none";

		 document.getElementById("div3").style.display = "block";
document.getElementById("div4").style.display = "none";
document.getElementById("div5").style.display = "none";

	 }

 if(document.form1.type.selectedIndex=="4") 

	 {

		 document.getElementById("div1").style.display = "none";

		 document.getElementById("div2").style.display = "none";

		 document.getElementById("div3").style.display = "none";
document.getElementById("div4").style.display = "block";
document.getElementById("div5").style.display = "none";

	 }

 if(document.form1.type.selectedIndex=="5") 

	 {

		 document.getElementById("div1").style.display = "none";

		 document.getElementById("div2").style.display = "none";

		 document.getElementById("div3").style.display = "none";
document.getElementById("div4").style.display = "none";
document.getElementById("div5").style.display = "block";

	 }


 }

 function numbersonly(myfield, e, dec)

{

var key;

var keychar;



if (window.event)

   key = window.event.keyCode;

else if (e)

   key = e.which;

else

   return true;

keychar = String.fromCharCode(key);



// control keys

if ((key==null) || (key==0) || (key==8) || 

    (key==9) || (key==13) || (key==27) )

   return true;



// numbers

else if ((("0123456789+.-").indexOf(keychar) > -1))

   return true;



// decimal point jump

else if (dec && (keychar == "."))

   {

   myfield.form.elements[dec].focus();

   return false;

   }

else

   return false;

}
