/***** 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");
		var activeFirstLevelNode = "", aboutUs, learningCenters;
		var devPronet = "https://devpronet.fiducial.com/lsb/webbuilder/publicpage/";
		var pronet = "https://www.fiducial.com/lsb/webbuilder/publicpage/";
	
		var scriptName;
		var indexNo1 = document.location.href.lastIndexOf("/");
		var indexOf2 = document.location.href.indexOf("?");
		if (indexOf2 != -1) 
		{
			scriptName = document.location.href.substring(indexNo1 + 1, indexOf2);
		}
		else
		{
			scriptName = document.location.href.substring(indexNo1 + 1, document.location.href.length);
		}
				
		if (scriptName == "aboutus_fiducial.asp" || scriptName == "aboutus_meetourstaff.asp" || scriptName == "more_news.asp")
		{
			for(var i = 0; i < atags.length; i++)
			{
				if(atags[i].className == "nav1")
				{
					if (atags[i].href == devPronet + "aboutustemplate.asp" || atags[i].href == pronet + "aboutustemplate.asp")
					{
						atags[i].className = "active1";	
					}
				}
			}
		}
		else if(scriptName == "OurArticlesTemplate.asp" || scriptName == "OurDocumentLibraryTemplate.asp")
		{
			for(var i = 0; i < atags.length; i++)
			{
				if(atags[i].className == "nav1")
				{
					if (atags[i].href == "http://www.fiducial.com/learning_centers/")
					{
						atags[i].className = "active1";	
					}
				}
			}
		}
		
		
		atags = document.getElementsByTagName("a");
		for(var i = 0; i < atags.length; i++)
		{
			if(atags[i].className == "nav1")
			{
				//alert(document.location.href);
				//alert(atags[i].href);
				if(document.location.href.indexOf(atags[i].href) != -1)
				{
					atags[i].className = "active1";
				}
			}
			
			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){
		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]+'"><img src="'+banner_img[n]+'" width="428" height="80" border="0" alt="'+banner_desc[n]+'"></a>');
//}


/***** 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("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;
	}
}
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;
}
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());
}
