<!--
function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}

// **** FIELD INPUT VALIDATION FOR COMPANY
function checkInformationFields() {
var pkgYN = false;
var advYN = false;
missinginfo = "";
	if (document.bgsignup.contactfirstname.value == "") {
	missinginfo += "\n     -  First Name";
	}
	if (document.bgsignup.contactlastname.value == "") {
	missinginfo += "\n     -  Last Name";
	}
	if (document.bgsignup.contacttitle.value == "") {
	missinginfo += "\n     -  Title";
	}
	if (document.bgsignup.contactemail.value == "") {
	missinginfo += "\n     -  E-mail Address";
	}
	if (document.bgsignup.confirmemail.value == "") {
	missinginfo += "\n     -  Please Confirm E-mail Address";
	}
	if (document.bgsignup.confirmemail.value.toString() != document.bgsignup.contactemail.value.toString())
	{
	missinginfo += "\n     -  Your Confirm E-mail Address Does Not Match Your E-mail Address";
	}
	if (document.bgsignup.compname.value == "") {
	missinginfo += "\n     -  Company Name";
	}
	if (document.bgsignup.compaddress1.value == "") {
	missinginfo += "\n     -  Company Address Line 1";
	}
	if (document.bgsignup.compcity.value == "") {
	missinginfo += "\n     -  Company City";
	}
	if (document.bgsignup.compcountry.options[document.bgsignup.compcountry.selectedIndex].value == "United States" || document.bgsignup.compcountry.options[document.bgsignup.compcountry.selectedIndex].value == "Canada"){
		if (document.bgsignup.compstate.value == "") {
		missinginfo += "\n     -  Company State or Province";
		}
	}
	if (document.bgsignup.compzip.value == "") {
	missinginfo += "\n     -  Company Postal Code";
	}
	if (document.bgsignup.compcountry.options[document.bgsignup.compcountry.selectedIndex].value == "") {
	missinginfo += "\n     -  Company Country";
	}
	if (document.bgsignup.compphone.value == "") {
	missinginfo += "\n     -  Company Phone Number";
	}
	// check for packages - loop through package elements
	for (var pCounter = 0; pCounter < document.bgsignup.listPackage.length; pCounter++)
	{
	    if(document.bgsignup.listPackage[pCounter].checked)
	    {
	        pkgYN = true;
	    }
	}
	if(pkgYN == false){
	missinginfo += "\n     -  A Package Type";
	}
	// check for advertisements - loop through advertisements elements
	//for (var aCounter = 0; aCounter < document.bgsignup.advertising.length; aCounter++)
	//{
	//    if(document.bgsignup.advertising[aCounter].checked)
	//    {
	//        advYN = true;
	//    }
	//}
	//if(advYN == false){
	//missinginfo += "\n     -  An Advertising Package";
	//}
// check to see if this will be an invoice or credit transaction
for (var i=0; i < document.bgsignup.payment.length; i++) {
                if (document.bgsignup.payment[i].checked) {
                       var radioValue = document.bgsignup.payment[i].value;
                  if (radioValue == "CreditCard")
                  {
					if(document.bgsignup.card_type.value == "")
					 {
					  alert("Please Select a Credit Card Type");
					  document.bgsignup.card_type.focus();  
					  return (false);
					 }
					if(document.bgsignup.card_number.value == "")
					 {
					  alert("Please Enter a Credit Card Number");
					  document.bgsignup.card_number.focus();  
					  return (false);
					 }
					if(document.bgsignup.exp_month.value == "")
					 {
					  alert("Please Enter a Expiration Month");
					  document.bgsignup.exp_month.focus();  
					  return (false);
					 }
					if(document.bgsignup.exp_year.value == "")
					 {
					  alert("Please Enter a Expiration Year");
					  document.bgsignup.exp_year.focus();  
					  return (false);
					 }
					if(document.bgsignup.cardholder_name.value == "")
					 {
					  alert("Please Enter a Card Holder Name");
					  document.bgsignup.cardholder_name.focus();  
					  return (false);
					 }
				  }
				} else {
					if (radioValue == "Invoice")
					{
					// do nothing
					}
				}
}
	// WRITES THE ALERT CONTAINING THE MISSING INFORMATION
	if (missinginfo != "") {
	missinginfo = "_____________________________\n" +
	"The following fields are required:\n" +
	missinginfo + "\n_____________________________" +
	"\nPlease enter and submit again.";
	alert(missinginfo);
	return false;
		} else {
		return true;
	  }
}

//CONTACT EMAIL VALIDATION
function VerifyContactEmailAddress()
{
  var Reason  = "Your e-mail address has been entered incorrectly.  \n\nReason:"
  var checkStr = document.bgsignup.contactemail.value;
  var RC = true;
  var x = AtSignValid = DoublePeriod = PeriodValid = SpaceValid = RL = 0;

  for (i = 0;  i < checkStr.length;  i++)
  {
    if (checkStr.charAt(i) == '@')
      AtSignValid++;
    else if (checkStr.charAt(i) == '.')
    {
      if (x == (i-80))
        DoublePeriod++;
      else
      {
        x = i;
        PeriodValid++;
      }
    }
    else if (checkStr.charAt(i) == ' ')
      SpaceValid ++;
  }
  RL = Reason.length;
  if (AtSignValid != 1)
    Reason += "\n- Only one '@' allowed, " + AtSignValid + " found.";
  if (PeriodValid == 0)
    Reason += "\n- Address must contain at least one period.";
  if (SpaceValid > 0)
    Reason += "\n- No Spaces allowed. Address contains " + SpaceValid + " space";
  if (SpaceValid > 1)
    Reason += "s.";
  if (DoublePeriod > 0)
    Reason += "\n- Address contains multiple periods in a row.";
  if (checkStr.length > 120)
    Reason += "\n- Please limit the Email Address to 120 characters.";

  if (RL != Reason.length)
  {
    if (confirm(Reason))
    {
      document.bgsignup.contactemail.focus();
      RC = false;
    }
    else
      RC = true;
  }
  else
    RC = true;
  return(RC);
}

function ConfirmEmail(emailAddress)
{
    if(emailAddress.toString() != document.bgsignup.contactemail.value.toString())
    {
        alert("The confirm e-mail address you have entered does not match the original e-mail address.");
        return false;
    } 
}

// master validation routine for pop_userinfo.html

function isCompanyCorrect() {

	if (!checkInformationFields())
	{
	return false;
	} else {
		if(!VerifyContactEmailAddress())
		{
		return false;
		}
	}
return true;
}

function isPosIntCardNum(){
// validate the single instance of the cardnumber field
    var passint = document.bgsignup.card_number.value;
            inputStr = passint.toString();
            for (var n = 0; n < inputStr.length; n++)
            {
            var oneChar = inputStr.charAt(n);
            if (oneChar < "0" || oneChar > "9")
            {
            alert("This field CANNOT contain letters or spaces");
            return (false);
            }
            }
}

function isPosIntCardExpMnth(){
// validate the single instance of the cardnumber field
    var passint = document.bgsignup.exp_month.value;
            inputStr = passint.toString();
            for (var n = 0; n < inputStr.length; n++)
            {
            var oneChar = inputStr.charAt(n);
            if (oneChar < "0" || oneChar > "9" || inputStr.length < 2)
            {
            alert("This field MUST BE 2 digits in length and CANNOT contain letters or spaces");
            return (false);
            }
            }
}

function isPosIntCardSecurity(){
// validate the single instance of the card security field
    var passint = document.bgsignup.card_security_number.value;
            inputStr = passint.toString();
            for (var n = 0; n < inputStr.length; n++)
            {
            var oneChar = inputStr.charAt(n);
            if (oneChar < "0" || oneChar > "9" || inputStr.length < 3)
            {
            alert("This field MUST BE 3 digits in length and CANNOT contain letters or spaces");
            return (false);
            }
            }
}

function isPosIntCardExpYear(){
// validate the single instance of the cardnumber field
    var passint = document.bgsignup.exp_year.value;
            inputStr = passint.toString();
            for (var n = 0; n < inputStr.length; n++)
            {
            var oneChar = inputStr.charAt(n);
            if (oneChar < "0" || oneChar > "9" || inputStr.length < 4)
            {
            alert("This field MUST BE 4 digits in length and CANNOT contain letters or spaces");
            return (false);
            }
            }
}

function SubTotal()
{
/*
Description: This function will find the appropriate elements within
	            a given container and calculate the sub-total and grand
	            total prices for customer's purchase.
	
Parameters: None
*/
	var evtGrandTotal = new Number(0);
	var pkgPrice = document.bgsignup.listPackage;
	//var printPrice = document.bgsignup.advertising;
	
	// loop through package elements to find prices
	for (var I = 0; I < pkgPrice.length; I++)
	{
	    if(pkgPrice[I].checked)
	    {
	        foundOffset = pkgPrice[I].value.indexOf(":");
	        endPos = pkgPrice[I].value.indexOf(":", 0);
            if (foundOffset == -1)
            {
            return null;
            }
            var pkgTotal = new Number(pkgPrice[I].value.substring(foundOffset+1,pkgPrice[I].value.length));
	        evtGrandTotal += pkgTotal;
	        
	        setPSUpgrade(pkgPrice[I].value.substring(0, endPos));
	    }
	}
	
	// loop through advertising elements to find prices
	//for (var I = 0; I < printPrice.length; I++)
	//{
	//    if(printPrice[I].checked)
	//    {
	//        foundOffset = printPrice[I].value.indexOf(":");
    //        if (foundOffset == -1)
    //        {
    //        return null;
    //        }
    //        var advTotal = new Number(printPrice[I].value.substring(foundOffset+1,printPrice[I].value.length));
	//        evtGrandTotal += advTotal;
	//    }
	//}
    
    // add Featured listing to total: REMOVED UNTIL PRICING IS READY
    //if(document.bgsignup.featurelisting.checked == true)
    //{
    //    evtGrandTotal += new Number(document.bgsignup.featurelisting.value);
    //}
    
    // add ProdServ Upgrade to total
    var psUpgradeQty = new Number(document.bgsignup.psupgradeqty.value);
    if(psUpgradeQty > 0)
    {
        evtGrandTotal += new Number(document.bgsignup.psupgradeqty.value * 195);
    }
    
    // set the Grand Total display and hidden form element values
    document.getElementById("TotalPurchase").innerHTML = "Your total purchase for this order is&nbsp;<strong>$" + evtGrandTotal + "</strong>";
    document.bgsignup.Total.value = evtGrandTotal;
}

function statNew(msg) {
        window.status = msg;
        return true;
}

function setPSUpgrade(pkgName)
{
	if(pkgName == "" || pkgName != "Ultra")
	{
	    document.bgsignup.psupgradeqty.disabled = true;
	}
	else
	{
	    document.bgsignup.psupgradeqty.disabled = false;
	}
}

function setCurrentPkg(pkgID)
{
	var pkgPrice = document.bgsignup.listPackage;
	
	// loop through package elements to find prices
	for (var I = 0; I < pkgPrice.length; I++)
	{
	    endPos = pkgPrice[I].value.indexOf(":", 0);
	    if(pkgPrice[I].value.substring(0, endPos) == "Ultra" && pkgID == 10)
	    {
	        pkgPrice[I].checked = true;
	    }
	    if(pkgPrice[I].value.substring(0, endPos) == "Enhanced" && pkgID == 9)
	    {
	        pkgPrice[I].checked = true;
	    }
	    if(pkgPrice[I].value.substring(0, endPos) == "Basic" && pkgID == 8)
	    {
	        pkgPrice[I].checked = true;
	    }
	}
}
//-->
