jQuery(document).ready(function(){
	$('#country_select').change(formAction);
	$('#state_select').change(formAction);
	
	try {
		if ( sign_deleted != "" ) {
			alert(sign_deleted);
		}
		if ( sign_locked != "" ) {
			alert(sign_locked);
		}
	} catch(e) {}
	$("select#country_select").keypress(eventclickcountry);
	$("select#state_select").keypress(eventclickcountry);
	
	$("#golink").click(goCountry);
	
})

var sel_value = '';

function formAction() {
	
	if ( $(this).val() == 'any' ) {
		return ;
	}
	
	action = $(this).parent().parent().find('a').attr('href');
	
	if ( '' == sel_value ) {
		if ( '/' != action ) {
			action = action+'/';
		}
	}
	sel_value = $(this).val();

	lastSlash = action.lastIndexOf('/');

	if ( -1 != lastSlash ) {
		if (lastSlash != (action.length-1) ) {
			action = action.slice(0, lastSlash+1);
		}
		$(this).parent().parent().find('a').attr('href', action+sel_value);
	}
}
function eventclickcountry(event){
    if (event.keyCode=='13') {
    	goCountry();
    }
}
function goCountry() {
    var link = $("a.btn1_white").attr('href');
    
    if (link=='/') {
    	$('.nocountry').show();
    	return false;
    } else {
    	$('.nocountry').hide();
    	location.href = link;
    }
}
