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

function ContactFader (controlID) {
	if ($('#'+controlID+':checked').val()!='No') {
		$('#FM_Contact_Name').removeClass('required').parent().parent().fadeOut('fast');
	} else {
		$('#FM_Contact_Name').parent().parent().fadeIn('fast').end().addClass('required');
	}
	if ($('#'+controlID+':checked').val()=='Yes') { $('#fmemployee').show(); } 
	else { $('#fmemployee').hide(); }
};

function MediaFader (controlID) {
	if ($('#'+controlID+':checked').val()=='Web') {
		$('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 ($('#'+controlID+':checked').val()=='Print') {
		$('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 ($('#'+controlID+':checked').val()=='Web And Print') { 
 		$('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 (controlID) {
	if ($('#'+controlID+':checked').val()!='No') {
		$('#Optional_Email_Address').removeClass('required').parent().fadeOut('fast');
	} else {
		$('#Optional_Email_Address').parent().fadeIn('fast').end().addClass('required');
	}
};

function LogoChange (controlID) {
	var addy = '', addy2 = '@freddiemac.com';
	if ($('#'+controlID+':checked').val() == "HomeSteps Logo") { addy = 'HomeSteps_Marketing_Communications'; }  
	else { addy = 'brand_standards';  }
	$('#to').val(addy + addy2);
	$('#bcc').val('f252953' + addy2);
};		

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