function resort(mychoice)
{ 
	Window=open("","","scrollbars=no,menubar=no,width=490,height=450, top=45,left=150");
	Window.document.open();
	Window.document.write("<HTML><head><title>Mt.Narshing Village Resort Enquiry</title></head>")
	Window.document.write("<body")
	Window.document.write("<div align='center'><center><b><font face='Arial' size='4'>MT NARSING VILLAGE RESORT ENQUIRY</font></b>")
	Window.document.write("<form name='myform' method='POST' action='resortbook.php'>")
	Window.document.write("<input type='hidden' name='roomchoice' value='")
	Window.document.write(mychoice)
	Window.document.write("'>")
	Window.document.write("<center><table border='0' cellpadding='0' cellspacing='0' width='100%' bgcolor='#5B83AD'><tr><td colspan=2></td></tr>")
	Window.document.write("<tr><td rowspan='12' width='30'></td><td>&nbsp;</td></tr><tr><td colspan='2'><font size='2' face='Tahoma'><b>Dear Visitor,</b></font></td></tr>")
	Window.document.write("<tr><td colspan='2'><font size='2' face='Tahoma'><b>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;You have chosen </b></font>")
	Window.document.write("<font size='2' face='Tahoma' color='white'><b>")
	Window.document.write(mychoice)
	Window.document.write("</b></font></center></td></tr>")
	Window.document.write("<tr><td colspan='2'><font size='2' face='Tahoma'><b>Please provide us with the following information about yourself</b></font></td></tr><hr>")
	Window.document.write("<tr><td><font size='2' face='Tahoma'><b>* Name :</b></font></td><td><input type=text name='name'> </td></tr>")
	Window.document.write("<tr><td><font size='2' face='Tahoma'><b>* Email :</b></font></td><td><input type=text name='email'> </td></tr>")
	Window.document.write("<tr><td><font size='2' face='Tahoma'><b>Arrival date :</b></font></td><td><input type=text name='arrival'> </td></tr>")
	Window.document.write("<tr><td><font size='2' face='Tahoma'><b>* Total number of persons :</b></font></td><td><input type=text name='persons'> </td></tr>")
	Window.document.write("<tr><td><font size='2' face='Tahoma'><b>* Total number of rooms :</b></font></td><td><input type=text name='rooms'> </td></tr>")
	Window.document.write("<tr><td><font size='2' face='Tahoma'><b>* Room Type :</b></font></td><td><select size='1' name='room_type'><option selected value='Single Room '>Single Room </option><option value='Double Room'>Double Room</option></select> </td></tr>")
	Window.document.write("<tr><td><font size='2' face='Tahoma'><b>* Room Plan :</b></font></td><td><select size='1' name='room_plan'><option selected value='European Plan '>European plan </option><option value='Modified American Plan'>Modified American plan</option><option value='American Plan'>American Plan</option></select> </td></tr>")
	Window.document.write("<tr><td><font size='2' face='Tahoma'><b>Other Information you would like:</b></font></td><td><textarea name='info' cols='20' rows='5'></textarea> </td></tr>")
	Window.document.write("<tr><td width='100%' align ='center' colspan='2' ><p align=center><input type='reset' value='Reset'><input type='button' name='send' value='send' ></p></td></tr>")
	Window.document.myform.send.onclick=check;
	Window.document.write("<tr><td>&nbsp;</td></tr></table><hr></center>")
	Window.document.write("</form>")
	Window.document.write("</div></body></html>")
	Window.focus();
}

function check()
{

	var formcheck=Window.document.myform.name.value;
	var formcheck2=Window.document.myform.email.value;


	var flag =0;
	
	if(formcheck=="" || formcheck2=="" )
	{
		alert('Please fill up the fields marked with a *');
		flag=1;
		return (false);
	}
	
	
	
	if(flag==0)
	{
		if(formcheck2.indexOf(" ") >= 0 )
		{
			alert("Please enter the E-Mail address without any white space character.");
			Window.document.myform.email.focus();
			return (false);
		}

		
		AtRateCheckfrom = formcheck2.indexOf("@");
		AtDotCheckfrom  = formcheck2.indexOf(".");

		
		AtRateCheckLastfrom = formcheck2.lastIndexOf("@");
		AtDotCheckLastfrom = formcheck2.lastIndexOf(".");
 

		
		if ( (AtRateCheckfrom == -1) || (AtDotCheckfrom == -1) && flag==0)
		{
			alert("Please enter your valid email-id"); 
			Window.document.myform.email.focus();
			
			
			return (false);
		}
		
			
		if( (AtRateCheckLastfrom != AtRateCheckfrom)  && flag==0)
		{
			alert("Please enter your valid email-id"); 
			Window.document.myform.email.focus();
			return (false);
		}

		BeforeAtRatefrom = formcheck2.substring(0,formcheck2.indexOf("@"));
		AfterAtRatefrom = formcheck2.substring(formcheck2.indexOf("@")+1,formcheck2.length);

				
		if (AfterAtRatefrom.indexOf(".") == -1 && flag==0)
		{
			alert("Please enter your valid email-id"); 
			Window.document.myform.email.focus();
			return (false);
		}

		
		middlefrom = AfterAtRatefrom.substring(0, AfterAtRatefrom.indexOf("."))
		lastfrom = AfterAtRatefrom.substring(AfterAtRatefrom.indexOf(".") + 1,AfterAtRatefrom.length)

		
		if (BeforeAtRatefrom.length == 0 || middlefrom.length == 0 || lastfrom.length == 0 && flag==0)
		{
			alert("Please enter your valid E-Mail"); 
			Window.document.myform.email.focus();
			return (false);
		}
		else
		{
			Window.document.myform.submit();
			return (true);
		}
		



	}


}
