
function showHidetext(box,id)  {  
var elm = document.getElementById('mytext')  
elm.style.display = box.checked? "none":"inline" 
}

function validShopReg(){

if (isWhitespace(document.myform.bill_first_name.value)) 
	{
	     alert("Please enter First Name  ");
	     document.myform.bill_first_name.focus();
	     return false;
	}  

if (isWhitespace(document.myform.bill_last_name.value)) 
	{
	     alert("Please enter Last Name  ");
	     document.myform.bill_last_name.focus();
	     return false;
	}  
	
if (isWhitespace(document.myform.bill_address1.value)) 
	{
	     alert("Please enter Address  ");
	     document.myform.bill_address1.focus();
	     return false;
	}  

if (document.myform.bill_address1.value.length <3) 
	{
			alert("Please enter valid Address ");
			document.myform.bill_address1.focus();
			return false;
	}	
	
if (isWhitespace(document.myform.bill_city.value)) 
	{
	     alert("Please enter City  ");
	     document.myform.bill_city.focus();
	     return false;
	} 
	
if ( (document.myform.bill_country.options[document.myform.bill_country.options.selectedIndex].value) == 0)
	{
			alert("Please enter Billing Country");
			document.myform.bill_country.focus();
			return false;
	}	
	
if (((document.myform.bill_country.options[document.myform.bill_country.options.selectedIndex].value) != 183) &&  ((document.myform.bill_country.options[document.myform.bill_country.options.selectedIndex].value) != 31))
	{
	 if(isWhitespace(document.myform.bill_state_prov.value)){
		alert("Please enter Billing State/Province");
		document.myform.bill_state_prov.focus();
		return false;
		}
	}	



	if ((((document.myform.bill_country.options[document.myform.bill_country.options.selectedIndex].value) == 183) || ((document.myform.bill_country.options[document.myform.bill_country.options.selectedIndex].value) == 31)) && ((document.myform.bill_state_prov.options[document.myform.bill_state_prov.options.selectedIndex].value) == 0))
	{ 
			alert("Please enter Billing State/Province");	
			document.myform.bill_state_prov.focus();
			return false;
	}

if (isWhitespace(document.myform.bill_zip.value)) 
	{
	     alert("Please enter Zip  ");
	     document.myform.bill_zip.focus();
	     return false;
	} 
//--if us check format--
if((document.myform.bill_country.options[document.myform.bill_country.options.selectedIndex].value) == 183){	
if (validateZIP(document.myform.bill_zip) == false ) {
	document.myform.bill_zip.focus();
	return false;
	} 
 }
//--check us phone
//if (isWhitespace(document.myform.bill_phone.value)) 
//	{
//	alert("Please enter Phone  ");
//	document.myform.bill_phone.focus();
//	return false;
//	}
//--if us check format--
//if((document.myform.bill_country.options[document.myform.bill_country.options.selectedIndex].value) == 183){	
//if (IsPhone(document.myform.bill_phone.value) == false ) {
//	document.myform.bill_phone.focus();
//	return false;
//	} 
// }
//--check billing email
if (isWhitespace(document.myform.bill_email.value)) 
	{
	     alert("Please enter Email");
	     document.myform.bill_email.focus();
	     return false;
	}  	
	
	if (document.myform.bill_email.value.length>0){ 
	document.myform.bill_email.value = NonSpace(document.myform.bill_email.value);
	if (isEmail(document.myform.bill_email.value)==false) {
			alert("Please enter a valid E-Mail address, like: name@companyname.com ");
			document.myform.bill_email.focus();
			return false;
	}
	}
//shipping--	
if (isWhitespace(document.myform.ship_first_name.value)) 
	{
	     alert("Please enter First Name  ");
	     document.myform.ship_first_name.focus();
	     return false;
	}  

if (isWhitespace(document.myform.ship_last_name.value)) 
	{
	     alert("Please enter Last Name  ");
	     document.myform.ship_last_name.focus();
	     return false;
	}  
	
if (isWhitespace(document.myform.ship_address1.value)) 
	{
	     alert("Please enter Address  ");
	     document.myform.ship_address1.focus();
	     return false;
	}  

if (document.myform.ship_address1.value.length <3) 
	{
			alert("Please enter valid Address ");
			document.myform.ship_address1.focus();
			return false;
	}	
	
if (isWhitespace(document.myform.ship_city.value)) 
	{
	     alert("Please enter City  ");
	     document.myform.ship_city.focus();
	     return false;
	} 
	
if ( (document.myform.ship_country.options[document.myform.ship_country.options.selectedIndex].value) == 0)
	{
			alert("Please enter Shipping Country");
			document.myform.ship_country.focus();
			return false;
	}	

if ( (document.myform.ship_continent.options[document.myform.ship_continent.options.selectedIndex].value) == 0)
	{
			alert("Please enter Shipping Continent");
			document.myform.ship_continent.focus();
			return false;
	}		
	
if ((((document.myform.ship_country.options[document.myform.ship_country.options.selectedIndex].value) != 183) &&  ((document.myform.ship_country.options[document.myform.ship_country.options.selectedIndex].value) != 31)) && (isWhitespace(document.myform.ship_state_prov.value)))
	{
		alert("Please enter Shipping State/Province");
		document.myform.ship_state_prov.focus();
		return false;
	}	

if ((((document.myform.ship_country.options[document.myform.ship_country.options.selectedIndex].value) ==183) || ((document.myform.ship_country.options[document.myform.ship_country.options.selectedIndex].value) == 31)) && ((document.myform.ship_state_prov.options[document.myform.ship_state_prov.options.selectedIndex].value) == 0))
	{ 
			alert("Please enter Shipping State/Province");	
			document.myform.ship_state_prov.focus();
			return false;
	}
	
if (isWhitespace(document.myform.ship_zip.value)) 
	{
	     alert("Please enter Zip  ");
	     document.myform.ship_zip.focus();
	     return false;
	} 
//--if us check format--
if((document.myform.ship_country.options[document.myform.ship_country.options.selectedIndex].value) == 183){	
if (validateZIP(document.myform.ship_zip) == false ) {
	document.myform.ship_zip.focus();
	return false;
	} 
 }
//if (isWhitespace(document.myform.ship_phone.value)) 
//	{
//	     alert("Please enter Phone  ");
//	     document.myform.ship_phone.focus();
//	     return false;
//	} 	
//--if us check format--
//if((document.myform.ship_country.options[document.myform.ship_country.options.selectedIndex].value) == 183){	
//if (IsPhone(document.myform.ship_phone.value)==false) {
//	document.myform.ship_phone.focus();
//	return false;
//	} 
// }
//---cc 
if (document.myform.pay_paypal.checked){
}else{
if (isWhitespace(document.myform.credit_type.value))
	{
	     alert("Please enter Credit Type  ");
	     document.myform.credit_type.focus();
	     return false;
	} 	
	
if (isWhitespace(document.myform.credit_number.value)) 
	{
	     alert("Please enter Credit Number  ");
	     document.myform.credit_number.focus();
	     return false;
	} 	
	
if	((document.myform.credit_exp_month.options[document.myform.credit_exp_month.options.selectedIndex].value) == 0)
	{
 		 alert("Please enter Credit Date Month ");
	     document.myform.credit_exp_month.focus();
	     return false;
	}

if	((document.myform.credit_exp_year.options[document.myform.credit_exp_year.options.selectedIndex].value) == 0)
	{
 		 alert("Please enter Credit Date Year ");
	     document.myform.credit_exp_month.focus();
	     return false;
	}
}//end of paypal check
	
}

//--check valid donate
function validDonateReg(){

if (isWhitespace(document.myform.bill_first_name.value)) 
	{
	     alert("Please enter First Name  ");
	     document.myform.bill_first_name.focus();
	     return false;
	}  

if (isWhitespace(document.myform.bill_last_name.value)) 
	{
	     alert("Please enter Last Name  ");
	     document.myform.bill_last_name.focus();
	     return false;
	}  
	
if (isWhitespace(document.myform.bill_address1.value)) 
	{
	     alert("Please enter Address  ");
	     document.myform.bill_address1.focus();
	     return false;
	}  

if (document.myform.bill_address1.value.length <3) 
	{
			alert("Please enter valid Address ");
			document.myform.bill_address1.focus();
			return false;
	}	
	
if (isWhitespace(document.myform.bill_city.value)) 
	{
	     alert("Please enter City  ");
	     document.myform.bill_city.focus();
	     return false;
	} 
	
if ( (document.myform.bill_country.options[document.myform.bill_country.options.selectedIndex].value) == 0)
	{
			alert("Please enter Billing Country");
			document.myform.bill_country.focus();
			return false;
	}	
	
if (((document.myform.bill_country.options[document.myform.bill_country.options.selectedIndex].value) != 183) &&  ((document.myform.bill_country.options[document.myform.bill_country.options.selectedIndex].value) != 31))
	{
	 if(isWhitespace(document.myform.bill_state_prov.value)){
		alert("Please enter Billing State/Province");
		document.myform.bill_state_prov.focus();
		return false;
		}
	}	



	if ((((document.myform.bill_country.options[document.myform.bill_country.options.selectedIndex].value) == 183) || ((document.myform.bill_country.options[document.myform.bill_country.options.selectedIndex].value) == 31)) && ((document.myform.bill_state_prov.options[document.myform.bill_state_prov.options.selectedIndex].value) == 0))
	{ 
			alert("Please enter Billing State/Province");	
			document.myform.bill_state_prov.focus();
			return false;
	}

if (isWhitespace(document.myform.bill_zip.value)) 
	{
	     alert("Please enter Zip  ");
	     document.myform.bill_zip.focus();
	     return false;
	} 
//--if us check format--
if((document.myform.bill_country.options[document.myform.bill_country.options.selectedIndex].value) == 183){	
if (validateZIP(document.myform.bill_zip) == false ) {
	document.myform.bill_zip.focus();
	return false;
	} 
 }
//--check us phone
//if (isWhitespace(document.myform.bill_phone.value)) 
//	{
//	alert("Please enter Phone  ");
//	document.myform.bill_phone.focus();
//	return false;
//	}
//--if us check format--
//if((document.myform.bill_country.options[document.myform.bill_country.options.selectedIndex].value) == 183){	
//if (IsPhone(document.myform.bill_phone.value) == false ) {
//	document.myform.bill_phone.focus();
//	return false;
//	} 
// }
//--check billing email
if (isWhitespace(document.myform.bill_email.value)) 
	{
	     alert("Please enter Email");
	     document.myform.bill_email.focus();
	     return false;
	}  	
	
	if (document.myform.bill_email.value.length>0){ 
	document.myform.bill_email.value = NonSpace(document.myform.bill_email.value);
	if (isEmail(document.myform.bill_email.value)==false) {
			alert("Please enter a valid E-Mail address, like: name@companyname.com ");
			document.myform.bill_email.focus();
			return false;
	}
	}
if (isWhitespace(document.myform.donate_total.value)) 
	{
	alert("Please enter Amount ");
	document.myform.donate_total.focus();
    return false;
	}
if (document.myform.donate_total.value<=0) 
	{
	alert("Please enter Amount ");
	document.myform.donate_total.focus();
    return false;
	}	
if (IsNumeric(document.myform.donate_total.value)==false) 
	{
	alert("Please enter Amount ");
	document.myform.donate_total.focus();
    return false;
	}	

}


//---dynamic java menu
function popSecondBill()
{
	var secBox,billstateprov,objvalue;
	var obj = document.myform.bill_country;
	objvalue = obj.options[obj.selectedIndex].value;
	if(objvalue)
	{
		if(objvalue == 183){
			secBox = "Select an option,Alabama,Alaska,Arizona,Arkansas,California,Colorado,Connecticut,District of Columbia,Delaware,";
			secBox += "Florida,Georgia,Hawaii,Idaho,Illinois,Indiana,Iowa,Kansas,Kentucky,Louisiana,Maine,Maryland,Massachusetts,Michigan,Minnesota,";
			secBox += "Mississippi,Missouri,Montana,Nebraska,Nevada,New Hampshire,New Jersey,New Mexico,New York,North Carolina,North Dakota,Ohio,Oklahoma,";
			secBox += "Oregon,Pennsylvania,Rhode Island,South Carolina,South Dakota,Tennessee,Texas,Utah,Vermont,Virginia,Washington,West Virginia,Wisconsin,Wyoming";
			secBox = secBox.split(",");
			billstateprov = '<select name="bill_state_prov">';
			for(var i=0;i<secBox.length;i++)
			billstateprov += "<option value=" + i + ">" + secBox[i] + "</option>"
			billstateprov += "</select>";
			document.getElementById("billstateprov").innerHTML = billstateprov;
	
		}
		else if(objvalue == 31){
			secBox = "Select an option,Alberta,British Columbia,Manitoba,New Brunswick,Newfoundland,Northwest Territories,Nova Scotia,Nunavut Territory,Ontario";
			secBox += "Prince Edward Island,Quebec,Saskatchewan,Yukon Territory";
			secBox = secBox.split(",");
			billstateprov = '<select name="bill_state_prov">';
			for(var i=0;i<secBox.length;i++)
			billstateprov += "<option value=" + i + ">" + secBox[i] + "</option>"
			billstateprov += "</select>";
			document.getElementById("billstateprov").innerHTML = billstateprov;
		}
		else{
			billstateprov = "<input type=text name=bill_state_prov>"
			document.getElementById("billstateprov").innerHTML = billstateprov;
		}
	}
}

function popSecondShip()
{
	var secBox,shipstateprov,objvalue;
	var obj = document.all.ship_country;
	objvalue = obj.options[obj.selectedIndex].value;
	if(objvalue)
	{
		if(objvalue == 183){
			secBox = "Select an option,Alabama,Alaska,Arizona,Arkansas,California,Colorado,Connecticut,District of Columbia,Delaware,";
			secBox += "Florida,Georgia,Hawaii,Idaho,Illinois,Indiana,Iowa,Kansas,Kentucky,Louisiana,Maine,Maryland,Massachusetts,Michigan,Minnesota,";
			secBox += "Mississippi,Missouri,Montana,Nebraska,Nevada,New Hampshire,New Jersey,New Mexico,New York,North Carolina,North Dakota,Ohio,Oklahoma,";
			secBox += "Oregon,Pennsylvania,Rhode Island,South Carolina,South Dakota,Tennessee,Texas,Utah,Vermont,Virginia,Washington,West Virginia,Wisconsin,Wyoming";
			secBox = secBox.split(",");
			shipstateprov = '<select name="ship_state_prov">';
			for(var i=0;i<secBox.length;i++)
			shipstateprov += "<option value=" + i + ">" + secBox[i] + "</option>"
			shipstateprov += "</select>";
			document.getElementById("shipstateprov").innerHTML = shipstateprov;
		}
		else if(objvalue == 31){
			secBox = "Select an option,Alberta,British Columbia,Manitoba,New Brunswick,Newfoundland,Northwest Territories,Nova Scotia,Nunavut Territory,Ontario";
			secBox += "Prince Edward Island,Quebec,Saskatchewan,Yukon Territory";
			secBox = secBox.split(",");
			shipstateprov = '<select name="ship_state_prov">';
			for(var i=0;i<secBox.length;i++)
			shipstateprov += "<option value=" + i + ">" + secBox[i] + "</option>"
			shipstateprov += "</select>";
			document.getElementById("shipstateprov").innerHTML = shipstateprov;
		}
		else{
			shipstateprov = "<input type=text name=ship_state_prov>"
			document.getElementById("shipstateprov").innerHTML = shipstateprov;
		}
	}
}
//------------------end  menu
function copy()
{
	var secBox2,billstateprov2,objvalue2;
	var obj2 = document.myform.bill_country;

  
	document.myform.ship_first_name.value = document.myform.bill_first_name.value;
	document.myform.ship_last_name.value = document.myform.bill_last_name.value;
	document.myform.ship_address1.value = document.myform.bill_address1.value;
	document.myform.ship_address2.value = document.myform.bill_address2.value;
	document.myform.ship_city.value = document.myform.bill_city.value;
	document.myform.ship_country.value = obj2.options[obj2.selectedIndex].value;


	objvalue2 = obj2.options[obj2.selectedIndex].value;
	if(objvalue2)
	{
		if(objvalue2 == 183){
			secBox2 = "Select an option,Alabama,Alaska,Arizona,Arkansas,California,Colorado,Connecticut,District of Columbia,Delaware,";
			secBox2 += "Florida,Georgia,Hawaii,Idaho,Illinois,Indiana,Iowa,Kansas,Kentucky,Louisiana,Maine,Maryland,Massachusetts,Michigan,Minnesota,";
			secBox2 += "Mississippi,Missouri,Montana,Nebraska,Nevada,New Hampshire,New Jersey,New Mexico,New York,North Carolina,North Dakota,Ohio,Oklahoma,";
			secBox2 += "Oregon,Pennsylvania,Rhode Island,South Carolina,South Dakota,Tennessee,Texas,Utah,Vermont,Virginia,Washington,West Virginia,Wisconsin,Wyoming";
			secBox2 = secBox2.split(",");
			shipstateprov2 = '<select name="ship_state_prov">';
			for(var i=0;i<secBox2.length;i++)
			shipstateprov2 += "<option value=" + i + ">" + secBox2[i] + "</option>"
			shipstateprov2 += "</select>";
			document.getElementById("shipstateprov").innerHTML = shipstateprov2;
			document.myform.ship_state_prov.value = document.myform.bill_state_prov.value ;	
		}
		else if(objvalue2 == 31){
			secBox2 = "Select an option,Alberta,British Columbia,Manitoba,New Brunswick,Newfoundland,Northwest Territories,Nova Scotia,Nunavut Territory,Ontario";
			secBox2 += "Prince Edward Island,Quebec,Saskatchewan,Yukon Territory";
			secBox2 = secBox2.split(",");
			shipstateprov2 = '<select name="ship_state_prov">';
			for(var i=0;i<secBox2.length;i++)
			shipstateprov2 += "<option value=" + i + ">" + secBox2[i] + "</option>"
			shipstateprov2 += "</select>";
			document.getElementById("shipstateprov").innerHTML = shipstateprov2;
			document.myform.ship_state_prov.value = document.myform.bill_state_prov.value ;			
		}
		else {
		shipstateprov2 = "<input type='text' name='ship_state_prov'>"
		document.getElementById("shipstateprov").innerHTML = shipstateprov2;
		document.myform.ship_state_prov.value = document.myform.bill_state_prov.value;
		}
	 }
		
	document.myform.ship_zip.value = document.myform.bill_zip.value;
	document.myform.ship_phone.value = document.myform.bill_phone.value;

}
// Returns true if string s is empty or 
// whitespace characters only.

function isWhitespace (s)

{   // Is s empty?
//    return (isEmpty(s));
    return (isEmpty(s) || reWhitespace.test(s));
}


function IsOK(val) {
	CharRep = /,/gi;
	newstr=val.replace(CharRep," ");
	return newstr;
}

function IsOKNumber(val) {
	CharRep = /,/gi;
	newstr=val.replace(CharRep,"");
	return newstr;
}

//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//-------- is a Number ----------------
function IsNumeric(sText)
{
   var ValidChars = "0123456789.";
   var IsNumber=true;
   var Char;

 
   for (i = 0; i < sText.length && IsNumber == true; i++) 
      { 
      Char = sText.charAt(i); 
      if (ValidChars.indexOf(Char) == -1) 
         {
         IsNumber = false;
         }
      }
   return IsNumber;
   
   }

//~~~~~~~     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;
}
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//~~~~~~~     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;                     

}

//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

//---end---

//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//~~~~~~~     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;
}

//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

// Check whether string s is empty.

function isEmpty(s)
{   return ((s == null) || (s.length == 0))
}



// Returns true if string s is empty or 
// whitespace characters only.

function isWhitespace (s)

{   // Is s empty?
//    return (isEmpty(s));
    return (isEmpty(s) || reWhitespace.test(s));
}


function IsOK(val) {
	CharRep = /,/gi;
	newstr=val.replace(CharRep," ");
	return newstr;
}

function IsOKNumber(val) {
	CharRep = /,/gi;
	newstr=val.replace(CharRep,"");
	return newstr;
}





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
}


//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//~~~~~~~      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;
}