
/*  **************************************************************
*  Note:  This script is shared across multiple external domains.  
*  Be sure to test across all of them if you make modifications. 
******************************************************************  */

function ContactFader () {
	if ($('#FM_Employee_1').is(':checked')) {
		$('#FM_Contact_Name').parent().parent().fadeIn('fast').end().addClass('required');
		$('#fmemployee').hide();
	}
	else {
		$('#FM_Contact_Name').removeClass('required').parent().parent().fadeOut('fast');
		$('#fmemployee').show(); 
	} 
};

function MediaFader () {
	if ($('#Print_Web_Info_0').is(':checked')) {
		$('h2:contains("Print Usage")').hide();
 		$('#File_Format').parent().fadeOut('fast');
		$('#Print_Option').removeClass('required').parent().fadeOut('fast');
		$('h2:contains("Web Usage")').fadeIn('fast');
 		$('#Web_URL').parent().fadeIn('fast');
 		$('#Background_Color_Info').parent().fadeIn('fast');
 		$('#Web_Logo_Width').parent().fadeIn('fast').end().addClass('required');
	}
	else if ($('#Print_Web_Info_1').is(':checked')) {
		$('h2:contains("Web Usage")').hide();
 		$('#Web_URL').parent().fadeOut('fast');
 		$('#Background_Color_Info').parent().fadeOut('fast');
		$('h2:contains("Print Usage")').fadeIn('fast');
 		$('#File_Format').parent().fadeIn('fast');
 		$('#Print_Option').parent().fadeIn('fast').end().addClass('required');
 		$('#Web_Logo_Width').removeClass('required').parent().fadeOut('fast');
	}
	else if ($('#Print_Web_Info_2').is(':checked')) { 
 		$('h2:contains("Print Usage")').fadeIn('fast');
 		$('#File_Format').parent().fadeIn('fast');
 		$('#Print_Option').parent().fadeIn('fast').end().addClass('required');
 		$('h2:contains("Web Usage")').fadeIn('fast');
 		$('#Web_URL').parent().fadeIn('fast');
 		$('#Background_Color_Info').parent().fadeIn('fast');
 		$('#Web_Logo_Width').parent().fadeIn('fast').end().addClass('required');
	}	  
};

function AltContactFader () {
	if ($('#Optional_Email_0').is(':checked')) {
		$('#Optional_Email_Address').removeClass('required').parent().fadeOut('fast');
	} else {
		$('#Optional_Email_Address').parent().fadeIn('fast').end().addClass('required');
	}
};

$().ready(function() {
	if(FM.form.domain == 'http://www.freddiemacfoundation.org') {
		$('#logo_0').val('Foundation logo');
		$('#Logo_Option').parent().hide();
	}
	$('input[name="FM_Employee"]').change(function() { ContactFader(); });
	$('input[name="FM_Employee"]').click( function() { ContactFader(); });
	$('input[name="Print_Web_Info"]').change( function() { MediaFader(); });
	$('input[name="Print_Web_Info"]').click( function()  { MediaFader(); });
	$('input[name="Use_Primary_Email"]').change( function()  { AltContactFader(); });
	$('input[name="Use_Primary_Email"]').click( function()  { AltContactFader(); });
	ContactFader();
	AltContactFader();
	MediaFader();
	$("form#TermsLogoReq").validate({submitHandler:function(fm) { $(":submit").attr("disabled", "disabled"); fm.submit(); }});
});
