/* NOTE: Consolidate these next three window.open() calls into one function */
function openCurrency() {
	currencyWindow = window.open("http://www.oanda.com/converter/classic?user=travelandleisure","currencyWin","width=600,height=540","toolbar=no","location=no","Status=yes");
	currencyWindow.focus();
}

/* this is used in _display_partner_promotions.cfm */
function openWin(URL,winName,features){
	var aWindow=""
	aWindow=window.open(URL,winName,features);
};

/* this is used in _display_homepage_features.cfm (and maybe elsewhere too) */
function pop_me_up(pURL, features){ 
	// The following line names the Originating window "parentWindow"
	// so that the slideshow targets it
	window.name="parentWindow";
	new_window = window.open(pURL, "tlslideWindow", features);
	new_window.focus();	
}

function emailWin(brand,to) {
	window.open('http://www.amexpub.com/applications/email.cfm?brand='+brand+'&to='+to+'&url='+location.href, 'emailwindow', 'width=350,height=350,scrollbars=No,location=No,left=50,top=50,menubar=No,alwaysRaised=No,resizable=Yes,toolbar=No,status=No');
}

function validateEmailSyntax(str) 
{
	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;
}

function validateEmail(form) {
	var error = "";
	
	if (form.e_mail.value == "")
		error = "Please fill in an EMail Address";
	else if (validateEmailSyntax(form.e_mail.value) == false)
		error = "Invalid EMail Address";
			
	if (error != "") 
	{
		window.alert(error);	
		return false;
	}
	return true;
}

///////////////////////////////////////////////////////////////////////////////
// FUNCTION: formatDate()
// HISTORY: Created 11/12/2002 [me] 
// USAGE: This function can take 0, 1 or 2 arguments and return a formatted date
///////////////////////////////////////////////////////////////////////////////
function formatDate(theDate, format) {
	
	// if no argument is provided to this function, recall the function using Now() as the date
	if (arguments.length == 0) {
		dtNow = new Date();
		return formatDate(dtNow);
	}
	
	// if no format is provided specify a format of Thursday October 14, 2004 
	if (arguments.length < 2) {
		format = "daymmmmdyyyy";
	}
	
	var aDays = new Array("Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday");
	var aMonths = new Array("January","February","March","April","May","June","July","August","September","October","November","December");
	
	var day = aDays[theDate.getDay()];
	var month = aMonths[theDate.getMonth()];
	var date = theDate.getDate();
	var year = theDate.getFullYear();
	var formattedDate = "";
	
	switch(format) {
		case "daymmmdd":
			formattedDate = day.substring(0,3) + ', ' + month.substring(0,3) + ' ' + date;
			break;
		case "daymmmmdyyyy":
			formattedDate = day + ' ' + month + ' ' + date + ', ' + year;
			break;
		default:
			formattedDate = "the format parameter to the formatDate function is incorrect.";
			break;
	}
	return formattedDate;
}

function REreplace(OrigString,searchStr,replaceStr) {
	var re = new RegExp(searchStr, "g");
	return OrigString.replace(re, replaceStr);
}




