//*********************************************************************************
// Title: 				getCookieValue
// Desc: 				Get cookie values for a given cookie
// Created : 			July 31, 2002
// Last Modified: 		Sept 23, 2002
// Accepts:				cookieName - Name of the cookie.
// Returns:				The cookie value(s).
//*********************************************************************************
function getCookieValue(cookieName){
	var cookieValue = document.cookie;
	var cookieStartsAt = cookieValue.indexOf(" " + cookieName + "=");
	
	// check if cookie exists.  If cookie does not exist, do a second check at the beginning of the string
	if (cookieStartsAt == -1){
		cookieStartsAt = cookieValue.indexOf(cookieName + "=");
	}
	
	if (cookieStartsAt == -1){
		// coookie really does not exist
		cookieValue = null;
	}else{
		cookieStartsAt = cookieValue.indexOf("=", cookieStartsAt) + 1;
		var cookieEndsAt = cookieValue.indexOf(";", cookieStartsAt);
		if (cookieEndsAt == -1){
			// cookie is the last one in the string
			cookieEndsAt = cookieValue.length;
		}
		cookieValue = unescape(cookieValue.substring(cookieStartsAt, cookieEndsAt));
	}
	return cookieValue;
}

//*********************************************************************************
// Title: 				setCookie
// Desc: 				Get cookie values for a given cookie
// Created : 			July 31, 2002
// Last Modified: 		April 1, 2004
// Accepts:				cookieName - Name of the cookie.
// 						cookieValue - Cookie value(s).
// 						cookiePath - Path cookie is valid for.
// 						cookieExpires - Expriy date/time of the cookie.
// Returns:				
//*********************************************************************************
function setCookie(cookieName, cookieValue, cookieExpires, cookiePath, cookieDomain){
	cookieValue = escape(cookieValue);
	
	if (cookieExpires == "" || cookieExpires == null){
		var nowDate = new Date();
		nowDate.setMonth(nowDate.getMonth() + 1);
		cookieExpires = nowDate.toGMTString();
	}
	
	if (cookiePath == "" || cookiePath == null){
		cookiePath = "; path=/";
	}else{
		cookiePath = "; path=" + cookiePath;
	}
	
	if (cookieDomain == "" || cookieDomain == null){
		cookieDomain = "; domain=" + document.domain;
	}else{
		cookieDomain = "; domain=" + cookieDomain;
	}
	//alert(cookieName + "=" + cookieValue + "; expires=" + cookieExpires + cookiePath + cookieDomain);
	document.cookie = cookieName + "=" + cookieValue + "; expires=" + cookieExpires + cookiePath + cookieDomain;
}

//*********************************************************************************
// Desc: 				Cookie tracking code for all pages on cibc.com
// Created : 			April 27, 2004
// Last Modified: 		June 29, 2004
//*********************************************************************************
var trackTest = getCookieValue("trackCookie");
var locTest = getCookieValue("locCookie");
var domain = ".cibc.com";
var trackingVal = "";
var theDate = new Date();
theDate.setYear(theDate.getFullYear() + 1);
dateExpires = theDate.toGMTString();
if(!trackTest){
	trackingVal = Math.random() * 99999999999999999;
	setCookie('trackCookie', trackingVal, dateExpires, '/', domain);
}
if(!locTest){
	trackingVal = "m";
	setCookie('locCookie', trackingVal, dateExpires, '/', domain);
}

//*********************************************************************************
// Title: 				todaysDate
// Desc: 				writes the date to the document object in a standard format
//						in English or French.
// Created : 			Unknown
// Last Modified: 		Unknown
// Accepts:				
// Returns:				N/A
//*********************************************************************************

// Get today's current date.
var now = new Date();
function todaysDate()	{
	//first determine language by checking path
	var x=""+document.location;
	if (x.indexOf('-fr.html') > 0) { lang="fr"; }
	else{ lang="en"; }
	
	// Array list of months.
	if (lang=="fr"){
		var months = new	Array('janvier','f&eacute;vrier','mars','avril','mai','juin','juillet','ao&ucirc;t','septembre','octobre','novembre','d&eacute;cembre');
	}
	else{
		var months = new	Array('January','February','March','April','May','June','July','August','September','October','November','December');
	}
	// Calculate the number of the current day in the week.
	var date = now.getDate();
	// Calculate four digit year.

	// Join it all together
	if (lang=="fr"){
		date = ((now.getDate()<10) ? "0" : "")+ date;
		today = "le " +  date + " " + months[now.getMonth()] + " " + (fourdigits(now.getYear()));
	}else{
		today =  months[now.getMonth()] + " " + date + ", " + (fourdigits(now.getYear()));
	}
	
	// Print out the data.
	document.write("" +today+ "");
}
//Usage: <script>todaysDate()</script>

//This is to cope with two digit years.
function fourdigits(number)	{
	return (number < 1000) ? number + 1900 : number;
}

//*********************************************************************************
// Title: 				formatDate
// Desc: 				writes a UTC date to the document object in a standard format
//						in English or French.
// Created : 			Feb 23, 2004
// Last Modified: 		August 30, 2004
// Accepts:				inDate, a date string
// Returns:				N/A
//*********************************************************************************
function formatDate(inDate)	{
	outDate=new Date(inDate);
	
	//first determine language by checking path
	var x=""+document.location;
	if (x.indexOf('-fr.html') > 0) { lang="fr"; }
	else{ lang="en"; }
	
	// Array list of months.
	if (lang=="fr"){
		var months = new	Array('janvier','f&eacute;vrier','mars','avril','mai','juin','juillet','ao&ucirc;t','septembre','octobre','novembre','d&eacute;cembre');
	}else{
		var months = new	Array('January','February','March','April','May','June','July','August','September','October','November','December');
	}
	// Calculate the number of the current day in the week.
	var date = outDate.getUTCDate();
	// Calculate four digit year.

	// Join it all together
	if (lang=="fr"){
		date = ((outDate.getUTCDate()<10) ? "0" : "")+ date;
		today = date + " " + months[outDate.getUTCMonth()] + " " + (fourdigits(outDate.getUTCFullYear()));
	}else{
		today =  months[outDate.getUTCMonth()] + " " + date + ", " + (fourdigits(outDate.getUTCFullYear()));
	}

	// Print out the data.
	document.write("" +today+ "");
}

//*********************************************************************************
// Title: 				submitSearch
// Desc: 				confirms that a search term has been entered
// Created : 			Unknown
// Last Modified: 		April 22, 2004
// Accepts:				
// Returns:				Boolean indicating whether search field is blank or not
//						and error message if blank
//*********************************************************************************
function submitSearch(){
	if(document.basicSearch.qt.value == ""){
		alert('The search word is missing. Enter the word or phrase to search.');
		return false;
	}else{
		document.basicSearch.qt.value = document.basicSearch.qt.value.replace(/\+ /g, "+");
		document.basicSearch.qt.value = document.basicSearch.qt.value.replace(/- /g, "-");
		document.characterSet="UTF-8";
		document.charset="UTF-8";
		document.defaultCharset="UTF-8";
		return true;
	}
}

//*********************************************************************************
// Title: 				submitSearchFR
// Desc: 				confirms that a search term has been entered
// Created : 			Jan 14, 2004
// Last Modified: 		April 22, 2004
// Accepts:				
// Returns:				Boolean indicating whether search field is blank or not
//						and error message if blank
//*********************************************************************************
function submitSearchFR(){
	if(document.basicSearch.qt.value == ""){
		alert('Le terme d\'interrogation n\'est pas inscrit. Inscrivez un mot ou une phrase à rechercher.');
		return false;
	}else{
		document.basicSearch.qt.value = document.basicSearch.qt.value.replace(/\+ /g, "+");
		document.basicSearch.qt.value = document.basicSearch.qt.value.replace(/- /g, "-");
		document.characterSet="UTF-8";
		document.charset="UTF-8";
		document.defaultCharset="UTF-8";
		return true;
	}
}

//*********************************************************************************
// Title: 				roundIt
// Desc: 				rounds a number to x decimal places.
// Created : 			July 15, 2003
// Last Modified: 		July 15, 2003
// Accepts:				number - the float to be changed to "count" decimal places.
//						count - the minimum number of decimal places
// Returns:				a number to "count" decimal places
//*********************************************************************************
/*function roundIt(number,count){
	//Convert value to string and split on the
	//decimal point. tempAmount[0] represents
	//dollars and tempAmount[1] represents cents.
	var outpt = "";
	var num = number+"";
	var index = num.indexOf('.');
	if(index==-1){
		return num;
	}else{
		var tempAmount = num.split(".");
		var test = tempAmount[1].charAt(count+1);
		
		if(parseInt(test)>=5){
			outpt += tempAmount[1].slice(0, (count-1));
			outpt += "" + (parseInt(tempAmount[1].charAt(count)) + 1);
		}else{
			outpt = tempAmount[1].slice(0, count);
		}
		
		//alert(tempAmount[0] + "." + outpt);
		return parseFloat(tempAmount[0] + "." + outpt);
	}
}*/

function roundIt(number,count){
	//Convert value to string and split on the
	//decimal point. tempAmount[0] represents
	//dollars and tempAmount[1] represents cents.
	var outpt = "";
	var num = number+"";
	var index = num.indexOf('.');
	if(index==-1){
		return num;
	}else{
		var tempAmount = num.split(".");
		outpt = "1." + tempAmount[1];
		outpt = Math.round(parseFloat(outpt) * Math.pow(10, count));
		outpt = "" + outpt;
		if (parseInt(outpt.charAt(0)) > 1){
			tempAmount[0] = Math.round(parseFloat(tempAmount[0]) + 0.5);
			return parseFloat(tempAmount[0] + "." + outpt.slice(1, outpt.length));
		}else{
			return parseFloat(tempAmount[0] + "." + outpt.slice(1, outpt.length));
		}
	}
}


//*********************************************************************************
// Title: 				toTwoDecimal
// Desc: 				Changes an integer input into a 2 decimal number.
// Created : 			Unknown
// Last Modified: 		Unknown
// Accepts:				number - the integer to be changed to 2 decimal places.
// Returns:				a number to two decimal places
//*********************************************************************************
function toTwoDecimal(number){
	//Convert value to string and split on the
	//decimal point. tempAmount[0] represents
	//dollars and tempAmount[1] represents cents.
	var count = 2;
	var outpt = "";
	var num = number+"";
	var index = num.indexOf('.');
	if(index==-1){
		return num + ".00";
	}else{
		var tempAmount = num.split(".");
		outpt = "1." + tempAmount[1];
		outpt = Math.round(parseFloat(outpt) * Math.pow(10, count));
		outpt = "" + outpt;
		if (parseInt(outpt.charAt(0)) > 1){
			tempAmount[0] = Math.round(parseFloat(tempAmount[0]) + 0.5);
		}
		if (parseFloat(outpt) != 0){
			return tempAmount[0] + "." + outpt.slice(1, outpt.length);
		}else{
			return tempAmount[0] + ".00";
		}
	}
}
//*********************************************************************************
// Title: 				toTwoDecimalFr
// Desc: 				Changes an integer input into a 2 decimal number in french.
// Created : 			Unknown
// Last Modified: 		July 12, 2005
// Accepts:				number - the integer to be changed to 2 decimal places.
// Returns:				a number to two decimal places
//*********************************************************************************
function toTwoDecimalFr(number){
	//Convert value to string and split on the
	//decimal point. tempAmount[0] represents
	//dollars and tempAmount[1] represents cents.

	var count = 2;
	var outpt = "";
	var num = number+"";
	var index = num.indexOf(',');

	if(index==-1){
		return num + ",00";
	}else{
		var tempAmount = num.split(",");
		outpt = "1," + tempAmount[1];
		outpt = Math.round(parseFloat(outpt) * Math.pow(10, count));
		outpt = "" + outpt;
		
		if (parseInt(outpt.charAt(0)) > 1){
			tempAmount[0] = Math.round(parseFloat(tempAmount[0]) + 0.5);
		}
		if (parseFloat(outpt) != 0){
			return tempAmount[0] + "," + outpt.slice(1, outpt.length);
		}else{
			return tempAmount[0] + ",00";
		}
	}
}

//*********************************************************************************
// Title: 				dollarOutput
// Desc: 				Function dollarOutput(value) returns value
//						coverted to currency format. Commas are
//						inserted as needed. If value has more than
//						two digits after the decimal point, the
//						digits that follow the first two are truncated.
//						If value has no digits after the decimal point
//						or has one digit after the decimal point one or
//						two trailing zeroes are appended respectively as
//						done by the toTwoDecimal(value) function.
//						Precond: value is a number. 
// Created : 			Unknown
// Last Modified: 		June 19, 2003
// Accepts:				value - the number to be changed to dollar format.
// Returns:				a number to two decimal places
//*********************************************************************************
function dollarOutput(value){	
	toTwoDecimal(value);
	//Convert value to string and split on the
	//decimal point. tempAmount[0] represents
	//dollars and tempAmount[1] represents cents.
	var tempAmount = (value + "").split(".");
	
	var offset = 1;
	var amount = "";

	//Go through each character in the dollar part
	//of value.
	for(var i = tempAmount[0].length - 1; i >= 0; i--){	
		
		//If current offset is a multiple of 3 add a comma.
		if((offset++ % 3) == 0){
			amount = "," + tempAmount[0].substr(i,1) + amount
		}
		else{	
			amount = tempAmount[0].substr(i,1) + amount
		}	
  }
	
	//If value had digits after the decimal point
	//append those back.
	if(tempAmount.length == 2){
		amount += "." + tempAmount[1];
	}
		
	//Get rid of the leading comma if it exists.	
	if(amount.charAt(0) == "," || (amount.charAt(0) == "-" && amount.charAt(1) == ",")){
		amount = amount.replace(/,/,"");		
	}
	
	//Convert the final amount to
	//two decimal point format and return.
	return amount;
}

//*********************************************************************************
// Title: 				dollarOutputFr
// Desc: 				Function dollarOutput(value) returns value
//						coverted to currency format. Commas are
//						inserted as needed. If value has more than
//						two digits after the decimal point, the
//						digits that follow the first two are truncated.
//						If value has no digits after the decimal point
//						or has one digit after the decimal point one or
//						two trailing zeroes are appended respectively as
//						done by the toTwoDecimal(value) function.
//						Precond: value is a number. 
// Created : 			June 18, 2003 (modified dollarOutput)
// Last Modified: 		July 12, 2005
// Accepts:				value - the number to be changed to dollar format.
// Returns:				a number to two decimal places
//*********************************************************************************
function dollarOutputFr(value){	
	toTwoDecimal(value);
	//Convert value to string and split on the
	//decimal point. tempAmount[0] represents
	//dollars and tempAmount[1] represents cents.
	var tempAmount = (value + "").split(".");
	
	var offset = 1;
	var amount = "";

	//Go through each character in the dollar part
	//of value.
	for(var i = tempAmount[0].length - 1; i >= 0; i--){	
		
		//If current offset is a multiple of 3 add a comma.
		if((offset++ % 3) == 0){
			amount = " " + tempAmount[0].substr(i,1) + amount
		}
		else{	
			amount = tempAmount[0].substr(i,1) + amount
		}	
  }
	
	//If value had digits after the decimal point
	//append those back.
	if(tempAmount.length == 2){
		amount += "," + tempAmount[1];
	}
		
	//Get rid of the leading comma if it exists.	
	if(amount.charAt(0) == " " || (amount.charAt(0) == "-" && amount.charAt(1) == " ")){
		amount = amount.replace(/,/,"");		
	}
	
	//Convert the final amount to
	//two decimal point format and return.
	return amount;
}


//*********************************************************************************
// Title: 				dollarOutputFrNbsp
// Desc: 				Returns French currency format 
//						Using &nbsp; as the thousand seperator so number will be
//						wrapped in two lines
// Created : 			July 8, 2005 (modified dollarOutput)
// Last Modified: 		July 8, 2005
// Accepts:				value - the number to be changed to dollar format.
// Returns:				a number to two decimal places
//*********************************************************************************
function dollarOutputFrNbsp(value){	
	toTwoDecimal(value);
	//Convert value to string and split on the
	//decimal point. tempAmount[0] represents
	//dollars and tempAmount[1] represents cents.
	var tempAmount = (value + "").split(".");
	
	var offset = 1;
	var amount = "";

	//Go through each character in the dollar part
	//of value.
	for(var i = tempAmount[0].length - 1; i >= 0; i--){	
		
		//If current offset is a multiple of 3 add a comma.
		if((offset++ % 3) == 0){
			amount = "&nbsp;" + tempAmount[0].substr(i,1) + amount
		}
		else{	
			amount = tempAmount[0].substr(i,1) + amount
		}	
  }
	
	//If value had digits after the decimal point
	//append those back.
	if(tempAmount.length == 2){
		amount += "," + tempAmount[1];
	}
		
	//Get rid of the leading comma if it exists.	
	if(amount.charAt(0) == " " || (amount.charAt(0) == "-" && amount.charAt(1) == " ")){
		amount = amount.replace(/,/,"");		
	}
	
	//Convert the final amount to
	//two decimal point format and return.
	return amount;
}
//*********************************************************************************
// Title: 				dollarOutputNoDec
// Desc: 				Function dollarOutput(value) returns value
//						coverted to currency format. Commas are
//						inserted as needed. No Decimal places are returned.
// Created : 			July 17, 2003
// Last Modified: 		July 17, 2003
// Accepts:				value - the number to be changed to dollar format.
// Returns:				a number formatted with commas.
//*********************************************************************************
function dollarOutputNoDec(value){	
	
	//Convert value to string and split on the
	//decimal point. tempAmount[0] represents
	//dollars and tempAmount[1] represents cents.
	value = Math.round(value);
	var tempAmount = value + ""
	
	var offset = 1;
	var amount = "";

	//Go through each character in the dollar part
	//of value.
	for(var i = tempAmount.length - 1; i >= 0; i--){	
		
		//If current offset is a multiple of 3 add a comma.
		if((offset++ % 3) == 0){
			amount = "," + tempAmount.substr(i,1) + amount
		}
		else{	
			amount = tempAmount.substr(i,1) + amount
		}	
  }
		
	//Get rid of the leading comma if it exists.	
	if(amount.charAt(0) == "," || (amount.charAt(0) == "-" && amount.charAt(1) == ",")){
		amount = amount.replace(/,/,"");		
	}

	return amount;
	
}

//*********************************************************************************
// Title: 				newWindow
// Desc: 				Opens a new window of standard size.
// Created : 			Unknown
// Last Modified: 		Jan 29, 2004
// Accepts:				help_url - the URL of the page to open
// Returns:				void
//*********************************************************************************
function newWindow(help_url) {
	var popupWin;
	popupWin = window.open(help_url,"popupWin","width=620,height=480,scrollbars=yes,menubars=yes,resizable=yes,top=30,left=30");
	popupWin.focus();
	//return false;
}
//Usage:
//function newWindowMainHelp() { newWindow("help_getting_started.html"); }
//function newWindowEmail() { newWindow("help_getting_started.html#email"); }
//<a href="javascript:newWindowMainHelp()">

//*********************************************************************************
// Title: 				newLargeWindow
// Desc: 				Opens a new window of large size.
// Created : 			Aug 19, 2003
// Last Modified: 		Jan 29, 2004
// Accepts:				pop_url - the URL of the page to open
// Returns:				void
//*********************************************************************************
function newLargeWindow(pop_url) {
	var custWindow;
	custWindow = window.open(pop_url,"custWindow","width=705,height=550,scrollbars=yes,menubars=yes,resizable=yes,top=10,left=10");
	custWindow.focus();
	//return false;
}
//Usage:
//function newWindowMainHelp() { newLargeWindow("help_getting_started.html"); }
//function newWindowEmail() { newLargeWindow("help_getting_started.html#email"); }
//<a href="javascript:newWindowMainHelp()">

//*********************************************************************************
// Title: 				newCustomWindow
// Desc: 				Opens a new window of large size.
// Created : 			Nov 25, 2003
// Last Modified: 		Jan 29, 2004
// Accepts:				pop_url - the URL of the page to open
// Returns:				void
//*********************************************************************************
function newCustomWindow(pop_url,win_width,win_height,win_name) {
	var custWindow;
	if(pop_url.indexOf('/marketing/locators/TeamLocatorSearch') != -1){
		pop_url = '/ca/apply/afp-error.html';
	}
	if(!win_name){
		win_name="custWindow";
	}
	custWindow = window.open(pop_url,win_name,"width="+win_width+",height="+win_height+",scrollbars=yes,menubars=yes,resizable=yes,top=10,left=10");
	
	//return false;
}
//Usage:
//function newWindowMainHelp() { newCustomWindow("help_getting_started.html","500","500"); }
//function newWindowEmail() { newCustomWindow("help_getting_started.html#email","500","500"); }
//<a href="javascript:newWindowMainHelp()">

//*********************************************************************************
// Title: 				newCustToolbarWindow
// Desc: 				Opens a new window of standard size.
// Created : 			July 14, 2004
// Last Modified: 		July 14, 2004
// Accepts:				apply_url - the URL of the page to open
// Returns:				void
//*********************************************************************************
function newCustToolbarWindow(pop_url,win_width,win_height) {
	var toolbr;
	toolbr=window.open(pop_url,"apply","width="+win_width+",height="+win_height+",directories=no,hotkeys=no,location=no,menubar=no,personalbar=no,resizable=yes,scrollbars=yes,status=no,titlebar=no,toolbar=yes,top=10,left=10");
	toolbr.focus();
	//return false;
}

//*********************************************************************************
// Title: 				newCustStatusWindow
// Desc: 				Opens a new window of standard size, with a Status bar.
// Created : 			June 24, 2005
// Last Modified: 		June 24, 2005
// Accepts:				apply_url - the URL of the page to open
// Returns:				void
//*********************************************************************************
function newCustStatusWindow(pop_url,win_width,win_height) {
	var statusbar;
	statusbar=window.open(pop_url,"newWin","width="+win_width+",height="+win_height+",directories=no,hotkeys=no,location=no,menubar=no,personalbar=no,resizable=yes,scrollbars=yes,status=yes,titlebar=no,toolbar=no,top=10,left=10");
	statusbar.focus();
	//return false;
}

//Usage:
//function newWindowMainHelp() { newCustomWindow("help_getting_started.html","500","500"); }
//function newWindowEmail() { newCustomWindow("help_getting_started.html#email","500","500"); }
//<a href="javascript:newWindowMainHelp()">

//*********************************************************************************
// Title: 				newApplyWindow
// Desc: 				Opens a new window of standard size.
// Created : 			Jan 29, 2004
// Last Modified: 		Jan 29, 2004
// Accepts:				apply_url - the URL of the page to open
// Returns:				void
//*********************************************************************************
function newApplyWindow(apply_url) {
	var apply;
	apply=window.open(apply_url,"apply","width=640,height=470,directories=no,hotkeys=no,location=no,menubar=no,personalbar=no,resizable=yes,scrollbars=yes,status=yes,titlebar=no,toolbar=yes,top=10,left=10");
	apply.focus();
	//return false;
}
//Usage:
//function newWindowMainHelp() { newWindow("help_getting_started.html"); }
//function newWindowEmail() { newWindow("help_getting_started.html#email"); }
//<a href="javascript:newWindowMainHelp()">

//*********************************************************************************
// Title: 				newApplyWindowLarge
// Desc: 				Opens a new window of standard size.
// Created : 			Jan 29, 2004
// Last Modified: 		Jan 29, 2004
// Accepts:				apply_url - the URL of the page to open
// Returns:				void
//*********************************************************************************
function newApplyWindowLarge(apply_url) {
	var applyLarge;
	applyLarge=window.open(apply_url,"applyLarge","width=797,height=550,directories=no,hotkeys=no,location=no,menubar=no,personalbar=no,resizable=yes,scrollbars=yes,status=yes,titlebar=no,toolbar=yes,top=10,left=10");
	applyLarge.focus();
	//return false;
}
//*********************************************************************************
// Title: 				openWindowOpener
// Desc: 			opens the url in the opener window and focuses it. If the opener 
//						window doesn't exist, it opens and focuses a new window.
// Created : 			May 28, 2004
// Accepts:				url - the URL of the page to be redirected / opened
// Returns:				N/A
//*********************************************************************************
function openWindowOpener(url){
	if(top.opener && !top.opener.closed){
		top.opener.location=url;
		top.opener.focus();
	}else{
		replaceOpenerWindow = window.open(url,'newOpener');
		replaceOpenerWindow.focus();
	}
}


//Usage:
//function newWindowMainHelp() { newWindow("help_getting_started.html"); }
//function newWindowEmail() { newWindow("help_getting_started.html#email"); }
//<a href="javascript:newWindowMainHelp()">

//*********************************************************************************
// Title: 				checkText
// Desc: 				Validates that the value of a field is text.
// Created : 			July 31, 2002
// Last Modified: 		Sept 23, 2002
// Accepts:				field - A reference to the field to be checked.
// Returns:				True if valid. False if not valid.
//*********************************************************************************


function checkText(field){
	var isValid = true;
	//field = eval(field);
	/*setup regular expression to use to validate text.  A backslash is used
	in the regular expression to escape a special regular expression
	character.  Since backslash is a special character within javascript, it
	must also be escaped, hence all the double slashes.  The expression
	includes alphanumerics, all standard puntuation, and extended latin
	characters.*/
	strExp = "^[A-Za-z0-9Ç-ùáíóúñÑÖÜ,/;:'-=_!@#%&\\\"\\f\\n\\r\\+\\*\\?\\.\\[\\]\\^\\$\\(\\)\\{\\}\\|\\\\\\&\\ ]+$";
	myReg = new RegExp(strExp);
	isValid = myReg.test(field.value);
	if(field.value.length > 0 && isValid){
		return true;
	}
	return false
}


function checkRadio(field){
	field = eval(field);
	for(var i=0; i<field.length; i++){
		if(field[i].checked){
			return true;
		}
	}
	return false;
}


function isEmpty( inputStr )
{
   if ((inputStr!=null)&&(inputStr!="")) { var c='?'; for (var i=0; i < inputStr.length; i++) { c=inputStr.charAt(i); if (c!=" ") return false; } }
   return true;
}


function isNumber( inputStr )
{
   var c="?";
   for (var i=0; i < inputStr.length; i++) { c=inputStr.charAt(i); if (c!=" ") { if ((c<"0") || (c>"9")) return false; } }
   return true;
}


function submitFeedbackForm()
{
   document.feedback.submit(); return true;
}


var whitespace = " \t\n\r";
function isWhitespace (s)
{   
    var i;

    // Is s empty?
    if (isEmpty(s)) return true;

    // Search through string's characters one by one
    // until we find a non-whitespace character.
    // When we do, return false; if we don't, return true.

    for (i = 0; i < s.length; i++)
    {   
        // Check that current character isn't whitespace.
        var c = s.charAt(i);

        if (whitespace.indexOf(c) == -1) return false;
    }

    // All characters are whitespace.
    return true;
}



function isEmail (s)
{   
    if (isEmpty(s)) 
       if (isEmail.arguments.length == 1) return false;
       else return (isEmail.arguments[1] == true);
   
    // is s whitespace?
    if (isWhitespace(s)) return false;
    
    //If 1st character is not an alpha numeric, it is then not a valid email address.
    ch = s.charAt(0);
    if (!((ch >= "a" && ch <= "z") || (ch >= "A" && ch <= "Z" ) ||
          (ch >= "0" && ch <= "9") || (ch == "_") || (ch == "-"))) 
    {

       return false;
    }

    // there must be >= 1 character before @, so we
    // start looking at character position 1 
    // (i.e. second character)
    var i = 1;
    var sLength = s.length;

    // look for @
    while ((i < sLength) && (s.charAt(i) != "@"))
    {
       // ensure character is alpha, numeric, underscore, or a dot
       ch = s.substring(i, i+1);
       if (!((ch >= "a" && ch <= "z") || (ch >= "A" && ch <= "Z" ) ||
             (ch >= "0" && ch <= "9") || (ch == "_") || (ch == ".") || (ch == "-"))) 
       {

          return false;
       }
       if ((s.charAt(i) == ".") && (s.charAt(i+1) == ".")) {
          return false;
       }
       if ((s.charAt(i) == ".") && (s.charAt(i+1) == "@")) {
          return false;
       }
       i++;
    }

    if ((i >= sLength) || (s.charAt(i) != "@")) {
       return false;
    } else if ((s.charAt(i) == "@") && (s.charAt(i+1) == ".")) {
       return false;
    } else {
       i += 1;
    }
    
    // look for at least one dot
    while ((i < sLength) && (s.charAt(i) != "."))
    { 
       // ensure character is alpha, numeric, or underscore
       ch = s.substring(i, i+1);
       if (!((ch >= "a" && ch <= "z") || (ch >= "A" && ch <= "Z" ) ||
             (ch >= "0" && ch <= "9") || (ch == "_") || (ch == "-"))) 
       {
          return false;
       }

       i++;
    }

    // there must be at least one character after the dot
    if ((i >= sLength - 1) || (s.charAt(i) != ".")) return false;

    //ensure there are no consecutive dots.
    if ((s.charAt(i) == ".") && (s.charAt(i+1) == ".")) {
       return false;
    }

    // ensure the rest of the characters after the first "." are alpha, 
    // numeric, underscore, or a dot.
    while ((i < sLength)) {
       ch = s.substring(i, i+1);
       if (!((ch >= "a" && ch <= "z") || (ch >= "A" && ch <= "Z" ) ||
             (ch >= "0" && ch <= "9") || (ch == "_") || (ch == "."))) 
       {
          return false;
       }
       
       if ((s.charAt(i) == ".") && (s.charAt(i+1) == ".")) {
          return false;
       }
       i++;
    }

    // ensure the last character is not a dot
    if (s.charAt(sLength-1) == ".") {
       return false;
    }
    
    return true;
}


//*********************************************************************************
// Title: 				trailingCurrencyEnglish
// Desc: 				To handle maggic numbers like 4.000000002
// Created : 			July 12, 2005
// Last Modified: 		July 12, 2005

//*********************************************************************************
  
	  function trailingCurrencyEnglish(curValue)
  { 
   	    curValue = Math.round(parseFloat(curValue) *100) / 100.00;

		return curValue;
  }


//*********************************************************************************
// Title: 				trailingCurrencyFrench
// Desc: 				To handle maggic numbers like 4.000000002
// Created : 			July 12, 2005
// Last Modified: 		July 12, 2005

//*********************************************************************************
  
	  function trailingCurrencyFrench(curValue)
  {  // var curValue = curValue.toString();
   	    curValue = Math.round(parseFloat(curValue) *100) / 100.00;
		return curValue
  }



