$(document).ready(function() {
    $("div.account_link").click( function() 
	{
        if ($("#menu_account").css('margin-top') != '0px') {
			if ( jQuery.browser.msie && (jQuery.browser.version < 7) && document.getElementById("menu_account").className == "down")
			{
				document.getElementById("menu_account").className = "";
			}
            $("#menu_account").animate({ marginTop: "0px" }, 500 );
			if ( jQuery.browser.msie && (jQuery.browser.version < 7) ) document.getElementById("ie6_account_link").className = "orange";
			else $(".account_button").removeClass('blue').addClass('orange');
            $("#openCloseIdentifier").show();
        } else {
            $("#menu_account").animate({ marginTop: "186px" }, 500 );
			if ( jQuery.browser.msie && (jQuery.browser.version < 7) ) document.getElementById("ie6_account_link").className = "blue";
			else $(".account_button").removeClass('orange').addClass('blue');
            $("#openCloseIdentifier").hide();
			$("#user_name").focus();
        }
    });
	
	$(".nonactive").click( function() 
	{
        $("#bedrijf_tooltip").fadeIn(100);
		setTimeout(function(){$("#bedrijf_tooltip").fadeOut(1000);},3000);
		return false;
    });
	
	$(".nonactive_vacature").click( function() 
	{
        $("#bedrijf_tooltip_vacature").fadeIn(100);
		setTimeout(function(){$("#bedrijf_tooltip_vacature").fadeOut(1000);},3000);
		return false;
    });
	
	$("#agenda_top").click( function() 
	{
        document.location='/home/nieuws_en_agenda/';
    });
	
	if ($("#user_name").is(".error") || $("#password").is(".error"))
	{
		$("#menu_account").css({ marginTop: "186px" }, 500 );
		$(".account_button").removeClass('orange').addClass('blue');
		$("#openCloseIdentifier").hide();
	}
	
	if ( jQuery.browser.msie && (jQuery.browser.version < 7) && document.getElementById("user_name") != null)
		{
			if (document.getElementById("user_name").className == "text error" || document.getElementById("password").className == "text error")
			{
				document.getElementById("menu_account").className = "down";
				document.getElementById("ie6_account_link").className = "blue";
				$("#openCloseIdentifier").hide();
			}
		}
	
	$(".contact").click( function() 
	{
		$("#overlay").fadeTo(0, 0.70, function(){ $("#overlay").fadeIn(500); $("#contact_form").fadeIn(500); $("#name_email").focus();});
		return false;
	});
	
	$(".form_close_button").click( function() 
	{
		$("#overlay").hide();
		$("#contact_form").hide();
		$("#contact_succes_msg").hide();
		document.forms['contact_form_form'].reset();
		$("#contact_form_form").show();
		return false;
	});
	
	$("#contact_form_form").submit(function()
	{
		$("#contact_form_form").hide();
		$("#contact_loading").show();
		var action = $(this).attr("action");
		$.ajax({
			type: "post",
			url:action,
			resetForm: true,
			data:{ 
				name_email: $("#name_email").val(),
				email_email: $("#email_email").val(),
				subject_email: $("#subject_email").val(),
				text_email: $("#text_email").val()
			},
			dataType:"html",
			success:function(data)
			{
				$("#contact_loading").hide();
				$("#contact_succes_msg").show();
				
			},
			error:function(xhr,err,e)
			{ 
				$("#contact_loading").hide();
				$("#contact_succes_msg").show().html("Het verzenden is niet gelukt...");
			}
	    });
		 return false;
		});
	
});
