// Conseguir valor radio
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 sendformDiv(what, valores, where) {
	$("#"+where).html("<center>"+lang["cargando"]+"</center>");
	$.ajax({
	   type: "POST",
	   url: what,
	   data: valores,
	   success: function(html){
		 $("#"+where).html(html);
	   },
	   error: function(XMLHttpRequest, textStatus, errorThrown) {
		   ajaxError("on", textStatus);
	   }
	 });
}
function formPeliculaCritica(where) {
	var data = "comentario="+document.getElementById("comentario").value+"&puntaje="+document.getElementById("puntaje").value+"&showid="+document.getElementById("showid").value+"&submit=true";
	sendformDiv("/criticas_p.php", data, where);
}
function formSerieCritica(where) {
	var data = "comentario="+document.getElementById("comentario").value+"&puntaje="+document.getElementById("puntaje").value+"&episodio="+document.getElementById("episodio").value+"&submit=true";
	sendformDiv("/criticas_s.php", data, where);
}
function formLogin(where) {
	var data = "usuario="+document.getElementById("usuario").value+"&password="+document.getElementById("password").value+"&ingresar=true";
	if (document.getElementById("recordarme").checked == true) {
		data += "&recordarme=si";
	}
	sendformDiv("/login_get.php", data, where);
}
function formLoginPass(where) {
	var data = "email="+document.getElementById("email").value+"&enviar=true";
	sendformDiv("/login_pass.php", data, where);
}
function formReg(where) {
	var data = "usuario="+document.getElementById("usuario").value+"&password="+document.getElementById("password").value+"&password2="+document.getElementById("password2").value+"&email="+document.getElementById("email").value+"&sexo="+getCheckedValue(document.forms["registro"].elements["sexo"])+"&dia="+document.getElementById("dia").value+"&mes="+document.getElementById("mes").value+"&ano="+document.getElementById("ano").value+"&registrar=true";
	sendformDiv("/registro_get.php", data, where);
}
function formRep(where, id) {
	var data = "comentario="+document.getElementById("comentario").value+"&reportar=true";
	if (document.getElementById("email")) {
		data += "&email="+document.getElementById("email").value;
	}
	sendformDiv("/botlink_rep.php?id="+id, data, where);
}
function formRep2(where, id) {
	if (document.getElementById("reporte").value == "-") {
		alert(lang["noreporte"]);
	} else {
		var data = "comentario="+document.getElementById("comentario").value+"&reporte="+document.getElementById("reporte").value+"&reportar=true";
		if (document.getElementById("email")) {
			data += "&email="+document.getElementById("email").value;
		}
		sendformDiv("/botlink_rep2.php?id="+id, data, where);
	}
}
function formRepVivo(where, id) {
	var data = "comentario="+document.getElementById("comentario").value+"&reportar=true";
	if (document.getElementById("email")) {
		data += "&email="+document.getElementById("email").value;
	}
	sendformDiv("/botlink_repvivo.php?id="+id, data, where);
}

function formUserPerfil(where) {
	var data = "pass="+document.getElementById("pass").value+"&newpass1="+document.getElementById("newpass1").value+"&newpass2="+document.getElementById("newpass2").value+"&sexo="+getCheckedValue(document.forms["perfil"].elements["sexo"])+"&dia="+document.getElementById("dia").value+"&mes="+document.getElementById("mes").value+"&ano="+document.getElementById("ano").value+"&actualizar=true";
	sendformDiv("/user_perfil.php", data, where);
}

function formUserOp(where) {
	var data = "subs="+document.getElementById("subs").value+"&recibirmails="+getCheckedValue(document.forms["opciones"].elements["recibirmails"])+"&guardar=true";
	sendformDiv("/user_opciones.php", data, where);
}