function VAccion(id,action){
	var timestamp = Math.round(new Date().getTime() / 1000);
	var form = $('#'+id);

	$.post("index.php?op="+action+"&"+timestamp, form.serialize(),
	function(datos){
		var datos_p = datos.split("|");
		if (datos_p[0] == "1"){
			$.prompt(datos_p[1],
			{buttons: {Aceptar:true},
			callback: Recargar
			});
		}
		else {
			$.prompt(datos_p[1],
			{buttons: {Aceptar:true}
			});
		}

	}
	);
	return false;
}

function VLogin(){
	var formu = document.u1;
	msg = "";
	if (formu.s_usuario.value == "" || formu.s_usuario.value == "Usuario"){
		msg += "- Usuario\n";
	}
	if (formu.s_clave.value == "" || formu.s_clave.value == "claveusr"){
		msg += "- Clave\n";
	}

	if (msg != ""){

		msg = "_________________________________________________\nVerifique los siguientes campos obligatorios:\n\n"+msg;
		alert(msg);
		return false;
	}
	return true;
}

function Recargar(){
	window.location.reload();
}


function RecargarCodigo(){
	var timestamp = Math.round(new Date().getTime() / 1000);
	$("#imgc").attr("src",'captcha.html?r='+timestamp);
}

function VFoto(){
	var formu = document.uf;
	msg = "";
	if (formu.foto.value == ""){
		msg += "- Foto\n";
	}

	if (msg != ""){

		msg = "_________________________________________________\nVerifique los siguientes campos obligatorios:\n\n"+msg;
		alert(msg);
		return false;
	}
	return true;
}

function VFb(n){
	$.prompt('Borrar Foto? Se eliminara de forma permanente',
	{buttons: {Aceptar:true,Cancelar:false},
	submit:function(v){
		if (v == true){
			var timestamp = Math.round(new Date().getTime() / 1000);

			$.get("index.php?op=fotos&n="+n+"&"+timestamp,'',
			function(datos){

				var datos_p = datos.split("|");
				if (datos_p[0] == "1"){
					document.getElementById(n).style.display = 'none';
					if (datos_p[1] == "2"){
						document.getElementById('img_p').src = 'images/nofoto.jpg';
					}
					$.prompt('Foto Eliminada.',
					{buttons: {Aceptar:true}
					
					});
				}
				else {
					$.prompt('Error borrando foto',
					{buttons: {Aceptar:true}
					});
				}

			}
			);
		}
	}
	}
	)
	;
}

function VFp(n){

	$.prompt('Establecer como principal?',
	{buttons: {Aceptar:true,Cancelar:false},
	submit:function(v){
		if (v == true){
			var timestamp = Math.round(new Date().getTime() / 1000);
			$.get("index.php?op=fotos&p="+n+"&"+timestamp,'',
			function(datos){
				var datos_p = datos.split("|");
				if (datos_p[0] == "1"){
					if (datos_p[1] != "0"){
						document.getElementById('img_p').src = datos_p[1];
					}
					$.prompt('Foto Seteada como Principal.',
					{buttons: {Aceptar:true},
					callback: Recargar
					});
				}
				else {
					$.prompt('Error asignando foto',
					{buttons: {Aceptar:true}
					});
				}

			}
			);
		}
	}
	}
	)
	;
}
