
function adv_search_form_keyword_action(){
	var action = "search-results-adv.bhtml";
	var prefix = prepareLinkName(jQuery("#keyword").val());
	if (prefix.length > 0){
		jQuery("#search_more_form").attr("action",prefix+"/"+action);
	} else {
		jQuery("#search_more_form").attr("action",action);
	}
	return true;
}

function prepareLinkName(str){
	str = str.replace(/ą/g,"a");
	str = str.replace(/ć/g,"c");
	str = str.replace(/ę/g,"e");
	str = str.replace(/ł/g,"l");
	str = str.replace(/ń/g,"n");
	str = str.replace(/ó/g,"o");
	str = str.replace(/ś/g,"s");
	str = str.replace(/ź/g,"z");
	str = str.replace(/ż/g,"z");
	str = str.replace(/Ą/g,"A");
	str = str.replace(/Ć/g,"C");
	str = str.replace(/Ę/g,"E");
	str = str.replace(/Ł/g,"L");
	str = str.replace(/Ń/g,"N");
	str = str.replace(/Ó/g,"O");
	str = str.replace(/Ś/g,"S");
	str = str.replace(/Ź/g,"Z");
	str = str.replace(/Ż/g,"Z");
	return str.replace(/[^a-zA-Z0-9-_]+/g,"+").toLowerCase();
}

function adv_search_form_year_valid(){
	var t=jQuery("#releaseDate").val();
	if(t == null || t=='' || (t>1900 && t<2100)){
		return true
	}
	else {
		alert('Format daty jest niepoprawny');
		return false;
	}
}

function adv_search_validate(){
	return adv_search_form_year_valid() && adv_search_form_keyword_action(); 
}

