<!--

function wJump(targ) {

    var newURL = targ;

    var x = 550;

    var y = 400;

    var secPrefix = "";

    var wcfg = "Height=" + y + ",width=" + x +

        ",status=no,location=no,menubar=no,toolbar=no,resizable=no,scrollbars=yes";

    newUrl = secPrefix + newURL;

    newWin = window.open(newURL, "new", config=wcfg);

    newWin.focus();

}



function openPopUpNew(URL) {

	newWindow = window.open(URL,"popup","scrollbars,HEIGHT=450,WIDTH=644, resizable=yes");

  	newWindow.focus();

}
//var myTimeout;
//var myTimeoutOld;
function changeNavState(element,className,state) {
/*	if (state == "On") { imageSrc = "../images/left_red_arrow.gif"; }
	else { imageSrc = "../images/white_arrow.gif"; }
*/	
/*	setTimeout('', 75);
*/

//  setTimeout("changeNavStateDelayed("+element+","+className+","+state+")", 75);
	imageSrc = getImageSrc (className + "Image" + state);
	if (document.getElementById(element)) { document.getElementById(element).className = className + state; }
	if (document.getElementById(element + "ImageDiv")) { document.getElementById(element + "ImageDiv").className = className + "Image" + state; }
	if (document.getElementById(element + "ImageLink")) { document.getElementById(element + "ImageLink").className = className  + state; }
	if (document.getElementById(element + "Image")) { MM_swapImage(element + "Image", "","file:///C|/DOCUME%7E1/oaxgryc/LOCALS%7E1/Temp/Temporary%20Internet%20Files/Content.IE5/0BC7WFIZ/getImageSrc%20(className%20%2B%20%22Image%22%20%2B%20state)", 1); }
	if (document.getElementById(element + "ItemDiv")) { document.getElementById(element + "ItemDiv").className = className + "Item" + state; }
	if (document.getElementById(element + "ItemLink")) { document.getElementById(element + "ItemLink").className = className  + state; }

	//if (myTimeout == myTimeoutOld){
		//clearTimeout(myTimeout);
	//}
	//myTimeoutOld = myTimeout;


}

function fmouseOut(element,className,state) {
/*	if (state == "On") { imageSrc = "../images/left_red_arrow.gif"; }
	else { imageSrc = "../images/white_arrow.gif"; }
*/	
/*	setTimeout('', 75);
*/
//	clearTimeout(myTimeout);
//  	myTimeout=setTimeout("changeNavState('"+element+"','"+className+"','"+state+"')", 75);
/*	imageSrc = getImageSrc (className + "Image" + state);
	if (document.getElementById(element)) { document.getElementById(element).className = className + state; }
	if (document.getElementById(element + "ImageDiv")) { document.getElementById(element + "ImageDiv").className = className + "Image" + state; }
	if (document.getElementById(element + "ImageLink")) { document.getElementById(element + "ImageLink").className = className  + state; }
	if (document.getElementById(element + "Image")) { MM_swapImage(element + "Image", "", getImageSrc (className + "Image" + state), 1); }
	if (document.getElementById(element + "ItemDiv")) { document.getElementById(element + "ItemDiv").className = className + "Item" + state; }
	if (document.getElementById(element + "ItemLink")) { document.getElementById(element + "ItemLink").className = className  + state; }
*/

}

function changeNavStateDelayed(element,className,state) {
//	alert(element+","+className+","+state);

	imageSrc = getImageSrc (className + "Image" + state);
	if (document.getElementById(element)) { document.getElementById(element).className = className + state; }
	if (document.getElementById(element + "ImageDiv")) { document.getElementById(element + "ImageDiv").className = className + "Image" + state; }
	if (document.getElementById(element + "ImageLink")) { document.getElementById(element + "ImageLink").className = className  + state; }
	if (document.getElementById(element + "Image")) { MM_swapImage(element + "Image", "","file:///C|/DOCUME%7E1/oaxgryc/LOCALS%7E1/Temp/Temporary%20Internet%20Files/Content.IE5/0BC7WFIZ/getImageSrc%20(className%20%2B%20%22Image%22%20%2B%20state)", 1); }
	if (document.getElementById(element + "ItemDiv")) { document.getElementById(element + "ItemDiv").className = className + "Item" + state; }
	if (document.getElementById(element + "ItemLink")) { document.getElementById(element + "ItemLink").className = className  + state; }

}


// -->
//**********  valditaion below ********************************
function validate(frm) {
/* *************************************************************
* set some variables that will be checked later         *
***************************************************************/
var msg = "";                 // an output message
var missing = "";             // for missing required fields
var invNum = "";              // for invalid numeric fields
var outOfRange = "";          // less than min or more than max
var invZIP = "";              // for invalid zip codes
var invPhone = "";            // for invalid phone numbers
var invState = "";            // for invalid state fields
var invEmail = "";			  // for invalid email fields
var invSelection = "";    // if user didn't make a selection
  
/* *************************************************************
* The main validation function, calls other sub-functions      *
***************************************************************/

	//alert("in validate form");
if (frm.rbInterest){

	var bChecked = false;

		for (var j=0;j<frm.rbInterest.length ;j++){
			
			if  (frm.rbInterest[j].checked){
				bChecked = true
				
			}
		}	
	if (!bChecked){
		alert("Please make a selection");
		
		return false;
	}
}

//	alert("after  !bchecked");
//	alert("missing.length =" + missing.length);


  for(i=0; i<frm.elements.length; i++){            // loop through form elements
    
	 // alert("in for loop for time " + i);
    var el = frm.elements[i];
    //alert(el.name);
    //alert(el.opts);
	
		
    if(el.opts & 1){             // if element has required property
                                 // test to see if field is empty
		//alert("in required");
      if(isEmpty(el)){
		 // alert(el.name);
		 switch (el.name) {
		 case "first":
			missing += "\n   - First Name is a required field";
			break;
		 case "FN":
			missing += "\n   - First Name is a required field";
			break;
		 case "last":
			missing += "\n   - Last Name is a required field";
			break;
		 case "LN":
			missing += "\n   - Last Name is a required field";
			break;
		 case "selType":
			missing += "\n   - Please Select a Complaint Type";
			break;
		 case "accType":
			missing += "\n   - Please Select an Account Type";
			break;
		 case "email":
			missing += "\n   - E-mail is a required field";
			break;
		 case "address1":
			missing += "\n   - Street Address is a required field";
			break;
		 case "add1":
			missing += "\n   - Street Address is a required field";
			break;
		 case "city":
			missing += "\n   - City is a required field";
			break;
		 case "county":
			missing += "\n   - County is a required field";
			break;
		 case "areacode":
			missing += "\n   - Daytime phone is a required field, please fill in area code";
			break;
		 case "exch":
			missing += "\n   - Daytime phone is a required field, please fill in exchange";
			break;
		 case "phone":
			missing += "\n   - Daytime phone is a required field";
			break;
		 case "probDesc":
			missing += "\n   - Please supply a problem description";
			break;
		 case "SlammedNumber":
			missing += "\n   - Telephone number that was slammed is required";
			break;
		 case "CompanyAtFault":
			missing += "\n   - Please supply the name of the company that slammed you";
			break;
		 case "AuthorizedLocalCompany":
			missing += "\n   - Please supply the name of your authorized local phone company";
			break;
		 case "AuthorizedDistanceCompany":
			missing += "\n   - Please supply the name of your authorized long distance company";
			break;
		 default:
			missing += "\n   - " + el.name + " is a required field";
		 } //close switch
      } //close isEmpty
    } //close if required
    if(el.opts & 2) {
      if(!isNumeric(el)) {
        invNum += "\n   - " + el.value + " is not a number";
      }
    }

	 if(el.isInt) {
      if(isFloat(el)) {
        invNum += "\n   - " + el.value + " decimal numbers not allowed";
      }
    }
	
    if(el.minVal || el.minVal == 0) {
		//alert("in minVal is=" +el.minVal);
      if(parseFloat(el.value) < el.minVal) {
        outOfRange +=  "\n   - " + el.name + " must be larger than " + el.minVal + ", you entered " + el.value;
      }
    }
    if(el.maxVal) {
      if(parseFloat(el.value) >= el.maxVal) {
        outOfRange +=  "\n   - " + el.name + " must be smaller than " + el.maxVal + ", you entered " + el.value
      }
    }
    if(el.opts & 8 && el.value.length !=0) {
      if(invalidZIP(el)) {
        invZIP += "\n  - " + el.value + " is an invalid ZIP code";
	  }
    }
    if(el.opts & 4 && el.value.length !=0) {
      if(invalidPhone(el)) {
        invPhone += "\n  - " + el.value + " is not a valid phone number";
      }
    }
    if(el.opts & 32 && el.value.length != 0){
      if(invalidState(el)){
        invState += "\n  - " + el.value + " is not a valid two-letter state abbreviation";
      }
    }
	if(el.opts & 16){
		if (validateEMail(el)){
		invEmail += "\n - " + el.value + " is not a valid email address.";
		}
  }
	if(el.chosen) {
		//alert("in rbInterest check");
		if (noRBSelected(el))	{
			invSelection += "\n - No selection made.";
		}
	}

	if(el.posNum)
	{
		if (isNegative(el))
		{
			invNum += "\n - No negative numbers allowed";
		}
	}

  } //close the for loop

	//alert("out of for loop");
  // build output message

	
//alert("missing.length= " + missing.length);
//alert("outOfRange.length " + outOfRange.length);

 if(missing.length !=0 || invNum.length != 0 || outOfRange.length != 0 || invZIP.length != 0 || invPhone.length != 0 || invState.length != 0 || invEmail.length != 0)
 

//if(missing.length !=0 || invEmail.length != 0 || invNum.length !=0) 
{
		 // alert("in the if statement for errors");
    if(missing.length !=0) {
      msg += "\n\nThe following required fields are missing:";
      msg += missing;
     }
    if(invNum.length !=0)  {
      msg += "\n\nYou entered incorrect numeric data in these fields:";
      msg += invNum;
     }
    if(outOfRange.length !=0) {
      msg += "\n\nYou entered out-of-range data in these fields:";
      msg += outOfRange;
     }
    if(invZIP.length !=0) {
      msg += "\n\nYou entered an incorrect ZIP code in these fields:";
      msg += invZIP;
     }
    if(invPhone.length !=0){
      msg += "\n\nYou entered an incorrect phone number in these fields:";
      msg += invPhone;
     }
    if(invState.length !=0){
      msg += "\n\nYou entered an incorrect state abbreviation";
      msg += invState;
     }
	if (invEmail.length !=0){
		msg +="\n\nYou entered an incorrect Email address";
		msg += invEmail;
	}
  // alert("after if statements");

    errMsg(msg);           // call the output function
    msg = ""; missing = ""; invNum = ""; invZIP = ""; invPhone = ""; invState = "" ; outOfRange = ""; // reset all our variables
    invEmail =""; invSelection="";
	return false;
    }
  else {
	//	alert("about to return true");
    return true;
    }
  }

/* *************************************************************
* Sub-functions follow from here to end of file                *
* All sub-functions return true if field is of invalid         *
* format and false if they are valid entries                   *
***************************************************************/
function isEmpty(field)
  {
  var str = field.value;

  //alert("the value is: " + field.value);

  if(str == "") 
    {
    return true;
    }
  else
    {
    for(j=0; j<str.length; j++)
      {
      if(str.charAt(j) != " ") return false;
      }
    }
  return true;
  }

function isNumeric(field)
  {
  var errCount = 0;
  var numdecs = 0;              // number of decimal points
  var nummins = 0;              // number of minus signs
  for(j=0;j<field.value.length;j++)
    {
    c = field.value.charAt(j);        // short hand notation for character at position j
    if((c >= 0 && c <= 9) || (c=="." || c=="-"))
      {
      if(c==".") numdecs++;     // count the number of decimal points
      if(c=="-") nummins++;     // count the number of minus signs
      }
    else
      {
      errCount++;               // if it's none of those, increment error counter
      }
    }
  // error if count is non-zero or there are more than one decimal point or minus sign
  if(errCount > 0 || numdecs > 1 || nummins > 1)
    {
    return false;
    }
  return true;
  }

function stripNonDigits(str)
  {
  newStr = "";
  for(j=0; j<str.length; j++)
    {
    c = str.charAt(j);
    if(c >= "0" && c <= "9")
      {
      newStr += c;
      }
    }
  return newStr;
  }

function invalidZIP(field)
  {
  newStr = stripNonDigits(field.value);
  if(newStr.length == 5 || newStr.length== 9)
    {
    return false;
    }
  return true;
  }

function invalidPhone(field)
  {
  newStr = stripNonDigits(field.value);
  if(newStr.length == 10)
    {
    return false;
    }
  return true;
  }

function invalidState(field)
  {
  var STATES = "AL/AK/AZ/AR/CA/CO/CT/DE/DC/FL/GA/HI/ID/IL/IN/IA/KS/LA/ME/MD/MA/MI/MN/MS/MO/MT/NE/NV/NH/NJ/NM/NY/NC/ND/OH/OK/OR/PA/PR/RI/SC/TN/TX/UT/VT/VA/WA/WV/WI/WY";
  var newStr = field.value.toUpperCase();
  if(STATES.indexOf(newStr) == -1 || newStr.indexOf("/") != -1 || newStr.length != 2)
    {
    return true;
    }
  return false;
  }

  function validateEMail(field) {
	var	email = field.value;
  var atsignPos = email.indexOf("@", 0)     // check for @
  if (atsignPos == -1)	
    {
    // alert("Enter a valid email address with an @, please!")
    return true;
    }
  if (email.indexOf(".", atsignPos) == -1)  // check for . after @	
    {
    // alert("Enter a valid email domain after the @, please!")
    return true;
    }
  return false;
  }

	function noRBSelected(field) {
	
		for (var i=0;i<frm.rbInterest.length ;i++){
	
			if (frm.rbInterest[i].checked){
				return false;
			}
			return true;
		}
	}
	
	function isNegative(field)
	{
		var n = field.value;
		var posNeg = n.indexOf("-");
		if (posNeg == -1)
		{
			return false;
		}
		return true;
	}

	function isFloat(field)
	{
		var n = field.value;
		var pos = n.indexOf(".");
		if (pos == -1)
		{
			return false;
		}
		return true;
	}


function errMsg(msg)
  {
  var theMsg = "You entered some incorrect values into the form. ";
  theMsg += "Please correct your entries then re-submit the form.\n";
  theMsg += "____________________________________________________________________";
  theMsg += msg;
  theMsg += "\n____________________________________________________________________\n";
  alert(theMsg);
  }

function testRef(){
//	document.layers["HomeMenu"].innerText="myTest";
//  alert("test ref " + document.layers["HomeMenu"].innerText); //getRef("HomeMenu").innerText);
}
//  alert("bn.js loaded in full");
function getRef(disId) {
//alert("in getRef");
if (isDOM) return document.getElementById(disId);
if (isIE4) return document.all[disId];
if (isNS4) return document.HomeMenu;
}
