<!--

function Over(link,id,overIm) {
  if(document.images) {
    im            = document.images[id];
    im.outIm      = new Image();
    im.overIm     = new Image();
    im.outIm.src  = document.images[id].src;
    im.overIm.src = overIm;
    im.src        =im.overIm.src;
    link.onmouseout  = new Function("var im=document."+id+"; im.src=im.outIm.src;");
    link.onmouseover = new Function("var im=document."+id+"; im.src=im.overIm.src;");
  }
}
function HideDIV(d) { document.getElementById(d).style.display = "none"; }
function DisplayDIV(d) { document.getElementById(d).style.display = "block"; }


function getCurrentTab() {
	for (var i=0; i<tabCount; i++) {
		if (document.images['img_navTab'+i]) {
			// Check state
			if (document.images['img_navTab'+i].src.match(/_on\.gif$/)) {
				return(i);
			}
		}			
	}
}

function tabHilite(tabID) {
	if (document.images['img_navTab'+tabID]) {
		// Check state
		if ( (tabID != thisSectionTab) && (!document.images['img_navTab'+tabID].src.match(/_on\.gif$/)) ) {
			imgHilite('img_navTab'+tabID);
		}
	}
}

function tabUnHilite(tabID) {
	if (document.images['img_navTab'+tabID]) {
		// Check state
		if ( (tabID != thisSectionTab) && (!document.images['img_navTab'+tabID].src.match(/_off\.gif$/)) ) {
			imgUnHilite('img_navTab'+tabID);
		}
	}
}
	
function isNumeric(x) {
	var myRegExp = /^[-+]?[0-9]*\.?[0-9]+(?:[eE][-+]?[0-9]+)?$/; 
	var result = x.match(myRegExp);

	if (result==null) result=false;

	return result;
}

function imgHilite(imgName) {
	// Amended 4/24/07 to generalize for PNG or GIF
	if (document.images[imgName]) {
		var img = document.images[imgName];
		var patt = /^([^\/]+)(.*?)(off)(\.(gif|png))$/;
		if (img.src.match(patt)) {
			img.src = RegExp.$2 + 'on' + RegExp.$4;
		}
	}
}

function imgUnHilite(imgName) {
	// Amended 4/24/07 to generalize for PNG or GIF
	if (document.images[imgName]) {
		var img = document.images[imgName];
		var patt = /^([^\/]+)(.*?)(on)(\.(gif|png))$/;
		if (img.src.match(patt)) {
			img.src = RegExp.$2 + 'off' + RegExp.$4;
		}
	}
}

function customDateString(oneDate) {
	var theDay = dayNames[oneDate.getDay() + 1];
	var theMonth = monthNames[oneDate.getMonth() + 1];
	var theYear = oneDate.getFullYear();
	return theDay.substring(0,3).toUpperCase() + "  |  " + theMonth.toUpperCase() + " " + oneDate.getDate() + ", " + theYear;
}

function DropdownChooser(Product) {
	if (Product != "") {
		window.location = Product;
	}
}

function reselectDropdown(frm,drop,val) {
	if (val != '') {
		var root = document.forms[frm].elements[drop];

		for (var t=0; t<root.length; t++) {
			if (root[t].value == val) {
				root.selectedIndex = t;
			}
		}
	}
}

function launchCT(tour) {
	if (tour == 'acartprocess') {
		openWindow('acartprocess/index.html','TOURWIN',1050,600,null,null,true,true);	
	}
	else if (tour == 'producttour') {
		openWindow('producttour/index.html','TOURWIN',1050,600,null,null,true,true);	
	}
}

function openWindow(URL,Name,W,H,L,T,Scrolls,Resize) {
	// Used to control params of pop-ups
	var defProps = 'copyhistory=0,directories=0,fullscreen=0,location=1,menubar=0,status=1,titlebar=1,toolbar=0';
	var poppedProps = '';

	if (W != null) {
		if (Scrolls == true) { W += 16; } // Allow for chrome in IE
		poppedProps += ('width='+W+',');
	}
	if (H != null) { poppedProps += ('height='+H+','); }
	if (L != null) { poppedProps += ('left='+L+','); }
	if (T != null) { poppedProps += ('top='+T+','); }
	poppedProps += 'scrollbars=' + ((Scrolls == true) ? 1 : 0) + ',' ;
	poppedProps += 'resizable=' + ((Resize == true) ? 1 : 0) + ',' ;
	poppedProps += defProps;

//	alert(poppedProps);
	poppedUp = window.open(URL,Name,poppedProps);
	setTimeout("poppedUp.window.focus();",100);
	return poppedUp;
}

function getObject(myid) {
	if ((HM_IE) || (HM_DOM)) {
		// Explorer
		if (HM_IE){
			return (document.all[myid]);
		}
		// DOM Browsers
		else if (HM_DOM) {
			return (document.getElementById(myid));
		}
	}
	else {
		return (false);
	}
}

function makeArray(n) {
//*** BUG: If I put this line in, I get two error messages:
//(1) Window.length can't be set by assignment
//(2) daysInMonth has no property indexed by 4
//If I leave it out, the code works fine.
//   this.length = n;
   for (var i = 1; i <= n; i++) {
      this[i] = 0
   } 
   return this
}

function showItem(myid,mydisplay) {
	if (mydisplay == "none") {
		getObject(myid).style.display = 'none';
		getObject(myid).style.visibility = 'hidden';
		if (SI) { SI.ClearChildren.clear(); } // Reset height
	}
	else if (mydisplay == "block") {
		getObject(myid).style.display = 'block';
		getObject(myid).style.visibility = 'visible';
		if (SI) { SI.ClearChildren.clear(); } // Reset height
	}
}

function toggleItem(myid, blnFade) {
	if (getObject(myid)) {
		var itemState = getObject(myid).style.display;
		if (itemState != 'none') {
			if (blnFade == 1) {
				fadeObj(myid,-1);
			}
			else {
				showItem(myid,'none');		
			}
			return (0);
		}
		else {
			if (blnFade == 1) {
				fadeObj(myid,1);
			}
			else {
				showItem(myid,'block');
			}
			return (1);
		}
	}
}

function toggleTextBoxVal(obj,ev,defVal) {
	if (obj) {
		if (ev == 'focus') {
			if (obj.value == defVal) {
				obj.value = '';
			}
		}
		else if (ev == 'blur') {
			if (obj.value == '') {
				obj.value = defVal;
			}
		}
	}
}

function setOpacity(obj, opacity) {
	opacity = (opacity == 100)?99:opacity; // Fixes re-draw bug when opacity = 1
	// IE/Win
	obj.style.filter = "alpha(opacity:"+opacity+")";
	if (obj.filters) {obj.filters.alpha.opacity=opacity;}
	// Safari<1.2, Konqueror
	obj.style.KHTMLOpacity = opacity/100;
	// Older Mozilla and Firefox
	obj.style.MozOpacity = opacity/100;
	// Safari 1.2, newer Firefox and Mozilla, CSS3
	obj.style.opacity = opacity/100;
	return opacity;
}

function fadeObj(obj,dir,lim) {
	if (dir == 1) {
		// Fade In
		if (!lim) {
			 // Full fade in
			lim = 100;

			// Set to 0 opacity hidden
			fOp[obj] = setOpacity(getObject(obj),0);
		}
		else {
			fOp[obj] = setOpacity(getObject(obj),lim);
		}

		getObject(obj).style.visibility = 'visible';
		getObject(obj).style.display = 'block';

		// Fade it
		fClr[obj] = setInterval(function() { fadeLoop(obj,10,lim); },25); // always use anonymous fn for intervals
	}
	else if (dir == -1) {
		// Fade Out
		if (!lim) {
			// Full fade out
			lim = 0;
			
			// Set to 100% opacity visible
			fOp[obj] = setOpacity(getObject(obj),100);
		}
		else {
			fOp[obj] = setOpacity(getObject(obj),lim);
		}
			
		getObject(obj).style.visibility = 'visible';
		getObject(obj).style.display = 'block';
		
		// Fade it
		fClr[obj] = setInterval(function() { fadeLoop(obj,-10,lim); },25); // always use anonymous fn for intervals
	}
}

function fadeLoop(obj,inc,lim) {
	if (inc > 0) {
		// Fade In
		if (fOp[obj] >= lim) {
			// Clean up and stop cycle
			clearInterval(fClr[obj]);
			if (SI) { SI.ClearChildren.clear(); }
		}
		else {
			fOp[obj] = setOpacity(getObject(obj),(fOp[obj]+inc));	
		}
	}
	else if (inc < 0) {
		// Fade Out
		if (fOp[obj] <= lim) {
			// Clean up and stop cycle
			if (lim == 0) { showItem(obj,'none'); } // Used to remove object from flow
			clearInterval(fClr[obj]);
			if (SI) { SI.ClearChildren.clear(); }
		}
		else {
			fOp[obj] = setOpacity(getObject(obj),(fOp[obj]+inc));
		}
	}
	else {
		// Catch all
		clearInterval(fClr[obj]);	
		if (SI) { SI.ClearChildren.clear(); }
	}
}

function obfusc(box,subj,dom) {
	if ((!dom) || (dom=='')) { dom = "em-i" + unescape("%2E") + "com"; }
	var obfusced = ("mail" + "to" + unescape("%3A") + box + unescape("%40") + dom);
	if ((subj) && (subj!='')) { obfusced += (unescape("%3F") + "subject" + unescape("%3D") + escape(subj)); }
	this.location.href=obfusced;
}

function toggleCol(colID, state) {
	// Count visible columns
	var c = 0;
	for (var t=1; t<=3; t++) {
		if (eval(getObject('div_col'+t)).style.display != 'none') {
			c++;
		}
	}
	
	// Get state of chosen column
	if (eval(getObject('div_col'+colID)).style.display != 'none') {
		// Visible, so hide
		state = 0;
		eval(getObject('div_col'+colID)).style.display = 'none';
		c--;		
	}
	else {
		state = 1;
		eval(getObject('div_col'+colID)).style.display = 'block';
		c++;		
	}
		
	// Set widths
	var availWidth = getObject('div_pgContent').offsetWidth;
	if (c > 0) {
	var newWidth = 100/c;
		for (var t=1; t<=3; t++) {
			if (eval(getObject('div_col'+t)).style.display != 'none') {
				eval(getObject('div_col'+t)).style.width = newWidth + '%';
			}
		}
	}
}

function matchColHeights() {
	var mHeight = 0;
	
	// Set array of column IDs to check in order of loading
	var aCols = new Array();
	aCols[1] = 'div_col1';
	aCols[2] = 'div_col2';
	aCols[3] = 'div_col3';
	
	// Get tallest column
	for(var i=aCols.length; i>0; i--) {
		if (getObject(aCols[i])) {
			elem = getObject(aCols[i]);
			// Last column has loaded - proceed
			if (elem.offsetHeight > mHeight) { mHeight = elem.offsetHeight; }
			elem.style.height = 'auto';
		}
	}
	
	if (mHeight > 0) {
		// Set all columns to tallest height
		for(i=aCols.length; i>0; i--) {
			if (getObject(aCols[i])) {
				elem = getObject(aCols[i]);
				elem.style.height = mHeight+'px';
			}
		}
		// Need to refresh footer position in IE
		getObject('div_footerCell').className = 'footerCell';
	}
}

function setBgScroll() {
	if (getObject('div_master')) {
		var masterWidth = getObject('div_master').offsetWidth;
		var bodyWidth = document.body.offsetWidth;
		var bodyRef = document.body;
		if (bodyWidth < masterWidth) {
			// Horizontal scrollbars are present - overlay fixed image if missing
			if (bodyRef.className != 'bodyScroll') {
				bodyRef.className = 'bodyScroll';
			}
		}
		else {
			// No horizontal scrollbars present - remove fixed image if present
			if (bodyRef.className != 'bodyFree') {
				bodyRef.className = 'bodyFree';
			}
		}
	}
}

function navToFadeOut() {
	if (getObject('div_navToHide')) {
		setOpacity(getObject('div_navToHide'),50);
	}
}

function navToFadeIn() {
	if (getObject('div_navToHide')) {
		setOpacity(getObject('div_navToHide'),100);
	}
}

function createCookie(name,value,days) {
	if (days) {
		var date = new Date();
		date.setTime(date.getTime()+(days*24*60*60*1000));
		var expires = "; expires="+date.toGMTString();
	}
	else var expires = "";
	document.cookie = name+"="+value+expires+"; path=/";
}

function readCookie(name) {
	var nameEQ = name + "=";
	var ca = document.cookie.split(';');
	for(var i=0;i < ca.length;i++) {
		var c = ca[i];
		while (c.charAt(0)==' ') c = c.substring(1,c.length);
		if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
	}
	return null;
}

function eraseCookie(name) {
	createCookie(name,"",-1);
}


/* Validations */
// Based on original PHP code by Cal Henderson (http://iamcal.com/publish/articles/php/parsing_email)
// Converted to JS regex
function is_valid_email_address(email) {
	var qtext = '[^\\x0d\\x22\\x5c\\x80-\\xff]';
	var dtext = '[^\\x0d\\x5b-\\x5d\\x80-\\xff]';
	var atom = '[^\\x00-\\x20\\x22\\x28\\x29\\x2c\\x2e\\x3a-\\x3c'+'\\x3e\\x40\\x5b-\\x5d\\x7f-\\xff]+';
	var quoted_pair = '\\x5c\\x00-\\x7f';
	var domain_literal = '\\x5b('+dtext+'|'+quoted_pair+')*\\x5d';
	var quoted_string = '\\x22('+qtext+'|'+quoted_pair+')*\\x22';
	var domain_ref = atom;
	var sub_domain = '('+domain_ref+'|'+domain_literal+')';
	var word = '('+atom+'|'+quoted_string+')';
	var domain = sub_domain+'(\\x2e'+sub_domain+')*';
	var local_part = word+'(\\x2e'+word+')*';
	var addr_spec = local_part+'\\x40'+domain;
	var filter = eval('/^' + addr_spec + '$/');
	
	return ((filter.test(email)) ? 1 : 0);
}

