$(document).ready(function(){
    changeForm("linkedin","");
    $("#af_signup_reference_linkedin .element input").val("Yes");

    $("#linked_in").click(function(){
        changeForm("linkedin","<span>When you have responded to our email to activate your email address, we will provide the link to the Mars & Wrigley/Martians Reunited group on LinkedIn. If you are not already a member, please join this so that we can view your profile and confirm you are a former associate of Mars, Inc.</span>");
        $("#af_signup_reference_linkedin .element input").val("Yes");
    });
    $("#mars_assoc").click(function(){
        $("#af_signup_reference_linkedin .element input").val("");
        changeForm("mars_accos","<span>Please provide the name, site and email address (if you have it) of a current associate of Mars, Inc in the box below.</span>");
    });
    $("#mars_reun").click(function(){
        $("#af_signup_reference_linkedin .element input").val("");
        changeForm("mars_reun","<span>If you are certain that your referee is already a member of Martians Reunited, please provide their name and email address (if you know it) in the box below.</span>");
    });
    $("#mars_other").click(function(){
        $("#af_signup_reference_linkedin .element textarea").val("");
        changeForm("other","<span>Please provide a brief description about your time at Mars, including the sites where you worked and the names of any senior managers, line managers or P&O managers you remember in the box below.</span>");
    });
    $("#val_signup_reference").change(function() {

        var value = $("#val_signup_reference").val();
        $(".e_reference_info span").html(value.length);
    });
    $("#af_signup_reference_linkedin .element").css("display","none");
/*
	$('#menu').hoverAccordion({
		keepheight: 'false'
	});*/
});
function hideall(){
    $("#af_signup_reference_linkedin .element input").val("");
    $("#af_signup_reference_mars_accos .element input").val("");
    $("#af_signup_reference_mars_reun .element input").val("");
    $("#af_signup_reference_other .element textarea").val("");
    $("#af_signup_reference_linkedin").fadeOut(500);
    $("#af_signup_reference_mars_accos").fadeOut(500);
    $("#af_signup_reference_mars_reun").fadeOut(500);
    $("#af_signup_reference_other").fadeOut(500);
}
function changeForm(method, text){
    hideall();
    $(".e_reference_info").fadeOut(500);
    setTimeout(function(){
        $(".e_reference_info span").html(text);
        $("#af_signup_reference_"+method).fadeIn("slow");
    }, 500);
    $(".e_reference_info").fadeIn("slow");
}



