/*-----------------------------------------------
| Mansour Paving Form Validations
| Version          : 01.00
-------------------------------------------------*/

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 the First Name.")))
		{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 the Last Name.")))
		{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 enter Telephone Number.")))
		{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.")))
		{return false;}}
		}
		
		
		
		//---------- Email  ----------
		mail = ""
		mail = document.frmenquiry.submit_by.value
		if (mail  == "")
		{if (!(PrintMesg(document.frmenquiry.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.frmenquiry.submit_by,"Please enter a valid E-mail Address.")))
		{return false;}}
		} 
		else
		{if (!(PrintMesg(document.frmenquiry.submit_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 specify your enquiry")))
		{return false;}}
		else  { 
		if (!SpaceChk(document.frmenquiry.specify))
		{if (!(PrintMesg(document.frmenquiry.specify,"Please specify your enquiry")))
		{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 }
}

function popimage(mylink, windowname)
{
if (! window.focus)return true;
var href;
if (typeof(mylink) == 'string')
   href=mylink;
else
   href=mylink.href;
window.open(href, windowname, 'width=750,height=730,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 tellpopup(mylink, windowname)
{
if (! window.focus)return true;
var href;
if (typeof(mylink) == 'string')
   href=mylink;
else
   href=mylink.href;
window.open(href, windowname, 'width=600,height=600,scrollbars=No');
return false;
}

