//formulario registrarse y LogIn
$(function () {
    // Inicializar los formularios y sus eventos ------------------------------------------------------------

    // eventos de controles
    $("#cerrarF a").click(function () {
        toggle_flashes();
        $("#overlay").fadeOut("fast", function () { $(this).css("display", "none") });
        $("#content_form").fadeOut("fast", function () { $(this).css("display", "none") });
        return false;
    });
    $("#cerrarR a").click(function () {
        toggle_flashes();
        $("#overlay").fadeOut("fast", function () { $(this).css("display", "none") });
        $("#content_formR").fadeOut("fast", function () { $(this).css("display", "none") });
        return false;
    });
    $("#cerrarM a").click(function () {
        toggle_flashes();
        $("#overlay").fadeOut("fast", function () { $(this).css("display", "none") });
        $("#content_formM").fadeOut("fast", function () { $(this).css("display", "none") });
        return false;
    });
    $("#boton_cerrarM").click(function () {
        toggle_flashes();
        $("#overlay").fadeOut("fast", function () { $(this).css("display", "none") });
        $("#content_formM").fadeOut("fast", function () { $(this).css("display", "none") });
        return false;
    });

    $("#cerrarP a").click(function () {
        toggle_flashes();
        $("#overlay").fadeOut("fast", function () { $(this).css("display", "none") });
        $("#content_formP").fadeOut("fast", function () { $(this).css("display", "none") });
        return false;
    });
    function form_regist_show() {
        toggle_flashes();
        $("#content_formR").css("left", ($(window).width() - $("#content_formR").outerWidth()) / 2);
        $("#content_formR").css("top", ($(window).height() - $("#content_formR").outerHeight()) / 2);
        $("#overlay").fadeIn("fast");
        $("#content_formR").fadeIn("fast", function () { $("#usuario").focus(); });
        reset_formRegistro();
    };

    function form_access_show() {
        toggle_flashes();
        $("#content_form").css("left", ($(window).width() - $("#content_form").outerWidth()) / 2);
        $("#content_form").css("top", ($(window).height() - $("#content_form").outerHeight()) / 2);
        $("#overlay").fadeIn("fast");
        $("#content_form").fadeIn("fast", function () { $("#usuariomail").focus(); });
        reset_formAccess();
    };
    function form_mensaje_show() {
        toggle_flashes();
        $("#content_formM").css("left", ($(window).width() - $("#content_form").outerWidth()) / 2);
        $("#content_formM").css("top", ($(window).height() - $("#content_form").outerHeight()) / 2);
        $("#overlay").fadeIn("fast");
        $("#content_formM").fadeIn("fast", function () { $("#usuariomail").focus(); });
    };

    $("#boton_loginM").click(function () {
        $("#content_formM").fadeOut("fast", function () { $(this).css("display", "none") });
        $("#content_form").css("left", ($(window).width() - $("#content_form").outerWidth()) / 2);
        $("#content_form").css("top", ($(window).height() - $("#content_form").outerHeight()) / 2);
        $("#content_form").fadeIn("fast", function () { $("#usuariomail").focus(); });
        reset_formAccess();
    });

    $("#boton_loginP").click(function () {
        $("#content_formP").fadeOut("fast", function () { $(this).css("display", "none") });
        $("#content_form").css("left", ($(window).width() - $("#content_form").outerWidth()) / 2);
        $("#content_form").css("top", ($(window).height() - $("#content_form").outerHeight()) / 2);
        $("#content_form").fadeIn("fast", function () { $("#usuariomail").focus(); });
        reset_formAccess();
    });
    $("#recuperar_contrasena").click(function () {
        $("#content_form").fadeOut("fast", function () { $(this).css("display", "none") });
        $("#content_formP").css("left", ($(window).width() - $("#content_form").outerWidth()) / 2);
        $("#content_formP").css("top", ($(window).height() - $("#content_form").outerHeight()) / 2);
        $("#content_formP").fadeIn("fast", function () { $("#usuariomail").focus(); });
        reset_formContrasena();
        return false;
    });

    function reset_formContrasena() {
        $('#passwordflotanteusername').val('');
        $("#passwordflotanteusername").removeClass('input-validation-error');
        $('#passwordGeneral').html('');
        $("#capa_formulario_reset_password").hide();
        $("#capa_formulario_request_password").show();
    }

    function reset_formAccess() {
        $('#loginflotanteusername').val('');
        $('#loginflotantepassword').val('');
        $('#loginGeneral').html('');
        $("#loginflotanteusername").removeClass('input-validation-error');
        $("#loginflotantepassword").removeClass('input-validation-error');
    }

    function reset_formRegistro() {
        $('#UserNameRegister').val('');
        $('#PasswordRegister').val('');
        $('#EmailRegister').val('');
        $('#NewsRegister').val('0');
        $('#ConditionsRegister').val('0');
        $('#ConfirmPasswordRegister').val('');
        $('#registroGeneral').html('');
        $("#NameRegister").val('');
        $("#SurnameRegister").val('');
        $('#codigo_colectivo').val('');
        $('#validacionokregistro').hide();
        $("#UserNameRegister").removeClass('input-validation-error');
        $("#PasswordRegister").removeClass('input-validation-error');
        $("#EmailRegister").removeClass('input-validation-error');
        $("#errorConditions").removeClass('input-validation-error');
        $("#ConfirmPasswordRegister").removeClass('input-validation-error');
        $("#NameRegister").removeClass('input-validation-error');
        $("#SurnameRegister").removeClass('input-validation-error');
    }

    $("#reset_password_submit").click(function () {
        reset_password();
    });

    function reset_password() {
        var form = $("form[name='formResetPassword']");
        $("#resetPasswordNewPass").removeClass('input-validation-error');
        $("#resetPasswordRepeatNewPass").removeClass('input-validation-error');
        $('#resetPasswordGeneral').html('');

        $.ajax({
            type: "POST",
            url: "/account-passwordreset.php",
            data: form.serialize(),
            dataType: "json",
            error: function (xhr, status, error) {
            },
            success: function (response) {
                //do something with response
                //$('#content_medioR').html(response);
                if (response.result != "nok") {
					toggle_flashes();
					$('#overlay').css("display", "none");
					$('#content_formP').css("display", "none");
					alert('Su password ha sido cambiada, por favor, utilice el formulario de login para acceder con normalidad');
					window.location.href="http://"+location.hostname;
                }
                else {
                    var htmlerror = '<div class="validation-summary-errors" style="width:537px;"><ul>';
                    if (response.general != "") {
                        htmlerror = htmlerror + '<li>' + response.general + '</li>';
                    }
                    if (response.password != "") {
                        htmlerror = htmlerror + '<li>' + response.password + '</li>';
                        $("#resetPasswordNewPass").addClass('input-validation-error');
                    }
                    if (response.confirmPassword != "") {
                        htmlerror = htmlerror + '<li>' + response.confirmPassword + '</li>';
                        $("#resetPasswordRepeatNewPass").addClass('input-validation-error');
                    }
                    htmlerror = htmlerror + "</ul></div>";

                    $("#resetPasswordGeneral").html(htmlerror);
                }
            }
        });

        return false;
    };

    $("#boton_password").click(function () {
        recover_password();
    });


    function recover_password() {
        var form = $("form[name='formaccesoP']");
        $("#passwordflotanteusername").removeClass('input-validation-error');
        $('#passwordGeneral').html('');

		var version = document.forms["formaccesoP"].version.value;

        $.ajax({
            type: "POST",
            url: "account-requestpasswordreset.php",
            data: form.serialize(),
            dataType: "json",
            error: function (xhr, status, error) {
            },
            success: function (response) {
                //do something with response
                //$('#content_medioR').html(response);
                if (response.result != "nok") {
					if(version=="v2"){
						toggle_flashes();
						$('#overlay').css("display", "none");
						$('#content_formP').css("display", "none");

						form_access_show();
						
						$('#passwordresetok').show();
					}else{
						reset_formContrasena();
						$('#validacionokpassword').show();
					}
                }
                else {
                    var htmlerror = '<div class="validation-summary-errors" style="width:537px;"><ul>';
                    if (response.general != "") {
                        htmlerror = htmlerror + '<li>' + response.general + '</li>';
                    }
                    if (response.userName != "") {
                        htmlerror = htmlerror + '<li>' + response.userName + '</li>';
                        $("#passwordflotanteusername").addClass('input-validation-error');
                    }
                    htmlerror = htmlerror + "</ul></div>";

                    $("#passwordGeneral").html(htmlerror);
                }
            }
        });

        return false;
    };

    $("#boton_registro").click(function () {
       register_user();
    });
    $('#formaccesoR input[type="text"],#formaccesoR input[type="password"]').keydown(function (event) {
        if (event.keyCode == 13) {
            register_user();
        }
    });




    function register_user() {
        var form = $("form[name='formRegister']");
        $("#registroGeneral").html('');
        $("#UserNameRegister").removeClass('input-validation-error');
        $("#PasswordRegister").removeClass('input-validation-error');
        $("#EmailRegister").removeClass('input-validation-error');
        $("#errorConditions").removeClass('input-validation-error');
        $("#ConfirmPasswordRegister").removeClass('input-validation-error');
        $("#NameRegister").removeClass('input-validation-error');
        $("#SurnameRegister").removeClass('input-validation-error');
        $('#validacionokregistro').hide();

		var version = "v1";//document.forms["formRegister"].version.value;
		//if(($('#code_register').hasClass("checked") && $('#codigo_colectivo').hasClass("codigo_ok")) || ($('#code_register').hasClass("no_checked") && $('#codigo_colectivo').val()== ""))
		//{
	        $.ajax({
	            type: "POST",
	            url: "/account-register.php",
	            data: form.serialize(),
	            dataType: "json",
	            error: function (xhr, status, error) {
	            },
	            success: function (response) {
	                //do something with response
	                //$('#content_medioR').html(response);
	                if (response.result == "ok") {
						if(version=="v2"){
							toggle_flashes();
							$('#overlay').css("display", "none");
							$('#content_formR').css("display", "none");
	
							form_access_show();
							
							$('#validacionokregistro').show();
						}else{
							reset_formRegistro();
							$('#validacionokregistro').show();
						}
	                    //$("body").append('<img height="1" width="1" style="border-style:none;" alt="" src="http://www.googleadservices.com/pagead/conversion/1046374013/?label=58D7CKfj_gEQ_cz58gM&amp;guid=ON&amp;script=0"/>');
						//$("body").append('<!-- Google Code for Registro Conversion Page --><div style="display:inline;"><img height="1" width="1" style="border-style:none;" alt="" src="http://www.googleadservices.com/pagead/conversion/1046374013/?label=58D7CKfj_gEQ_cz58gM&amp;guid=ON&amp;script=0"/></div><div style="display:inline;"><img height="1" width="1" style="border-style:none;" alt="" src="http://www.googleadservices.com/pagead/conversion/1046374013/?label=T6-rCOfjqgIQ_cz58gM&amp;guid=ON&amp;script=0"/></div>');
					}
	                else {
	
						if(version=="v2"){
							var htmlerror = '<div class="validation-summary-errors" style="width:537px;">';
							var htmlseparador = '';
							if (response.general != "") {
								htmlerror = htmlerror + htmlseparador + response.general;
							}
							if (response.userName != "") {
								htmlerror = htmlerror + htmlseparador + response.userName;
								$("#UserNameRegister").addClass('input-validation-error');
								htmlseparador = ", ";
							}
							if (response.password != "") {
								htmlerror = htmlerror + htmlseparador + response.password;
								$("#PasswordRegister").addClass('input-validation-error');
								htmlseparador = ", ";
							}
							if (response.email != "") {
								htmlerror = htmlerror + htmlseparador + response.email;
								$("#EmailRegister").addClass('input-validation-error');
								htmlseparador = ", ";
							}
							if (response.name != "") {
								htmlerror = htmlerror + htmlseparador + response.name;
								$("#NameRegister").addClass('input-validation-error');
								htmlseparador = ", ";
							}
							if (response.surname != "") {
								htmlerror = htmlerror + htmlseparador + response.surname;
								$("#SurnameRegister").addClass('input-validation-error');
								htmlseparador = ", ";
							}
							if (response.confirmPassword != "") {
								htmlerror = htmlerror + htmlseparador + response.confirmPassword;
								$("#ConfirmPasswordRegister").addClass('input-validation-error');
								htmlseparador = ", ";
							}
							if (response.conditions != "") {
								htmlerror = htmlerror + htmlseparador + response.conditions;
								$("#errorConditions").addClass('input-validation-error');
								htmlseparador = ", ";
							}
							
							$("#registroGeneral").html(htmlerror.toLowerCase());
							
						}else{
	
							var htmlerror = '<div class="validation-summary-errors" style="width:537px;"><ul>';
							if (response.general != "") {
								htmlerror = htmlerror + '<li>' + response.general + '</li>';
							}
							if (response.userName != "") {
								htmlerror = htmlerror + '<li>' + response.userName + '</li>';
								$("#UserNameRegister").addClass('input-validation-error');
							}
							if (response.password != "") {
								htmlerror = htmlerror + '<li>' + response.password + '</li>';
								$("#PasswordRegister").addClass('input-validation-error');
							}
							if (response.conditions != "") {
								htmlerror = htmlerror + '<li>' + response.conditions + '</li>';
								$("#errorConditions").addClass('input-validation-error');
							}
							if (response.email != "") {
								htmlerror = htmlerror + '<li>' + response.email + '</li>';
								$("#EmailRegister").addClass('input-validation-error');
							}
							if (response.confirmPassword != "") {
								htmlerror = htmlerror + '<li>' + response.confirmPassword + '</li>';
								$("#ConfirmPasswordRegister").addClass('input-validation-error');
							}
							htmlerror = htmlerror + "</ul></div>";
							
							$("#registroGeneral").html(htmlerror);
						}
	
	                    //                    $("#loginGeneral").html(htmlerror);
	                    //                    $('#registerUserName').html(response.userName);
	                    //                    $('#registerPassword').html(response.password);
	                    //                    $('#registerConditions').html(response.conditions);
	                    //                    $('#registerEmail').html(response.email);
	                    //                    $('#registerConfirmPassword').html(response.confirmPassword);
	                    //                    $('#errorGeneral').html(response.general);
	                }
	            }
	        });
		//}else
		//{
		//	var htmlerror = '<div class="validation-summary-errors" style="width:537px;">';
		//	htmlerror+= "Código colectivo incorrecto";
		//	$("#registroGeneral").html(htmlerror.toLowerCase());
		//	htmlerror = htmlerror + ".</div>";
		//}	
        return false;
    };

    $("#boton_login").click(function () {
        logon_user();
    });
    $('#formacceso input[type="text"],#formacceso input[type="password"]').keydown(function (event) {
        //alert(event.keyCode);
        if (event.keyCode == 13) {
            logon_user();
        }
    });


    function logon_user() {
        var form = $("form[name='formacceso']");
        $("#loginGeneral").html('');
        $("#loginflotanteusername").removeClass('input-validation-error');
        $("#loginflotantepassword").removeClass('input-validation-error');

        $.ajax({
            type: "POST",
            url: "account-partiallogon.php",
            data: form.serialize(),
            dataType: "json",
            error: function (xhr, status, error) {
            },
            success: function (response) {
                //do something with response
                //$('#content_medioR').html(response);
                if (response.result != "nok") {
                    //                    $("#cerrarF a").trigger("click");
                    toggle_flashes();
                    $('#overlay').css("display", "none");
                    $('#content_form').css("display", "none");
                    //$('#menu_top').html('<ul><li>Bienvenido ' + response.result + '</li><li>&nbsp; | &nbsp;</li><li><a href="/datospersonales.php" class="ablanco">Perfil</a></li><li>&nbsp; | &nbsp;</li><li><a href="/desconectar.php" class="ablanco" id="logout"> Desconectar</a></li><li>&nbsp; | &nbsp;</li><li><a class="ablanco" href="http://profesionales.carsycars.com" target="_blank">Profesionales</a></li><li>&nbsp; | &nbsp;</li><li><a class="imagen_top" href="http://www.facebook.com/tucarsycars" class="apie"><img src="/images/boton_facebook.png"></a></li><li><a class="imagen_top" href="http://twitter.com/#!/carsycars" class="apie"><img src="/images/boton_twitter.png"></a></li><li><a class="imagen_top" href="http://youtube.com/carsycars" class="apie"><img src="/images/boton_youtube.png"></a></li></ul>');
					$('#menu_top').html('<ul><li class="grupo individual"><div class="inner clearfix"><div id="datos_usuario">Bienvenido, <a class="menu_grupo_desplegar" href="#">' + response.result + '</a></div><div style="display:none" class="fix2"><img src="images/menu_grupo_fix2.png" width="3" height="3" alt="" /></div><div style="display:none" class="fix"><img src="images/menu_grupo_fix.png" width="3" height="3" alt="" /></div><div style="display:none" class="menu_usuario_grupo"><div class="clearfix"><ul><li><a href="/datospersonales.php" class="ablanco">Mi Perfil</a></li><li><a href="/favoritos.php">Vehículos Guardados</a></li><li><a href="/desconectar.php" class="ablanco" id="logout">Desconectar</a></li></ul></div></div></div></li>			<li><a class="ablanco" href="http://profesionales.carsycars.com" target="_blank">Profesionales</a></li><li>&nbsp; | &nbsp;</li><li><a class="imagen_top" href="http://www.facebook.com/tucarsycars" class="apie"><img src="/images/boton_facebook.png"></a></li><li><a class="imagen_top" href="http://twitter.com/#!/carsycars" class="apie"><img src="/images/boton_twitter.png"></a></li><li><a class="imagen_top" href="http://youtube.com/carsycars" class="apie"><img src="/images/boton_youtube.png"></a></li></ul>');
                    $("#comparativa_favoritos form").load('/favorites-show-favorites-bar.php');
                    //window.location.href='/datospersonales.php';	
                    //alert(redirectAfterLogin);
                    if (typeof redirectAfterLogin != 'undefined' && redirectAfterLogin != '') {
                        window.location = redirectAfterLogin;
                    }else{
						window.location.reload();
					}

                }
                else {
                    var htmlerror = '<div class="validation-summary-errors" style="width:537px;"><ul>';
                    if (response.general != "") {
                        htmlerror = htmlerror + '<li>' + response.general + '</li>';
                    }
                    if (response.userName != "") {
                        htmlerror = htmlerror + '<li>' + response.userName + '</li>';
                        $("#loginflotanteusername").addClass('input-validation-error');
                    }
                    if (response.password != "") {
                        htmlerror = htmlerror + '<li>' + response.password + '</li>';
                        $("#loginflotantepassword").addClass('input-validation-error');
                    }
                    htmlerror = htmlerror + "</ul></div>";

                    $("#loginGeneral").html(htmlerror);
                }
            }
        });

        return false;
    };
    //--------------------------------------------------------------------------------------------------------------

    //adjuntar eventos a los elementos que llaman a los formularios

    $("a.b_acceder").live('click', function () { form_access_show(); return false; });
    $("a.b_registrarme").live('click', function () { form_regist_show(); return false; });
    $("#regist").click(function () { form_regist_show(); return false; });
    $("#acces").click(function () { form_access_show(); return false; });

    $("#content_formR .acrear").click(function () {
        $("#content_formR").hide();
        form_access_show();
        return false;
    });
    $("#content_form .acrear").click(function () {
        $("#content_form").hide();
        form_regist_show();
        return false;
    });

    //

    // mostrar/ocultar  mensaje de error
    function display_error(texto) {
        if (texto != "") {
            $("#error_msg span").text(texto);
            $("#error_msg").slideDown();
        }
    }
    function hide_error() {
        $("#error_msg").slideUp();
    }


    //barra de búsqueda click
    $("#marcamodelo").focus(function () {
        if ($(this).val() == "Buscar por marca y modelo") {
            $(this).css("color", "black");
            $(this).val("");
        }
    });
    $("#marcamodelo").blur(function () {
        if ($(this).val() == "") {
            $(this).css("color", "#999999");
            $(this).val("Buscar por marca y modelo");
        }
    });

    //ocultar elementos flash si existen
    function toggle_flashes() {
        var obj = $("object[type='application/x-shockwave-flash']");
        if (obj.length > 0) {
            for (var i = 0; i < obj.length; i++) {
                if ($(obj[i]).css("visibility") == "visible") { $(obj[i]).css("visibility", "hidden"); } else { $(obj[i]).css("visibility", "visible"); }
            }
        }
    }

    if ($("#abrirForm").val() == "acceso") {
        form_access_show();
    } else if ($("#abrirForm").val() == "registro") {
        form_regist_show();
    }

	//Forms y popup relacionados con las ofertas de cardays

	$("#cerrarO a").click(function () {
        toggle_flashes();
        $("#overlay").fadeOut("fast", function () { $(this).css("display", "none") });
        $("#content_formO").fadeOut("fast", function () { $(this).css("display", "none") });
        return false;
    });
    function form_ofertas_show() {
        toggle_flashes();
        $("#content_formO").css("left", ($(window).width() - $("#content_formO").outerWidth()) / 2);
        $("#content_formO").css("top", ($(window).height() - $("#content_formO").outerHeight()) / 2);
        $("#overlay").fadeIn("fast");
        $("#content_formO").fadeIn("fast");

		$("#formO_ok1").hide();
		$("#formO_ok2").hide();
		$("#formO_nok").hide();
		$("#formaccesoO").hide();
    };

	function enviarFormOfertas(form){
        $.ajax({
            type: "POST",
            url: "account-ofertas.php",
            data: form.serialize(),
            dataType: "json",
            error: function (xhr, status, error) {
            },
            success: function (response) {
				$("#content_formO h1").html(response.titulo);
                if (response.result=="ok1") {
					$("#formO_nok").hide();
					$("#formaccesoO").hide();
					$("#formO_ok1").show();
                }else if (response.result=="ok2") {
					$("#formO_nok").hide();
					$("#formaccesoO").hide();
					$("#formO_ok2").show();
                }else if (response.result=="nok1") {
					$("#formaccesoO").show();
                }else{
					$("#formO_nok").html(response.texto);
					$("#formO_nok").show();
                }
            }
        });
	}

    $("#carsdays_form_boton").click(function () {
		var form = $("form[name='carsdays_form']");

		form_ofertas_show();

		enviarFormOfertas(form);

        return false;
    });

    $("#ofertas_userr_submit").click(function () {
		var form = $("form[name='formOfertasUserR']");
		
		document.formOfertasUserR.email.value = document.carsdays_form.email.value;
      
		enviarFormOfertas(form);

        return false;
    });
    
	$('#carsdays_form input[name="email"]').focus(function(){
		if($(this).val() === 'Escribe tu email'){
			$(this).val('');
		}
	}).blur(function(){
		if($(this).val() === ''){
			$(this).val('Escribe tu email');
		}
	});

	$('#carsdays_form ').submit(function(){
		$("#carsdays_form_boton").click();
		return false;
	})

	/*Comprabar si el código del grupo es correcto*/
	$("#code_register").click(function(){
    	if($('#code_register').hasClass('checked')){	
    		$('#codigo_colectivo').val("");
    		$("#codigo_colectivo").removeClass("codigo_ok");
			$("#codigo_colectivo").removeClass("codigo_ko");
			$("#show_notification_code").css('display','none');
			$("#show_notification_code").removeClass("show_succesfull");
			$("#show_notification_code").css('display','none');
			$("#show_notification_code").removeClass("show_error");
    		$('#div_codigo_descuento').css("display","none");
    	}else{
    		$('#div_codigo_descuento').css("display","block");
    		
    	}	
    });

    $("#codigo_colectivo").focusout(function() {
		$("#codigo_colectivo").removeClass("codigo_ok");
		$("#codigo_colectivo").addClass("codigo_ko");
		$("#show_notification_code").css('display','block');
		$("#show_notification_code").html('Código colectivo vacío');
		$("#show_notification_code").removeClass("show_succesfull");
		$("#show_notification_code").addClass("show_error");
    	if($('#codigo_colectivo').val() != ""){	
	    	$.ajax({
	            type: "POST",
	            url: "checkCodigoColectivo.php?codigo="+$('#codigo_colectivo').val(),
	            error: function (xhr, status, error) {
	            },
	            success: function (response) {
					if (response=="ok"){
						$("#codigo_colectivo").removeClass("codigo_ko");
						$("#codigo_colectivo").addClass("codigo_ok");
						$("#show_notification_code").css('display','block');
						$("#show_notification_code").html('Código colectivo correcto');
						$("#show_notification_code").removeClass("show_error");
						$("#show_notification_code").addClass("show_succesfull");
					}
	            }
	        });
    	}
    });

});

function form_access_show() {
  toggle_flashes();
  $("#content_form").css("left", ($(window).width() - $("#content_form").outerWidth()) / 2);
  $("#content_form").css("top", ($(window).height() - $("#content_form").outerHeight()) / 2);
  $("#overlay").fadeIn("fast");
  $("#content_form").fadeIn("fast", function () { $("#usuariomail").focus(); });
  reset_formAccess();
};

function reset_formAccess() {
  $('#loginflotanteusername').val('');
  $('#loginflotantepassword').val('');
  $('#loginGeneral').html('');
  $("#loginflotanteusername").removeClass('input-validation-error');
  $("#loginflotantepassword").removeClass('input-validation-error');
}

function toggle_flashes() {
  var obj = $("object[type='application/x-shockwave-flash']");
  if (obj.length > 0) {
	  for (var i = 0; i < obj.length; i++) {
		  if ($(obj[i]).css("visibility") == "visible") { $(obj[i]).css("visibility", "hidden"); } else { $(obj[i]).css("visibility", "visible"); }
	  }
  }
}
