// 01/14/04 DJK - added section for the driver vehicle order tab page.
// 05/24/05 DJK - added section for retail outlet.
// 07/07/04 DJK - added section for alerts. 
// 04/15/05 DJK - added fucntion for demo fc
// 02/27/06 DJK - added displayIntro function for displaying web flash intro page.
// 04/13/06 DJK - added function fnlinkTop to link out of frameset pages.
// 09/11/06 DJK - add textCounter function to limit chars entered in textareas on forms.
// 09/12/06 DJK - add initDriverOption to default driver turnin option within Web fc. (not needed - kept for future)
// 09/28/06 DJK - add openDemoWebFC for popup-window to display help related information for the new web based fleetConnect.
// 02/18/08 LGE - P6904:Add toggleAutoRun() used for AutoRun MyReports functionality.
// 03/11/08 LGE - P6904:Remove changes to AUTOFREQ. Causing submit problems.
// 08/15/08 DJK - P15613: make refreshPage function specific to webserver code is runing on. May need to make more dynamic latter.
// 09/23/08 DJK - Comment out display intro finction. No longer needed.
// 12/29/08 LGE - P16841: Critical Alerts Enhancements
// 04/13/09 LGE - P17037: Driver Ordering 
// 08/05/09 DJK - P18175: change beta.emkay.com to demo.emkay.com. Also modify refreshPage method (to refresh first page of myReports option) 
//                        to refer to the correct domain name of the server it is running on.
// 12/16/09 DJK - P17889: driver paid options proj. 
//
// the following functions replade the old drop down menu functions
// *******************************************************************
function showMenu(menu,submenu)
{
	var elementid = document.getElementById(submenu);
	
	var xCoord = getXCoord(menu);
	var yCoord = getYCoord(menu);
//	var yCoord = getYCoord(menu);

    // added by direction from vihn at ewaken
	var menuid = document.getElementById(menu);
    xCoord += menuid.offsetWidth;
	// added by direction from vihn at ewaken
	
	// following code commented out by direction from vihn at ewaken
	/*if ((window.screen.width == 800) && ((document.location.href).indexOf("home",0) >= 0))
	{
		xCoord += 97;
	}
	else
	{
		xCoord += 125;
	}*/
	
	if (navigator.appName == "Microsoft Internet Explorer")
	{
		var	totalHeight = yCoord + getHeight(submenu) + 10
		var availHeight = parseInt(document.body.offsetHeight)*1 + parseInt(document.body.scrollTop)*1
		
		if (totalHeight > availHeight)
		{
			yCoord = yCoord - getHeight(submenu) + 16;
		}
	}
	else
	{
	}
	
	xCoord += 'px';
	yCoord += 'px';
	
	elementid.style.visibility = 'visible';
	elementid.style.left = xCoord;
	elementid.style.top = yCoord;
}

function hideMenu(submenu)
{
	var elementid = document.getElementById(submenu);
	
	if (elementid.style.visibility == 'visible') elementid.style.visibility = 'hidden';
}

function getXCoord(id)
{
	var elementid = document.getElementById(id);
	var xCoord = elementid.offsetLeft;
	var parent = elementid.offsetParent;
	
	while (parent != null)
	{
		xCoord += parent.offsetLeft;
		parent = parent.offsetParent;
	}
	return xCoord;
}

function getYCoord(id)
{
	var elementid = document.getElementById(id);
	var yCoord = elementid.offsetTop;
	var parent = elementid.offsetParent;
	
	while (parent != null)
	{
		yCoord += parent.offsetTop;
		parent = parent.offsetParent;
	}
	return yCoord;
}

function getHeight(id)
{
	var elementid = document.getElementById(id);
	var height = elementid.offsetHeight;
	return height;
}
//********************************************************************
// these are the old drop down menu functions
// they have not been deleted just in case
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_ShowLayers()
{
 //v3.0
  var i,p,v,obj,args=MM_ShowLayers.arguments;
  for (i=0; i<(args.length-2); i+=3) if ((obj=MM_findObj(args[i]))!=null) { v=args[i+2];
    if (obj.style) { obj=obj.style; v=(v=='show')?'visible':(v='hide')?'hidden':v; }
    obj.visibility=v; 

//if (navigator.appName == "Microsoft Internet Explorer")
if (true)
{
	x1 = window.event.clientX;
	x2 = window.event.offsetX;
	
	y1 = window.event.clientY;
	y2 = window.event.offsetY;
	
	obj.left = x1 - x2 +  ( document.body.scrollLeft ) + 120;
	obj.top = y1 - y2 +  ( document.body.scrollTop ) - 5;

	if ((parseInt((obj.top).substring(0,(obj.top).length-2)) + parseInt((obj.height).substring(0,(obj.height).length-2)) + window.screen.availHeight + 5 - document.body.offsetHeight) > (parseInt(document.body.scrollTop) + parseInt(window.screen.availHeight)))
	{
		//objPos = parseInt((obj.top).substring(0,(obj.top).length-2)) + parseInt((obj.height).substring(0,(obj.height).length-2)) + window.screen.availHeight + 5 - document.body.offsetHeight;
		//screenPos = parseInt(document.body.scrollTop) + parseInt(window.screen.availHeight);

		//obj.top = parseInt((obj.top).substring(0,(obj.top).length-2)) - (objPos - screenPos);
		obj.top = parseInt((obj.top).substring(0,(obj.top).length-2)) - parseInt((obj.height).substring(0,(obj.height).length-2)) + 30;
	}
}

else
{
//	obj.left = Z;
}

}
}

function MM_ShowLayers2()
{
 //v3.0
  var i,p,v,obj,args=MM_ShowLayers2.arguments;
  for (i=0; i<(args.length-2); i+=3) if ((obj=MM_findObj(args[i]))!=null) { v=args[i+2];
    if (obj.style) { obj=obj.style; v=(v=='show')?'visible':(v='hide')?'hidden':v; }
    obj.visibility=v; 

}
}

function MM_HideLayers()
{
 //v3.0
  var i,p,v,obj,args=MM_HideLayers.arguments;
  for (i=0; i<(args.length-2); i+=3) if ((obj=MM_findObj(args[i]))!=null) { v=args[i+2];
    if (obj.style) { obj=obj.style; v=(v=='show')?'visible':(v='hide')?'hidden':v; }
    obj.visibility=v; }
}

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_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_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];}
}

//Function for page navigation
function fnLink(pPageNam)
{
	location.href = pPageNam;
}

// Function for page navagation out of windows with frames.
function fnLinkTop(pPageNam) 
{
	top.location.href = pPageNam;
}

// emkay custom functions brought over from prior web site
function Legal_agreement(link) {
   window.open(link,"Legal","width=500,height=400,screenX=300,screenY=300,statusbar,scrollbars,menubar");
}

function Close_window(command){
   window.opener.location = command;
   window.close();
}

function openLinks(link) {
	newWindow = window.open(link, "Links", "resizable,toolbar,scrollbars,height=480,width=640");
    newWindow.focus();
}

// P17889 - <begin>
function openPolicy(link) {
	newWindow = window.open(link, "FleetPolicy", "screenX=300,screenY=300,resizable,toolbar,scrollbars,height=600,width=800");
    newWindow.focus();
}
// P17889 - <end>

function refreshPage() {
	var pos = document.cookie.indexOf("reload", 0);
	
	if (pos == -1) {
		var createPos = document.cookie.indexOf("create", 0);
		var maintPos = document.cookie.indexOf("maint", 0);
		var firstPos = document.URL.indexOf("signon.begin", 0);
		    					
		if ((createPos != -1) || (maintPos != -1) || (firstPos != -1)) {
			var demoPos = document.URL.indexOf("demo.emkay.com", 0);
								
			if (createPos != -1) {
				document.cookie="create=Y;expires=Sat, 01-Jan-2000 19:14:07 GMT;path=/";
				    
				if (demoPos != -1) {
					window.location.href = "http://demo.emkay.com/emkay/services?command=clientfleetdyn.createmenu&signon=client&country=USA";
				} else { window.location.href = "http://www.emkay.com/emkay/services?command=clientfleetdyn.createmenu&signon=client&country=USA";
				  }
			}
				
			if ((maintPos != -1) || (firstPos != -1)) {
				document.cookie="maint=Y;expires=Sat, 01-Jan-2000 19:14:07 GMT;path=/";
				    
				if (demoPos != -1) {
					window.location.href = "http://demo.emkay.com/emkay/services?command=clientfleetdyn.selectioncreate&signon=client&country=USA";
				} else { window.location.href = "http://www.emkay.com/emkay/services?command=clientfleetdyn.selectioncreate&signon=client&country=USA";
				  }
			}
						        
		    document.cookie="reload=N;path=/";
		}
			
	} else {
	        document.cookie="reload=N;expires=Sat, 01-Jan-2000 19:14:07 GMT;path=/";
	       }
}

function doSubmit() {
	document.cookie="reload=N;path=/";
}

function cleanUp() {
	document.cookie="create=Y;expires=Sat, 01-Jan-2000 19:14:07 GMT;path=/";
	document.cookie="maint=Y;expires=Sat, 01-Jan-2000 19:14:07 GMT;path=/";
}

function openImageWindow(command) {
	window.open(command,"imagewindow","width=600,height=500,screenX=25,screenY=50,toolbar=no,statusbar=1,scrollbars=yes,resizable=1");	
}
function openImageWindowWparms(command,parms) {
	window.open(command,"imagewindow",parms);	
}

// the following functions are used for the driver vehicle order page.
function displayExplore() {
    document.all.item('exploretab').style.visibility = "visible";
	document.all.item('ordertab').style.visibility = "hidden";
	document.all.item('paidoptstab').style.visibility = "hidden";
	document.all.item('oldunittab').style.visibility = "hidden";
	document.all.item('confirmtab').style.visibility = "hidden";
}

function displayOrder() {
    document.all.item('exploretab').style.visibility = "hidden";
	document.all.item('ordertab').style.visibility = "visible";
	document.all.item('paidoptstab').style.visibility = "hidden";
	document.all.item('oldunittab').style.visibility = "hidden";
	document.all.item('confirmtab').style.visibility = "hidden";
}

function displayPaidOpts() {
    if (checkDrvVehOrd()) {
		document.all.item('exploretab').style.visibility = "hidden";
		document.all.item('ordertab').style.visibility = "hidden";
		document.all.item('paidoptstab').style.visibility = "visible";
		document.all.item('oldunittab').style.visibility = "hidden";
		document.all.item('confirmtab').style.visibility = "hidden";
	}
}

function displayOldUnit() {
	if (checkDrvVehOrd()) {
		document.all.item('exploretab').style.visibility = "hidden";
		document.all.item('ordertab').style.visibility = "hidden";
		document.all.item('paidoptstab').style.visibility = "hidden";
		document.all.item('oldunittab').style.visibility = "visible";
		document.all.item('confirmtab').style.visibility = "hidden";
	}
}

function displayConfirm() {
	if (checkDrvVehOrd()) {
		document.all.item('exploretab').style.visibility = "hidden";
		document.all.item('ordertab').style.visibility = "hidden";
		document.all.item('paidoptstab').style.visibility = "hidden";
		document.all.item('oldunittab').style.visibility = "hidden";
		document.all.item('confirmtab').style.visibility = "visible";
	}
}

function updateCatField(form)
{
    var currentVal;
	
	for (var b = 0; b < form.carSelected.length; b++) {
      	if (form.carSelected[b].checked)
        	currentVal = form.carSelected[b].value;
	}
	
	form.currentCar.value = currentVal;
}

function addCols(form) {
    var optPrice1, optPrice2, optPrice3, optPrice4, optPrice5, optPrice6;
	var currenyVal;
		
	currencyVal = formatCurrency(form.OPTPRICE1.value);
	form.OPTPRICE1.value = currencyVal;
	currencyVal = formatCurrency(form.OPTPRICE2.value);
	form.OPTPRICE2.value = currencyVal;
	currencyVal = formatCurrency(form.OPTPRICE3.value);
	form.OPTPRICE3.value = currencyVal;
	currencyVal = formatCurrency(form.OPTPRICE4.value);
	form.OPTPRICE4.value = currencyVal;
	currencyVal = formatCurrency(form.OPTPRICE5.value);
	form.OPTPRICE5.value = currencyVal;
	currencyVal = formatCurrency(form.OPTPRICE6.value);
	form.OPTPRICE6.value = currencyVal;
	currencyVal = formatCurrency(form.OPTPRICETOT.value);
	form.OPTPRICETOT.value = currencyVal;
				
	optPrice1 = parseFloat(filterNum(form.OPTPRICE1.value)); 
	optPrice2 = parseFloat(filterNum(form.OPTPRICE2.value)); 
	optPrice3 = parseFloat(filterNum(form.OPTPRICE3.value)); 
	optPrice4 = parseFloat(filterNum(form.OPTPRICE4.value)); 
	optPrice5 = parseFloat(filterNum(form.OPTPRICE5.value)); 
	optPrice6 = parseFloat(filterNum(form.OPTPRICE6.value)); 
	 
	form.OPTPRICETOT.value = optPrice1 + optPrice2 + optPrice3 + optPrice4 + optPrice5 + optPrice6;
	
	currencyVal = formatCurrency(form.OPTPRICETOT.value);
	form.OPTPRICETOT.value = currencyVal;
}

function filterNum(str) {
<!-- Original:  Fred Roberts (fred@gloryofgod.com) -->
<!-- This script and many more are available free online at -->
<!-- The JavaScript Source!! http://javascript.internet.com -->
re = /^\$|,/g;
// remove "$" and ","
return str.replace(re, "");
}


function formatCurrency(num) {
<!-- Original:  Cyanide_7 (leo7278@hotmail.com) -->
<!-- Web Site:  http://www7.ewebcity.com/cyanide7 -->
<!-- This script and many more are available free online at -->
<!-- The JavaScript Source!! http://javascript.internet.com -->
num = num.toString().replace(/\$|\,/g,'');
if(isNaN(num))
num = "0";
sign = (num == (num = Math.abs(num)));
num = Math.floor(num*100+0.50000000001);
cents = num%100;
num = Math.floor(num/100).toString();
if(cents<10)
cents = "0" + cents;
for (var i = 0; i < Math.floor((num.length-(1+i))/3); i++)
num = num.substring(0,num.length-(4*i+3))+','+
num.substring(num.length-(4*i+3));
return (((sign)?'':'-') + '$' + num + '.' + cents);
}

function closeRequiredWindow() {
	document.all.item('required').style.visibility = "hidden";
}

function openRequiredWindow() {
    var coordY = event.clientY + document.body.scrollTop - 40;
	this.obj = document.getElementById('required').style;
    this.obj.top = coordY;
	document.all.item('required').style.visibility = "visible";
}

function openEmailErrorWindow() {
    var coordY = event.clientY + document.body.scrollTop - 40;
	this.obj = document.getElementById('emailError').style;
    this.obj.top = coordY;
//	this.obj.top = window.event.y;
//	this.obj.top = window.event.clientY;
//	alert("this is mouse position: " + window.event.clientX);
	document.all.item('emailError').style.visibility = "visible";
//	this.obj.top = 600;
//	for (var i = 0; i < 500; i++) {
//		this.obj.top = i;
//	}
}

function closeEmailErrorWindow() {
	document.all.item('emailError').style.visibility = "hidden";
}

function checkDrvVehOrd() {
    var returnVal;
	
	returnVal = 1;
	
	if (Trim(document.UIservletForm.LASTNAME.value)==""){ 
    	returnVal = 0;
	} 
	if (Trim(document.UIservletForm.FIRSTNAME.value)==""){ 
    	returnVal = 0;
	} 
	if(Trim(document.UIservletForm.ADDRESS1.value)==""){ 
    	returnVal = 0;
	} 
//	if(Trim(document.UIservletForm.ADDRESS2.value)==""){ 
//    	returnVal = 0;
//	}
	if(Trim(document.UIservletForm.COUNTY.value)==""){ 
    	returnVal = 0;
	} 
	if(Trim(document.UIservletForm.CITY.value)==""){ 
    	returnVal = 0;
	} 
	if(Trim(document.UIservletForm.REGION.value)==""){ 
    	returnVal = 0;
	} 
	if(Trim(document.UIservletForm.POSTALCODE.value)==""){ 
    	returnVal = 0;
	}
	if(Trim(document.UIservletForm.__compound__0_xxx_PHONE.value)==""){ 
    	returnVal = 0;
	} 
	if(Trim(document.UIservletForm.__compound__1_xxx_PHONE.value)==""){ 
    	returnVal = 0;
	} 
	if(Trim(document.UIservletForm.__compound__2_xxx_PHONE.value)==""){ 
    	returnVal = 0;
	} 
	if(Trim(document.UIservletForm.EMAIL.value)==""){ 
    	returnVal = 0;
	}
	if(Trim(document.UIservletForm.EMAIL2.value)==""){ 
    	returnVal = 0;
	}
	if(Trim(document.UIservletForm.EXTCOLOR.value)==""){ 
    	returnVal = 0;
	}
	if(Trim(document.UIservletForm.INTCOLOR.value)==""){ 
    	returnVal = 0;
	}
	if(Trim(document.UIservletForm.currentCar.value)==""){ 
    	returnVal = 0;
	}
	
	if (returnVal == 0) {
		openRequiredWindow();
	} else { returnVal = checkEmail();
	       }
	
	return returnVal;		
}

function checkEmail() {
    var returnVal;
	
	returnVal = 1;

	if (Trim(document.UIservletForm.EMAIL.value) != Trim(document.UIservletForm.EMAIL2.value)) {
		openEmailErrorWindow();
		returnVal = 0;
		
		return returnVal;
	}
	
	if (echeck(Trim(document.UIservletForm.EMAIL.value)) == false) {
		openEmailErrorWindow();
		returnVal = 0;
		
		return returnVal;
	}
		
	return returnVal;
}

function Trim(TRIM_VALUE){
	if(TRIM_VALUE.length < 1){
		return"";
	}
	
	TRIM_VALUE = RTrim(TRIM_VALUE);
	TRIM_VALUE = LTrim(TRIM_VALUE);

	if(TRIM_VALUE==""){
		return "";
	}
	else { return TRIM_VALUE;
         }
} 

function RTrim(VALUE){
	var w_space = String.fromCharCode(32);
	var v_length = VALUE.length;
	var strTemp = "";

	if(v_length < 0){
		return"";
	}

	var iTemp = v_length -1;

	while(iTemp > -1){
		if(VALUE.charAt(iTemp) == w_space){
		}
		else {
				strTemp = VALUE.substring(0,iTemp +1);
				break;
		 	 }
	
		iTemp = iTemp-1;

	} //End While
	
	return strTemp;
}

function LTrim(VALUE){
	var w_space = String.fromCharCode(32);
	
	if(v_length < 1){
		return"";
	}

	var v_length = VALUE.length;
	var strTemp = "";

	var iTemp = 0;

	while(iTemp < v_length){
		if(VALUE.charAt(iTemp) == w_space){
		}
		else {
				strTemp = VALUE.substring(iTemp,v_length);
				break;
			 }

		iTemp = iTemp + 1;
	} //End While

	return strTemp;
}

function openVehicleSpecs(link) {
    link = link + '?' + (new Date()).getTime();
	newWindow = window.open(link, "Vehicle_Specs", "resizable,toolbar,scrollbars,height=480,width=640");
//	for (i=0;i<10000;i++);
//	newWindow.location.reload(true);
//	newWindow.location.href = newWindow.location.href;
	newWindow.focus();
}

function openVehicleQuoteWin(link) {
	newWindow = window.open(link, "Vehicle_Quote", "resizable,toolbar,scrollbars,height=480,width=640");
    newWindow.focus();
}

function echeck(str) {
/*
   Code based on script from: Courtesy of SmartWebby.com (http://www.smartwebby.com/dhtml/) with
   various modifications.
      
   This function is used to verify if the given value is a possible valid email address. This 
   function thus simply makes sure the email address has one (@), atleast one (.). It also makes 
   sure that there are no spaces, extra '@'s or a (.) just before or after the @. It also makes 
   sure that there is atleast one (.) after the @.
 */

	var at="@"
	var dot="."
	var lat=str.indexOf(at)
	var lstr=str.length
	var ldot=str.indexOf(dot)
	
	if (str.indexOf(at)==-1){
		return false
	}

	if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
		return false
	}

	if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr) {
		return false
	}

	if (str.indexOf(at,(lat+1))!=-1) {
		return false
	}

	if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot) {
		return false
	}

	if (str.indexOf(dot,(lat+2))==-1) {
		return false
	}
		
	if (str.indexOf(" ")!=-1) {
		return false
	}

 	return true					
}

//
// The following functions are used for the alerts section of the website.
//
function openAlertsCfg(link) {
	newWindow = window.open(link, "Alerts_Configure", "scrollbars,height=500,width=644,top=30");
    newWindow.focus();
}

function openAlertsRpt(link) {
	newWindow = window.open(link, "Alerts_Reports", "resizable,scrollbars,height=375,width=700,left=80");
    newWindow.focus();
}

function criticalAlertToggle() {
    if (document.UIservletForm.CRITICALALERT.checked) {
		document.UIservletForm.SUPPRESSALERT.checked = false
		turnoff()
	}
}

function criticalAlertToggleFuelCfg() {
    if (document.UIservletForm.CRITICALALERT.checked) {
		document.UIservletForm.SUPPRESSALERT.checked = false
		turnoffFuelCfg()
	}
}

function turnoff() {
    if (document.UIservletForm.SUPPRESSALERT.checked) {
		document.all.item('alertCfgData').style.visibility = "hidden";
		document.UIservletForm.CRITICALALERT.checked = false
	} else { document.all.item('alertCfgData').style.visibility = "visible"
	       };
}

// 12/29/08  LGE - P16841: Critical Alerts Enhancement
//                 Adding new criteria
function turnoffFuelCfg() {
    if (document.UIservletForm.SUPPRESSALERT.checked) {
		document.all.item('alertCfgData').style.visibility = "hidden";
		document.all.item('alertCfgDataFuelCardPremFuelOpt').style.visibility = "hidden";
		document.all.item('alertCfgDataFuelCardOilOpt').style.visibility = "hidden";
		document.all.item('alertCfgDataFuelCardNonFuelOpt').style.visibility = "hidden";
		document.all.item('alertCfgDataFuelCardTankOption').style.visibility = "hidden";
		document.all.item('alertCfgDataFuelCardDailyTransOption').style.visibility = "hidden";
		document.all.item('alertCfgDataFuelCardMultiFillUpsOption').style.visibility = "hidden";
		document.UIservletForm.CRITICALALERT.checked = false
	} else { document.all.item('alertCfgData').style.visibility = "visible"
				premFuelOptsToggle();
				oilFuelOptsToggle();
				nonFuelOptsToggle();	
				fuelTankCapacityToggle();
				fuelDailyTransToggle();
				fuelMultiFillUpToggle();
	       };
}

function premFuelOptsToggle() {
    if (document.UIservletForm.PREFUEL.checked) {
		document.all.item('alertCfgDataFuelCardPremFuelOpt').style.visibility = "hidden"
	} else { document.all.item('alertCfgDataFuelCardPremFuelOpt').style.visibility = "visible"
	       };
}

function oilFuelOptsToggle() {
    if (document.UIservletForm.OILCHANGES.checked) {
		document.all.item('alertCfgDataFuelCardOilOpt').style.visibility = "hidden"
	} else { document.all.item('alertCfgDataFuelCardOilOpt').style.visibility = "visible"
	       };
}

function nonFuelOptsToggle() {
    if (document.UIservletForm.NONFUEL.checked) {
		document.all.item('alertCfgDataFuelCardNonFuelOpt').style.visibility = "hidden"
	} else { document.all.item('alertCfgDataFuelCardNonFuelOpt').style.visibility = "visible"
	       };
}

// 12/29/08  LGE - P16841: Critical Alerts Enhancements <begin>
function fuelTankCapacityToggle() {
    if (document.UIservletForm.FUELTANKCAPACITY.checked) {
		document.all.item('alertCfgDataFuelCardTankOption').style.visibility = "hidden"
	} else { document.all.item('alertCfgDataFuelCardTankOption').style.visibility = "visible"
	       };
}

function fuelDailyTransToggle() {
	if (document.UIservletForm.FUELDAILYTRANS.checked) {
		document.all.item('alertCfgDataFuelCardDailyTransOption').style.visibility = "hidden"
	} else { document.all.item('alertCfgDataFuelCardDailyTransOption').style.visibility = "visible"
		   };
}

function fuelMultiFillUpToggle() {
	if (document.UIservletForm.FUELMULTIFILLUPS.checked) {
		document.all.item('alertCfgDataFuelCardMultiFillUpsOption').style.visibility = "hidden"
	} else { document.all.item('alertCfgDataFuelCardMultiFillUpsOption').style.visibility = "visible"
		   };
}
	

// 12/29/08  LGE - P16841: Critical Alerts Enhancements <end>



// 
// the following functions are used for the retial outlet section
//
function openRetailPics(link) {
	newWindow = window.open(link, "Retail_Outlet", "scrollbars,height=375,width=644");
    newWindow.focus();
}

//
// the following fuction is for the demo fc - this will only be needed for the test website
//
function openDemoFC(link) {
	newWindow = window.open(link, "DEMO_FC", "height=552,width=800");
    newWindow.focus();
}

//
// djk - the following fuction is for the web fc help files.
//
function openDemoWebFC(link) {
	newWindow = window.open(link, "DEMO_FC", "height=620,width=820");
    newWindow.focus();
}

//
// the following function can be used to break out of a frame.
//
function breakout_of_frame()
{
  if (top.location != location) {
    top.location.href = document.location.href;
  }
}


//
// the following function is used to display the web site flash intro page
//
// retired since web 2008 re-design
//
//function displayIntro() {
//	var pos = document.cookie.indexOf("intro", 0);
//	
//	if (pos == -1) {
//		document.cookie="intro=Y;expires=Sat, 01-Jan-2100 00:00:00 GMT;path=/";
//		
//		var betaPos = document.URL.indexOf("beta.emkay.com", 0);
//		
//		if (betaPos != -1) {
//			var betaDevPos = document.URL.indexOf("newlook", 0);
//			
//			if (betaDevPos != -1) {
//				window.location.href = "http://beta.emkay.com/newlook/intro.htm";	
//			} else {
//				window.location.href = "http://beta.emkay.com/intro.htm";	
//			  }
//			
//		} else { window.location.href = "http://www.emkay.com/intro.htm";
//		  }
//	}
//}



// Original:  Ronnie T. Moore -->
// Web Site:  The JavaScript Source -->
// Dynamic 'fix' by: Nannette Thacker -->
// Web Site: http://www.shiningstar.net -->
// This script and many more are available free online at -->
// The JavaScript Source!! http://javascript.internet.com -->
//
// 09/11/2006 - djk - modified to work without an included counter.
//
function textCounter(field, maxlimit) {
	if (field.value.length > maxlimit) // if too long...trim it!
	field.value = field.value.substring(0, maxlimit);
}


// code to check if replace driver option is not checked within web fc
// 
// 09/12/2006 - djk - initial version. - not needed. kept for future reference.
//
function initDriverOption() {
    var driverOptionChecked 

	for (var i=0; i < document.form.TURNINDRIVEROPTION.length; i++) {
		if (document.form.TURNINDRIVEROPTION[i].checked) {
			driverOptionChecked  = document.form.TURNINDRIVEROPTION[i].value
		}
	}
		
	if(!driverOptionChecked) { 
		document.form.TURNINDRIVEROPTION[0].checked = true;
	}
}

//
// script to toggle passed in layer either on or off.
// iState = 1 visible, 0 hidden
//
// 12/06 - djk - initial version.
//

function toggleDiv(szDivID, iState) {
	var obj = document.layers ? document.layers[szDivID] :
		      document.getElementById ?  document.getElementById(szDivID).style :
		      document.all[szDivID].style;
	    
     obj.visibility = document.layers ? (iState ? "show" : "hide") :
	                  (iState ? "visible" : "hidden");
}

//
// function: toggleAutoRun() 
// desc:     Script to toggle autoRun features on or off. 
//           Ensures user cleanly selects between period or range
//           and AutoRun.  
//
//           If the AutoRun checkbox is checked then
//           start date, email text, frequency is enabled and
//           start-end date range is disaabled. 
//           
//           If the AutoRun checkbox is NOT checked, then
//           disable start date, email text, frequency controls and
//           enable the start-end date range.
//
//
// 02/18/08  lge: P6904 initial version.
//
function toggleAutoRun() {
    var b;

    if (document.UIservletForm.AUTORUN.checked) {
        document.UIservletForm.AUTOSTARTDATE.disabled = false;
        document.UIservletForm.AUTOEMAILS.disabled = false;
        for (b = 0; b < document.UIservletForm.AUTOFREQ.length; b++)
             document.UIservletForm.AUTOFREQ[b].disabled = false;             

    } else {  
        document.UIservletForm.AUTOSTARTDATE.value = "";    
        document.UIservletForm.AUTOEMAILS.value = "";
              			                                  
    }
}

// 
// function: openDrvOrdMgrEmail(link)
// desc:     Script to open up the email resend
//
// 04/13/09  lge: P17037 Driver Ordering
function openDrvOrdMgrEmail(link) {
	newWindow = window.open(link, "Driver_Order_Mgr_Email", "height=350,width=697,top=30");
    newWindow.focus();
}

// 
// function: openDrvOrdMgr(link)
// desc:     Script to open up the email resend
//
// 04/13/09  lge: P17037 Driver Ordering
function openDrvOrdMgr(link) {
	newWindow = window.open(link, "Driver_Order_Mgr", "resizable,scrollbars,height=775,width=715,top=80");
    newWindow.focus();
}

// P17889 - <begin>
function openPrintPrev(link) {
	newWindow = window.open(link, "Print_View", "resizable,scrollbars,height=775,width=800,top=80");
    newWindow.focus();
}
// P17889 - <end>
