imgout=new Image(9,9);
imgin=new Image(9,9);

imgout.src="./images/Off.gif";
imgin.src="./images/On.gif";

function validate(chk,id)
 {
 if (chk.checked == 1)
  {
  if (document.getElementById)
   {
   document.getElementById(id).style.display = 'block';
	}
  else
   {
   if (document.layers)
    {	
	 document.id.display = 'block';
	 }
   else
    {
    document.all.id.style.display = 'block';
    }
   }
  }
 else
  {
  if (document.getElementById)
   {
   document.getElementById(id).style.display = 'none';
	}
  else
   {
   if (document.layers)
    {	
	 document.id.display = 'none';
	 }
   else
    {
    document.all.id.style.display = 'none';
    }
   }
  }
 }

function filter(imagename,objectsrc){
	if (document.images){
		document.images[imagename].src=eval(objectsrc+".src");
	}
}

function shoh(id)
{
   if (document.getElementById)
    { // DOM3 = IE5, NS6
	 if (document.getElementById(id).style.display == "none")
     {
	  document.getElementById(id).style.display = 'block';
	  filter(("img"+id),'imgin');			
	  }
    else
     {
	  filter(("img"+id),'imgout');
	  document.getElementById(id).style.display = 'none';
     }
    }
   else
    {
	 if (document.layers)
     {	
	  if (document.id.display == "none")
      {
		document.id.display = 'block';
		filter(("img"+id),'imgin');
		}
     else
      {
		filter(("img"+id),'imgout');	
		document.id.display = 'none';
		}
	  }
    else
     {
	  if (document.all.id.style.visibility == "none")
      {
		document.all.id.style.display = 'block';
		}
     else
      {
		filter(("img"+id),'imgout');
		document.all.id.style.display = 'none';
		}
	  }
	 }
}

function shohni(id)
{
   if (document.getElementById)
    { // DOM3 = IE5, NS6
	 if (document.getElementById(id).style.display == "none")
     {
	  document.getElementById(id).style.display = 'block';
	  }
    else
     {
	  document.getElementById(id).style.display = 'none';
     }
    }
   else
    {
	 if (document.layers)
     {	
	  if (document.id.display == "none")
      {
		document.id.display = 'block';
		}
     else
      {
		document.id.display = 'none';
		}
	  }
    else
     {
	  if (document.all.id.style.visibility == "none")
      {
		document.all.id.style.display = 'block';
		}
     else
      {
		document.all.id.style.display = 'none';
		}
	  }
	 }
}

function doPhone2(currv, evt, decimal)
    {
    evt = (evt) ? evt : event;
    var charCode = (evt.charCode) ? evt.charCode : ((evt.keyCode) ? evt.keyCode :
        ((evt.which) ? evt.which : 0));
    if (charCode > 31 && (charCode < 48 || charCode > 57) && charCode != 46)
     {
     return false;
     }

   if(document.My_Form.Phone2.value.length > 11)
     {
     My_String = document.My_Form.Phone2.value;
     My_Sub_String = My_String.substring(0,12);
     document.My_Form.Phone2.value = My_Sub_String;
     return false;
     }

    if (charCode == 46)
     {
     if (decimal == 0)
      {
      return false;
      }
     }

    if((document.My_Form.Phone2.value.length == 3 || document.My_Form.Phone2.value.length == 7) && (charCode != 10 && charCode != 8))
     {
     document.My_Form.Phone2.value += "-";
     }

    if(charCode == 10 || charCode == 8)
     {
     var num = document.My_Form.Phone2.value;
     var len = num.length;
     len = len - 1;
     if(document.My_Form.Phone2.value.length == 5 || document.My_Form.Phone2.value.length == 9)
      {
      document.My_Form.Phone2.value = num.substring(0,len);
      }
     }
    return true;
    }


function doPhone1(currv, evt, decimal){
    evt = (evt) ? evt : event;
    var charCode = (evt.charCode) ? evt.charCode : ((evt.keyCode) ? evt.keyCode :
        ((evt.which) ? evt.which : 0));

    if (charCode > 31 && (charCode < 48 || charCode > 57) && charCode != 46) {
        return false;
    }

   if(document.My_Form.Phone1.value.length > 11)
     {
     My_String = document.My_Form.Phone1.value;
     My_Sub_String = My_String.substring(0,12);
     document.My_Form.Phone1.value = My_Sub_String;
     return false;
     }

if (charCode == 46) {
        if (decimal == 0) {
            return false;
        }
     }
    if((document.My_Form.Phone1.value.length == 3 || document.My_Form.Phone1.value.length == 7) && (charCode != 10 && charCode != 8)){
        document.My_Form.Phone1.value += "-";
        }

    if(charCode == 10 || charCode == 8){
        var num = document.My_Form.Phone1.value;
        var len = num.length;
        len = len - 1;
        if(document.My_Form.Phone1.value.length == 5 || document.My_Form.Phone1.value.length == 9){
            document.My_Form.Phone1.value = num.substring(0,len);
        }
    }
    return true;
}

function TestPassword()
{
Password=document.ChangePass.Password.value;
if (Password=='')
 {
 alert('Your password can not be blank.');
 }
else
 {
 Phrase = "Are you sure you want to change your password to: " + Password + "?";
 if (confirm(Phrase))
  {
  document.ChangePass.submit();
  }
 }
}

function TestUser()
{
Your_Variable=document.My_Form.FirstName.value;
if (Your_Variable=='')
 {
 alert('The First Name field can not be blank.');
 return;
 }

Your_Variable=document.My_Form.LastName.value;
if (Your_Variable=='')
 {
 alert('The Last Name field can not be blank.');
 return;
 }

Your_Variable=document.My_Form.Phone1.value;
if (Your_Variable=='')
 {
 alert('The Phone1 field can not be blank.');
 return;
 }

if(Your_Variable.length < 12)
 {
 alert('Phone1 must be a valid US phone number with area code.');
 return;
 }

Your_Variable=document.My_Form.Phone2.value;
if(Your_Variable.length < 12 && Your_Variable.length > 0 )
 {
 alert('Phone2 must be a valid US phone number with area code.');
 return;
 }

Phrase = "Are you sure you want to add this user?";
if (confirm(Phrase))
 {
 document.My_Form.submit();
 }
}

function TestUserB()
{
Your_Variable=document.My_Form.FirstName.value;
if (Your_Variable=='')
 {
 alert('The First Name field can not be blank.');
 return;
 }

Your_Variable=document.My_Form.LastName.value;
if (Your_Variable=='')
 {
 alert('The Last Name field can not be blank.');
 return;
 }

Your_Variable=document.My_Form.Phone1.value;
if (Your_Variable=='')
 {
 alert('The Phone1 field can not be blank.');
 return;
 }

if(Your_Variable.length < 12)
 {
 alert('Phone1 must be a valid US phone number with area code.');
 return;
 }

Your_Variable=document.My_Form.Phone2.value;
if(Your_Variable.length < 12 && Your_Variable.length > 0 )
 {
 alert('Phone2 must be a valid US phone number with area code.');
 return;
 }

Phrase = "Are you sure you want to update this user?";
if (confirm(Phrase))
 {
 document.My_Form.submit();
 }
}

function TestCustomer()
{
Your_Variable=document.Customer_Form.FirstName.value;
if (Your_Variable=='')
 {
 alert('The user must have a First Name.');
 return;
 }

Your_Variable=document.Customer_Form.LastName.value;
if (Your_Variable=='')
 {
 alert('The user must have a Last Name.');
 return;
 }

Your_Variable=document.Customer_Form.UserName.value;
if (Your_Variable=='')
 {
 alert('The user must have a UserName.');
 return;
 }

Phrase = "Are you sure you want to update this customer?";
if (confirm(Phrase))
 {
 document.Customer_Form.submit();
 }
}

function TestUserDetails()
{
Your_Variable=document.ArticleForm.FirstName.value;
if (Your_Variable=='')
 {
 alert('You must enter a First Name.');
 return false;
 }
Your_Variable=document.ArticleForm.LastName.value;
if (Your_Variable=='')
 {
 alert('You must enter a Last Name.');
 return false;
 }
Your_Variable=document.ArticleForm.U.value;
if (Your_Variable=='')
 {
 alert('You must enter a UserName.');
 return false;
 }
Your_Variable=document.ArticleForm.P1.value;
if (Your_Variable=='')
 {
 alert('You must enter a Password.');
 return false;
 }
Your_Variable1=document.ArticleForm.P1.value;
Your_Variable2=document.ArticleForm.P2.value;
if (Your_Variable1!=Your_Variable2)
 {
 alert('The Password entered does not match the Re-Typed Password entered.');
 return false;
 }

if (document.ArticleForm.Newsletter.checked == 1)
 {
 NoSelection='0';

 if (document.ArticleForm.NEmail.checked == 1)
  {
  NoSelection='1';
  Your_Variable=document.ArticleForm.Email.value;
  if (Your_Variable=='')
   {
   alert('You have elected to receive our newsletter by Email.  You must enter a valid email address.');
   return false;
   }
  }

 if (document.ArticleForm.NUSPS.checked == 1)
  {
  NoSelection='1';
  Your_Variable=document.ArticleForm.Address1.value;
  if (Your_Variable=='')
   {
   alert('You have elected to receive our newsletter by US Postal Service.  You must enter a valid street address.');
   return false;
   }
  Your_Variable=document.ArticleForm.City.value;
  if (Your_Variable=='')
   {
   alert('You have elected to receive our newsletter by US Postal Service.  You must enter a valid city.');
   return false;
   }
  Your_Variable=document.ArticleForm.State.value;
  if (Your_Variable=='')
   {
   alert('You have elected to receive our newsletter by US Postal Service.  You must enter a valid state.');
   return false;
   }
  Your_Variable=document.ArticleForm.Zip.value;
  if (Your_Variable=='')
   {
   alert('You have elected to receive our newsletter by US Postal Service.  You must enter a valid zip code.');
   return false;
   }
  }

 if (NoSelection=='0')
  {
  alert('You have elected to receive our newsletter, but you have not selected a method by which you wish to receive it.');
  return false;
  }
 }

if (document.ArticleForm.Endorser.checked == 1)
 {
 if(document.ArticleForm.Endorserby['0'].checked)
  {
  Your_Variable=document.ArticleForm.Email.value;
  if (Your_Variable=='')
   {
   alert('You have indicated that you wish to be contacted, by email, regarding becoming an Endorser.  You must enter a valid email address.');
   return false;
   }
  }
 if(document.ArticleForm.Endorserby['1'].checked)
  {
  NoSelection='1';
  Your_Variable=document.ArticleForm.Address1.value;
  if (Your_Variable=='')
   {
   alert('You have indicated that you wish to be contacted, by US Postal Service, regarding becoming an Endorser.  You must enter a valid street address.');
   return false;
   }
  Your_Variable=document.ArticleForm.City.value;
  if (Your_Variable=='')
   {
   alert('You have indicated that you wish to be contacted, by US Postal Service, regarding becoming an Endorser.  You must enter a valid city.');
   return false;
   }
  Your_Variable=document.ArticleForm.State.value;
  if (Your_Variable=='')
   {
   alert('You have indicated that you wish to be contacted, by US Postal Service, regarding becoming an Endorser.  You must enter a valid state.');
   return false;
   }
  Your_Variable=document.ArticleForm.Zip.value;
  if (Your_Variable=='')
   {
   alert('You have indicated that you wish to be contacted, by US Postal Service, regarding becoming an Endorser.  You must enter a valid zip code.');
   return false;
   }
  }
 if(document.ArticleForm.Endorserby['2'].checked)
  {
  Your_Variable=document.ArticleForm.Phone1.value;
  if (Your_Variable=='')
   {
   alert('You have indicated that you wish to be contacted, by Phone1, regarding becoming an Endorser.  You must enter valid phone number into Phone1.');
   return false;
   }
  }
 if(document.ArticleForm.Endorserby['3'].checked)
  {
  Your_Variable=document.ArticleForm.Phone2.value;
  if (Your_Variable=='')
   {
   alert('You have indicated that you wish to be contacted, by Phone2, regarding becoming an Endorser.  You must enter valid phone number into Phone2.');
   return false;
   }
  }
 }
return true;
}

