//---- Email a Friend
//---- Added by Amjath [19-12-2008]
function validEmailaFriend()
{
	//---------- Name Validation  ----------
		if ( document.frmemailafriend.name.value == ""  )
  		 {if (!(PrintMesg(document.frmemailafriend.name,"Please enter the Name.")))
   			{return false;}}
		 else  { 
   		if (!SpaceChk(document.frmemailafriend.name))
   		 {if (!(PrintMesg(document.frmemailafriend.name,"Please enter Name other than space.")))
    		{return false;}}
		 }

	//----------  Visitors Email Validation  ----------
		
	mail = document.frmemailafriend.submit_by.value
 	if (mail  == "")
    {if (!(PrintMesg(document.frmemailafriend.submit_by,"Please enter Email address")))
    {return false;}}
 	else 
	{ 

  		 n = mail.indexOf("@")
   		if (n >= 0)
   		{ newstr = mail.substring(n)
	 	  n= newstr.indexOf(".")
	 	  if (n<0)
	    	{if (!(PrintMesg(document.frmemailafriend.submit_by,"Please Enter a valid E-mail Address")))
	    	{return false;}}
   		} 
   		else
    	{if (!(PrintMesg(document.frmemailafriend.submit_by,"Please Enter a valid E-mail Address")))
    	{return false;}}}	
	
	
	//---------- Friends Emails Validation  ----------
		if ( document.frmemailafriend.to_emails.value == ""  )
  		 {if (!(PrintMesg(document.frmemailafriend.to_emails,"Please enter your friends emails seperated by comma.")))
   			{return false;}}
		 else  {
			if(!checkAll()) 
			{return false;}}
		 
		//-----------------------------------------[start] Multiple Email Check seperated by comma - Added by Amjath [19-12-08]
		function validate(email)
		{
		var reg = /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/;
		return reg.test(email);
		}

		function trim(str)
		{
		var	str = str.replace(/^\s\s*/,''),
		ws = /\s/,
		i = str.length;
		while (ws.test(str.charAt(--i)));
		return str.slice(0, i + 1);
		}

		function checkAll(){
		var status = true;
		var i = 0;
		var emails = document.frmemailafriend.to_emails.value.split(",");
		for(i=0; i<emails.length; i++){
		if(!validate(trim(emails[i]))){			
			alert("Incorrect format: "+emails[i]);
			document.frmemailafriend.to_emails.focus()
			status = false;
			break;
			}}
		if(status)	
		{return true;}
		else
		{return false;}
}

		//-----------------------------------------[end] Multiple Email Check seperated by comma
		 
		return true;
}
//------- Here ends






//---- Join Mailing List 
//---- Added by Jini [15-10-2008]
function validForm()
{
	//---------- First Name  ----------
		if ( document.frmjoin.first_name.value == ""  )
  		 {if (!(PrintMesg(document.frmjoin.first_name,"Please enter the First Name.")))
   			{return false;}}
		 else  { 
   		if (!SpaceChk(document.frmjoin.first_name))
   		 {if (!(PrintMesg(document.frmjoin.first_name,"Please enter First Name other than space.")))
    		{return false;}}
		 }
	
	//---------- Last Name  ----------
		if ( document.frmjoin.last_name.value == ""  )
  		 {if (!(PrintMesg(document.frmjoin.last_name,"Please enter the Last Name.")))
   			{return false;}}
		 else  { 
   		if (!SpaceChk(document.frmjoin.last_name))
   		 {if (!(PrintMesg(document.frmjoin.last_name,"Please enter Last Name other than space.")))
    		{return false;}}
		 }
/*
	//----------  Phone  ----------	
	if (! document.frmjoin.phoneno.value == ""  )
  		 {if (isNaN(document.frmjoin.phoneno.value))
   			{
				alert("Please enter a number");
				document.frmjoin.phoneno.focus()
				return false;
		}}	
	
	//----------  Work Phone  ----------	
	if (! document.frmjoin.workphone.value == ""  )
  		 {if (isNaN(document.frmjoin.workphone.value))
   			{
				alert("Please enter a number");
				document.frmjoin.workphone.focus()
				return false;
		}}	
	
	//----------  Mobile Phone  ----------	
	if (! document.frmjoin.mobileno.value == ""  )
  		 {if (isNaN(document.frmjoin.mobileno.value))
   			{
				alert("Please enter a number");
				document.frmjoin.mobileno.focus()
				return false;
		}}	
	
*/

	//----------  Email  ----------
		
	mail = document.frmjoin.submit_by.value
 	if (mail  == "")
    {if (!(PrintMesg(document.frmjoin.submit_by,"Please enter Email address")))
    {return false;}}
 	else 
	{ 

  		 n = mail.indexOf("@")
   		if (n >= 0)
   		{ newstr = mail.substring(n)
	 	  n= newstr.indexOf(".")
	 	  if (n<0)
	    	{if (!(PrintMesg(document.frmjoin.submit_by,"Please Enter a valid E-mail Address")))
	    	{return false;}}
   		} 
   		else
    	{if (!(PrintMesg(document.frmjoin.submit_by,"Please Enter a valid E-mail Address")))
    	{return false;}}}	
	
	//---------- Post Code  ----------
		if ( document.frmjoin.postcode.value == ""  )
  		 {if (!(PrintMesg(document.frmjoin.postcode,"Please enter the Post Code.")))
   			{return false;}}
		 else  { 
   		if (!SpaceChk(document.frmjoin.postcode))
   		 {if (!(PrintMesg(document.frmjoin.postcode,"Please enter Post Code other than space.")))
    		{return false;}}
		 }
		return true;
}
//------- Here ends

//-----General Enquiry Form --------------//
function validateReservation()
{

		//---------- date  ----------
		if ( document.rform.rdate.value == ""  )
  		 {if (!(PrintMesg(document.rform.rdate,"Please enter the required date.")))
   			{return false;}}
		 else  { 
   		if (!SpaceChk(document.rform.rdate))
   		 {if (!(PrintMesg(document.rform.rdate,"Please enter date other than space.")))
    		{return false;}}
		 }

		if ( document.rform.rtime.value == ""  )
  		 {if (!(PrintMesg(document.rform.rtime,"Please enter the required time.")))
   			{return false;}}
		 else  { 
   		if (!SpaceChk(document.rform.rtime))
   		 {if (!(PrintMesg(document.frmenquiry.rtime,"Please enter time other than space.")))
    		{return false;}}
		 }

		if ( document.rform.nop.value == ""  )
  		 {if (!(PrintMesg(document.rform.nop,"Please enter the no. of people.")))
   			{return false;}}
		 else  { 
   		if (!SpaceChk(document.rform.nop))
   		 {if (!(PrintMesg(document.rform.nop,"Please enter no. of people other than space.")))
    		{return false;}}

		if ( isNaN(document.rform.nop.value) )
  		 {if (!(PrintMesg(document.rform.nop,"Please enter a numeric value.")))
   			{return false;}}
   	      }

		//---------- Name  ----------
		if ( document.rform.name.value == ""  )
  		 {if (!(PrintMesg(document.rform.name,"Please enter the Name.")))
   			{return false;}}
		 else  { 
   		if (!SpaceChk(document.rform.name))
   		 {if (!(PrintMesg(document.rform.name,"Please enter Name other than space.")))
    		{return false;}}
		 }


		 //---------- TelePhone  ----------
		if ( document.rform.cno.value == ""  )
  		 {if (!(PrintMesg(document.rform.cno,"Please enter Telephone Number.")))
   			{return false;}}
		 else  { 
   		if (!SpaceChk(document.rform.cno))
   		 {if (!(PrintMesg(document.rform.cno,"Please Telephone Number other than space.")))
    		{return false;}}
		 }


		//--------e-mail
	mail = ""
	mail = document.rform.submit_by.value
 	if (mail  == "")
    {if (!(PrintMesg(document.rform.submit_by,"Please enter E-mail Address.")))
    {return false;}}
	 else { 
   	n = mail.indexOf("@")
   	if (n >= 0)
   	{ newstr = mail.substring(n)
	 n= newstr.indexOf(".")
	 if (n<0)
	    {if (!(PrintMesg(document.rform.submit_by,"Please enter a valid E-mail Address.")))
	    {return false;}}
   	} 
   	else
    {if (!(PrintMesg(document.rform.submit_by,"Please enter a valid E-mail Address.")))
    {return false;}}
 	}

	//---------- How did you hear about Pink Salt? 
	
		if ( document.rform.hear.value == ""  )
  		 {if (!(PrintMesg(document.rform.hear,"Please enter 'How did you hear about Pink Salt?'")))
   			{return false;}}
		 else  { 
   		if (!SpaceChk(document.rform.hear))
   		 {if (!(PrintMesg(document.rform.hear,"Please enter 'How did you hear about Pink Salt?'")))
    		{return false;}}
		 }
	
		return true;
}
//==============================

function validateEnquiry()
	{

		//---------- FName  ----------
		if ( document.frmenquiry.first_name.value == ""  )
  		 {if (!(PrintMesg(document.frmenquiry.first_name,"Please enter the First Name.")))
   			{return false;}}
		 else  { 
   		if (!SpaceChk(document.frmenquiry.first_name))
   		 {if (!(PrintMesg(document.frmenquiry.first_name,"Please enter First Name other than space.")))
    		{return false;}}
		 }

		//---------- LName  ----------
		if ( document.frmenquiry.last_name.value == ""  )
  		 {if (!(PrintMesg(document.frmenquiry.last_name,"Please enter the Last Name.")))
   			{return false;}}
		 else  { 
   		if (!SpaceChk(document.frmenquiry.last_name))
   		 {if (!(PrintMesg(document.frmenquiry.last_name,"Please enter Last Name other than space.")))
    		{return false;}}
		 }

		 //---------- TelePhone  ----------
		if ( document.frmenquiry.telephone.value == ""  )
  		 {if (!(PrintMesg(document.frmenquiry.telephone,"Please enter Telephone Number.")))
   			{return false;}}
		 else  { 
   		if (!SpaceChk(document.frmenquiry.telephone))
   		 {if (!(PrintMesg(document.frmenquiry.telephone,"Please Telephone Number other than space.")))
    		{return false;}}
		 }

		//---------- postcode  ----------
		if ( document.frmenquiry.postcode.value == ""  )
  		 {if (!(PrintMesg(document.frmenquiry.postcode,"Please enter your postcode.")))
   			{return false;}}
		 else  { 
   		if (!SpaceChk(document.frmenquiry.postcode))
   		 {if (!(PrintMesg(document.frmenquiry.postcode,"Please enter your postcode other than space.")))
    		{return false;}}
		 }

		//---------- Req. date----------
		if ( document.frmenquiry.rdate.value == ""  )
  		 {if (!(PrintMesg(document.frmenquiry.rdate,"Please enter the required Date.")))
   			{return false;}}
		 else  { 
   		if (!SpaceChk(document.frmenquiry.rdate))
   		 {if (!(PrintMesg(document.frmenquiry.rdate,"Please enter Date other than space.")))
    		{return false;}}
		 }
		//---------- no. of people ----------
		if ( document.frmenquiry.nopeople.value == ""  )
  		 {if (!(PrintMesg(document.frmenquiry.nopeople,"Please enter No. of people.")))
   			{return false;}}
		 else  { 
   		if (!SpaceChk(document.frmenquiry.nopeople))
   		 {if (!(PrintMesg(document.frmenquiry.nopeople,"Please No. of people other than space.")))
    		{return false;}}

		if ( isNaN(document.frmenquiry.nopeople.value) )
  		 {if (!(PrintMesg(document.frmenquiry.nopeople,"Please enter a numeric value")))
   			{return false;}}

		 }


/* COMMENTED BY jINI AS NOT NEEDED
 
		//--------e-mail
	mail = ""
	mail = document.frmenquiry.submitenq_by.value
 	if (mail  == "")
    {if (!(PrintMesg(document.frmenquiry.submitenq_by,"Please enter E-mail Address.")))
    {return false;}}
	 else { 
   	n = mail.indexOf("@")
   	if (n >= 0)
   	{ newstr = mail.substring(n)
	 n= newstr.indexOf(".")
	 if (n<0)
	    {if (!(PrintMesg(document.frmenquiry.submitenq_by,"Please enter a valid E-mail Address.")))
	    {return false;}}
   	} 
   	else
    {if (!(PrintMesg(document.frmenquiry.submitenq_by,"Please enter a valid E-mail Address.")))
    {return false;}}
 	}
*/
	//---------- Please specify your enquiry
	
		if ( document.frmenquiry.specify.value == ""  )
  		 {if (!(PrintMesg(document.frmenquiry.specify,"Please enter 'Please specify your enquiry'")))
   			{return false;}}
		 else  { 
   		if (!SpaceChk(document.frmenquiry.specify))
   		 {if (!(PrintMesg(document.frmenquiry.specify,"Please enter 'Please enter 'Please specify your enquiry")))
    		{return false;}}
		 }

	//---------- How did you hear about Botany Bay? 
		if ( document.frmenquiry.hear.value == ""  )
  		 {if (!(PrintMesg(document.frmenquiry.hear,"Please enter 'How did you hear about Botany Bay?'")))
   			{return false;}}
		 else  { 
   		if (!SpaceChk(document.frmenquiry.hear))
   		 {if (!(PrintMesg(document.frmenquiry.hear,"Please enter 'How did you hear about Botany Bay?'")))
    		{return false;}}
		 }

	
		return true;
	}




//prints messages
function PrintMesg(ctrlvar,mesg)
{ alert(mesg); ctrlvar.focus(); return false }

// function to check spaces
function SpaceChk(ctrlvar)
{
   chkstr     = ctrlvar.value
   stlength   = chkstr.length
   spacecount = 0
   if (stlength >0)  {
    for(i=0;i<=stlength;i++)
     if ( chkstr.charAt(i)==" ") { spacecount=spacecount+1  }
    if (stlength == spacecount) { return false }
   return true }
}

//---------------popup 04-06-2008

function popup(mylink, windowname)
{
if (! window.focus)return true;
var href;
if (typeof(mylink) == 'string')
   href=mylink;
else
   href=mylink.href;
window.open(href, windowname, 'width=635,height=530,scrollbars=Yes');
return false;
}
function popimage(mylink, windowname)
{
var arrTemp=self.location.href.split("?");
   var picUrl = (arrTemp.length>0)?arrTemp[1]:"";
   var NS = (navigator.appName=="Netscape")?true:false;
   
   iWidth = (NS)?window.innerWidth:document.body.clientWidth;
       iHeight = (NS)?window.innerHeight:document.body.clientHeight;
       iWidth = document.images[0].width - iWidth;
       iHeight = document.images[0].height - iHeight;
	   //alert(iHeight);
	   
if (! window.focus)return true;
var href;
if (typeof(mylink) == 'string')
   href=mylink;
else
   href=mylink.href;

window.open(href, windowname, 'width=700,height=600,scrollbars=Yes');
return false;
}

//---------------


function popvideo(mylink, windowname)
{
if (! window.focus)return true;
var href;
if (typeof(mylink) == 'string')
   href=mylink;
else
   href=mylink.href;
window.open(href, windowname, 'width=435,height=370,scrollbars=No');
return false;
}
function checkMailingList() 
{
	//---------- Name Validation  ----------
		if ( document.frmMailList.custname.value == ""  )
  		 {if (!(PrintMesg(document.frmMailList.custname,"Please enter the Name.")))
   			{return false;}}
		 else  { 
   		if (!SpaceChk(document.frmMailList.custname))
   		 {if (!(PrintMesg(document.frmMailList.custname,"Please enter Name other than space.")))
    		{return false;}}
		 }

	//----------  Email Validation  ----------
		
	mail = document.frmMailList.email.value
 	if (mail  == "")
    {if (!(PrintMesg(document.frmMailList.email,"Please enter Email address")))
    {return false;}}
 	else 
	{ 

  		 n = mail.indexOf("@")
   		if (n >= 0)
   		{ newstr = mail.substring(n)
	 	  n= newstr.indexOf(".")
	 	  if (n<0)
	    	{if (!(PrintMesg(document.frmMailList.email,"Please Enter a valid E-mail Address")))
	    	{return false;}}
   		} 
   		else
    	{if (!(PrintMesg(document.frmMailList.email,"Please Enter a valid E-mail Address")))
    	{return false;}}}	
		//---------- Name Validation  ----------
		if ( document.frmMailList.phone.value == ""  )
  		 {if (!(PrintMesg(document.frmMailList.phone,"Please enter the Contact Number.")))
   			{return false;}}
		 else  { 
   		if (!SpaceChk(document.frmMailList.phone))
   		 {if (!(PrintMesg(document.frmMailList.phone,"Please enter Contact Number other than space.")))
    		{return false;}}
		 }

	return true;
}


