function lookup(query) {
    if(query.length == 0) {
        // Hide the suggestion box.
        $('#suggestions').hide();
    } else {
        $.post("search_mainsearch.html?isAjax=ajax&query=" + query, function(data){
            if(data.length > 0) {
                $('#suggestions').show();
                $('#autoSuggestionsList').html(data);
            }
			else {
				alert("No Match. Please try again!");
				var newStr = query.substring(0, query.length - 1);
				$('#query').val(newStr);
			}
        });
    }
} // lookup

function fill(thisValue) {
   $('#query').val(thisValue);
   $('#suggestions').hide();
}

function vote(query, status, where) {
	$.get("vote.html?isAjax=ajax&query=" + query + "&status=" + status + "&where=" + where, function(data) {
		if (data.length > 0) {
			alert("Thank you for rating. \n Your vote has been casted!");
			$("#yeah_" + query).html(data);
			$("#rating_" + query).html("<img src=images/yes-grey-work.png> <img src=images/no-grey-work.png>");
		}
		else alert("Something wrong. Please try again.");
	});
}

function storepop(store) {
	newWindow = window.open("rebate_popstores.html?isAjax=ajax&store=" + store,'Stores','width=350,height=300,scrollbars=1');
	newWindow.blur();
}

function autoSelect(coupon, display) {
	if (display == "Yes")
	{
		document.getElementById("copied_" + coupon).style.display = "inline";		 
		document.getElementById("copied_" + coupon).focus();
		document.getElementById("copied_" + coupon).select();

		var shortcut;
		if (navigator.appVersion.indexOf("Mac")!=-1) shortcut="Cmd";
		else shortcut="Ctrl";
		$("#chelp_" + coupon).html("<i>(press <strong><font color=blue>" + shortcut + "</font>+<font color=blue>C</font></strong> to copy this coupon code)</i>");
		$("#chelp_" + coupon).css("display", "inline");
	}
	else {
		$("#copied_" + coupon).css("display", "none");
		$("#chelp_" + coupon).css("display", "none");
	}
}