// JavaScript Document

function navegador(){
<!--
var nombre = navigator.appName
	if (nombre == "Microsoft Internet Explorer")
		return nombre = "ie";
	else
		return nombre = "ns";
//-->
}

///////////////////////////////////////////////////////
// ABRIR VENTANAS
function abreWindow(mypage, myname, w, h, scroll) {
	var winl = (screen.width - w) / 2;
	var wint = (screen.height - h) / 2;

winprops = 'height='+h+',width='+w+',top='+wint+',left='+winl+',scrollbars='+scroll+',resizable';

	win = window.open(mypage, myname, winprops);
	
	if (parseInt(navigator.appVersion) >= 4) { 
		win.window.focus(); 
	}

}

$(document).ready(function (){

	$("#denuncia_patente").focus();

	$("form input:text, form input:password, form textarea").focus(function (){
		$(this).addClass("resalta");
	});
	
	$("form input:text, form input:password, form textarea").keyup(function (){
		$(this).addClass("resalta");
	});
	
	$("form input:text, form input:password, form textarea").blur(function (){
		$(this).removeClass("resalta");
	});
	
	$('#denunciaform').submit(function() {
		$("#denunciaUser form").hide();
		$("#denunciaUserPre").show();
		return false;
	});
	
	$('#buttonSusB').click(function() {
		
		var error = false;

		$("#loginuserform input").each(function(i){
		  if($(this).val() == ''){
		  	$(this).focus();
			$(this).parent().css("border","1px dashed #EFB700");
			error = true;
			return false;
		  }
		});

		if(error == false){
		$("#loginuser form, #loginuser #resultOkB, #loginuser #resultErrorB").hide();		
		
		$("#form_pre_carga").show();
		
			$.post("proceso.php?op=login&"+$("#loginuserform input").serialize(), $("#loginuserform input").serialize(),
				function(data){
						$("#form_pre_carga").hide();
					if(data.substring(0,2) == "ok"){
						$("#resultErrorB, #loginuserform form").remove();
						$('#loginuser #resultOkB').show();
						$('#loginuser #resultOkB').html(data.substring(2));
						window.location.reload();
					} else {
						$('#loginuser #resultErrorB').html(data);
						$('#resultErrorB, #loginuser form').show();
					}
				});
		}
			return false;
		});

});