



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];}
}

 //### Numeric Check #####
function ISnumeric(argNum)
{
 if(argNum=="")
 {
 	return false;
 }
 var valid = "0123456789X"
 var ok = "yes";
 var temp;
 for (var i=0; i<argNum.length; i++) 
	{
		temp = "" + argNum.substring(i, i+1);
		if (valid.indexOf(temp) == "-1")
		{ 
		
		 return false;
		  break; 
	    } 
	}
   return true;
}//end function 

//####### Email Syntex Check #######
function validateEmail(email)
{
	
	// This function is used to validate a given e-mail 
	// address for the proper syntax
	
	if (email == ""){
		return false;
	}
	badStuff = ";:/,' \"\\";
	for (i=0; i<badStuff.length; i++){
		badCheck = badStuff.charAt(i)
		if (email.indexOf(badCheck,0) != -1){
			return false;
		}
	}
	posOfAtSign = email.indexOf("@",1)
	if (posOfAtSign == -1){
		return false;
	}
	if (email.indexOf("@",posOfAtSign+1) != -1){
		return false;
	}
	posOfPeriod = email.indexOf(".", posOfAtSign)
	if (posOfPeriod == -1){
		return false;
	}
	if (posOfPeriod+2 > email.length){
		return false;
	}
	return true
}//end function

//### Email Check ###########
function emailCheck (emailStr)
{
	var checkTLD=1;
	var knownDomsPat=/^(com|net|org|edu|int|mil|gov|arpa|biz|aero|name|coop|info|pro|museum)$/;
	var emailPat=/^(.+)@(.+)$/;
	var specialChars="\\(\\)><@,;:\\\\\\\"\\.\\[\\]";
	var validChars="\[^\\s" + specialChars + "\]";
	var quotedUser="(\"[^\"]*\")";
	var ipDomainPat=/^\[(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})\]$/;
	var atom=validChars + '+';
	var word="(" + atom + "|" + quotedUser + ")";
	var userPat=new RegExp("^" + word + "(\\." + word + ")*$");
	var domainPat=new RegExp("^" + atom + "(\\." + atom +")*$");
	var matchArray=emailStr.match(emailPat);
	if (matchArray==null)
	{
		return false;
	}
	var user=matchArray[1];
	var domain=matchArray[2];

	// Start by checking that only basic ASCII characters are in the strings (0-127).

	for (i=0; i<user.length; i++) 
	{
		if (user.charCodeAt(i)>127) 
		{
			//alert("Ths username contains invalid characters.");
			return false;
   		}
	}
	for (i=0; i<domain.length; i++) 
	{
		if (domain.charCodeAt(i)>127) 
		{
			//alert("Ths domain name contains invalid characters.");
			return false;
   		}
	}

	if (user.match(userPat)==null) 
	{
		return false;
	}
	
	var IPArray=domain.match(ipDomainPat);
	if (IPArray!=null) 
	{

		for (var i=1;i<=4;i++) 
		{
			if (IPArray[i]>255) 
			{
				return false;
   			}
		}
		return true;
	}
 
	var atomPat=new RegExp("^" + atom + "$");
	var domArr=domain.split(".");
	var len=domArr.length;
	for (i=0;i<len;i++) 
	{
		if (domArr[i].search(atomPat)==-1) 
		{
			return false;
   		}
	}
	
	if (checkTLD && domArr[domArr.length-1].length!=2 && domArr[domArr.length-1].search(knownDomsPat)==-1) 
	{
		return false;
	}

	// Make sure there's a host name preceding the domain.

	if (len<2) 
	{
		return false;
	}

// If we've gotten this far, everything's valid!
return true;
}//end function

//### Verify Action #####
function verify(msg)
{
	if(confirm(msg))
		return true;
	else
		return false;	
}//end function

//######### Pop Window ###########
function PopupPic(img_src)
{ 
  //window.open("large.php?imgsrc="+img_src,'','toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=1,resizable=1,maximize=0,width='+width+',height='+height');
  window.open("large.php?imgsrc="+img_src,"mydoc","toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=0,resizable=0,maximize=0");
}//end function 

function winBRopen(theURL,height,width) 
{ 
var winleft = (screen.width - 500) / 2;
var winUp = (screen.height - 500) / 4;


winProp = 'width='+width+',height='+height+',left='+winleft+',top='+winUp+',scrollbars=yes,resizable=yes,toolbar=0,menubar=0';

Win = window.open(theURL,'', winProp)
	if (parseInt(navigator.appVersion) >= 4) 
		{
 		Win.window.focus(); 
 		}
}
//##################################################################################


function chk_registration()
{
  frm=document.user_registration;	
  
  if(frm.username.value=='')
  {
    alert("Please specify your username!");
    frm.username.focus();
    return false;
  }
  if(frm.password.value=='')
  {
    alert("Please specify the password!");
    frm.password.focus();
    return false;
  }
  if(frm.firstname.value=='')
  {
    alert("Please specify the first name!");
    frm.firstname.focus();
    return false;
  }
  
  if(frm.lastname.value=='')
  {
    alert("Please specify the last name!");
    frm.lastname.focus();
    return false;
  }
  
  if(frm.company.value=='')
  {
    alert("Please specify the company name!");
    frm.company.focus();
    return false;
  }
  if(frm.bphone.value=='')
  {
    alert("Please specify the business phone!");
    frm.bphone.focus();
    return false;
  }
  if(frm.bphone.value!='')
  {
       if (!ISnumeric(frm.bphone.value))
	{
		alert("Please input a valid phone number.");
		frm.bphone.focus();
		return false;
	}
  }
 if(frm.email.value=='')
  {
    alert("Please specify the email!");
    frm.email.focus();
    return false;
  }
  if(!emailCheck(frm.email.value))
  {
     alert("Email is in an invalid format - Please RE-Enter");
     frm.email.focus();
     return false;
  }


  
}//end function  

function chk_loginVal()
{
  frm=document.frmlogin;	
  if(frm.email.value=='')
  {
    alert("Please specify the email!");
    frm.email.focus();
    return false;
  }
  if(!emailCheck(frm.email.value))
  {
     alert("Email is in an invalid format - Please RE-Enter");
     frm.email.focus();
     return false;
  }
  if(frm.password.value=='')
  {
    alert("Please specify the password!");
    frm.password.focus();
    return false;
  }
  
  frm.submit();
}//end function

function chk_forgotVal()
{
  frm=document.frmforgot;
  if(frm.email.value=='')
  {
    alert("Please specify the email!");
    frm.email.focus();
    return false;
  }
  if(!emailCheck(frm.email.value))
  {
     alert("Email is in an invalid format - Please RE-Enter");
     frm.email.focus();
     return false;
  } 	
}//end function

function clearField(frm)
{
   if((frm.value=="XXX")||(frm.value=="XXXX"))
   {
	frm.value="";
	frm.focus();
   }
}


function chk_myacount()
{
  frm=document.frmMyAccountEdit;	

 if(frm.email.value=='')
  {
    alert("Please specify the email!");
    frm.email.focus();
    return false;
  }
  if(!emailCheck(frm.email.value))
  {
     alert("Email is in an invalid format - Please RE-Enter");
     frm.email.focus();
     return false;
  }
  if(frm.password.value=='')
  {
    alert("Please specify the password!");
    frm.password.focus();
    return false;
  }
 if(frm.title.value=='')
  {
    alert("Please specify the title!");
    frm.title.focus();
    return false;
  }
  
  if(frm.company.value=='')
  {
    alert("Please specify the company name!");
    frm.company.focus();
    return false;
  }
  if(frm.company_address.value=='')
  {
    alert("Please specify the company address!");
    frm.company_address.focus();
    return false;
  }
  if(frm.city.value=='')
  {
    alert("Please specify the company city!");
    frm.city.focus();
    return false;
  }
  if(frm.zip.value=='')
  {
    alert("Please specify the zipcode!");
    frm.zip.focus();
    return false;
  }
  if(frm.country.value=='')
  {
    alert("Please specify the country!");
    frm.country.focus();
    return false;
  }
  if(frm.phone1.value!='')
  {
       if (!ISnumeric(frm.phone1.value))
	{
		alert("Please input a valid phone number.");
		frm.phone1.focus();
		return false;
	}
  }
  if(frm.phone2.value!='')
  {
       if (!ISnumeric(frm.phone2.value))
	{
		alert("Please input a valid phone number.");
		frm.phone2.focus();
		return false;
	}
  }
  if(frm.phone3.value!='')
  {
       if (!ISnumeric(frm.phone3.value))
	{
		alert("Please input a valid phone number.");
		frm.phone3.focus();
		return false;
	}
  }
  if(frm.phone4.value!='')
  {
       if (!ISnumeric(frm.phone4.value))
	{
		alert("Please input a valid phone number.");
		frm.phone4.focus();
		return false;
	}
  }
  if(frm.badge_name.value=='')
  {
    alert("Please specify the name on badge!");
    frm.badge_name.focus();
    return false;
  }
  if(frm.company_badge_name.value=='')
  {
    alert("Please specify the comapany on badge!");
    frm.company_badge_name.focus();
    return false;
  }
  /*
  if((frm.ccfname.value!="")||(frm.cclname.value!="")||(frm.ccnumber.value!="")||(frm.ccexpdate.value!="")||(frm.csv.value!=""))
  {
	  if(frm.ccfname.value=='')
	  {
	    alert("Please specify the credit card first name!");
	    frm.ccfname.focus();
	    return false;
	  }
	  if(frm.cclname.value=='')
	  {
	    alert("Please specify the credit card last name!");
	    frm.cclname.focus();
	    return false;
	  }
	  if(frm.ccnumber.value=='')
	  {
	    alert("Please specify the credit card number!");
	    frm.ccnumber.focus();
	    return false;
	  }
	  if(frm.ccexpdate.value=='')
	  {
	    alert("Please specify the credit card expiry date!");
	    frm.ccexpdate.focus();
	    return false;
	  }
	  if(frm.csv.value=='')
	  {
	    alert("Please specify the csv number!");
	    frm.csv.focus();
	    return false;
	  }
   }
   */	  
  	  
}//end function  	

function chk_EventRegis(val)
{
  frm=document.event_registtration;
  if(frm.email.value=='')
  {
    alert("Please specify the email!");
    frm.email.focus();
    return false;
  }
  if(!emailCheck(frm.email.value))
  {
     alert("Email is in an invalid format - Please RE-Enter");
     frm.email.focus();
     return false;
  }
  if(frm.fname.value=='')
  {
    alert("Please specify the first name!");
    frm.fname.focus();
    return false;
  }
  if(frm.lname.value=='')
  {
    alert("Please specify the last name!");
    frm.lname.focus();
    return false;
  }
  if(frm.phone1.value!='')
  {
       if (!ISnumeric(frm.phone1.value))
	{
		alert("Please input a valid phone number.");
		frm.phone1.focus();
		return false;
	}
  }
  if(frm.phone2.value!='')
  {
       if (!ISnumeric(frm.phone2.value))
	{
		alert("Please input a valid phone number.");
		frm.phone2.focus();
		return false;
	}
  }
  if(frm.phone3.value!='')
  {
       if (!ISnumeric(frm.phone3.value))
	{
		alert("Please input a valid phone number.");
		frm.phone3.focus();
		return false;
	}
  }
  if(frm.phone4.value!='')
  {
       if (!ISnumeric(frm.phone4.value))
	{
		alert("Please input a valid phone number.");
		frm.phone4.focus();
		return false;
	}
  }
  if(frm.badge_name.value=='')
  {
    alert("Please specify the name on badge!");
    frm.badge_name.focus();
    return false;
  }
  if(frm.company_badge_name.value=='')
  {
    alert("Please specify the comapany on badge!");
    frm.company_badge_name.focus();
    return false;
  }
  if(val==1)
  {
  	if(frm.ccfname.value=='')
	  {
	    alert("Please specify the credit card first name!");
	    frm.ccfname.focus();
	    return false;
	  }
	  if(frm.cclname.value=='')
	  {
	    alert("Please specify the credit card last name!");
	    frm.cclname.focus();
	    return false;
	  }
	  if(frm.ccnumber.value=='')
	  {
	    alert("Please specify the credit card number!");
	    frm.ccnumber.focus();
	    return false;
	  }
	  if(frm.ccexpdate.value=='')
	  {
	    alert("Please specify the credit card expiry date!");
	    frm.ccexpdate.focus();
	    return false;
	  }
	  if(frm.csv.value=='')
	  {
	    alert("Please specify the csv number!");
	    frm.csv.focus();
	    return false;
	  }
  }
  	  
}//end function 


//used in member_directory.php
function chk_searchuser()
{
	if(document.searchform.searchfor.value=='')
	{
		alert("Please specify the text for search.");
		document.searchform.searchfor.focus();
		return false;
	}
		
}

function swapForm(nm)
{
	flag=nm;
	var str = document.getElementById("complete").value;
	var obj1=document.getElementById("notcomplete");
	
	if(flag == "1")
	{
	 	
	 	obj1.style.display="";
 	
	}
	if(flag == "2")
	{
		
	 	obj1.style.display="none";
	}		
}		

function swapForm2(nm)
{
	flag=nm;
	var str = document.getElementById("anomaly").value;
	var obj1=document.getElementById("showanomaly");
	var obj2=document.getElementById("noshowanomaly");
	
	if(flag == "1")
	{
	 
	 	obj1.style.display="none";
	 	
	 	obj2.style.display="";
 	
	}
	if(flag == "2")
	{
		
	 	obj1.style.display="";
	 
	 	obj2.style.display="none";
	}		
}	
