function enviar_form_interno( pagina, q ){
	form = document.getElementById("search-form");
	form.q.value = q;
	q = escape( q.replace(/ /g,"+") );
	form.action = pagina + "?q=" + q;
	form.submit();
}

function enviando_form( form, pagina ){
	var q = escape( form.q.value.replace(/ /g,"+") );
	form.action = pagina + "?q=" + q;
	return true;
}

function enviar_form( form, pagina ){
	var q = escape( form.q.value.replace(/ /g,"+") );
	form.action = pagina + "?q=" + q;
	form.submit();
}

function verificar( mensaje, comprobacion, malament, form, confirm_url ) {

	var fallo = false;
	var captcha = false;
	var capt_ok = true;
	
	mensaje += "\n";
	
	for( i = 0; i < form.elements.length; i++ ){
		if ( ( form.elements[i].value == "" || ( form.elements[i].type == "checkbox" && form.elements[i].checked == "" ) ) && form.elements[i].className == "obligued" && form.elements[i].type != "hidden" ) {
			if( form.elements[i].name == 'captcha' ){
				captcha = true;
			}else{
				fallo = true;
				mensaje += "\n " + document.getElementById( "lang_" + form.elements[i].name ).value;
			}
		}else{
			if( form.elements[i].name == 'captcha' ){
				$.ajax	({
			           async: true,
			           dataType: "html",
			           url: confirm_url + "/" + form.elements[i].value,
			           complete:	function(datos, resultado){
										if( resultado == "success" ){
											var result = datos.responseText;
											if( result != "ok" ){
												capt_ok = false;
												terminar( form, fallo, mensaje, captcha, comprobacion, capt_ok, malament );
											}else{
												terminar( form, fallo, mensaje, captcha, comprobacion, capt_ok, malament );
											}
										}else{
											capt_ok = false;
											terminar( form, fallo, mensaje, captcha, comprobacion, capt_ok, malament );
										}
									}
			        });
			}
		}
	}
	
	if( captcha == true ){
		terminar( form, fallo, mensaje, captcha, comprobacion, capt_ok, malament );
	}
}

function terminar( form, fallo, mensaje, captcha, comprobacion, capt_ok, malament ){
	if( fallo ){
		alert(mensaje);
	}else{
		if( captcha ){
			alert( comprobacion );
		}else{
			if( !capt_ok ){
				alert( malament );
			}else{
				form.submit();
			}
		}
	}
}
