function SeeNoEvil(msg, url, line) {
	return true;  //error checking off
}
function SeeEvil(msg, url, line) {
//	alert('JavaScript Error detected on line '+line)
	return false; //error checking on
}
window.onerror=SeeNoEvil;

var showLoadingLayer = true;
//Page load code
function showLoad() {
	if (showLoadingLayer)
	{
		document.write('<div id="divLoadCont" class=loadin><table width=100% height=100% align=center valign=middle cellpadding=0 cellspacing=0><tr><td width=100% height=100% align=center valign=middle bgcolor=#CCCCCC><font color="Navy"><h2><!--img src=images/clock.gif width=25 height=25 border=0 align=middle-->please wait...</h2></font></td></tr></table></div>');
		window.status='Please wait while this page loads....';
		if (navigator.userAgent.indexOf("IE 6") > 0) document.body.style.cursor = 'url("images/time.ani"),wait';
		else document.body.style.cursor = 'wait';
	}
	else
		showLoadingLayer = true;
}
//Hide layer with Page Loading text.
function hideLoad(tdiv) {
	if(!tdiv) tdiv='divLoadCont';
	if(document.getElementById(tdiv)) document.getElementById(tdiv).style.visibility='hidden';
	window.status=defaultStatus;
	document.body.style.cursor = 'default';
}
//Page save code
function showSave(tdiv) {
	if(!tdiv) tdiv='divLoadCont';
	if(document.getElementById(tdiv)) document.getElementById(tdiv).style.visibility='';
	window.status='Please wait while this page is processed....';
	if (navigator.userAgent.indexOf("IE 6") > 0) document.body.style.cursor = 'url("images/time.ani"),wait';
	else document.body.style.cursor = 'wait';
}
function doLoadExecSummary(id) {
	document.form1.ID.value=id;
	document.form1.referer.value=window.location.href;
	document.form1.action = "loadExecutiveSummary.do?ID="+id;
	showSave();
	document.form1.submit();
}
function doLoadOpp(id) {
	document.form1.ID.value=id;
	document.form1.referer.value=window.location.href;
	document.form1.action = "loadOpportunity.do?ID="+id;
	showSave();
	document.form1.submit();
}
function doLoadBiz(id) {
	document.form1.ID.value=id;
	document.form1.referer.value=window.location.href;
	document.form1.action = "opportunitybusinesscases.jsp?ID="+id;
	showSave();
	document.form1.submit();
}
//Global Variable
var parentOpen = true;
//opens a new window, centered
var popWinCenterFloat;	//Name that window
var popWinCenterOpen = false;
function popWinCenter(popWinCenterURL,popWinCenterName,winwidth,winheight){
	if (winheight < screen.height) {
		winleft=screen.width/2-winwidth/2;
		wintop=screen.height/2-winheight/2;
	} else {
		winheight=screen.height;
		winleft=screen.width/2-winwidth/2;
		wintop=0;
	}
	if ( ( !popWinCenterFloat ) || ( popWinCenterFloat.closed ) ) {
	} else popWinCenterFloat.close();  //if it already exists, close it.
	popWinCenterFloat = window.open(popWinCenterURL,popWinCenterName,'width='+winwidth+',height='+winheight+',scrollbars=no,toolbar=no,resizable=no,status=no,top='+wintop+',left='+winleft)
	popWinCenterOpen = true;
}
//opens a new window, centered
var popWinTopFloat;	//Name that floating window
var popWinTopOpen = false;
function popWinTop(popWinTopURL,popWinTopName,winwidth,winheight){
	if (winheight < screen.height) {
		winleft=screen.width/2-winwidth/2;
	} else {
		winheight=screen.height;
		winleft=screen.width/2-winwidth/2;
	}
	if ( ( !popWinTopFloat ) || ( popWinTopFloat.closed ) ) {
	} else popWinTopFloat.close();  //if it already exists, close it.
	popWinTopFloat = window.open(popWinTopURL,popWinTopName,'width='+winwidth+',height='+winheight+',scrollbars=no,toolbar=no,resizable=no,status=no,top=0,left='+winleft)
	popWinTopOpen = true;
}
//opens a new window, centered, with user defined features
var popWinGenericFloat;	//Name that floating window
var popWinGenericOpen = false;
function popWinGeneric(popWinGenericURL,popWinGenericName,winwidth,winheight,features){
	if (winheight < screen.height) {
		winleft=screen.width/2-winwidth/2;
		wintop=screen.height/2-winheight/2;
	} else {
		winheight=screen.height;
		winleft=screen.width/2-winwidth/2;
		wintop=0;
	}
	if ( ( !popWinGenericFloat ) || ( popWinGenericFloat.closed ) ) {
	} else popWinGenericFloat.close();
	popWinGenericFloat = window.open(popWinGenericURL,popWinGenericName,'width='+winwidth+',height='+winheight+',top='+wintop+',left='+winleft+','+features)
	popWinGenericOpen = true;
}
function checkTheKids() {
	//Only if child window is still open, set the parentOpen property
	if (popWinGenericOpen == true)	popWinGenericFloat.parentOpen = false;
	if (popWinCenterOpen == true)	popWinCenterFloat.parentOpen = false;
	if (popWinTopOpen == true)	popWinTopFloat.parentOpen = false;
}
function closeTheKids() {
	//Only if child window is still open, set the parentOpen property
	if (popWinGenericOpen == true)	popWinGenericFloat.close();
	if (popWinCenterOpen == true)	popWinCenterFloat.close();
	if (popWinTopOpen == true)	popWinTopFloat.close();
}
// Function to print the current frame
function custom_print() {
	if (document.all) {
		if (navigator.appVersion.indexOf("5.0") == -1) {
			var OLECMDID_PRINT = 6;
			var OLECMDEXECOPT_DONTPROMPTUSER = 2;
			var OLECMDEXECOPT_PROMPTUSER = 1;
			var WebBrowser = "<OBJECT ID=\"WebBrowser1\" WIDTH=0 HEIGHT=0 CLASSID=\"CLSID:8856F961-340A-11D0-A96B-00C04FD705A2\"></OBJECT>";
			document.body.insertAdjacentHTML("beforeEnd", WebBrowser);
			WebBrowser1.ExecWB(6, 2);
			WebBrowser1.outerHTML = "";
		} else self.print();
	} else self.print();
}
//Simple e-mail validation code
function checkEmail(myForm) {
	if (/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(myForm.value)){
		return (true)
	} else {
		alert('Please enter a valid e-mail address')
		myForm.focus()
		return (false)
	}
}
//Character Counter
function textCounter(field, countfield, maxlimit) {
	if (field.value.length > maxlimit) field.value = field.value.substring(0, maxlimit);
	else countfield.value = maxlimit - field.value.length;
}
function charCounter(field, countfield) {
	countfield.value = field.value.length;
}
function eeover() {
  event.returnValue = false;
  window.event.dataTransfer.dropEffect = "move";
}
function eedrop() {
	event.returnValue=false;
  	window.event.dataTransfer.dropEffect="copy";
	if(window.event.dataTransfer.getData("Text") == 'veloman') {
		popWinGeneric('flash/credits.html','creditz',screen.availWidth-10,340,'menubar=no,toolbar=no,location=no,directories=no,status=no,scrollbars=yes,resizable=no,dependent,left=0')
	} else if(window.event.dataTransfer.getData("Text") == 'mainfoot') {
		if(window.sirtet) sirtet();
		else {
		window.status='Please don\'t drag the footer';
		var flyout1;
		if ( ( !flyout1 ) || ( flyout.closed1 ) ) {
		} else flyout1.close();
		flyout1=window.open("","flyout1","resizable=no,scrollbars=no,width=220,height=147,top=100,left=100")
		flyout1.document.open();
		flyout1.document.writeln('<HTML><HEAD><TITLE>Be careful out there</TITLE></HEAD><BODY topmargin=0 leftmargin=0 onblur=self.close()><img src=images/bc1.gif width=220 height=147 border=0 style="cursor:hand;" alt="click to close" onclick=self.close()></BODY></HTML>')
		flyout1.document.close();
		flyout1.focus();
		}
	} else if(window.event.dataTransfer.getData("Text") == 'velomans') {
		var flyout2;
		if ( ( !flyout2 ) || ( flyout2.closed ) ) {
		} else flyout2.close();
		flyout2=window.open("","flyout2","resizable=no,scrollbars=no,width=220,height=147,top=100,left=100")
		flyout2.document.open();
		flyout2.document.writeln('<HTML><HEAD><TITLE>Be careful out there</TITLE></HEAD><BODY topmargin=0 leftmargin=0 onblur=self.close()><img src=images/bc2.gif width=220 height=147 border=0 style="cursor:hand;" alt="click to ride" onclick="window.open(\'flash/bike.mpeg\',\'bi\',\'resizable=no,scrollbars=no,width=320,height=240,top=100,left=100\')"></BODY></HTML>')
		flyout2.document.close();
		flyout2.focus();
	} else if(window.event.dataTransfer.getData("Text") == 'velomanm') {
		var flyout;
		if ( ( !flyout ) || ( flyout.closed ) ) {
		} else flyout.close();
		flyout=window.open("","flyout","resizable=no,scrollbars=no,width=320,height=240,top=100,left=100")
		flyout.document.open();
		flyout.document.writeln('<HTML><HEAD><TITLE>My Bike</TITLE></HEAD><BODY topmargin=0 leftmargin=0><OBJECT ID=MediaPlayer WIDTH=320 HEIGHT=240 CLASSID="CLSID:22D6F312-B0F6-11D0-94AB-0080C74C7E95" STANDBY="Loading Windows Media Player components..." TYPE=application/x-oleobject><PARAM NAME=FileName VALUE="flash/bike.mpeg"><EMBED TYPE=application/x-mplayer2 SRC="flash/bike.mpeg" NAME=MediaPlayer WIDTH=320 HEIGHT=240></EMBED></OBJECT></BODY></HTML>')
		flyout.document.close();
		flyout.focus();
	}
}
function eeinfo() {
	window.event.dataTransfer.setData("Text", window.event.srcElement.id);
	window.event.dataTransfer.effectAllowed = "move";
}
//Returns only numbers when the user is entering text
var isNetscape=(navigator.appName=="Netscape");
function numbersonly(e) {
	keyStroke = (isNetscape) ? e.which : event.keyCode;
	if (keyStroke < 48 || keyStroke > 57) return false;
}
function floatonly(e) { //returns numbers and .
	var acceptKeys ="46;48;49;50;51;52;53;54;55;56;57;"
	keyStroke = (isNetscape) ? e.which : event.keyCode;
	if (acceptKeys.indexOf(keyStroke) == -1) return false;
}
function moneyonly(e) {
	var acceptKeys ="44;48;49;50;51;52;53;54;55;56;57;"
	keyStroke = (isNetscape) ? e.which : event.keyCode;
	if (acceptKeys.indexOf(keyStroke) == -1) return false;
}
function phoneonly(e) {
	var acceptKeys ="32;40;41;43;45;46;48;49;50;51;52;53;54;55;56;57;"
	keyStroke = (isNetscape) ? e.which : event.keyCode;
	if (acceptKeys.indexOf(keyStroke) == -1) return false;
}
//Five functions to manipulate select boxes
function moveFromTo (SelectFrom, SelectTo) {
	var SelectedIndex = SelectFrom.options.selectedIndex;
	if (SelectedIndex != -1) {
		for (i=0; i<SelectFrom.options.length; i++) {
			if(SelectFrom.options[i].selected) {
				var theText = SelectFrom.options[i].text;
				var theValue = SelectFrom.options[i].value;
				SelectFrom.options[i] = null;
				SelectTo.options[SelectTo.options.length]=new Option (theText,theValue);
				i=i-1;
			}
		}
	}
}
function moveSelection(FromField,ToField)  {
	var boxLength = ToField.length;
	var selectedItem = FromField.selectedIndex;
	var selectedText = FromField.options[selectedItem].text;
	var selectedValue = FromField.options[selectedItem].value;
	var i;
	var isNew = true;
	if (boxLength != 0) {
		for (i = 0; i < boxLength; i++) {
			thisitem = ToField.options[i].text;
			if (thisitem == selectedText) {
				isNew = false;
				break;
			}
		}
	}
	if (isNew) {
		newoption = new Option(selectedText, selectedValue, false, false);
		ToField.options[boxLength] = newoption;
	}
	FromField.selectedIndex=-1;
}
function removeSelection(ToField) {
	var boxLength = ToField.length;
	arrSelected = new Array();
	var count = 0;
	for (i = 0; i < boxLength; i++) {
		if (ToField.options[i].selected) {
			arrSelected[count] = ToField.options[i].value;
		}
		count++;
	}
	var x;
	for (i = 0; i < boxLength; i++) {
		for (x = 0; x < arrSelected.length; x++) {
			if (ToField.options[i].value == arrSelected[x]) {
				ToField.options[i] = null;
	   		}
		}
		boxLength = ToField.length;
	}
}
function removeAllSelections(ToField) {
	var boxLength = ToField.length;
	for (i = 0; i < boxLength; i++) {
		ToField.options[0] = null;
	}
}
function selectAll(ToField) { //selects every option of a multiselect box
	var boxLength = ToField.length;
	for (i = 0; i < boxLength; i++) {
		ToField.options[i].selected = true;
	}
}
//Used for "type ahead" function.
function matchFieldSelect (field, select, value) {
	var property = value ? 'value' : 'text';
	var found = false;
	for (var i = 0; i < select.options.length; i++)
		if ((found = select.options[i][property].toLowerCase().indexOf(field.value.toLowerCase()) == 0))
			break;
		if (found)
			select.selectedIndex = i;
		else
			select.selectedIndex = -1;
		if (field.createTextRange) {
			var ignoreKeys ="8;16;18;46;37;38;39;40;33;34;35;36;45;"
			if (ignoreKeys.indexOf(event.keyCode+";") == -1) {
				var oldValueRange = field.createTextRange()
				var oldValue = oldValueRange.text;
				var newValue = found ? select.options[i][property] : oldValue;
				if (newValue != field.value) {
					field.value = newValue
					var rNew = field.createTextRange() //Creates a text range object
					rNew.moveStart('character', oldValue.length)
					rNew.select()
				}
			}
		}
}
function refreshParent(url) {
	if (self.opener) {
		if (url) self.opener.location=url;
		else self.opener.location=self.opener.location.href;
		self.opener.focus();
	}
}
function validateCharacters(fieldValue,type) {
	var acceptChars = "1234567890"  //default
	if (type) {
		switch (type.toUpperCase()) {
			case 'N' : acceptChars = "1234567890"; //numbers
				break;
			case 'P' : acceptChars = "()-.0123456789"; //phone num
				break;
			case 'M' : acceptChars = ",0123456789"; //money
				break;
			case 'D' : acceptChars = "0123456789/"; //date
				break;
		}
	}
	for (var i = 0; i < fieldValue.length; i++) {
		if (acceptChars.indexOf(fieldValue.charAt(i)) == -1) return false;
	}
	return true;
}
function tbOver(x,cn,msg,wdc) { //x=object, cn=classname, msg=status text, wdc=wingding character
	window.status = msg;
	if(wdc) x.value=wdc;
	if((x.filters) && (x.filters[0])) {
		x.filters[0].apply();
		x.className=cn;
		x.filters[0].play();
	} else 	x.className=cn;
}
function tbOut(x,cn,wdc) {
	window.status = defaultStatus;
	if(wdc) x.value=wdc;
	if((x.filters) && (x.filters[0])) {
		x.filters[0].apply();
		x.className=cn;
		x.filters[0].play();
	} else 	x.className=cn;
}
function chgClass(x,cn,msg,wdc) { //x=object, cn=classname, msg=status text, wdc=wingding character
	if((msg) && (msg != '')) window.status = msg; else window.status=defaultStatus;
	if(wdc) x.value=wdc;
	if((x.filters) && (x.filters[0])) {
		x.filters[0].apply();
		x.className=cn;
		x.filters[0].play();
	} else 	x.className=cn;
}
function trim(str) {
	for(var i = 0 ; i<str.length && str.charAt(i)==" " ; i++ ) ;
	return str.substring(i,str.length); 
}
var oPopup = window.createPopup();
function openPopup(popTitle,popMsg,popWidth,popHeight) {
	if(!popWidth) popWidth=300;
	if(!popHeight) popHeight=180;
    var oPopBody = oPopup.document.body;
    oPopBody.innerHTML = "<div style='position:absolute; top:0; left:0; border:1px solid black;" + 
    "width:"+popWidth+"px; height:"+popHeight+"px; padding:10px; color:white; font-family:tahoma; " +
     "font-size:13pt;filter:progid:DXImageTransform.Microsoft.Gradient()'>" +
     "<b>" + popTitle + "</b><hr size='1'>"+popMsg+"</div>"
    oPopup.show(290, 190, popWidth, popHeight, document.body);
}

function openModal(popMsg) {
	var myObject = new Object();
	myObject.popMsg = popMsg;
	tpop=window.showModelessDialog("timeout.html",myObject,"dialogHeight: 200px; dialogWidth: 340px; dialogTop: px; dialogLeft: px; edge: Raised; center: Yes; help: No; resizable: No; status: No;");
}
function doTimeout(jmp) {
	if(jmp) self.location='logoff.jsp'
	else {
		self.focus();
		if (window.createPopup) openPopup('Vélo Session Expiration Warning','Your session with the Vélo server will expire in the next 60 seconds.  Please save your changes or refresh your browser to keep your session active.');
		else openModal('Session Timeout');
		timerLoop = setTimeout('doTimeout(60)', 60000);
	}
}
function replaceAll(inString, findString, replaceString) {
	var outString = inString;
	if (findString.length == 0) return outString;
	var idx = outString.indexOf(findString);
	while (idx >= 0) {       
		outString = outString.substring(0,idx) + replaceString + outString.substr(idx+findString.length);
		idx = outString.indexOf(findString);
	}
	return outString;
}
function toggleCheckMark(image,onImage,offImage,onText,offText,formField) {
	if(formField.value == '0' ) {
		window.status = 'Checked';
		formField.value = '1';
		image.alt = onText;
		image.src = onImage;
	} else {
		window.status = 'Unchecked';
		formField.value = '0';
		image.alt = offText;
		image.src = offImage;
	}
}
function openCalc(formField) {
	var myObject = new Object();
	myObject.formField = formField;
	rv = window.showModalDialog('calculator.html',myObject,'dialogHeight:160px;dialogWidth:98px;scroll:no;help:no;resizable:no;center:no;edge:sunken;status:no;dialogTop='+event.y+';dialogLeft='+event.x+';');
}
function stripNumbers (InString)  {
	var RefString="1234567890 ";
	var strippedString = "";
	for (Count=0; Count < InString.length; Count++)  {
		if (RefString.indexOf (InString.charAt(Count), 0)==-1) strippedString = strippedString + InString.charAt(Count);
	}
	return strippedString;
}
function doTextSearch() {
	var oDialog = new Object();
	oDialog.parentDoc = window;
	ft = window.showModelessDialog('findinpage.html',oDialog,'dialogTop='+event.y+';dialogLeft='+event.x+';dialogHeight:100px;dialogWidth:200px;scroll:no;help:no;resizable:no;center:no;edge:raised;status:no;unadorned:yes;');
	return false;
}
function doLogoff() {
	if(confirm('Are you certain you want to Logoff Vélo?')) {
		document.location='logoff.jsp';
	} else return false;
}

