$(function() {
	$("#tags").autocomplete({
			source: "http://"+document.location.hostname+"/giftcard_search.php",
			minLength: 1,
			select: function( event, ui ) {
				$(location).attr('href',ui.item.url);
			}
		});

});
function tc(id){
	window.open("/terms.html?id=" + id, 'terms', "toolbar=0,scrollbars=1,location=0,statusbar=0,menubar=0,resizable=1,width=500,height=600,left = 0,top = 0");
}
function error_giftcard_image(source){
	source.src = "/images/giftcard-image-standard.gif";
	source.onerror = "";
	return true;
}
function card_comparison() {
	day = new Date(); id = day.getTime(); amm = 0;
	cardids = new String("");
	for(var j=0; !(document.listofcards.elements[j] == null || document.listofcards.elements[j] == undefined); j++){
		var1 = document.listofcards.elements[j].name;
		var2 = var1.split("_");
		if(var2[0]=="checkboxid" && document.listofcards.elements[j].checked){
			cardids = cardids.concat(var2[1]+"|");
			amm=amm+1;
		};
	}
	if(amm<2){ alert("Please, select at least 2 cards for comparison."); return false; }
	else if(amm>6){ alert("Please, select up to 6 cards for comparison."); return false; }
	wsize = Math.min(screen.width-40,(150+amm*136));
	hsize = Math.min(screen.height-90,800);
	weblink = 'compare-card-offers.html/'+cardids;
	eval("page" + id + " = window.open(weblink, '" + id + "', 'toolbar=0,scrollbars=1,location=0,statusbar=0,menubar=0,resizable=1,width=" + wsize + ",height=" + hsize + ",left = 0,top = 0');");
	return false;
}
function openpage(url) {
	newwindow=window.open(url,'name','height=700,width=670,scrollbars=1,resizable=1');
	if (window.focus) {newwindow.focus()}
	return false;
}
