//------------------ General --------------------
function lista(pagina){
	obj = document.f1;
	obj.redireccion.value = pagina;
	obj.target="_self";
	obj.method = "post";
	obj.action = "redireccion.php";
	obj.submit();
}

//----------- Usuarios -----------------------
function lista_usuarios(){
	obj = document.f1;
	obj.target="_self";
	obj.method = "post";
	obj.action = "usuarioHome.php";
	obj.submit();
}

function page_crear() {
	document.f1.target="_self";
	document.f1.method = "post";
	document.f1.action = "usuarioCrear.php";
	document.f1.submit();
}

function crearUsuario() {
	obj = document.f1;
	if(obj.nombre.value == ""){
		alert("Debe Ingresar el Nombre");
		return;	
	}
	if(obj.nick.value == ""){
		alert("Debe Ingresar el Nick");
		return;	
	}
	if(obj.password.value == ""){
		alert("Debe Ingresar el Password");	
		return;
	}
	if(obj.password2.value == ""){
		alert("Debe reingresar el password");	
		return;
	}
	if(obj.password.value != obj.password2.value){
		alert("Debe reingresar el password, ya que los ingresados son distintos.");	
		return;
	}
	if(obj.email.value == ""){
		alert("Debe ingresar el mail");	
		return;
	}
	obj.target="_self";
	obj.method = "post";
	obj.action = "usuarioInsert.php";
	obj.submit();
}

function selectficha(numero) {
	obj = document.f1;
    obj.numero_usuario.value=numero;
}


function verficha() {
	obj = document.f1;
	if (obj.numero_usuario.value=="" || obj.numero_usuario.value==null)	{
		alert("Seleccione un usuario.");
		return;
	}
	obj.method="post";
	obj.target="_parent";
    obj.action="usuarioVer.php";
    obj.submit();
}

function eliminarficha() {
	obj = document.f1;
	if (obj.numero_usuario.value=="" || obj.numero_usuario.value==null)	{
		alert("Seleccione un usuario.");
		return;
	}
	mensaje = window.confirm ("¿Desea eliminar el usuario seleccionado?")
	if (mensaje){
		obj.method="post";
		obj.target="_parent";
		obj.action="usuarioDelete.php";
		obj.submit();
	}
	else{
		return;
	}
}

function modificarficha() {
	obj = document.f1;
	if (obj.numero_usuario.value=="" || obj.numero_usuario.value==null)	{
		alert("Seleccione un usuario.");
		return;
	}
	obj.method="post";
	obj.target="_parent";
    obj.action="usuarioModificar.php";
    obj.submit();
}

function modificarUsuario() {
	obj = document.f1;
	if(obj.nombre.value == ""){
		alert("Debe Ingresar el Nombre");
		return;	
	}
	if(obj.nick.value == ""){
		alert("Debe Ingresar el Nick");
		return;	
	}
	if(obj.password.value == ""){
		alert("Debe Ingresar el Password");	
		return;
	}
	if(obj.password2.value == ""){
		alert("Debe reingresar el password");	
		return;
	}
	if(obj.password.value != obj.password2.value){
		alert("Debe reingresar el password, ya que los ingresados son distintos.");	
		return;
	}
	if(obj.email.value == ""){
		alert("Debe ingresar el mail");	
		return;
	}
	obj.target="_self";
	obj.method = "post";
	obj.action = "usuarioUpdate.php";
	obj.submit();
}

//------------------ Noticias -------------------------
function selectnoticia(numero) {
	obj = document.f1;
    obj.numero_noticia.value=numero;
}
function page_crear_noti() {
	document.f1.target="_self";
	document.f1.method = "post";
	document.f1.action = "noticiaCrear.php";
	document.f1.submit();
}
function crearNoticia() {
	obj = document.f1;
	if(obj.titulo.value == ""){
		alert("Debe Ingresar el Título");
		return;	
	}
	if(obj.bajada.value == ""){
		alert("Debe Ingresar la Bajada de la Noticia");
		return;	
	}
	if(obj.fecha.value == ""){
		alert("Debe Ingresar la Fecha");	
		return;
	}
	if(obj.texto.value == ""){
		alert("Debe reingresar el Texto de la Noticia");	
		return;
	}
	//obj.enctype="multipart/form-data";
	//obj.target="_self";
	//obj.method = "post";
	//obj.action = "noticiaInsert.php";
	obj.submit();
}
function ver_noticia() {
	obj = document.f1;
	if (obj.numero_noticia.value=="" || obj.numero_noticia.value==null)	{
		alert("Seleccione una Noticia.");
		return;
	}
	obj.method="post";
	obj.target="_parent";
    obj.action="noticiaVer.php";
    obj.submit();
}
function eliminar_noticia() {
	obj = document.f1;
	if (obj.numero_noticia.value=="" || obj.numero_noticia.value==null)	{
		alert("Seleccione una Noticia.");
		return;
	}
	mensaje = window.confirm ("¿Desea eliminar la noticia seleccionada?")
	if (mensaje){
		obj.method="post";
		obj.target="_parent";
		obj.action="noticiaDelete.php";
		obj.submit();
	}
	else{
		return;
	}
}
function fromModificarNoticia() {
	obj = document.f1;
	if (obj.numero_noticia.value=="" || obj.numero_noticia.value==null)	{
		alert("Seleccione una Noticia.");
		return;
	}
	obj.method="post";
	obj.target="_parent";
    obj.action="noticiaModificar.php";
    obj.submit();
}
function modificarNoticia() {
	obj = document.f1;
	if(obj.titulo.value == ""){
		alert("Debe Ingresar el Título");
		return;	
	}
	if(obj.bajada.value == ""){
		alert("Debe Ingresar la Bajada de la Noticia");
		return;	
	}
	if(obj.fecha.value == ""){
		alert("Debe Ingresar la Fecha");	
		return;
	}
	if(obj.texto.value == ""){
		alert("Debe reingresar el Texto de la Noticia");	
		return;
	}
	obj.submit();
}
//------ Public -------------------------------
function ver_detalle_public(idnoticia){
	obj = document.f1;
	obj.id_noticia.value = idnoticia;
	obj.redireccion.value = "public_det_noticias.php";
	obj.target="_self";
	obj.method = "post";
	obj.action = "redireccion.php";
	obj.submit();

}