// JavaScript Document
function lookup(inputString,e) {
	if(inputString.length == 0) {
		// Hide the suggestion box.
		$('#suggestions').hide();
		hidePopup();
		var tag=document.getElementsByTagName("select");
		for(i=0;i<tag.length;i++){
			$(tag[i]).css("display","inline");			
		}
	} else {	
		loadpopup=true;
		$.post("zipcode.jsp", {queryString: ""+inputString+""}, function(data){
			if(trim(data).length>67) {				
				if(navigator.appName == "Microsoft Internet Explorer" && $.browser.version=="6.0"){	
					var tag=document.getElementsByTagName("select");
					for(i=0;i<tag.length;i++){
						$(tag[i]).css("display","none");
					}
				}
								
				/*$('#suggestions').show();
				$('#autoSuggestionsList').html(trim(data));	
				if(navigator.appName == "Microsoft Internet Explorer" && $.browser.version=="6.0"){
					document.getElementById("suggestions").style.top=(397+40)+"px";
					document.getElementById("suggestions").style.left=640+"px";
					document.getElementById("suggestions").style.top=(document.getElementById("zipCode").offsetTop-10)+"px";
					document.getElementById("suggestions").style.left=document.getElementById("zipCode").offsetLeft+"px";
				}else if(navigator.appName == "Microsoft Internet Explorer" && $.browser.version=="7.0"){
					document.getElementById("suggestions").style.top=(397+40)+"px";
					document.getElementById("suggestions").style.left=650+"px";
				}else{
					document.getElementById("suggestions").style.top=(397+10)+"px";
					document.getElementById("suggestions").style.left=650+"px";
				}*/
				$('#autoSuggestionsList').html(trim(data));	
				xstooltip_show("autoSuggestionsList","zipCode");
			}else{
				hidePopup();
				var tag=document.getElementsByTagName("select");
				for(i=0;i<tag.length;i++){
					$(tag[i]).css("display","inline");			
				}
			}
		});
	}
} // lookup
	
function fillText(thisValue) {
	loadpopup=false;
	$('#zipCode').val(thisValue);
	//document.getElementById("zipCode").focus();
	setTimeout("hidePopup();", 200);
}
function hidePopup(){
	xstooltip_hide("autoSuggestionsList");
	var tag=document.getElementsByTagName("select");
	for(i=0;i<tag.length;i++){
		$(tag[i]).css("display","inline");			
	}
}

function trim(str){
	return str.replace(/^\s*|\s*$/g,"");
}

function lookupYear(inputString,e) {
	if(inputString.length == 0) {
		// Hide the suggestion box.
		$('#suggestions').hide();
	} else {	
		loadpopup=true;
		$.post("yearcode.jsp", {queryString: ""+inputString+""}, function(data){
			if(trim(data).length>67) {				
				if(navigator.appName == "Microsoft Internet Explorer" && $.browser.version=="6.0"){	
					var tag=document.getElementsByTagName("select");
					for(i=0;i<tag.length;i++){
						$(tag[i]).css("display","none");
					}
				}
				$('#suggestions').show();
				$('#autoSuggestionsList').html(trim(data));	
				if(navigator.appName == "Microsoft Internet Explorer" && $.browser.version=="6.0"){
					document.getElementById("suggestions").style.top=(397+75)+"px";
					document.getElementById("suggestions").style.left=640+"px";
				}else if(navigator.appName == "Microsoft Internet Explorer" && $.browser.version=="7.0"){
					document.getElementById("suggestions").style.top=(397+70)+"px";
					document.getElementById("suggestions").style.left=650+"px";
				}else{
					document.getElementById("suggestions").style.top=(397+40)+"px";
					document.getElementById("suggestions").style.left=650+"px";
				}
			}else{
				hidePopup();
				var tag=document.getElementsByTagName("select");
				for(i=0;i<tag.length;i++){
					$(tag[i]).css("display","inline");			
				}
			}
		});
	}
}
	
function fill(thisValue) {
	loadpopup=false;
	$('#nagsYear').val(thisValue);
	//document.getElementById("nagsYear").focus();
	setTimeout("hidePopup();", 200);
	onYearFocus();
}

function onYearFocus(){
	if($('#nagsYear').val()!=""){
		//document.getElementById("nagsModel").focus();
		findMakeByYear();
	}
}

