function lookupCityNames()
{
    var postalCode = jq$('#postalCode').val();
    var postalCodeTrimmed = postalCode.replace(/ /g, '');
    if(postalCodeTrimmed.length > 3){
	    var countrySelector = jq$('#userCountryId');
	    var country = "";
	    if(countrySelector){
		    var country = jq$('#userCountryId :selected').attr("id");		    
		}
	    var url = "/portletController.do";
	    var params = 'portletName=lookupCityNamesPortlet&postalCode='+postalCodeTrimmed+'&country='+country;
	    jq$("#cityNames").load(url+"?"+params);        
	}

    return false;
}

jq$(document).ready(function(){

	/*  onReady set focus on the input with tabindex=0
	 *  If no input field has tabindex=0 we set focus on the first visible text input */
	if(!jq$("input[tabindex=0]").focus().length && !jq$("#tabs").length > 0)
	{
		jq$("input:text:visible:first").focus();
	}
	
	/* Handle all links with class="confirm" */
	jq$("div#col2").delegate("a.confirm", "click", function(event){		
		if(!confirm(jq$(this).attr("data-confirm-message"))) {
			event.preventDefault();
		}		
    });	
});
