//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//~~~~~~~      Macromedia Utilities     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~


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 MM_openBrWindow(theURL,winName,features) { //v2.0
  myWin = window.open(theURL,winName,features);
  myWin.focus();
}
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~//~~~~~~~      Pages Menu Status    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~var menu1, menu2, menu3, menu4, menu5, sLoc	function SearchMenu(url,page){   return url.indexOf("/"+page+".".toLowerCase())==-1?"":1;}	sLoc=(document.URL).toLowerCase();			// Submenu items			ssubmenu1 = SearchMenu(sLoc,"signin");	ssubmenu2 = SearchMenu(sLoc,"aboutus_contact");	ssubmenu3 = SearchMenu(sLoc,"help");			// Menu items			smenu1 = SearchMenu(sLoc,"index");		smenu20 = SearchMenu(sLoc,"products");	smenu21 = SearchMenu(sLoc,"products");	smenu22 = SearchMenu(sLoc,"products_lectionary");	smenu23 = SearchMenu(sLoc,"products_topics");	smenu24 = SearchMenu(sLoc,"products_detail");	smenu25 = SearchMenu(sLoc,"basket");	smenu26 = SearchMenu(sLoc,"shipping");	smenu27 = SearchMenu(sLoc,"revieworder");		smenu2 = smenu20||smenu21||smenu22||smenu23||smenu24||smenu25||smenu26||smenu27?1:"";		smenu30 = SearchMenu(sLoc,"education");	smenu31 = SearchMenu(sLoc,"education_seminars");	smenu32 = SearchMenu(sLoc,"education_courses");	smenu33 = SearchMenu(sLoc,"education_leadership");	smenu34 = SearchMenu(sLoc,"education_register");		smenu3 = smenu30||smenu31||smenu32||smenu33||smenu34?1:"";		smenu40 = SearchMenu(sLoc,"news");	smenu41 = SearchMenu(sLoc,"news_recent");	smenu42 = SearchMenu(sLoc,"news_archives");		smenu4 = smenu40||smenu41||smenu42?1:"";				   		smenu50 = SearchMenu(sLoc,"aboutus");	smenu51 = SearchMenu(sLoc,"aboutus_bios");	smenu52 = SearchMenu(sLoc,"aboutus_contact");	smenu53 = SearchMenu(sLoc,"aboutus_faq");	smenu54 = SearchMenu(sLoc,"aboutus_links");	smenu55 = SearchMenu(sLoc,"aboutus_terms");		smenu5 = smenu50||smenu51||smenu52||smenu53||smenu54||smenu55?1:"";																																	   			// Detailmenu items					 	  	sdetailmenu1 = SearchMenu(sLoc,"experiences")||SearchMenu(sLoc,"aboutus_bios")||SearchMenu(sLoc,"news_recent")||SearchMenu(sLoc,"education_seminars")||SearchMenu(sLoc,"products");	sdetailmenu2 = SearchMenu(sLoc,"lectionary")||SearchMenu(sLoc,"aboutus_contact")||SearchMenu(sLoc,"news_archives")||SearchMenu(sLoc,"education_courses")||SearchMenu(sLoc,"products_lectionary");	sdetailmenu3 = SearchMenu(sLoc,"topics")||SearchMenu(sLoc,"aboutus_faq")||SearchMenu(sLoc,"education_leadership")||SearchMenu(sLoc,"products_topics");	sdetailmenu4 = SearchMenu(sLoc,"aboutus_links")||SearchMenu(sLoc,"education_register");	sdetailmenu5 = SearchMenu(sLoc,"aboutus_terms");function SetMenu(){		// Submenu items	if(ssubmenu1)	{		MM_swapImage('submenu1','','images/submenu_marker_over.gif',1);		document.getElementById("submenuLink1").className = "SubmenuDinamicLink";	}	if(ssubmenu2)	{		MM_swapImage('submenu2','','images/submenu_marker_over.gif',1);		document.getElementById("submenuLink2").className = "SubmenuDinamicLink";	}		if(ssubmenu3)	{		MM_swapImage('submenu3','','images/submenu_marker_over.gif',1);		document.getElementById("submenuLink3").className = "SubmenuDinamicLink";	}		    		// Menu items	if(smenu1) MM_swapImage('menu1','','images/menu1_hit.gif',1);	if(smenu2) MM_swapImage('menu2','','images/menu2_hit.gif',1);	if(smenu3) MM_swapImage('menu3','','images/menu3_hit.gif',1);	if(smenu4) MM_swapImage('menu4','','images/menu4_hit.gif',1);	if(smenu5) MM_swapImage('menu5','','images/menu5_hit.gif',1);			// Detailmenu items	if(sdetailmenu1)	{		MM_swapImage('detailmenu1','','images/detailmenu_marker_over.gif',1);		document.getElementById("detailmenuLink1").className = "SubmenuDinamicLink";	}	if(sdetailmenu2)	{		MM_swapImage('detailmenu2','','images/detailmenu_marker_over.gif',1);		document.getElementById("detailmenuLink2").className = "SubmenuDinamicLink";	}		if(sdetailmenu3)	{		MM_swapImage('detailmenu3','','images/detailmenu_marker_over.gif',1);		document.getElementById("detailmenuLink3").className = "SubmenuDinamicLink";	}		if(sdetailmenu4)	{		MM_swapImage('detailmenu4','','images/detailmenu_marker_over.gif',1);		document.getElementById("detailmenuLink4").className = "SubmenuDinamicLink";	}		if(sdetailmenu5)	{		MM_swapImage('detailmenu5','','images/detailmenu_marker_over.gif',1);		document.getElementById("detailmenuLink5").className = "SubmenuDinamicLink";	}}	




//________________________________________________________________________________________________
//_____________________      LoginValid     _____________________________________________________________

function LoginValid() {

	if (isWhitespace(document.myform.UserName.value)) 	{
	     alert("Please enter User Name!  ");
	     document.myform.UserName.focus();
	     return;
	}  
	if (isWhitespace(document.myform.UserPassword.value)) 	{
	     alert("Please enter  User Password! ");
	     document.myform.UserPassword.focus();
	     return;
	}  
	    document.myform.submit();
}


//________________________________________________________________________________________________
//_____________________      ValidEmailF     _____________________________________________________________

function ValidEmailF() {
	if (isWhitespace(document.myform.UserName.value)) 	{
			alert("Please enter User Name");
			document.myform.UserName.focus();
			return;
	}	
	if (isWhitespace(document.myform.UserEmail.value)) 	{
			alert("Please enter Email Address");
			document.myform.UserEmail.focus();
			return;
	}	
	document.myform.UserEmail.value = NonSpace(document.myform.UserEmail.value);
	if (isEmail(document.myform.UserEmail.value)==false) {
			alert("Please enter a valid E-Mail address, like: name@companyname.com ");
			document.myform.UserEmail.focus();
			return;
	}
	    document.myform.submit();
}

//________________________________________________________________________________________________
//_____________________      ValidMailing     _____________________________________________________________

function ValidMailing() {
	if (isWhitespace(document.myform.MLEmail.value)) 	{
			alert("Please enter Email Address");
			document.myform.MLEmail.focus();
			return ;
	}	
	document.myform.MLEmail.value = NonSpace(document.myform.MLEmail.value);
	if (isEmail(document.myform.MLEmail.value)==false) {
			alert("Please enter a valid E-Mail address, like: name@companyname.com ");
			document.myform.MLEmail.focus();
				return false;
			}
        return true;
}


//________________________________________________________________________________________________
//_____________________      ValidRegisterX    _____________________________________________________________

function ValidRegisterX() {
	if (isWhitespace(document.myform.UserName.value)) 	{
	     alert("Please enter  User Name! ");
	     document.myform.UserName.focus();
	     return;
	}  
	 if (document.myform.UserName.value.length < 4) 	 {
	     alert("The Minimum length for User Name should be 4!");
	     document.myform.UserName.focus();
	     return;
	 }
	if (isWhitespace(document.myform.UserPassword.value)) 	{
	     alert("Please enter Password! ");
	     document.myform.UserPassword.focus();
	     return;
	}  
	 if (document.myform.UserPassword.value.length < 4) 	 {
	     alert("The Minimum length for Password should be 4!");
	     document.myform.UserPassword.focus();
	     return;
	 }
	if (isWhitespace(document.myform.ConfirmPassword.value)) 	{
	     alert("Please Confirm Password! ");
	     document.myform.ConfirmPassword.focus();
	     return;
	}  
	 if (document.myform.ConfirmPassword.value.length < 4) 
	 {
	     alert("The Minimum length for Password should be 4!");
	     document.myform.ConfirmPassword.focus();
	     return;
	 }
	 if (document.myform.ConfirmPassword.value!=document.myform.UserPassword.value) 
	 {
	     alert("Confirm Password must be the same with New Password!");
	     document.myform.ConfirmPassword.focus();
	     return;
	 }
	if (isWhitespace(document.myform.UserEmail.value)) 	{
			alert("Please enter Email Address");
			document.myform.UserEmail.focus();
	     return;
	}	
	document.myform.UserEmail.value = NonSpace(document.myform.UserEmail.value);
	if (isEmail(document.myform.UserEmail.value)==false) {
			alert("Please enter a valid E-Mail address, like: name@companyname.com ");
			document.myform.UserEmail.focus();
	     return;
	}
	     document.myform.submit();
}




//____________________________________________________________________________________
//_____________     ValidContact      _________________________________________________________

function ValidContact() {

	if (isWhitespace(document.myform.lname.value)) {
	     alert("Please enter Last Name! ");
	     document.myform.lname.focus();
	     return false;
	}  
	if (document.myform.phone.value !="" && !checkUSPhone(document.myform.phone)) {
		document.myform.phone.focus();
		return false;
	}
	if (isWhitespace(document.myform.phone.value)) {
		if (isWhitespace(document.myform.email.value)) {
			alert("Please enter Phone or Email! ");
			document.myform.phone.focus();
			return false;
	     }
	}  	
	if (document.myform.email.value.length>0){ 
	document.myform.email.value = NonSpace(document.myform.email.value);
	if (isEmail(document.myform.email.value)==false) {
			alert("Please enter a valid Email address, like: name@companyname.com! ");
			document.myform.email.focus();
			return false;
	}  
	}
	if (isWhitespace(document.myform.comments.value)) {
	     alert("Please enter Comments! ");
	     document.myform.comments.focus();
	     return false;
	}  
	 return true;
}


//____________________________________________________________________________________
//_____________     ValidContact      _________________________________________________________

function ValidCC() {
	if ( (document.myform.card_cardType.options[document.myform.card_cardType.options.selectedIndex].value)=="0")	{
	     alert("Please enter Credit Card Type! ");
		 document.myform.card_cardType.focus();
	     return false;
	}  
	if (isWhitespace(document.myform.card_accountNumber.value)) {
	     alert("Please enter Credit Card Number! ");
	     document.myform.card_accountNumber.focus();
	     return false;
	}  
	if ( (document.myform.card_expirationMonth.options[document.myform.card_expirationMonth.options.selectedIndex].value)=="0")	{
	     alert("Please enter Credit Card Expiration Month! ");
		 document.myform.card_expirationMonth.focus();
	     return false;
	}  
	if ( (document.myform.card_expirationYear.options[document.myform.card_expirationYear.options.selectedIndex].value)=="0")	{
	     alert("Please enter Credit Card Expiration Year! ");
		 document.myform.card_expirationYear.focus();
	     return false;
	} 
 return true;
}


//____________________________________________________________________________________
//_____________     ValidSignNews      _________________________________________________________

function ValidSignNews() {
	if (isWhitespace(document.signinform.signintext.value)) 	{
	     alert("Please enter Email! ");
	     document.signinform.signintext.focus();
	     return false;
	}  
	if (document.signinform.signintext.value.length>0){ 
	document.signinform.signintext.value = NonSpace(document.signinform.signintext.value);
	if (isEmail(document.signinform.signintext.value)==false) {
			alert("Please enter a valid Email address, like: name@companyname.com! ");
			document.signinform.signintext.focus();
			return false;
	}  
	}
	 return true;
}




//____________________________________________________________________________________
//_____________     ValidRegister      _________________________________________________________

function ValidRegister() {

	if (isWhitespace(document.myform.UserFirstName.value)) {
	     alert("Please enter First Name! ");
	     document.myform.UserFirstName.focus();
		return;
	}  
	if (isWhitespace(document.myform.UserLastName.value)) {
	     alert("Please enter Last Name! ");
	     document.myform.UserLastName.focus();
		return;
	}  
	if (isWhitespace(document.myform.UserChurch.value)) {
	     alert("Please enter Church Name! ");
	     document.myform.UserChurch.focus();
		return;
	} 
	if (isWhitespace(document.myform.UserPhone.value)) 	{
	     alert("Please enter Phone! ");
	     document.myform.UserPhone.focus();
		return;
	}  
	if (document.myform.UserPhone.value !="" && !checkUSPhone(document.myform.UserPhone)) {
		document.myform.UserPhone.focus();
		return;
	}
	if (!(isWhitespace(document.myform.UserFax.value))) 	{
		if (document.myform.UserFax.value !="" && !checkUSPhone(document.myform.UserFax)) {
			document.myform.UserFax.focus();
		return;
		}
	}  
	if (isWhitespace(document.myform.UserEmail.value)) 	{
	     alert("Please enter Email! ");
	     document.myform.UserEmail.focus();
		return;
	}  
	if (document.myform.UserEmail.value.length>0){ 
	document.myform.UserEmail.value = NonSpace(document.myform.UserEmail.value);
	if (isEmail(document.myform.UserEmail.value)==false) {
			alert("Please enter a valid Email address, like: name@companyname.com! ");
			document.myform.UserEmail.focus();
		return;
	}  
	}
	if (isWhitespace(document.myform.UserName.value)) {
	     alert("Please enter User Name! ");
	     document.myform.UserName.focus();
		return;
	}  
	if (isWhitespace(document.myform.UserPassword.value)) {
	     alert("Please enter Password! ");
	     document.myform.UserPassword.focus();
		return;
	}  
	 if (document.myform.UserPassword.value.length < 5) {
	     alert("The Minimum length for Password should be 5!");
	     document.myform.UserPassword.focus();
		return;
	 }
	if (isWhitespace(document.myform.Password.value)) {
	     alert("Please Confirm Password! ");
	     document.myform.Password.focus();
		return;
	}  
	if (document.myform.Password.value!=document.myform.UserPassword.value) {
	     alert("Password doesn't match! ");
	     document.myform.Password.focus();
		return;
	}  
	if (isWhitespace(document.myform.AddAddress.value)) {
	     alert("Please enter Address!");
	     document.myform.AddAddress.focus();
		return;
	}  
	if (isWhitespace(document.myform.AddCity.value)) {
	     alert("Please enter City!");
	     document.myform.AddCity.focus();
		return;
	}  
	if (isWhitespace(document.myform.AddZip.value)) {
	     alert("Please enter Zip!");
	     document.myform.AddZip.focus();
		return;
	}  
	if ( (document.myform.AddCountryID.options[document.myform.AddCountryID.options.selectedIndex].value)=="220")	{
		if ( (document.myform.AddStateID.options[document.myform.AddStateID.options.selectedIndex].value)=="0")	{
			alert("Please enter State!");
			document.myform.AddStateID.focus();
		return;
		}  
	}			
	 if (validateZIP(document.myform.AddZip)==false) {
				document.myform.AddZip.focus();
		return;
	} 
	if (myform.AddPhone1.value !="" && !checkUSPhone(myform.AddPhone1)) {
		myform.AddPhone1.focus();
		return;
	}
	if (myform.AddPhone2.value !="" && !checkUSPhone(myform.AddPhone2)) {
		myform.AddPhone2.focus();
		return;
	}
	if (document.myform.AddEmail.value.length>0){ 
	document.myform.AddEmail.value = NonSpace(document.myform.AddEmail.value);
	if (isEmail(document.myform.AddEmail.value)==false) {
			alert("Please enter a valid Email address, like: name@companyname.com! ");
			document.myform.AddEmail.focus();
		return;
	}  
	}
	
	  document.myform.submit();
}



//____________________________________________________________________________________
//_____________     ValidShipping      _________________________________________________________

function ValidShipping() {
	if (isWhitespace(document.myform.AddAddress.value)) {
	     alert("Please enter Address!");
	     document.myform.AddAddress.focus();
	     return false;
	}  
	if (isWhitespace(document.myform.AddCity.value)) {
	     alert("Please enter City!");
	     document.myform.AddCity.focus();
	     return false;
	}  
	if (isWhitespace(document.myform.AddZip.value)) {
	     alert("Please enter Zip!");
	     document.myform.AddZip.focus();
	     return false;
	}  
	if ( (document.myform.AddCountryID.options[document.myform.AddCountryID.options.selectedIndex].value)=="220")	{
		if ( (document.myform.AddStateID.options[document.myform.AddStateID.options.selectedIndex].value)=="0")	{
			alert("Please enter State!");
			document.myform.AddStateID.focus();
	     return false;
		}  
	}			
	 if (validateZIP(document.myform.AddZip)==false) {
				document.myform.AddZip.focus();
	     return false;
	} 
	if (myform.AddPhone1.value !="" && !checkUSPhone(myform.AddPhone1)) {
		myform.AddPhone1.focus();
	     return false;
	}
	if (myform.AddPhone2.value !="" && !checkUSPhone(myform.AddPhone2)) {
		myform.AddPhone2.focus();
	     return false;
	}
	if (document.myform.AddEmail.value.length>0){ 
	document.myform.AddEmail.value = NonSpace(document.myform.AddEmail.value);
	if (isEmail(document.myform.AddEmail.value)==false) {
			alert("Please enter a valid Email address, like: name@companyname.com! ");
			document.myform.AddEmail.focus();
	     return false;
	}  
	}	
	 return true;
}



//________________________________________________________________________________________________
//_____________________      NonSpace     _____________________________________________________________

function NonSpace(field) {

	var xpos =0;
	var xlen =field.length;
	var xpos1 =0;
	var xpos2 =xlen;

	for (var i=0; i < xlen; i++) {
		temp = "" + field.substring(i, i+1);
		if (temp == " ") {xpos++;}
		else {var xpos1=xpos;break;  }
	}
	field = field.substring(xpos1, xlen)
	var xlen1 = field.length;

	for (var i=0; i < xlen1; i++) {
		temp = "" + field.substring(i, i+1);
		if (temp != " ") {xpos1++;}
		else {xpos2=i;break;  }
	}
	field = field.substring(0, xpos2)
	return field;
}


//________________________________________________________________________________________________
//_____________________      isEmail     _____________________________________________________________

function isEmail(string) {
    if (string.search(/^\w+((-\w+)|(\.\w+))*\@[A-Za-z0-9]+((\.|-)[A-Za-z0-9]+)*\.[A-Za-z0-9]+$/) != -1)
        return true;
    else
        return false;
}




//________________________________________________________________________________________________
//_____________________      IsPhone     _____________________________________________________________

function IsPhone(str)          // is phone str valid
    {
    if (str.length != 12) 
              // nope - wrong str length
		{
		alert('Invalid PhoneNo. Must be in the form NNN-NNN-NNNN.');
		return false;
	}		
  for (i=0; i<12; i++)
    {
    if (i == 3 || i == 7)
    {
      if (str.charAt(i) != "-")     // nope - "-" missing
			{
			alert(' Missing - . PhoneNo  must be in the form NNN-NNN-NNNN.');
			return false;
			}
	}		
	else
    {
      if (!isNum(str.charAt(i)))
		{
		alert('Non-numeric characters. PhoneNo must be in the form NNN-NNN-NNNN.');
		return false;
		}
	}		
  }
  return true;                     

}



//________________________________________________________________________________________________
//_____________________      IsFax     _____________________________________________________________

function IsFax(str)          // is Fax str valid
    {
    if (str.length != 12) 
              // nope - wrong str length
		{
		alert('Invalid FaxNo. Must be in the form NNN-NNN-NNNN.');
		return false;
	}		
  for (i=0; i<12; i++)
    {
    if (i == 3 || i == 7)
    {
      if (str.charAt(i) != "-")     // nope - "-" missing
			{
			alert(' Missing - . FaxNo  must be in the form NNN-NNN-NNNN.');
			return false;
			}
	}		
	else
    {
      if (!isNum(str.charAt(i)))
		{
		alert('Non-numeric characters. FaxNo must be in the form NNN-NNN-NNNN.');
		return false;
		}
	}		
  }
  return true;                     

}



//________________________________________________________________________________________________
//_____________________      validateZIP     _____________________________________________________________

function validateZIP(field) {
var valid = "0123456789-";
var hyphencount = 0;

if (field.value.length!=5 && field.value.length!=10) {
alert("Please enter your 5 digit or ( 5 + 4 ) digit  ZIP  code.");
return false;
}
for (var i=0; i < field.value.length; i++) {
temp = "" + field.value.substring(i, i+1);
if (temp == "-") hyphencount++;
if (valid.indexOf(temp) == "-1") {
alert("Invalid characters in your ZIP code.  Please try again.");
return false;
}
if ((hyphencount > 1) || ((field.value.length==10) && ""+field.value.charAt(5)!="-")) {
alert("The hyphen character should be used with a properly formatted 5 digit+four  ZIP  code, like '12345-6789'.   Please try again.");
return false;
   }
}
return true;
}


//________________________________________________________________________________________________
//_____________________      isNum     _____________________________________________________________

function isNum(chr)            // is character a number?
  {
  if (chr < "0" || chr > "9")  // nope
    return false;
  else                         // yep
    return true;
  }


//________________________________________________________________________________________________
//_____________________      isNumber19     _____________________________________________________________

function isNumber19(InString)  {
        RefString="123456789";

        for (Count=0; Count < InString.length; Count++)  {
            TempChar= InString.substring (Count, Count+1);
            if (RefString.indexOf (TempChar, 0)==-1) { 
				alert("Please enter numbers only: 1 - 9 ");
				return false;
			}
		}
        return true;
}


//________________________________________________________________________________________________
//_____________________      isNumber09     _____________________________________________________________

function isNumber09(InString)  {
        RefString="0123456789";

        for (Count=0; Count < InString.length; Count++)  {
            TempChar= InString.substring (Count, Count+1);
            if (RefString.indexOf (TempChar, 0)==-1) { 
				alert("Please enter numbers only: 0 - 9 ");
				return false;
			}
		}
        return true;
}

//________________________________________________________________________________________________
//_____________________      isNumberZip     _____________________________________________________________

function isNumberZip(InString)  {
        RefString="0123456789-";

        for (Count=0; Count < InString.length; Count++)  {
            TempChar= InString.substring (Count, Count+1);
            if (RefString.indexOf (TempChar, 0)==-1) { 
				alert("Please enter a valid Zip Code! ");
				return false;
			}
		}
        return true;
}


//________________________________________________________________________________________________
//_____________________      ValidPercent     _____________________________________________________________

function ValidPercent(field)  {
        RefString="0123456789.";
        for (Count=0; Count < field.length; Count++)  {
            TempChar= field.substring (Count, Count+1);
            if (RefString.indexOf (TempChar, 0)==-1) { 
						alert ("Please enter a valid percent (99.99 or a number <=100) !");
				return false;
			}
		}
		
	var xpos =0;
	var xlen =field.length;
	for (var i=0; i < xlen ; i++) {
		temp = field.substring(i, i+1);
		if (temp == ".") {xpos=i;}
	}

	if (xpos == 0) {var per=field;}
	else {var per =field.substring(0,xpos);}
	if (per > 100) {
			alert ("Please enter a valid percent (99.99 or a number <=100) !");
			return false; }
	else
		{ return true;}

}



//________________________________________________________________________________________________
//_____________________      getExtension     _____________________________________________________________

function getExtension(field) {
	var xpos =0;
	var xlen =field.length;
	for (var i=xlen; i > 0 ; i--) {
		temp = "" + field.substring(i, i-1);
		if (temp != ".") {xpos--;}
			else {break;
		}
	}
	var myext =field.substring(xlen+xpos, xlen).toLowerCase();
		if ((myext != "gif") && (myext != "jpg") && (myext != "jpeg") && (myext != "bmp") && (myext != "jpe") && (myext != "swf")){
				alert ("Please Upload an Image with GIF,JPEG,JPE,JPG,BMP or SWF extension !");
		return false; }
		else
		{ return true;}

}





//________________________________________________________________________________________________
//_____________________      warnEmpty     _____________________________________________________________
var reWhitespace = /^\s+$/
// warnEmpty (theField, s)             Notify user that required field theField is empty.


// Notify user that required field theField is empty.
// String s describes expected contents of theField.value.
// Put focus in theField and return false.

function warnEmpty (theField, s)
{   theField.focus()
    alert(mPrefix + s + mSuffix)
    return false
}


//________________________________________________________________________________________________
//_____________________      isEmpty     _____________________________________________________________
function isEmpty(s)
{   return ((s == null) || (s.length == 0))
}



//________________________________________________________________________________________________
//_____________________      isWhitespace     _____________________________________________________________

function isWhitespace (s)

{   // Is s empty?
//    return (isEmpty(s));
    return (isEmpty(s) || reWhitespace.test(s));
}



//________________________________________________________________________________________________
//_____________________      goRefresh     _____________________________________________________________

function goRefresh(url)   
{
		document.forms[0].sCMD.value = "";
		document.forms[0].action = url;
		document.forms[0].submit();
}


//________________________________________________________________________________________________
//_____________________      goSubmMS     _____________________________________________________________

function goSubmMS(url,TopicID,searchinput,page,groupCrt){
		document.myform.TopicID.value = TopicID;
		document.myform.searchinput.value = searchinput;
		document.myform.groupCrt.value = groupCrt;
		document.myform.page.value = page;
		document.myform.action = url;
}



//________________________________________________________________________________________________
//_____________________      goDel     _____________________________________________________________

function goDel(url,ID) {
	if (confirm("This Record will be deleted! Are you sure !?"))
		{
		document.myform.sCMD.value = "del";
		document.myform.ID.value = ID;
		document.myform.action = url;
		document.myform.submit();
		}
}



//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//~~~~~~~     goMod      ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

function goMod(url,ID)   
{
		document.myform.sCMD.value = "edit";
		document.myform.action = url;
		document.myform.ID.value = ID;
		document.myform.submit();
}


//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//~~~~~~~     goAdd      ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

function goAdd(url)   
{

		document.forms[0].sCMD.value = "add";
		document.forms[0].ID.value = "";
		document.forms[0].action = url;
		document.forms[0].submit();
}



//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//~~~~~~~     goSort      ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

function goSort(url,sSortBy,sSortOrd)
{
//		document.forms[0].sCMD.value = "sort";
		document.forms[0].action = url;
		document.forms[0].SortBy.value  = sSortBy;
		document.forms[0].SortOrd.value = sSortOrd;
		document.forms[0].submit( );
}


//~~~~~~~     goSubmit      ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

function goSubmit(url){
		document.myform.action = url;
		document.myform.submit();
}

//________________________________________________________________________________________________
//_____________________      goBasketUpd     _____________________________________________________________

function goBasketUpd(CMD,BasketID,ID,F5AdminInput){
		document.myform.sCMD.value = CMD;
		document.myform.BasketID.value = BasketID;
//		document.myform.tmpBasketID.value = BasketID;
		document.myform.ProductID.value = ID;
		document.myform.F5AdminInput.value = F5AdminInput;
		document.myform.action = "Basket.asp";
//		document.myform.submit();
}


//________________________________________________________________________________________________
//_____________________      goBasketDel    _____________________________________________________________

function goBasketDel(CMD,BasketID,ID,F5AdminInput){
	if (confirm("This Experience will be deleted from your Cart! Are you sure !?")){

		document.myform.sCMD.value = CMD;
		document.myform.BasketID.value = BasketID;
//		document.myform.tmpBasketID.value = BasketID;
		document.myform.ProductID.value = ID;
		document.myform.F5AdminInput.value = F5AdminInput;
		document.myform.action = "Basket.asp";
		document.myform.submit();
		}
}



//________________________________________________________________________________________________
//_____________________      goBasketDelCD    _____________________________________________________________

function goBasketDelCD(UserID,BasketID,F5AdminInput){
	if (confirm("The CD will be deleted from your Cart! Are you sure !?")){
		document.myform.sCMD.value = "delcd";
		document.myform.UserID.value = UserID;
		document.myform.BasketID.value = BasketID;
		document.myform.F5AdminInput.value = F5AdminInput;
		document.myform.action = "Basket.asp";
		document.myform.submit();
		}
}


//________________________________________________________________________________________________
//_____________________      goBasketAdd     _____________________________________________________________

function goBasketAdd(ID,F5AdminInput){
		document.myform.sCMD.value = "add";
		document.myform.ProductID.value = ID;
		document.myform.Quantity.value =1;
		document.myform.F5AdminInput.value = F5AdminInput;
		document.myform.action = "Basket.asp";
		document.myform.submit();
}



function Start(page) {
	OpenWin = this.open(page, "CtrlWindow", "toolbar=no,menubar=no,location=no,scrollbars=yes,resizable=yes,width=550,height=250,top=50,left=50");
}


function submitonce(theform) {
	// if IE 4+ or NS 6+
	if (document.all || document.getElementById) {
		// hunt down "submit" and "reset"
		for (i=0;i<theform.length;i++) {
			var tempobj=theform.elements[i];
			if(tempobj.type.toLowerCase()=="submit"||tempobj.type.toLowerCase()=="reset") {
				//disable it
				tempobj.disabled=true;
			}
		}
	}
}



function Valid_Date(datein){
        
        var indate=datein;
        if (indate.indexOf("-")!=-1){
                var sdate = indate.split("-")
        }
        else {
                var sdate = indate.split("/")
        }
        var chkDate=new Date(Date.parse(indate))
        var cmpDate=(chkDate.getMonth()+1)+"/"+(chkDate.getDate())+"/"+(chkDate.getFullYear())
        var indate2=(Math.abs(sdate[0]))+"/"+(Math.abs(sdate[1]))+"/"+(Math.abs(sdate[2]))

		if ((chkDate.getFullYear() > 3000)||(chkDate.getFullYear() < 1900)) {
                alert("You've entered an invalid year");
				return false;
		}				
		if ((Math.abs(sdate[2]) > 3000)||(Math.abs(sdate[2])< 1900)) {
                alert("You've entered an invalid year");
				return false;
		}				


   if (indate2=="0/NaN/NaN"){
				return true;
   }        
	else {
 		
        if (indate2!=cmpDate){
                alert("You've entered an invalid date or date format.  Please use the MM/DD/YYYY format.");
				return false;
        }
        else {
                if (cmpDate=="NaN/NaN/NaN"){
                        alert("You've entered an invalid date or date format. Please use the MM/DD/YYYY format.");
						return false;
                }
                else {
						return true;
                }       
        }
}        
}


//---------------- valid phone ----------------
// VARIABLE DECLARATIONS

var digits = "0123456789";

// whitespace characters
var whitespace = " \t\n\r";

// decimal point character differs by language and culture
var decimalPointDelimiter = "."

// non-digit characters which are allowed in phone numbers
var phoneNumberDelimiters = "()-./ ";

// characters which are allowed in US phone numbers
var validUSPhoneChars = digits + phoneNumberDelimiters;

// U.S. phone numbers have 10 digits.
// They are formatted as 123-456-7890 or (123) 456-7890.
var digitsInUSPhoneNumber = 10;

// CONSTANT STRING DECLARATIONS

// m = "missing"

var mPrefix = "You did not enter a value into the "
var mSuffix = " field. This is a required field. Please enter it now."

// s --- "string"

var sPhone = "Phone Number"

// i is an abbreviation for "invalid"
var iUSPhone = "This field must be a 10 digit U.S. phone number (like 415-555-1212). Please reenter it now."
// p is an abbreviation for "prompt"
var pEntryPrompt = "Please enter a "
var pUSPhone = "10 digit U.S. phone number (like 415-555-1212)."
var defaultEmptyOK = false
// Check whether string s is empty.

function isEmpty(s)
{   return ((s == null) || (s.length == 0))
}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 isDigit (c)
{   return ((c >= "0") && (c <= "9"))
}
function isInteger (s)

{   var i;

    if (isEmpty(s)) 
       if (isInteger.arguments.length == 1) return defaultEmptyOK;
       else return (isInteger.arguments[1] == true);

    // Search through string's characters one by one
    // until we find a non-numeric character.
    // When we do, return false; if we don't, return true.

    for (i = 0; i < s.length; i++)
    {   
        // Check that current character is number.
        var c = s.charAt(i);

        if (!isDigit(c)) return false;
    }

    // All characters are numbers.
    return true;
}
function reformat (s)

{   var arg;
    var sPos = 0;
    var resultString = "";

    for (var i = 1; i < reformat.arguments.length; i++) {
       arg = reformat.arguments[i];
       if (i % 2 == 1) resultString += arg;
       else {
           resultString += s.substring(sPos, sPos + arg);
           sPos += arg;
       }
    }
    return resultString;
}


function isUSPhoneNumber (s)
{   if (isEmpty(s)) 
       if (isUSPhoneNumber.arguments.length == 1) return defaultEmptyOK;
       else return (isUSPhoneNumber.arguments[1] == true);
    return (isInteger(s) && s.length == digitsInUSPhoneNumber)
}

// Notify user that contents of field theField are invalid.
// String s describes expected contents of theField.value.
// Put select theField, pu focus in it, and return false.

function warnInvalid (theField, s)
{   theField.focus()
    theField.select()
    alert(s)
    return false
}

function reformatUSPhone (USPhone)
{   return (reformat (USPhone, "", 3, "-", 3, "-", 4))
}


function checkUSPhone (theField, emptyOK)
{   if (checkUSPhone.arguments.length == 1) emptyOK = defaultEmptyOK;
    if ((emptyOK == true) && (isEmpty(theField.value))) return true;
    else
    {  var normalizedPhone = stripCharsInBag(theField.value, phoneNumberDelimiters)
       if (!isUSPhoneNumber(normalizedPhone, false)) 
          return warnInvalid (theField, iUSPhone);
       else 
       {  // if you don't want to reformat as (123) 456-789, comment next line out
          theField.value = reformatUSPhone(normalizedPhone)
          return true;
       }
    }
}


//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~


function checkDim1(loc) {
	loc = "../include/Images1.htm?" + loc;
	windowprops = 'menubar=0,toolbar=0,status=0,location=0,width=500,height=500';
	popupWindow = open(loc, 'previewWin', windowprops);
	if (popupWindow.opener == null) 
	popupWindow.opener = self;
}

function checkDim2(loc) {
	loc = "../include/Images2.htm?" + loc;
	windowprops = 'menubar=0,toolbar=0,status=0,location=0,width=500,height=500';
	popupWindow = open(loc, 'previewWin', windowprops);
	if (popupWindow.opener == null) 
	popupWindow.opener = self;
}

function checkDim3(loc) {
	loc = "../include/Images3.htm?" + loc;
	windowprops = 'menubar=0,toolbar=0,status=0,location=0,width=500,height=500';
	popupWindow = open(loc, 'previewWin', windowprops);
	if (popupWindow.opener == null) 
	popupWindow.opener = self;
}




function checkImage(loc) {
	loc = "../include/image-popup.html?" + loc;
	windowprops = 'menubar=0,toolbar=0,status=0,location=0';
	popupWindow = open(loc, 'previewWin', windowprops);
	if (popupWindow.opener == null) 
	popupWindow.opener = self;
}

function checkImageSm(loc) {
	loc = "../include/image-popupSm.html?" + loc;
	windowprops = 'menubar=0,toolbar=0,status=0,location=0';
	popupWindow = open(loc, 'previewWin', windowprops);
	if (popupWindow.opener == null) 
	popupWindow.opener = self;
}

function isInt(chr)           
{
	if (isNaN(chr))
	{return false; }
	else
	  {
		if (chr>0)
		{ return true;	}
		else
		  { return false; }	  
	   }
}


//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~//~~~~~~~     isZip      ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~function validZIP(field) {	var valid = "0123456789-";	var hyphencount = 0;	if (field.length!=5 && field.length!=10) {		alert("Please enter your 5 digit or 5 digit+4 zip code.");		return false;	}	for (var i=0; i < field.length; i++) {		temp = "" + field.substring(i, i+1);		if (temp == "-") hyphencount++;			if (valid.indexOf(temp) == "-1") {				alert("Invalid characters in your zip code.  Please try again.");		return false;	}	if ((hyphencount > 1) || ((field.length==10) && ""+field.charAt(5)!="-")) {		alert("The hyphen character should be used with a properly formatted 5 digit+four zip code, like '12345-6789'.   Please try again.");		return false;	}}return true;}  
function Open(page) {
	OpenWin = this.open(page, "CtrlWindow", "toolbar=no,menubar=no,location=no,scrollbars=yes,resizable=yes,width=500,height=450,top=10,left=10");
	return true;
}
