function extractDomainName()
{
   // get where we are
   var here = new String(document.URL);
   // get the position of the delimeter in the URL
   var colon = here.indexOf("://");
   // offset past the delimiter
   colon = colon + 3;
   // get the substring past the delimiter
   var pastdelim = here.substring(colon);
   // get the position of the slash
   var slash = pastdelim.indexOf("/");
   // initialize storage for the root url
   var root = "";
   // extract the root url from the remaining string
   if( slash != -1 )
   {
      root = pastdelim.substring(0,slash);
   }
   else
   {
      root = pastdelim;
   }
   return root;
}

function gotoURL( chan, subchan )
{
   window.location =
      "http://" +
      extractDomainName() +
      "/servlet/com.kx.cs.servlets.CsServlet?" +
      "channel=" +
      chan +
      "&subchannel=" +
      subchan;
}

function gotoAdamURL( chan, subchan, idnbr )
{
   window.location =
      "http://" +
      extractDomainName() +
      "/servlet/com.kx.cs.servlets.CsServlet?" +
      "channel=" +
      chan +
      "&subchannel=" +
      subchan +
      "&adammode=on&adamstyle=photo" +
      "&photoid=" +
      idnbr;
}

// display pages which can only be viewed over an HTTPS connection
function gotoSSL( secure, chan, subchan )
{
   window.location =
      secure +
      "://" +
      extractDomainName() +
      "/servlet/com.kx.cs.servlets.CsServlet?" +
      "channel=" +
      chan +
      "&subchannel=" +
      subchan;
}

// display pages which can only be viewed over an HTTPS connection
function gotoSSL2( secure, chan, subchan, prod, style, promo )
{
   window.location =
      secure +
      "://" +
      extractDomainName() +
      "/servlet/com.kx.cs.servlets.CsServlet?" +
      "channel=" +
      chan +
      "&subchannel=" +
      subchan +
      "&product=" +
      prod +
      "&style=" +
      style +
      "&promo_code=" +
      promo;
}

function myacct()
{
   document.form1.action.value='myaccount';
//   document.form1.channel.value='{//@channel}';
   document.form1.submit();
}

function myhist()
{
   document.form1.action.value='billinghistory';
//   document.form1.channel.value='{//@channel}';
   document.form1.submit();
}

   function goProductSSL( chan, product, subproduct, anchor, secure )
   {
      window.location =
         secure +
         "://" +
         extractDomainName() +
         "/servlet/com.kx.cs.servlets.CsServlet?" +
         "channel=" +
         chan +
         "&product=" +
         product +
         "&subproduct=" +
         subproduct +
         "&anchor=" +
         anchor;
   }

  function goProductSSL3( chan, product, subproduct, anchor, secure, showaddress )
   {
      window.location =
         secure +
         "://" +
         extractDomainName() +
         "/servlet/com.kx.cs.servlets.CsServlet?" +
         "channel=" +
         chan +
         "&product=" +
         product +
         "&subproduct=" +
         subproduct +
         "&anchor=" +
         anchor +
         "&showaddress=" +
         showaddress;
   }



   function goShareProductSSL( chan, product, subproduct, anchor, secure, view )
   {
      window.location =
         secure +
         "://" +
         extractDomainName() +
         "/servlet/com.kx.cs.servlets.CsServlet?" +
         "channel=" +
         chan +
         "&product=" +
         product +
         "&subproduct=" +
         subproduct +
         "&anchor=" +
         anchor +
         "&view=" +
         view;
   }

   function goProduct( chan, product, subproduct, anchor )
   {
      window.location =
         "http" +
         "://" +
         extractDomainName() +
         "/servlet/com.kx.cs.servlets.CsServlet?" +
         "channel=" +
         chan +
         "&product=" +
         product +
         "&subproduct=" +
         subproduct +
         "&anchor=" +
         anchor;
   }

   function gotoURL2( chan, subchan, product, subproduct, anchor )
   {
      window.location = "/servlet/com.kx.cs.servlets.CsServlet?" +
         "channel=" +
         chan +
         "&subchannel=" +
         subchan +
         "&product=" +
         product +
         "&subproduct=" +
         subproduct +
         "&anchor=" +
         anchor;
   }

   function gotoURL3( chan, subchan, topic, question )
   {
      window.location = "/servlet/com.kx.cs.servlets.CsServlet?" +
         "channel=" +
         chan +
         "&subchannel=" +
         subchan +
         "&topic=" +
         topic +
         "&question=" +
         question;
   }

   function gotoURL4( chan, subchan, anchor )
   {
      window.location = "/servlet/com.kx.cs.servlets.CsServlet?" +
         "channel=" +
         chan +
         "&subchannel=" +
         subchan +
         "&anchor=" +
         anchor;
   }

   function openWindow()
   {
         var URL = "/xsl/welcome/dontknow.htm"
         remote = window.open(URL, "info",
         "resizable=no,toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=0,copyhistory=0,width=390,height=135");

   }

   function userAgreement()
   {
         var URL = "/xsl/welcome/useragreement.htm";
         window.open(URL, "User_Agreement",
         "resizable=no,toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=1,copyhistory=0,width=480,height=350");
   }

   function userAgreementBgc()
   {
         var URL = "/xsl/home/bgcheck/user_agreement.htm";
         window.open(URL, "User_Agreement",
         "resizable=no,toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=1,copyhistory=0,width=480,height=350");
   }


        //Popup Window Script
        function openpopup()
        {
            var popurl="../taketour.htm"
            winpops=window.open(popurl,"","width=450,height=325,resizable,")
        }



// validation related stuff ----------------------------------------------------

         function valExists( field, name )
         {
            if( field == "" )
            {
               alert( 'You must enter a value for ' + name );
               return false;
            }
            return true;
         }

         function valNbr( field, name, mask )
         {
            // empty field ok
            if( field == "" )
            {
               return true;
            }

            if( !validateNumericField(field, name, mask) )
            {
               alert( 'You must enter a numeric value for ' + name + " in the format " + mask );
               return false;
            }
            return true;
         }

         // every '0' position is a required digit
         // every '#' position is an optional digit
         // every '-', '/', or '.' position is a literal marker
         function validateNumericField( field, name, mask )
         {
            // mask: 00000-####
            // nbr:  12345
            // nbr:  12345-1234

            // mask: 000-000-0000
            // nbr:  770-982-0683

            var s = new String(field);
            var m = new String(mask);

            if( s.length > m.length )
            {
               return false;
            }


               for( var i = 0; i < m.length; i++ )
               {
                  // if we are at the end of the field and there are still more reqd chars
                  if( i >= s.length )
                  {
                     if( m.substring(i).indexOf('0') != -1 )
                     {
                        return false;
                     }
                     return true;
                  }
                  if( m.charAt(i) == '0' && isNaN(s.charAt(i)) )
                  {
                     return false;
                  }
                  if( m.charAt(i) == '#' && isNaN(s.charAt(i)) )
                  {
                     return false;
                  }
                  if( m.charAt(i) == '-' || m.charAt(i) == '/' || m.charAt(i) == '.' )
                  {
                     if( m.charAt(i) != s.charAt(i) )
                     {
                        return false;
                     }
                  }
               }
            return true;
         }

         function valNbrExists( field, name, mask )
         {
            if( !valExists(field,name) )
            {
               return false;
            }
            if( !valNbr(field,name,mask) )
            {
               return false;
            }
            return true;
         }

         function valState( field, name, notcovered )
         {
            var s = new String(field);
            var n = new String(notcovered);
            if( notcovered.indexOf(s) != -1 )
            {
               alert( 'The state of ' + field + ' is not covered for this product.  Please make another selection.' );
               return false;
            }
            return true;
         }

			function valEitherOrExists( field, name, field2, name2 )
			{
            if ( ( field == "" ) && ( field2 == "" ) )
            {
               alert( 'You must enter a value for ' + name + ' or ' + name2 );
               return false;
            }
            return true;
			}


// TOA validation form -------------------------------------------------

function checkToa(form)
{

  if(!document.form2.toa.checked)
  {
     alert("You must agree to the ChoiceTrust user agreement to continue.");
     return false;
  }
  else
  {

     if( document.form2.ccnbr.value != '' )
     {
         return ccvalidate();
     }
     return true;
   }
}

function checkToa2(form)
{

  if(!document.form2.toa.checked)
  {
     alert("You must agree to the ChoiceTrust user agreement to continue.");
     return false;
  }
  else
  {
     return true;
  }
}

function checkToa3(form)
{

  if(!document.form2.toa.checked)
  {
     alert("You must agree to the ChoiceTrust user agreement to continue.");
     return false;
  }else if (!document.form2.backgroundcheckuseragreement.checked)
  {
     alert("You must agree to the Background Check user and permissible use agreement to continue.");
     return false;
  }
  else
  {
     return true;
  }
}


// credit card validation form -------------------------------------------------

//open account
function ccvalidate()
{
   if(ccvalidation())
   {
      document.form2.submit();
   }
   else
   {
      return false;
   }
}

function validateTellAFriendForm()
{
   if( document.form2.to.value == "")
   {
   	alert( 'You must enter at least one valid email address to continue.' );
   	return false;
   }
else if(document.form2.from.value == "")
   {
      alert( 'You must enter your email address to continue.' );
      return false;
   }

else
	{
		return true;
	}
}

//get ccinfo
function ccvalidate2()
{
   if(ccvalidation2())
   {
      document.form2.submit();
   }
}

function ccvalidation()
{
   if( document.form2.ccnbr.value == '' )
   {
      alert( 'You must enter a credit card number' );
      return false;
   }

   var today = new Date();
   var month = today.getMonth() + 1;
   var year = today.getYear();
   var formYear = document.form2.ccexpy.options[document.form2.ccexpy.selectedIndex].value;
   var formMonth = document.form2.ccexpm.options[document.form2.ccexpm.selectedIndex].value;

   // adjustment for IE/NS differences, good until 2100
   if( year < 200 )
   {
      year = year + 1900;
   }

   emonth = formMonth;

   //adjustment to allow for 2 digit years in the form
   //check to see if the 2 digit or 4 digit year is passed in
   if(formYear.length < 4 )
   {
      eyear = '20' + formYear;
   }
   else
   {
      eyear = formYear;
   }

   if( eyear < year || (eyear == year && emonth < month) )
   {
      alert( 'You must enter a valid expiration date' );
      return false;
   }

/* removed 06-SEP-2002 JSC (at Tim/Deslie's request)
   if( document.form2.ccfname.value == '' || document.form2.cclname.value == '' )
   {
      alert( 'You must enter first and last name' );
      return false;
   }

   if( document.form2.baddr1.value == '' || document.form2.bcity.value == '' || document.form2.bstate.selectedIndex == 0 || document.form2.bzip.value == '')
   {
      alert( 'You must enter your billing address' );
      return false;
   }
*/
   return true;
}



function ccvalidation2()
{
   if( document.form2.ccnbr.value == '' )
   {
      alert( 'You must enter a credit card number' );
      return false;
   }

   var today = new Date();
   var month = today.getMonth() + 1;
   var year = today.getYear();
   var formYear = document.form2.ccexpy.options[document.form2.ccexpy.selectedIndex].value;
   var formMonth = document.form2.ccexpm.options[document.form2.ccexpm.selectedIndex].value;

   // adjustment for IE/NS differences, good until 2100
   if( year < 200 )
   {
      year = year + 1900;
   }

   emonth = formMonth;

   //adjustment to allow for 2 digit years in the form
   //check to see if the 2 digit or 4 digit year is passed in
   if(formYear.length < 4 )
   {
      eyear = '20' + formYear;
   }
   else
   {
      eyear = formYear;
   }

   if( eyear < year || (eyear == year && emonth < month) )
   {
      alert( 'You must enter a valid expiration date' );
      return false;
   }

/* removed 06-SEP-2002 JSC (at Tim/Deslie's request)
   if( document.form2.ccfname.value == '' || document.form2.cclname.value == '' )
   {
      alert( 'You must enter first and last name' );
      return false;
   }

   if( document.form2.baddr1.value == '' || document.form2.bcity.value == '' || document.form2.bstate.selectedIndex == 0 || document.form2.bzip.value == '')
   {
      alert( 'You must enter your billing address' );
      return false;
   }
*/

   return true;
}

// navigation and action related stuff -----------------------------------------


// start new search
function newSearch( product )
{
   document.form2.action.value = "prodtop";
   document.form2.product.value = product;
   document.form2.subproduct.value = "search";
   document.form2.submit();
}

// modify search parameters
function modifySearch( product )
{
   document.form2.action.value = "prodtop-replay";
   document.form2.product.value = product;
   document.form2.subproduct.value = "search";
   document.form2.submit();
}

// view product info
function info( product )
{
   document.form2.action.value = "prodtop";
   document.form2.product.value = product;
   document.form2.subproduct.value = "prodinfo";
   document.form2.submit();
}

// view sample
function sample( product )
{
   document.form2.action.value = "prodtop";
   document.form2.product.value = product;
   document.form2.subproduct.value = "sample";
   document.form2.submit();
}


// purchase report
function report( docid )
{
   document.form2.docid.value = docid;
   document.form2.action.value = 'report';
   document.form2.submit();
}

// "buy all" functionality
function all()
{
   document.form2.all.value = "y";
   document.form2.action.value = "report-all";
   document.form2.submit();
}



<!-- *********************************************************************** -->

// search paging functions

function next( index, psize )
{
   index--;
   index++;
   psize--;
   psize++;
   index = index + psize;
   document.form2.start.value = index;
   document.form2.action.value = "page";
   document.form2.submit();
}

// previous page
function prev( index, psize )
{
   index--;
   index++;
   psize--;
   psize++;
   index = index - psize;
   document.form2.start.value = index;
   document.form2.action.value = "page";
   document.form2.submit();
}

// move to a particular page
function page( pagenbr, psize )
{
   var index;
   index = ((pagenbr-1) * psize) + 1;
   document.form2.start.value = index;
   document.form2.action.value = "page";
   document.form2.submit();
}


function valforgot1()
{
   if( document.form2.userid.value == "" )
   {
      alert( 'You must enter your user id' );
      return false;
   }
   return true;
}

function valforgot2()
{
   if( document.form2.firstname.value == ""
    || document.form2.lastname.value == ""
    || document.form2.email.value == "" )
   {
      alert( 'You must enter your first name, last name, and email address' );
      return false;
   }
   return true;
}

function VerifyBgCheckData()
{
    // if the user enters selfcheck as a purpose on the
    // family security product, send them to TC
    if(document.form1.purpose[7].checked == true)
    {
        goProduct("home", "pesc", "pescinterest", "");
        return false;
    }
	var errorMsg = new String( "" );

	if ( document.form1.firstname.value == "" )
	{
		errorMsg = errorMsg + "\nA First Name must be provided.";
	}
	if ( document.form1.lastname.value == "" )
	{
		errorMsg = errorMsg + "\nA Last Name must be provided.";
	}
	if ( document.form1.state.options[ document.form1.state.selectedIndex ].value == "" )
	{
		errorMsg = errorMsg + "\nA State must be provided.";
	}
	if (  ( document.form1.phone1.value == ""		) ||
			( document.form1.phone2.value == ""		) ||
			( document.form1.phone3.value == ""		) ||
			( isNaN( document.form1.phone1.value ) ) ||
			( isNaN( document.form1.phone2.value ) ) ||
			( isNaN( document.form1.phone3.value ) ) )
	{
		errorMsg = errorMsg + "\nA Phone Number must be provided.";
	}
	if(document.form1.mvr != null && document.form1.purpose[7].checked == true)
	{
		errorMsg = errorMsg + "\n Self-Check cannot be selected when the MVR search has been chosen.";
	}
	var a = 0;
	while( a < document.form1.purpose.length )
	{
		if ( document.form1.purpose[a].checked )
		{
			break;
		}
		a = a + 1;
	}
	if ( a == document.form1.purpose.length )
	{
		errorMsg = errorMsg + "\nA Purpose is required.";
	}

	if (document.form1.purpose[8].checked == true && document.form1.other_text.value == "")
	{
		errorMsg = errorMsg + "\nA Description is required with Other choice.";
	}

	if ( errorMsg.length != 0 )
	{
		alert( errorMsg );
	}
	else
	{
		document.form1.submit();
	}
}

function VerifyReview()
{
	if( !document.form1.toa.checked )
	{
		alert( 'You must comply with the terms of the Background Check agreement in order to continue.' );
		return false;
	}

}

function verifyBGCustom()
{
	var checked = false;

	if(document.form1.ncr.checked)
	{
		checked = true;
	}
	else if(document.form1.ccr.checked)
	{
		checked = true;
	}
else if(document.form1.stsex.checked)
	{
		checked = true;
	}

else if(document.form1.mvr.checked)
	{
		checked = true;
	}
else if(document.form1.id_ver.checked)
	{
		checked = true;
	}
else if(document.form1.refchk.checked)
	{
		checked = true;
	}
else if(document.form1.edu_ver.checked)
	{
		checked = true;
	}
else if(document.form1.crd_ver.checked)
	{
		checked = true;
	}
else if(document.form1.emp_ver.checked)
	{
		checked = true;
	}

	if(!checked)
	{
		alert("You must select a Background Check Service to continue.");
		return false;
	}
else
	{
		return true;
	}
}

// Background Check Verfications
function VerifyPurpose()
{
  if (document.form1.purpose[8].checked == true && document.form1.other_text.value == "") {
    window.alert('You must enter something for the Other choice you have selected.')
    }
  else
  {
  document.form1.submit();
  }
}


function validateClueEmailRequestForm()
{
   if( document.form2.to.value == "")
   {
   	alert( 'You must enter at least one valid email address to continue.' );
   	return false;
   }
else if(document.form2.from.value == "")
   {
      alert( 'You must enter YOUR email address to continue.' );
      return false;
   }
else if(document.form2.name.value == "")
{
	alert( 'You must enter your full name to continue.' );
	return false;
}
else
	{
		return true;
	}
}

function validateClueShareRequest()
{
   if( document.form2.to.value == "")
   {
   	alert( 'You must enter at least one valid email address to continue.' );
   	return false;
   }
else if(document.form2.subject.value == "")
   {
      alert( 'You must enter a subject to continue.' );
      return false;
   }
else if(document.form2.message.value == "")
{
	alert( 'You must enter a message to continue.' );
	return false;
}
else
	{
		return true;
	}
}

// Hotjobs Share Report
function validatehotjobs()
{
  if( document.form2.to.value == "")
   {
   	alert( 'You must enter at least one valid email address to continue.' );
   	return false;
   }
  else if(document.form2.subject.value == "")
   {
      alert( 'You must enter a subject to continue.' );
      return false;
   }
  else if (document.form2.authorize.checked == false)
  {
    alert( 'AUTHORIZATION NEEDED:\n\nPlease provide authorization by checking the box\nnext to "I authorize ChoiceTrust to send these results\nto the email addresses I provided above."' );
   	return false;
  }
  else
	{
		return true;
	}
}
// End Hotjobs Share Report

// Login
function clearThis()
{
if (document.form2.mstatus[0].checked == true)
	{
		document.form2.userid.value = "";
    document.form2.password.value = "";
    document.form2.submit2.disabled = true;
	}
}

function openSubmit()
{
if (document.form2.mstatus[1].checked == true)
	{
    document.form2.submit2.disabled = false;
	}
}

function selfcheckwindow()
{
    var URL = "http://www.cnn.com"
         remote = window.open(URL, "info",
         "resizable=no,toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=0,copyhistory=0,width=800,height=600");
}

function existingMember()
{
  document.form2.mstatus[1].checked = true;
  document.form2.submit2.disabled = false;
}
// End Login


// Fact Act
function vData(form)
{
  var errorMsg = new String( "" );

  if ( document.form2.housenbr.value == "" )
  {
    errorMsg = errorMsg + "\nPlease enter a valid Primary Address House/Unit #.";
  }
  
  if ( document.form2.streetname.value == "" )
  {
    errorMsg = errorMsg + "\nPlease enter a valid Primary Address Street Name.";
  }
  
  if ( document.form2.city.value == "" )
  {
    errorMsg = errorMsg + "\nPlease enter a valid Primary Address City.";
  }
  
  if ( document.form2.state.selectedIndex == 0 )
  {
    errorMsg = errorMsg + "\nPlease select a Primary Address State.";
  }
  
  if ( document.form2.zip.value == "" )
  {
    errorMsg = errorMsg + "\nPlease enter a valid Primary Address Zip Code.";
  }
  if (( document.form2.zip.value != "" ) && ( document.form2.zip.value.length != 5))
  {
    errorMsg = errorMsg + "\nPlease enter a valid Primary Address Zip Code.";
  }
  
  if (( document.form2.zipext.value != "" ) && ( document.form2.zipext.value.length != 4))
  {
    errorMsg = errorMsg + "\nPlease enter a 4 digit Primary Address Zip Extension.";
  }

  if ( errorMsg.length != 0 )
  {
    alert( errorMsg + "\n\nPlease Try Again" );
    return false;
  }

    return true;
}
// End Fact Act

<!-- *********************************************************************** -->

