/***** FIDUCIAL.JS *****/
/***** modern code *****/

// donavhighlights()
// this function will apply CSS classes as appropriate to the main navigation to 
// identify what page the user is currently on.
// Mike Raichelson - dec 08, 2003
// * modified dec 09, 2003: changed variable scope of counters (i) to be local and
//   not global variables. (MR)
// * modified dec 22, 2003: made change to CSS so that active navigation elements 
//   require only one CSS class to be applied to them. updated accordingly.
//   this fixes one glitch in NN4 where active nav elements would appear unstyled.
//   
function donavhighlights(){
	if(!document.layers){
		var atags=document.getElementsByTagName("a");
		for(var i=0;i<atags.length;i++){
			if(atags[i].className=="nav1"){
				if(document.location.href.indexOf(atags[i].href)!=-1){
					atags[i].className="active1";
				}
			}
		}
		var atags=document.getElementsByTagName("a");
		for(var i=0;i<atags.length;i++){
			if(atags[i].className=="nav2"){
				if(document.location.href.indexOf(atags[i].href)!=-1){
					atags[i].className="active2";
				}
			}
		}
	}
}


// checkesolform()
// this checks to see if the user has entered a username and password before submitting 
// the esolutions login form. this is just to cut down on unnecessary server load for 
// trying to process blank requests.
// Mike Raichelson - dec 04, 2003
function checkesolform(){
	var checkname=false;
	var checkpass=false;
	if(document.logform.uname.value){
		var checkname=true;
	}
	if(document.logform.pwd.value){
		var checkpass=true;
	}
	
	if(checkname&&checkpass){
		/*if (document.logform.UserCate.value=="com")
			document.logform.action="/checklogin.asp";*/
		document.logform.submit();
	}else{
		if(!checkname&&!checkpass){
			alert('Please enter your Username and Password.');
		}else if(checkname&&!checkpass){
			alert('Please enter your Password.');
		}else{
			alert('Please enter your Username.');
		}
	}
}


// checklocform()
// this checks to see if the user has entered a zip code before submitting the 
// locate a franchisee form. again, it's just here to cut down on unnecessary server load
// for blank requests and such.
// Mike Raichelson - dec 04, 2003
// * modified dec 09, 2003: now checks input to make sure that it is a number and not text
//   form will not submit with text as input. (MR)
function checklocform(){
	if(document.locateFranchisee.filterBy.value&&!isNaN(parseInt(document.locateFranchisee.filterBy.value))){
		document.locateFranchisee.submit();
	}else{
		alert('Please enter your Zip Code.');
		return false;
	}
}


// bannerad()
// this grabs a random banner ad from the banners.js array file and displays it on the page.
// Mike Raichelson - jan 13, 2004
function bannerad(){
	var n=Math.floor(Math.random() * banner_img.length);
	document.write('<a href="'+banner_url[n]+'?banner=true"><img src="'+banner_img[n]+'" width="428" height="80" border="0" alt="'+banner_desc[n]+'"></a>');
}

// bannerad2()
// this grabs a random banner ad from the ad_banners.js array file and displays it on the page.
// added for bottom of page banners.
// Mike Raichelson - apr 21, 2004
function bannerad2(){
	var n=Math.floor(Math.random() * adbanner_img.length);
	document.write('<a href="'+adbanner_url[n]+'?bottombanner=true"><img src="'+adbanner_img[n]+'" width="428" height="80" border="0" alt="'+adbanner_desc[n]+'"></a>');
}

// taxcountdown()
// this writes the number of days left between the current date and april 15th as a 
// countdown to when taxes are due.
// Mike Raichelson - feb 27, 2004
function taxcountdown(){
	var taxday=new Date("April 15, 2004 00:00");
	var today=new Date();
	var perday=24*60*60*1000; // 24 hours * 60 minutes * 60 seconds * 1000 milliseconds = milliseconds per day
	var daysleft=(taxday.getTime()-today.getTime())/perday;
	var daysoutput=Math.round(daysleft);
	document.write("There's only "+daysoutput+" days left until April 15th!");
}

// launchdemo(url)
// this opens a popup window to show a product demo.
// Mike Raichelson - mar 05, 2004
function launchdemo(url){
	var left = (screen.width - 610)/2;
	var top = (screen.height - 470)/2;
	var demoWin=window.open(url,'demoWin','width=600,height=420,left='+left+',top='+top+',scrollbars=no,resizeable=no,status=yes,location=no,menubar=no,toolbar=no');
	demoWin.focus();
}

/***** LEGACY CODE *****/
// these are old Macromedia scripts.
// they are here only because they are used in some legacy content.
// most noticeably they are used in the /our_services/ppc_demo/ pages.

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}
function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}
function MM_findObj(n, d) { //v4.0
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && document.getElementById) x=document.getElementById(n); return x;
}
function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}


// more legacy JS code, again for the PPC demo
function TaxFiling()
{
	taxfile=window.open("/our_services/payroll/TaxFiling.htm", "taxfiling", "toolbar=no,resizable=no,scrollbars=no,height=350,width=330")
}
function isNumeric(elm)
{
	if (isNaN(elm.value) == false)
	{
		return true;
	}
	else
	{
		return false;
	}
}
function isFilled(elm)
{
	if (elm.value == "" ||
	    elm.value == null)
	{
		return false;
	}	
	else 
	{
		return true;
	}
}
function isValidEmail(elm) 
{
	if (elm.value.indexOf("@") !="-1" &&
	    elm.value.indexOf(".") !="-1" ||
	    elm.value == "")
	{
		return true;
	}
	else 
	{
		return false;
	}
}
// validation script for consulting form
function checkconsform(form) 
{
	if (isFilled(form.txtFName) == false)
	{
		alert("Please enter your first name.");
		form.txtFName.focus();
		return false;
	}
	if (isFilled(form.txtLName) == false)
	{
		alert("Please enter your last name.");
		form.txtLName.focus();
		return false;
	}
	if (isFilled(form.txtAddress) == false)
	{
		alert("Please enter your address.");
		form.txtAddress.focus();
		return false;
	}
	if (isFilled(form.txtCity) == false)
	{
		alert("Please enter your city.");
		form.txtCity.focus();
		return false;
	}
	if (isFilled(form.txtZip) == false)
	{
		alert("Please enter your zip code.");
		form.txtZip.focus();
		return false;
	}
	if (isFilled(form.txtDayPhone) == false)
	{
		alert("Please enter your phone number.");
		form.txtDayPhone.focus();
		return false;
	}
	if (isFilled(form.txtEmail) == false)
	{
		alert("Please enter your e-mail.");
		form.txtEmail.focus();
		return false;
	}
	if (isValidEmail(form.txtEmail) == false)
	{
		alert("Please enter e-mail in the following format:\n\nname@email.com");
		form.txtEmail.focus();
		return false;
	}
	var chkd = 0
	for (rr=0;rr<form.rdoContactBy.length;rr++)
	{
		if (form.rdoContactBy[rr].checked == true)
		{
			chkd = chkd + 1
		}
	}
	if (chkd == 0)
	{
		alert("Please select a preferred contact method.");
		form.rdoContactBy[0].focus();
		return false;
	}
	var chkd = 0
	for (ii=0;ii<form.chkInterest.length;ii++)
	{
		if (form.chkInterest[ii].checked == true)
		{
			chkd = chkd + 1
		}
	}
	if (chkd == 0)
	{
		alert("Please select items you are interested in.");
		form.chkInterest[0].focus();
		return false;
	}
	if (isFilled(form.txtOtherSituation) == false)
	{
		var chkd = 0
		for (ca=0;ca<form.chkSituation.length;ca++)
		{
			if (form.chkSituation[ca].checked == true)
			{
				chkd = chkd + 1
			}
		}
		if (chkd == 0)
		{
			alert("Please select a situation or enter a situation into the specified field.");
			form.chkSituation[0].focus();
			return false;
		}		
	}
	return true;
}
// validation script for PPC processing
function checkform(form) 
{
	if (isFilled(form.Company) == false)
	{
		alert("Please enter your company name.");
		form.Company.focus();
		return false;
	}
	if (isFilled(form.ContactFName) == false)
	{
		alert("Please enter your first name.");
		form.ContactFName.focus();
		return false;
	}
	if (isFilled(form.ContactLName) == false)
	{
		alert("Please enter your last name.");
		form.ContactLName.focus();
		return false;
	}
	if (isFilled(form.Email) == false)
	{
		alert("Please enter your e-mail.");
		form.Email.focus();
		return false;
	}
	if (isValidEmail(form.Email) == false)
	{
		alert("Please enter e-mail in the following format:\n\nname@email.com");
		form.Email.focus();
		return false;
	}
	if (isFilled(form.Address) == false)
	{
		alert("Please enter your address.");
		form.Address.focus();
		return false;
	}
	if (isFilled(form.City) == false)
	{
		alert("Please enter your city.");
		form.City.focus();
		return false;
	}
	if (isFilled(form.Zip) == false)
	{
		alert("Please enter your zip code.");
		form.Zip.focus();
		return false;
	}
	if (isNumeric(form.Zip) == false)
	{
		alert("Zip code must be numeric.");
		form.Zip.focus();
		return false;
	}
	if (isFilled(form.Phone) == false)
	{
		alert("Please enter your phone number.");
		form.Phone.focus();
		return false;
	}
	if (isFilled(form.No_of_Employees) == false)
	{
		alert("Please enter number of employees.");
		form.No_of_Employees.focus();
		return false;
	}
	if (isNumeric(form.No_of_Employees) == false)
	{
		alert("This field must be numeric.");
		form.No_of_Employees.focus();
		return false;
	}
	return true;
}

// validation script for service processing / special report SEM
function CheckServiceForm(form) 
{
	if (isFilled(form.Company) == false)
	{
		alert("Please enter your company name.");
		form.Company.focus();
		return false;
	}
	if (isFilled(form.ContactFName) == false)
	{
		alert("Please enter your first name.");
		form.ContactFName.focus();
		return false;
	}
	if (isFilled(form.ContactLName) == false)
	{
		alert("Please enter your last name.");
		form.ContactLName.focus();
		return false;
	}
	if (isFilled(form.Email) == false)
	{
		alert("Please enter your e-mail.");
		form.Email.focus();
		return false;
	}
	if (isValidEmail(form.Email) == false)
	{
		alert("Please enter e-mail in the following format:\n\nname@email.com");
		form.Email.focus();
		return false;
	}
	if (isFilled(form.Address) == false)
	{
		alert("Please enter your address.");
		form.Address.focus();
		return false;
	}
	if (isFilled(form.City) == false)
	{
		alert("Please enter your city.");
		form.City.focus();
		return false;
	}
	if (isFilled(form.Zip) == false)
	{
		alert("Please enter your zip code.");
		form.Zip.focus();
		return false;
	}
	if (isNumeric(form.Zip) == false)
	{
		alert("Zip code must be numeric.");
		form.Zip.focus();
		return false;
	}
	if (isFilled(form.Phone) == false)
	{
		alert("Please enter your phone number.");
		form.Phone.focus();
		return false;
	}
	if (isNumeric(form.Phone) == false)
	{
		alert("Please enter only numeric value for phone number.");
		form.Phone.focus();
		return false;
	}
	
	return true;
}

// validation script for special report SEM2
function checkSEM2Form(form) 
{
	if (isFilled(form.txtFName) == false)
	{
		alert("Please enter your first name.");
		form.txtFName.focus();
		return false;
	}
	if (isFilled(form.txtLName) == false)
	{
		alert("Please enter your last name.");
		form.txtLName.focus();
		return false;
	}
	if (isFilled(form.txtAddress) == false)
	{
		alert("Please enter your address.");
		form.txtAddress.focus();
		return false;
	}
	if (isFilled(form.txtCity) == false)
	{
		alert("Please enter your city.");
		form.txtCity.focus();
		return false;
	}
	if (isFilled(form.txtZip) == false)
	{
		alert("Please enter your zip code.");
		form.txtZip.focus();
		return false;
	}
	if (isNumeric(form.txtZip) == false)
	{
		alert("Zip code must be numeric.");
		form.txtZip.focus();
		return false;
	}
	if (isFilled(form.txtDayPhone) == false)
	{
		alert("Please enter your phone number.");
		form.txtDayPhone.focus();
		return false;
	}
	if (isNumeric(form.txtDayPhone) == false)
	{
		alert("Please enter only numeric value for phone number.");
		form.txtDayPhone.focus();
		return false;
	}
	if (isFilled(form.txtEmail) == false)
	{
		alert("Please enter your e-mail.");
		form.txtEmail.focus();
		return false;
	}
	if (isValidEmail(form.txtEmail) == false)
	{
		alert("Please enter e-mail in the following format:\n\nname@email.com");
		form.txtEmail.focus();
		return false;
	}
	return true;
}

function two(sURL2){
	newwindow2=open(sURL2,"one2e","scrollbars=yes,toolbar=no,directories=no,menubar=no,resizable=yes,status=no,width=300,height=300");
	if (window.focus) (newwindow2.focus());
}

// validation script for Acquisition processing
function checkformAcq(form) 
{
 if (isFilled(form.Company) == false)
 {
  alert("Please enter your company name.");
  form.Company.focus();
  return false;
 }
 if (isFilled(form.ContactFName) == false)
 {
  alert("Please enter your first name.");
  form.ContactFName.focus();
  return false;
 }
 if (isFilled(form.ContactLName) == false)
 {
  alert("Please enter your last name.");
  form.ContactLName.focus();
  return false;
 }
 if (isFilled(form.Email) == false)
 {
  alert("Please enter your e-mail.");
  form.Email.focus();
  return false;
 }
 if (isValidEmail(form.Email) == false)
 {
  alert("Please enter e-mail in the following format:\n\nname@email.com");
  form.Email.focus();
  return false;
 }
 if (isFilled(form.Address) == false)
 {
  alert("Please enter your address.");
  form.Address.focus();
  return false;
 }
 if (isFilled(form.City) == false)
 {
  alert("Please enter your city.");
  form.City.focus();
  return false;
 }
 if (isFilled(form.Zip) == false)
 {
  alert("Please enter your zip code.");
  form.Zip.focus();
  return false;
 }
 if (isNumeric(form.Zip) == false)
 {
  alert("Zip code must be numeric.");
  form.Zip.focus();
  return false;
 }
 if (isFilled(form.Phone) == false)
 {
  alert("Please enter your phone number.");
  form.Phone.focus();
  return false;
 }
 if (isFilled(form.No_of_Employees) == false)
 {
  alert("Please enter number of employees.");
  form.No_of_Employees.focus();
  return false;
 }
 if (isNumeric(form.No_of_Employees) == false)
 {
  alert("This field must be numeric.");
  form.No_of_Employees.focus();
  return false;
 }
 return true;
}

// validation script for Payroll Accounts Purchase 
function checkformPayroll(form) 
{
 if (isFilled(form.Company) == false)
 {
  alert("Please enter your company name.");
  form.Company.focus();
  return false;
 }
 if (isFilled(form.ContactFName) == false)
 {
  alert("Please enter your first name.");
  form.ContactFName.focus();
  return false;
 }
 if (isFilled(form.ContactLName) == false)
 {
  alert("Please enter your last name.");
  form.ContactLName.focus();
  return false;
 }
 if (isFilled(form.Email) == false)
 {
  alert("Please enter your e-mail.");
  form.Email.focus();
  return false;
 }
 if (isValidEmail(form.Email) == false)
 {
  alert("Please enter e-mail in the following format:\n\nname@email.com");
  form.Email.focus();
  return false;
 }
 if (isFilled(form.Address) == false)
 {
  alert("Please enter your address.");
  form.Address.focus();
  return false;
 }
 if (isFilled(form.City) == false)
 {
  alert("Please enter your city.");
  form.City.focus();
  return false;
 }
 if (isFilled(form.Zip) == false)
 {
  alert("Please enter your zip code.");
  form.Zip.focus();
  return false;
 }
 if (isNumeric(form.Zip) == false)
 {
  alert("Zip code must be numeric.");
  form.Zip.focus();
  return false;
 }
 if (isFilled(form.Phone) == false)
 {
  alert("Please enter your phone number.");
  form.Phone.focus();
  return false;
 }
}
 
 // validation script for ad campaign Special Reports 
function checkformReports(form) 
{
 if (isFilled(form.Company) == false)
 {
  alert("Please enter your company name.");
  form.Company.focus();
  return false;
 }
 if (isFilled(form.ContactFName) == false)
 {
  alert("Please enter your first name.");
  form.ContactFName.focus();
  return false;
 }
 if (isFilled(form.ContactLName) == false)
 {
  alert("Please enter your last name.");
  form.ContactLName.focus();
  return false;
 }
 if (isFilled(form.Email) == false)
 {
  alert("Please enter your e-mail.");
  form.Email.focus();
  return false;
 }
 if (isValidEmail(form.Email) == false)
 {
  alert("Please enter e-mail in the following format:\n\nname@email.com");
  form.Email.focus();
  return false;
 }
 if (isFilled(form.Address) == false)
 {
  alert("Please enter your address.");
  form.Address.focus();
  return false;
 }
 if (isFilled(form.City) == false)
 {
  alert("Please enter your city.");
  form.City.focus();
  return false;
 }
 if (isFilled(form.Zip) == false)
 {
  alert("Please enter your zip code.");
  form.Zip.focus();
  return false;
 }
 if (isNumeric(form.Zip) == false)
 {
  alert("Zip code must be numeric.");
  form.Zip.focus();
  return false;
 }
 if (isFilled(form.Phone) == false)
 {
  alert("Please enter your phone number.");
  form.Phone.focus();
  return false;
 }
  
}


function na_open_window(name, url, left, top, width, height, toolbar, menubar, statusbar, scrollbar, resizable)
{
  toolbar_str = toolbar ? 'yes' : 'no';
  menubar_str = menubar ? 'yes' : 'no';
  statusbar_str = statusbar ? 'yes' : 'no';
  scrollbar_str = scrollbar ? 'yes' : 'no';
  resizable_str = resizable ? 'yes' : 'no';
  cookie_str = document.cookie;
  cookie_str.toString();
  pos_start  = cookie_str.indexOf(name);
  pos_end    = cookie_str.indexOf('=', pos_start);
  cookie_name = cookie_str.substring(pos_start, pos_end);
  pos_start  = cookie_str.indexOf(name);
  pos_start  = cookie_str.indexOf('=', pos_start);
  pos_end    = cookie_str.indexOf(';', pos_start);
  
  if (pos_end <= 0) pos_end = cookie_str.length;
  cookie_val = cookie_str.substring(pos_start + 1, pos_end);
  if (cookie_name == name && cookie_val  == "done")
    return;
  window.open(url, name, 'left='+left+',top='+top+',width='+width+',height='+height+',toolbar='+toolbar_str+',menubar='+menubar_str+',status='+statusbar_str+',scrollbars='+scrollbar_str+',resizable='+resizable_str);
}

function RestrictUserToView(strURL, strPermission)
{
	document.location = strURL;
}