// JavaScript Document
function findname(a)
{
	if(a=="Please enter your Name")
	{
	document.frmcontact.txtname.value="";
	document.getElementById('txtname').style.backgroundColor="";
	document.getElementById('txtname').style.color="";
	}
}

function findemail(a)
{
	if(a=="Enter email address" || a=="Invlaid email address" || a=="Enter Email Address")
	{
	 document.frmcontact.txtemail.value="";	
	 document.getElementById('txtemail').style.backgroundColor="";
	document.getElementById('txtemail').style.color="";
	}
	if(document.frmcontact.txtname.value=="")
	{
	document.frmcontact.txtname.value="Please enter your Name";
	document.getElementById('txtname').style.backgroundColor="#c22b4a";
	document.getElementById('txtname').style.color="#FFFFFF";
	}
		
}

function emailis(a)
{
 if (echeck(a)==false)

	{

	   document.frmcontact.txtemail.value="Invlaid email address"; 
	   document.frmcontact.txtemail.focus();
		document.getElementById('txtemail').style.backgroundColor="#c22b4a";
		document.getElementById('txtemail').style.color="#FFFFFF";
		return false;
		}	
}
function findphone(a)
{
	if(a=="Enter Phone Number")
	{
	document.frmcontact.txtphone.value="";
	document.getElementById('txtphone').style.backgroundColor="";
	document.getElementById('txtphone').style.color="";
	}
	if(a=="Invalid Phone Number")
	{
	 document.frmcontact.txtphone.value="";
	 document.getElementById('txtphone').style.backgroundColor="";
	document.getElementById('txtphone').style.color="";
	}
	if(document.frmcontact.txtname.value=="")
	{
	document.frmcontact.txtname.value="Please enter your Name";	
	document.getElementById('txtname').style.backgroundColor="#c22b4a";
	document.getElementById('txtname').style.color="#FFFFFF";
	}
	
	if(document.frmcontact.txtemail.value=="")
	{
	document.frmcontact.txtemail.value="Enter Email Address";	
	document.getElementById('txtemail').style.backgroundColor="#c22b4a";
	document.getElementById('txtemail').style.color="#FFFFFF";
	}
	
}
function checkphone(a)
{
if (checkInternationalcode(a)==false)

	{

	  // document.frmcontact.txtphone.value="false";
	   document.frmcontact.txtphone.value="Invalid Phone Number";
	   document.getElementById('txtphone').style.backgroundColor="#c22b4a";
		document.getElementById('txtphone').style.color="#FFFFFF";
	   document.frmcontact.txtphone.focus();

		return false;
		}	
		
		if (checkInternationalPhone(a)==false)

	{

	  // document.frmcontact.txtphone.value="false";
	     document.frmcontact.txtphone.value="Invalid Phone Number";
	document.getElementById('txtphone').style.backgroundColor="#c22b4a";
		document.getElementById('txtphone').style.color="#FFFFFF";
	   document.frmcontact.txtphone.focus();

		return false;
		}		
}
function checkrequire(a)
{
document.getElementById('requirements').innerHTML=""; 	
}

function checkservice(a)
{
	 if (a==0)
 { 
  document.getElementById('serviceselect').innerHTML="Please select One Service!"; 
 
 }
 else
 {
document.getElementById('serviceselect').innerHTML=""; 
 }
}
function echeck(str) {

		var at="@"
		var dot="."
		var lat=str.indexOf(at)
		var lstr=str.length
		var ldot=str.indexOf(dot)
		if (str.indexOf(at)==-1){
		  document.frmcontact.txtemail.value="Invlaid email address"; 
		   return false
		}

		if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
		   document.frmcontact.txtemail.value="Invlaid email address"; 
		   return false
		}

		if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
		    document.frmcontact.txtemail.value="Invlaid email address"; 
		    return false
		}

		 if (str.indexOf(at,(lat+1))!=-1){
		    document.frmcontact.txtemail.value="Invlaid email address"; 
		    return false
		 }

		 if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
		   document.frmcontact.txtemail.value="Invlaid email address"; 
		    return false
		 }

		 if (str.indexOf(dot,(lat+2))==-1){
		   document.frmcontact.txtemail.value="Invlaid email address"; 
		    return false
		 }
		
		 if (str.indexOf(" ")!=-1){
		  document.frmcontact.txtemail.value="Invlaid email address"; 
		    return false
		 }

 		 return true					
	}
	var digits = "0123456789";

// non-digit characters which are allowed in phone numbers

var phoneNumberDelimiters = "()- ";

// characters which are allowed in international phone numbers

// (a leading + is OK)

var validWorldPhoneChars = phoneNumberDelimiters + "+";

// Minimum no of digits in an international phone no.

var minDigitsInIPhoneNumber = 10;

var minDigitsInIcode = 5;

function isInteger(s)

{   var i;

    for (i = 0; i < s.length; i++)

    {   

        // Check that current character is number.

        var c = s.charAt(i);

        if (((c < "0") || (c > "9"))) return false;

    }

    // All characters are numbers.

    return true;

}

function trim(s)

{   var i;

    var returnString = "";

    // Search through string's characters one by one.

    // If character is not a whitespace, append to returnString.

    for (i = 0; i < s.length; i++)

    {   

        // Check that current character isn't whitespace.

        var c = s.charAt(i);

        if (c != " ") returnString += c;

    }

    return returnString;

}

function stripCharsInBag(s, bag)

{   var i;

    var returnString = "";

    // Search through string's characters one by one.

    // If character is not in bag, append to returnString.

    for (i = 0; i < s.length; i++)

    {   

        // Check that current character isn't whitespace.

        var c = s.charAt(i);

        if (bag.indexOf(c) == -1) returnString += c;

    }

    return returnString;

}



function checkInternationalPhone(strPhone){

var bracket=3

strPhone=trim(strPhone)

if(strPhone.indexOf("+")>1) return false

if(strPhone.indexOf("-")!=-1)bracket=bracket+1

if(strPhone.indexOf("(")!=-1 && strPhone.indexOf("(")>bracket)return false

var brchr=strPhone.indexOf("(")

if(strPhone.indexOf("(")!=-1 && strPhone.charAt(brchr+2)!=")")return false

if(strPhone.indexOf("(")==-1 && strPhone.indexOf(")")!=-1)return false

s=stripCharsInBag(strPhone,validWorldPhoneChars);

return (isInteger(s) && s.length >= minDigitsInIPhoneNumber);

}

function checkInternationalcode(strPhone){

var bracket=3

strPhone=trim(strPhone)

if(strPhone.indexOf("+")>1) return false

if(strPhone.indexOf("-")!=-1)bracket=bracket+1

if(strPhone.indexOf("(")!=-1 && strPhone.indexOf("(")>bracket)return false

var brchr=strPhone.indexOf("(")

if(strPhone.indexOf("(")!=-1 && strPhone.charAt(brchr+2)!=")")return false

if(strPhone.indexOf("(")==-1 && strPhone.indexOf(")")!=-1)return false

s=stripCharsInBag(strPhone,validWorldPhoneChars);

return (isInteger(s) && s.length >= minDigitsInIcode);

}

function validate()
{
	
	
	var name= document.frmcontact.txtname.value;
	var email= document.frmcontact.txtemail.value;
	 var strPhone = document.frmcontact.txtphone.value;
	
	 if (name==null|| name=="")
 {
 document.frmcontact.txtname.value="Please enter your Name";
document.getElementById('txtname').style.backgroundColor="#c22b4a";
document.getElementById('txtname').style.color="#FFFFFF"; 
 }
   if (email==null|| email=="")
 {
 document.frmcontact.txtemail.value="Enter email address"; 
document.getElementById('txtemail').style.backgroundColor="#c22b4a";
document.getElementById('txtemail').style.color="#FFFFFF";
 }
 
  
 if (document.frmcontact.serviceselect.value == 0 )
 { 
  document.getElementById('serviceselect').innerHTML="Please select One Service!"; 
 }	
  if (name==null|| name=="")
 {

document.frmcontact.txtname.value="Please enter your Name";
document.getElementById('txtname').style.backgroundColor="#c22b4a";
document.getElementById('txtname').style.color="#FFFFFF";
 document.frmcontact.txtname.focus();

 return false;

 }
  if (email==null|| email=="")

 {

 document.frmcontact.txtemail.value="Enter email address"; 
document.getElementById('txtemail').style.backgroundColor="#c22b4a";
document.getElementById('txtemail').style.color="#FFFFFF";
 document.frmcontact.txtemail.focus();

 return false;

 }

 if (echeck(email)==false)

	{

	   document.frmcontact.txtemail.value="Invlaid email address"; 
	   document.frmcontact.txtemail.focus();
		document.getElementById('txtemail').style.backgroundColor="#c22b4a";
		document.getElementById('txtemail').style.color="#FFFFFF";
		return false;
		}


	if (document.frmcontact.serviceselect.value == 0 )
 { 
  document.getElementById('serviceselect').innerHTML="Please select One Service!"; 
 return false; 
 }	
 
if(	document.frmcontact.txtphone.value!="")
	{
	 if (checkInternationalcode(strPhone)==false)

	{

	  // document.frmcontact.txtphone.value="false";
	  document.frmcontact.txtphone.value="Invalid Phone Number";
	   document.getElementById('txtphone').style.backgroundColor="#c22b4a";
		document.getElementById('txtphone').style.color="#FFFFFF";

	   document.frmcontact.txtphone.focus();

		return false;
		}	
		
		if (checkInternationalPhone(strPhone)==false)

	{

	 document.frmcontact.txtphone.value="Invalid Phone Number";
	   document.getElementById('txtphone').style.backgroundColor="#c22b4a";
		document.getElementById('txtphone').style.color="#FFFFFF";

	   document.frmcontact.txtphone.focus();

		return false;
		}	
		
	}
 

  return true;
  
 }
 var _siteRoot='index.html',_root='index.html';
function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}
function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}
function openwin(a)
{
	window.location=a;
}
