jQuery(document).ready(function($){
	$('#inputString').blur(function() {
	 	if($('#inputString').val()=="" || $('#inputString').val()=="Enter first few letters of the product"){
			$('#inputString').val("Enter first few letters of the product");
			$('#inputString').css("color","#BDBDBD");
			$('#product-submit').hide();
			$('#product-suggest').fadeOut();
		}
	});
	
	$('#inputString').focus(function () {
		if($('#inputString').val()=="Enter first few letters of the product"){
			$('#inputString').val('');
		}
	});
	
	$('#inputString').keyup(function() {
		var inputString = $('#inputString').val();
		if(inputString.length == 0) {
			$('#product-suggest').fadeOut(); // Hide the suggestions box
		} else {
			$('#loading').fadeIn();
			$.ajax({
   				type: "GET",
   				url:  "/autoprodsuggest",
   				data: "queryString="+inputString+"&sid="+Math.random(),
   				success: function(msg){
   					$('#loading').fadeOut();
					$('#product-suggest').fadeIn(); // Show the suggestions box
					$('#product-suggest').html(msg); // Fill the suggestions box
   				}
 			});
		}
	});
});
var $js = jQuery;
function closeSuggest(){
	$js('#product-submit').hide();
	$js('#product-suggest').fadeOut();
}
function selectProduct(str,pid,cityid){
	$js("#inputString").val(str);
	$js('#inputString').css("color","#2780D1");
	$js("#pid_id").val(pid);
	$js("#city_id").val(cityid);
	$js('#product-suggest').fadeOut();
	$js('#product-submit').fadeIn();
}
function openForm(){
	var product=$js("#pid_id").val();
	var city=$js("#city_id").val();
	window.open("reviewform.jsp?pid="+product+"&cityidpass="+city,'_top');
}
