var littleSize = "118"; //size of small select box
var bigSize = "170"; //size of large select box

function embiggen(elementName){
        document.getElementsByName(elementName)[0].style.width = bigSize;
}

function belittle(elementName){
        document.getElementsByName(elementName)[0].style.width = littleSize;
}

function openPopup(URL, title, scrollbars) {
	width = 520;
	height = 600;
	screenWidth = window.screen.availWidth;
	screenHeight = window.screen.availHeight;

	window.open(URL,title,
		'width='+width+
		',height='+height+
		',top='+(screenHeight-height)/2+
		',left='+(screenWidth-width)/2+
		',menubar=no,scrollbars='+ scrollbars + ',statusbar=no,toolbar=no,resizable=no');
}

function openPrintPopup(URL) {
	width = 800;
	height = 500;
	screenWidth = window.screen.availWidth;
	screenHeight = window.screen.availHeight;

	window.open(URL,'print',
		'width='+width+
		',height='+height+
		',top='+(screenHeight-height)/2+
		',left='+(screenWidth-width)/2+
		',menubar=yes,scrollbars=yes,statusbar=yes,toolbar=yes,resizable=yes');
}


function showHelp(topic) {
	openPopup('SearchHelp.do#' + topic, 'SearchHelp', 'yes');
}

function isEnter(event) {
	return event.keyCode == 13;
}

////////////////////////////////////////////
// CrossSell Logic
////////////////////////////////////////////

function CrossSell(linkURL, imageURL) {
	this.linkURL = linkURL;
	this.imageURL = imageURL;
}
var crossSell = new Array(2);
crossSell['0'] = new CrossSell('https://www152.americanexpress.com/eforms/un/en_AU/eformsPage.do?face=en_AU&prod=Rapid&todo=view',
							'/au/MerchantDirectory/img/AMEXI1320_RHCS_corp_v3.gif');
crossSell['1'] = new CrossSell('https://www152.americanexpress.com/eforms/un/en_AU/eformsPage.do?face=en_AU&prod=Rapid&todo=view',
							'/au/MerchantDirectory/img/AMEXI1320_RHCS_smlBiz_v3.gif');

function getCurrentCrossSell() {
	var previousCrossSellIndex = readCookie('crossSellIndex');
	var currentCrossSellIndex;
	if (previousCrossSellIndex == null || previousCrossSellIndex == '')
		currentCrossSellIndex = '0';
	else
		currentCrossSellIndex = previousCrossSellIndex == '0' ? 1 : 0;
	createCookie('crossSellIndex', currentCrossSellIndex);
	return crossSell[currentCrossSellIndex];
}

////////////////////////////////////////////

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);
}
