window.onerror = null; // Disable script error popups
var formClashArray = new Array(); // Create a new array of form element names for DHTML/form clash prevention
var formClashIndex = 0;

/* Functions that swaps images. */
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 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;
}

/* Functions that handle preload. */
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];}}
}

// stop hiding -->

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 linkFlash() {
	// If the browser is IE
	if(document.all) {
		// Flash the register link between orange and grey for 4 seconds
		window.registerLink.style.color = "#FF6600";
		var temp1 = setTimeout('window.registerLink.style.color = "#CCCCCC"', 500);
		var temp2 = setTimeout('window.registerLink.style.color = "#FF6600"', 750);
		var temp3 = setTimeout('window.registerLink.style.color = "#CCCCCC"', 850);
		var temp4 = setTimeout('window.registerLink.style.color = "#FF6600"', 750);
		var temp5 = setTimeout('window.registerLink.style.color = "#CCCCCC"', 500);
		// Then call this function again in 3 seconds.
		var temp6 = setTimeout('linkFlash()', 3000);
	}
}

function openWin(theURL, pW, pH, toolbar, directories, status, menubar, scrollbars, resizable) {
	var toolbar		= toolbar || 0;
	var directories	= directories || 0;
	var status		= status || 0;
	var menubar		= menubar || 0;
	var scrollbars	= scrollbars || 1;
	var resizable	= resizable || 1;
	var pW			= pW || 400;	
	var pH			= pH || 500;
	var pWidth      = pW ? pW+20 : 800;		
	var pHeight     = pH ? pH : 600;						    // Popup height
	var pXOffset    = (screen) ? (screen.width / 2) - (pWidth / 2) : (800 / 2) - (pWidth / 2);		// Popup X placement
	var pYOffset    = 200;										// Popup Y placement
	
	nsWin = window.open (theURL, 'gaPopup', 'left=' + pXOffset + ',top=' + pYOffset + ',height=' + pHeight + ',width=' + pWidth + ',toolbar=' + toolbar + ',directories=' + directories + ',status=' + status + ',menubar=' + menubar + ',scrollbars=' + scrollbars + ',resizable=' + resizable);
}

function navBar(tableCellRef, hoverFlag, navStyle, color, fontColor) {
	color = color || '#E9E9F6';
	fontColor = fontColor || '#FFFFFF';
	if (hoverFlag) {
		switch (navStyle) {
			case 1:
				tableCellRef.style.backgroundColor = '#FFFF99';
				tableCellRef.style.borderWidth = 1;
				if(color == '#FFFF98')
					if ( document.getElementsByTagName ) {
						tableCellRef.getElementsByTagName('a')[0].style.color = fontColor;
					}
				else if(color == '77779E')
					if ( document.getElementsByTagName ) {
						tableCellRef.getElementsByTagName('a')[0].style.color = color;
						}
				else
					if ( document.getElementsByTagName ) {
						tableCellRef.getElementsByTagName('a')[0].style.color = '#FF6600';
					}
				break;
			default:
//				tableCellRef.style.backgroundColor = '#ccc';
				if ( document.getElementsByTagName ) {
					tableCellRef.getElementsByTagName( 'a' )[0].style.color = '#c00';
				}
		}
	} else {
		switch (navStyle) {
			case 1:
				tableCellRef.style.backgroundColor = color;
				tableCellRef.style.borderWidth = 0;
				if(color == '#66667C')
					if ( document.getElementsByTagName ) {
						tableCellRef.getElementsByTagName('a')[0].style.color = fontColor;
						}
				else if(color == '77779E')
					if ( document.getElementsByTagName ) {
						tableCellRef.getElementsByTagName('a')[0].style.color = color;
						}
				else
					if ( document.getElementsByTagName ) {
						tableCellRef.getElementsByTagName('a')[0].style.color = '#000000';
					}
				break;
			default:
//				tableCellRef.style.backgroundColor = '#ddd';
				if ( document.getElementsByTagName ) {
					tableCellRef.getElementsByTagName( 'a' )[0].style.color = '#000000';
				}
		}
	}
}

function chat(locatorID) {
	// Open a popup window
	chatWin = openWin('/chatinvite.cfm?locatorID=' + locatorID, 400, 450, 0, 0, 0, 0, 'no', 'no');
}


function formClashItem(menuNumber, elementName) {
	this.menuNumber = menuNumber;
	this.elementName = elementName;
	
	return this;
}

function formClash(menu, visibility) {
	visibility = (visibility == 1) ? 'visible' : 'hidden';
	for(index = 0; index < formClashArray.length; index++) {
		if(formClashArray[index].menuNumber == menu) {
			if(eval(formClashArray[index].elementName))
				eval(formClashArray[index].elementName + ".style.visibility = '" + visibility + "'");
		}
	}
}


function helpTip(helpTipID, width, height, resizable) {
	width = width || 340;
	height = height || 425;
	var resizable	= resizable || 0;
	var helpTipURL = '/helpTips.cfm/helpTipID/' + helpTipID;
	window.open(helpTipURL,"HelpTips","width=" + width + ",height=" + height + ",menubar=no,scrollbars=1,resizable=' + resizable");
}

function textLimit(formfield, limit) {
	// If the length of the value in the formfield is over the limit
	if(formfield.value.length >= limit)
		formfield.value = formfield.value.substr(0, limit); // Truncate the form field to that limit
}

// Identify user agent
isIE4 = (document.all) ? true : false;
isW3C = (document.getElementById && !isIE4) ? true : false;
isNN4 = (document.layers) ? true : false;


function styleChange(elementID) {
	if (isIE4) {
		return document.all[elementID];
	} else if(isW3C) {
		return document.getElementById(elementID);
	}
}

// For DHTML menus
if(window.event + "" == "undefined") event = null;
function HM_f_PopUp(){return false};
function HM_f_PopDown(){return false};
popUp = HM_f_PopUp;
popDown = HM_f_PopDown;

