// JavaScript Document
<!--
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_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_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 validateprofile()
{
	var strpass=trimString(document.adminindex.pass.value);
	var strrepass=trimString(document.adminindex.rpass.value);
	
	if(strrepass!=strpass)
	{
		alert("Your confirm password does not match");
		document.adminindex.rpass.focus();
		return false;
	}
	return true;
}
function trimString (str) {
	
  str = this != window? this : str;
  return str.replace(/^\s+/g, '').replace(/\s+$/g, '');
}
/*
function checkfrm()
{
	if(document.contact.name.value == '')
	{
		alert("Please enter your name");
		document.contact.name.focus();
		return false;
		
	}
	if(document.contact.email.value == '')
	{
		alert("Please enter your email");
		document.contact.email.focus();
		return false;
		
	}
	else if(!(checkEmail(document.contact.email.value)))
	{
		alert("Please enter valid email");
		document.contact.email.focus();
		return false;
				
	}
	if(document.contact.phone.value == '')
	{
		alert("Please enter your phone number");
		document.contact.phone.focus();
		return false;
		
	}
	if(document.contact.phone.value.length < 10)
	{
		alert("Please enter your full phone number");
		document.contact.phone.focus();
		return false;
		
	}
	if(document.contact.timetocall.value == '')
	{
		alert("Please enter your best time to call");
		document.contact.timetocall.focus();
		return false;
		
	}
	if(document.contact.whoreferred.value == '')
	{
		alert("Please select who referred you?");
		document.contact.whoreferred.focus();
		return false;
		
	}
	if(document.contact.whoreferred.value == 'Other' && document.contact.other.value == '')
	{
		alert("Please enter who referred you?");
		document.contact.other.focus();
		return false;
		
	}
	if(document.contact.message.value == '')
	{
		alert("Please enter message");
		document.contact.message.focus();
		return false;
		
	}
	return true;
}
*/
function checkfrm()
{
	if(document.contact.fname.value == '')
	{
		alert("Please enter your first name");
		document.contact.fname.focus();
		return false;
		
	}
	if(document.contact.lname.value == '')
	{
		alert("Please enter your last name");
		document.contact.lname.focus();
		return false;
		
	}
	if(document.contact.email.value == '')
	{
		alert("Please enter your email");
		document.contact.email.focus();
		return false;
		
	}
	else if(!(checkEmail(document.contact.email.value)))
	{
		alert("Please enter valid email");
		document.contact.email.focus();
		return false;
				
	}
	if(document.contact.userdigit.value == '')
	{
		alert("Please enter the code shown in the box");
		document.contact.userdigit.focus();
		return false;
		
	}
	if(document.contact.phone.value == '')
	{
		alert("Please enter your Phone no ");
		document.contact.phone.focus();
		return false;
		
	}
	
	return true;
}
	

///email check  validation start
function checkEmail(emailStr) {


var emailPat=/^(.+)@(.+)$/


var specialChars="\\(\\)<>@,;:\\\\\\\"\\.\\[\\]"
var specialChars1="\\(\\)<>@_,;:\\\\\\\"\\.\\[\\]"

/* The following string represents the range of characters allowed in a 
   username or domainname.  It really states which chars aren't allowed. */
var validChars="\[^\\s" + specialChars + "\]"
var validChars1="\[^\\s" + specialChars1 + "\]"


var quotedUser="(\"[^\"]*\")"


var ipDomainPat=/^\[(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})\]$/


var atom=validChars + '+'
var atom1=validChars1 + '+'


var word="(" + atom + "|" + quotedUser + ")"

// The following pattern describes the structure of the user
var userPat=new RegExp("^" + word + "(\\." + word + ")*$")

/* The following pattern describes the structure of a normal symbolic
   domain, as opposed to ipDomainPat, shown above. */
var domainPat=new RegExp("^" + atom1 + "(\\." + atom1 +")*$")


var matchArray=emailStr.match(emailPat)
if (matchArray==null) {
 
	return false
}

var user=matchArray[1]
var domain=matchArray[2]

// See if "user" is valid 
if (user.match(userPat)==null) {
    // user is not valid
    //alert("The username doesn't seem to be valid.")
    return false
}

/* if the e-mail address is at an IP address (as opposed to a symbolic
   host name) make sure the IP address is valid. */
var IPArray=domain.match(ipDomainPat)
if (IPArray!=null) {
    // this is an IP address
	  for (var i=1;i<=4;i++) {
	    if (IPArray[i]>255) {
	   //     alert("Destination IP address is invalid!")
		return false
	    }
    }
    return true
}

// Domain is symbolic name
var domainArray=domain.match(domainPat)
if (domainArray==null) {
	//alert("The domain name doesn't seem to be valid.")
    return false
}


var atomPat=new RegExp(atom,"g")
var domArr=domain.match(atomPat)
var len=domArr.length
if (domArr[domArr.length-1].length<2 || 
    domArr[domArr.length-1].length>3) {
   // the address must end in a two letter or three letter word.
   //alert("The address must end in a three-letter domain, or two letter country.")
   return false
}

// Make sure there's a host name preceding the domain.
if (len<2) {
   var errStr="This address is missing a hostname!"
   //alert(errStr)
   return false
}

// If we've gotten this far, everything's valid! 
return true;
}
/* use
 if (emailCheck(theForm.txt_email_address.value) == false)
  {
    theForm.txt_email_address.focus();
    return (false);
  }

*/


///email check  validation end
/*function trimString (str) {
	
  str = this != window? this : str;
  return str.replace(/^\s+/g, '').replace(/\s+$/g, '');
}*/
