function submit_cautare(form_h){
    form_what = form_h.cauta_what.value;
	form_where = getCheckedValue(form_h.cauta_where);
	form_h.action = '/cautare/'+ form_where + '/' + form_what.replace('&',' ') + '/';
	if (form_what=='') alert('Introduceti termenii cautarii');
	else {
		if(form_where=='') alert('Alegeti sectiunea pentru cautare');
		else form_h.submit();
	}
}
function get_sel(sel_h){
 select_box = sel_h;
 select_index = select_box.selectedIndex;
 select_value = select_box[select_index].value;
return select_value;
}
function getCheckedValue(radioObj) {
	if(!radioObj)
		return "";
	var radioLength = radioObj.length;
	if(radioLength == undefined)
		if(radioObj.checked)
			return radioObj.value;
		else
			return "";
	for(var i = 0; i < radioLength; i++) {
		if(radioObj[i].checked) {
			return radioObj[i].value;
		}
	}
	return "";
}
function parse_search_word(max,maxstr) {
	/*maxstr < max - ca sa aiba relevanta codul*/
	var inpt;
	var fw;
	inpt = document.getElementById("cauta_what");
	fw=inpt.value;
	fw = word_no_spaces(fw,maxstr);
	fw = get_paragraph(fw,max,maxstr);
	document.getElementById("cauta_what").value = document.getElementById("cauta_what").value.substring(0,fw.length);
}
function word_no_spaces(str,maxstr) {
	var lsp;
	lsp = str.lastIndexOf(" ");
	if( lsp==-1 && str.length>maxstr) str=str.substring(0,maxstr);
	return str;
}
function get_paragraph(str,max,maxstr) {
	var chk;
	var lsp;
	if(str.length>max) {
		chk=str.substring(0,max);
		chk=word_no_spaces(chk,maxstr);
		if(chk.length>=max+1 && str[max+1]==" ") str=chk;
		else {
			lsp = chk.lastIndexOf(" ");
			if(lsp!=-1) {
				chk=chk.substring(0,lsp);
				str=chk;
			}
		}
		
	}
	return str;
}
