function noimgsmall(imgPath) {
	eval(imgPath).src = "images/noimg150.gif";
}




function formVal(thefields) {
	thereturn = true;
	splitfields = thefields.split(",");
	for(i=0; i<(splitfields.length); i++) {
		document.getElementById(splitfields[i]).style.background = "#FFFFFF";
		if (document.getElementById(splitfields[i]).value=="" || document.getElementById(splitfields[i]).value=="0") {
			document.getElementById(splitfields[i]).style.background = "#FFDDDD";
			thereturn = false;
		}
	}
	if (thereturn==false) { alert("Please complete all required fields"); }
	return thereturn;
}


// ADD TO FAVOURITES LINK
function addfave() {
	var url="http://www.excelhotels.com/";
	var title="Excel Hotels - Find and Book Hotels in New Zealand with the best rates";

	try {
		// INTERNET EXPLORER
		window.external.AddFavorite(url,title);
	} catch(e) {
		try {
			window.sidebar.addPanel(title,url,"");
		} catch(e2) {
			return true;
		}
	}
	
	return false;
}

// ATTACH IN A NICE, NON OBTRUSIVE WAY
window.onload = function() {
	if (document.getElementById('addfavelink')) {
		document.getElementById('addfavelink').onclick = function() {
			return addfave();
		}
	}
	
 	if (!document.getElementsByTagName) return; 
 	var anchors = document.getElementsByTagName("a"); 
 	for (var i=0; i<anchors.length; i++) { 
		var anchor = anchors[i]; 
		if (anchor.getAttribute("href") && anchor.getAttribute("rel") == "external") {
     		anchor.target = "_blank"; 
     	}
 	}
}

// FORMAT CURRENCY FUNCTION
function formatCurrency(num) {
	num = num.toString().replace(/\$|\,/g,'');
	if(isNaN(num))
	num = "0";
	sign = (num == (num = Math.abs(num)));
	num = Math.floor(num*100+0.50000000001);
	cents = num%100;
	num = Math.floor(num/100).toString();
	if(cents<10)
	cents = "0" + cents;
	for (var i = 0; i < Math.floor((num.length-(1+i))/3); i++)
	num = num.substring(0,num.length-(4*i+3))+','+
	num.substring(num.length-(4*i+3));
	return (((sign)?'':'-') + num + '.' + cents);
}

