

$(document).ready(function(){
	
	//error notification go to link
	$('.errorTopNotification a').click(function () {
		//scroll to the first error
		var firstErrorPos = $(".formRow.missingRequiredField").eq(0).offset().top;
		$("html, body").animate({scrollTop: (firstErrorPos - 40)});
		return false;
	});

	if (!$("#donationIsTribute").attr('checked')) {
		$(".tribute").hide();
	}
	
	$("#donationIsTribute").click(function(){		  	
        if ($("#donationIsTribute").attr('checked')) {
			$(".tribute").show();			
        } else {
			$(".tribute").hide();
		}
   	});
	
	
	if (!$("#donationHasCard").attr('checked')) {
		$(".card").hide();
	}
	
	$("#donationHasCard").click(function(){		  	
        if ($("#donationHasCard").attr('checked')) {
			$(".card").show();			
        } else {
			$(".card").hide();
		}
   	});


        if ($("#donationDonorTypeID1").attr('checked')) {			
			$(".giftBusinessName").hide();
			$(".giftOrganizationFoundation").hide();
        }
     if ($("#donationDonorTypeID2").attr('checked')) {			
			$(".giftBusinessName").show();
			$(".giftOrganizationFoundation").hide();
        }
		    if ($("#donationDonorTypeID3").attr('checked')) {			
			$(".giftBusinessName").hide();
			$(".giftOrganizationFoundation").show();
        }

	//this gift is from
	 	$("#donationDonorTypeID1").click(function(){		  	
        if ($("#donationDonorTypeID1").attr('checked')) {			
			$(".giftBusinessName").hide();
			$(".giftOrganizationFoundation").hide();
        }
   		 });

	 	$("#donationDonorTypeID2").click(function(){		  	
        if ($("#donationDonorTypeID2").attr('checked')) {			
			$(".giftBusinessName").show();
			$(".giftOrganizationFoundation").hide();
        }
   		 });
	
		$("#donationDonorTypeID3").click(function(){		  	
        if ($("#donationDonorTypeID3").attr('checked')) {			
			$(".giftBusinessName").hide();
			$(".giftOrganizationFoundation").show();
        }
   		 });
	
	
		
	     if ($("#honorCountry").val() == "US") {			
			$(".honorCountryUS").show();
			$(".honorCountryCA").hide();
			$(".honorCountryOther").hide();
			$(".honorPostalCode").hide();
			$(".honorPhoneUS").show();
			$(".honorPhoneOther").hide();
        } else if ($("#honorCountry").val() == "CA") {			
			$(".honorCountryUS").hide();
			$(".honorCountryCA").show();
			$(".honorCountryOther").hide();
			$(".honorPostalCode").show();
			$(".honorPhoneUS").show();
			$(".honorPhoneOther").hide();
        } else {
			$(".honorCountryUS").hide();
			$(".honorCountryCA").hide();
			$(".honorCountryOther").show();
			$(".honorPostalCode").show();
			$(".honorPhoneUS").hide();
			$(".honorPhoneOther").show();
            }


 	$("#cardCountry").change(function(){		  	
        if ($("#cardCountry").val() == "US") {			
			$(".cardCountryUS").show();
			$(".cardCountryCA").hide();
			$(".cardCountryOther").hide();
			$(".cardPostalCode").hide();
			$(".cardPhoneUS").show();
			$(".cardPhoneOther").hide();
        } else if ($("#cardCountry").val() == "CA") {			
			$(".cardCountryUS").hide();
			$(".cardCountryCA").show();
			$(".cardCountryOther").hide();
			$(".cardPostalCode").show();
			$(".cardPhoneUS").show();
			$(".cardPhoneOther").hide();
        } else {
			$(".cardCountryUS").hide();
			$(".cardCountryCA").hide();
			$(".cardCountryOther").show();
			$(".cardPostalCode").show();
			$(".cardPhoneUS").hide();
			$(".cardPhoneOther").show();
            }
    });

	
	
	
	     if ($("#cardCountry").val() == "US") {			
			$(".cardCountryUS").show();
			$(".cardCountryCA").hide();
			$(".cardCountryOther").hide();
			$(".cardPostalCode").hide();
			$(".cardPhoneUS").show();
			$(".cardPhoneOther").hide();
        } else if ($("#cardCountry").val() == "CA") {			
			$(".cardCountryUS").hide();
			$(".cardCountryCA").show();
			$(".cardCountryOther").hide();
			$(".cardPostalCode").show();
			$(".cardPhoneUS").show();
			$(".cardPhoneOther").hide();
        } else {
			$(".cardCountryUS").hide();
			$(".cardCountryCA").hide();
			$(".cardCountryOther").show();
			$(".cardPostalCode").show();
			$(".cardPhoneUS").hide();
			$(".cardPhoneOther").show();
            }


 	$("#cardCountry").change(function(){		  	
        if ($("#cardCountry").val() == "US") {			
			$(".cardCountryUS").show();
			$(".cardCountryCA").hide();
			$(".cardCountryOther").hide();
			$(".cardPostalCode").hide();
			$(".cardPhoneUS").show();
			$(".cardPhoneOther").hide();
        } else if ($("#cardCountry").val() == "CA") {			
			$(".cardCountryUS").hide();
			$(".cardCountryCA").show();
			$(".cardCountryOther").hide();
			$(".cardPostalCode").show();
			$(".cardPhoneUS").show();
			$(".cardPhoneOther").hide();
        } else {
			$(".cardCountryUS").hide();
			$(".cardCountryCA").hide();
			$(".cardCountryOther").show();
			$(".cardPostalCode").show();
			$(".cardPhoneUS").hide();
			$(".cardPhoneOther").show();
            }
    });

	
	
		//User registration

     if ($("#profileCountry").val() == "US") {			
			$(".profileCountryUS").show();
			$(".profileCountryCA").hide();
			$(".profileCountryOther").hide();
			$(".profilePostalCode").hide();
			$(".profilePhoneUS").show();
			$(".profilePhoneOther").hide();
        } else if ($("#profileCountry").val() == "CA") {			
			$(".profileCountryUS").hide();
			$(".profileCountryCA").show();
			$(".profileCountryOther").hide();
			$(".profilePostalCode").show();
			$(".profilePhoneUS").show();
			$(".profilePhoneOther").hide();
        } else {
			$(".profileCountryUS").hide();
			$(".profileCountryCA").hide();
			$(".profileCountryOther").show();
			$(".profilePostalCode").show();
			$(".profilePhoneUS").hide();
			$(".profilePhoneOther").show();
            }


 	$("#profileCountry").change(function(){		  	
        if ($("#profileCountry").val() == "US") {			
			$(".profileCountryUS").show();
			$(".profileCountryCA").hide();
			$(".profileCountryOther").hide();
			$(".profilePostalCode").hide();
			$(".profilePhoneUS").show();
			$(".profilePhoneOther").hide();
        } else if ($("#profileCountry").val() == "CA") {			
			$(".profileCountryUS").hide();
			$(".profileCountryCA").show();
			$(".profileCountryOther").hide();
			$(".profilePostalCode").show();
			$(".profilePhoneUS").show();
			$(".profilePhoneOther").hide();
        } else {
			$(".profileCountryUS").hide();
			$(".profileCountryCA").hide();
			$(".profileCountryOther").show();
			$(".profilePostalCode").show();
			$(".profilePhoneUS").hide();
			$(".profilePhoneOther").show();
            }
    });
	
	//country show/ hide
	var country = $("select#country").val();
	
	if (country == 'US') {
		$("#countryUS").show();
		$("#countryCA").hide();
		$("#countryOther").hide();
	} else if (country == 'CA') {
		$("#countryUS").hide();
		$("#countryCA").show();
		$("#countryOther").hide();
	} else {
		$("#countryUS").hide();
		$("#countryCA").hide();
		$("#countryOther").show();
	}
	
	$("select#country").change(function(){
		country = $("select#country").val();
		
		if (country == 'US') {
			$("#countryUS").show();
			$("#countryCA").hide();
			$("#countryOther").hide();
		} else if (country == 'CA') {
			$("#countryUS").hide();
			$("#countryCA").show();
			$("#countryOther").hide();
		} else {
			$("#countryUS").hide();
			$("#countryCA").hide();
			$("#countryOther").show();
		}
	});
	
	//team country show/ hide
	var teamCountry = $("select#teamCountry").val();
	
	if (teamCountry == 'US') {
		$("#teamCountryUS").show();
		$("#teamCountryCA").hide();
		$("#teamCountryOther").hide();
	} else if (teamCountry == 'CA') {
		$("#teamCountryUS").hide();
		$("#teamCountryCA").show();
		$("#teamCountryOther").hide();
	} else {
		$("#teamCountryUS").hide();
		$("#teamCountryCA").hide();
		$("#teamCountryOther").show();
	}
	
	$("select#teamCountry").change(function(){
		teamCountry = $("select#teamCountry").val();
		
		if (teamCountry == 'US') {
			$("#teamCountryUS").show();
			$("#teamCountryCA").hide();
			$("#teamCountryOther").hide();
		} else if (teamCountry == 'CA') {
			$("#teamCountryUS").hide();
			$("#teamCountryCA").show();
			$("#teamCountryOther").hide();
		} else {
			$("#teamCountryUS").hide();
			$("#teamCountryCA").hide();
			$("#teamCountryOther").show();
		}
	});
	
		//kid country show/ hide
	var kidCountry = $("select#kidCountry").val();
	
	if (kidCountry == 'US') {
		$("#kidCountryUS").show();
		$("#kidCountryCA").hide();
		$("#kidCountryOther").hide();
	} else if (kidCountry == 'CA') {
		$("#kidCountryUS").hide();
		$("#kidCountryCA").show();
		$("#kidCountryOther").hide();
	} else {
		$("#kidCountryUS").hide();
		$("#kidCountryCA").hide();
		$("#kidCountryOther").show();
	}
	
	$("select#kidCountry").change(function(){
		kidCountry = $("select#kidCountry").val();
		
		if (kidCountry == 'US') {
			$("#kidCountryUS").show();
			$("#kidCountryCA").hide();
			$("#kidCountryOther").hide();
		} else if (kidCountry == 'CA') {
			$("#kidCountryUS").hide();
			$("#kidCountryCA").show();
			$("#kidCountryOther").hide();
		} else {
			$("#kidCountryUS").hide();
			$("#kidCountryCA").hide();
			$("#kidCountryOther").show();
		}
	});
	
	if($("#profileAddressTypeIDBusiness").attr('checked')) {
		$(".profileAddressTypeBusiness").show();
	} else if($("#profileAddressTypeIDHome").attr('checked')) {
		$(".profileAddressTypeBusiness").hide();
	}

	
	$("#profileTypeID").click(function() {
		if ($(this).val() != 1) {
			$(".profileAddressTypeBusiness").show();
			$("#profileAddressTypeIDBusiness").attr('checked', 'checked');
			$("#fullNameLabel").text('*Contact Person: ');
			$('#profileBusinessNameLabel').text('*Business Name: ');
		} else {
			$(".profileAddressTypeBusiness").hide();
			$("#profileAddressTypeIDHome").attr('checked', 'checked');
			$("#fullNameLabel").text('*Your Name: ');
			$('#profileBusinessNameLabel').text('Business Name: ');
		}
    });
	
	$("#profileAddressTypeIDHome").click(function(){
		if($("#profileAddressTypeIDHome").attr('checked')) {
			$(".profileAddressTypeBusiness").hide();
		}
    });
	
	//additional info
	$(".profileMinorAgeRange").hide();
	if($("#profileLegalStatusID2").attr('checked')) {
		$(".profileMinorAgeRange").show();
	}

	//profileLegalStatusID1
		$("#profileLegalStatusID1").click(function(){
		if($("#profileLegalStatusID1").attr('checked')) {
			$(".profileMinorAgeRange").hide();
		}
  
    });
	
	$("#profileLegalStatusID2").click(function(){
		if($("#profileLegalStatusID2").attr('checked')) {
			$(".profileMinorAgeRange").show();
		}
    });
	
	//Occupational info
	$(".profileOccupationStudent").hide();
	$(".profileOccupationEducator").hide();
	$(".profileOccupationMilitary").hide();
	$(".profileOccupationOther").hide();
	if($("#profileOccupationID").val() == "1") {			
		$(".profileOccupationStudent").show();
	}
	if($("#profileOccupationID").val() == "2") {
		$(".profileOccupationEducator").show();
	}
	if($("#profileOccupationID").val() == "11") {
		$(".profileOccupationMilitary").show();
	}
	if($("#profileOccupationID").val() == "12" || $("#profileOccupationID").val() == "13" || $("#profileOccupationID").val() == "14" || $("#profileOccupationID").val() == "99") {
		$(".profileOccupationOther").show();
	}

	$("#profileOccupationID").change(function() {
		$(".profileOccupationStudent").hide();
		$(".profileOccupationEducator").hide();
		$(".profileOccupationMilitary").hide();
		$(".profileOccupationOther").hide();
		if($("#profileOccupationID").val() == "1") {			
			$(".profileOccupationStudent").show();
		}
		if($("#profileOccupationID").val() == "2") {
			$(".profileOccupationEducator").show();
		}
		if($("#profileOccupationID").val() == "11") {
			$(".profileOccupationMilitary").show();
		}
		if($("#profileOccupationID").val() == "12" || $("#profileOccupationID").val() == "13" || $("#profileOccupationID").val() == "14" || $("#profileOccupationID").val() == "99") {
			$(".profileOccupationOther").show();
		}
    });

	if ($(".howAffected:checked").length == 0) {
		$(".profileHowAffectedDetails").hide();
	}
	if($("#howAffected2").attr('checked')) {
		$(".profileHowAffectedIsFamilyYES").show();
		$(".profileHowAffectedDetails").show();
		
	} else {
		$(".profileHowAffectedIsFamilyYES").hide();
		if ($(".howAffected:checked").length == 0) {
			$(".profileHowAffectedDetails").hide();
		}
	}

	$('.howAffected').click(function() {
		//show/hide family type selectbox if clicking family of child w/ cancer
		if ($(this).attr('id') == 'howAffected2') {
			if ($(this).attr('checked')) {
				$(".profileHowAffectedIsFamilyYES").show();
			} else {
				$(".profileHowAffectedIsFamilyYES").hide();
			}
		}
		//show/hide extras if appropriate
		if ($(this).attr('checked')) {			
			$(".profileHowAffectedDetails").show();						
		} else if ($(".howAffected:checked").length == 0) {
			$(".profileHowAffectedDetails").hide();
		}
	}); 
	
	
	if ($("#whereHear13").attr('checked')) {
		$(".profileWhereHearTradeOrgDetails").show();
	} else {
		$(".profileWhereHearTradeOrgDetails").hide();
	}
	
	
	$("#whereHear13").click(function(){
		if ($("#whereHear13").attr('checked')) {
			$(".profileWhereHearTradeOrgDetails").show();
		} else {
			$(".profileWhereHearTradeOrgDetails").hide();
		}
    });
	
	
	if ($("#whereHear14").attr('checked')) {
		$(".profileWhereHearHospitalDetails").show();
	} else {
		$(".profileWhereHearHospitalDetails").hide();
	}
	
	$("#whereHear14").click(function(){
		if($("#whereHear14").attr('checked')) {
			$(".profileWhereHearHospitalDetails").show();
		} else {
			$(".profileWhereHearHospitalDetails").hide();
		}
    });
	
	
	if ($("#whereHear16").attr('checked')) {
		$(".profileWhereHearOtherDetails").show();
	} else {
		$(".profileWhereHearOtherDetails").hide();
	}

	
	$("#whereHear16").click(function(){
		if ($("#whereHear16").attr('checked')) {
			$(".profileWhereHearOtherDetails").show();
		} else {
			$(".profileWhereHearOtherDetails").hide();
		}
    });

	//hide other cancer type box on load
	$('#otherCancerTypeContainer').hide();
	
	$('#profileHowAffectedCancerTypeID').change(function() {
		if ($(this).val() == '99') {
			$('#otherCancerTypeContainer').show();
		} else {
			$('#otherCancerTypeContainer').hide();
		}
	});
	

// Edit Profile Specific
if ($('#profileTypeID:hidden').length > 0) {
	if ($('#profileTypeID:hidden').val() != 1) {
		$(".profileAddressTypeBusiness").show();
	} else {
		$(".profileAddressTypeBusiness").hide();
	}
}
	
//Participant Registration	
    if ($("#eventCountry").val() == "US") {			
		$(".caEventSearch").hide();
		$(".usEventSearch").show();
		$(".intEventSearch").hide();
		$(".postalCode").hide();
		$(".zipCode").show();
    } else if ($("#eventCountry").val() == "CA") {			
		$(".caEventSearch").show();
	    $(".usEventSearch").hide();
		$(".intEventSearch").hide();
		$(".postalCode").show();
		$(".zipCode").hide();
    }
   else {
		$(".caEventSearch").hide();
		$(".usEventSearch").hide();
		$(".intEventSearch").show();
		$(".postalCode").show();
		$(".zipCode").hide();
        }


  $("#eventCountry").change(function(){	  	
    if ($("#eventCountry").val() == "US") {			
		$(".caEventSearch").hide();
		$(".usEventSearch").show();
		$(".intEventSearch").hide();
		$(".postalCode").hide();
		$(".zipCode").show();
    } else if ($("#eventCountry").val() == "CA") {			
		$(".caEventSearch").show();
	    $(".usEventSearch").hide();
		$(".intEventSearch").hide();
		$(".postalCode").show();
		$(".zipCode").hide();
    }
   else {
		$(".caEventSearch").hide();
		$(".usEventSearch").hide();
		$(".intEventSearch").show();
		$(".postalCode").show();
		$(".zipCode").hide();
        }
});

if ($("#ckbBarber").attr('checked') == true) {
    $(".barber").show();
}
else {
    $(".barber").hide();
}

$("#ckbBarber").click(function(){
    if ($("#ckbBarber").attr('checked') == true) {
      $(".barber").show();
    }
    else {
      $(".barber").hide();
    }
});
    

//kid stuff
if ($('#applicantTypeID').length > 0) {
	
	//Setup kid hide/show for event registration
   if ($("#kidCountry").val() == "US") {
        $(".usState").show();
        $(".internationalAddress").hide();
        $(".caProvince").hide();
        $(".caState").hide();
        $(".nonUSCode").hide();
    }
    else {
        if ($("#kidCountry").val() == "CA") {
            $(".usState").hide();
            $(".internationalAddress").hide();
            $(".caProvince").show();
            $(".caState").show();
            $(".nonUSCode").show();
        }
        else {
            $(".usState").hide();
            $(".internationalAddress").show();
            $(".caProvince").hide();
            $(".nonUSCode").show();
            $(".caState").hide();
        }
	}
	
	$("#kidCountry").change(function(){
	    	
        if ($("#kidCountry").val() == "US") {
            $(".usState").show();
            $(".internationalAddress").hide();
            $(".caProvince").hide();
            $(".caState").hide();
            $(".nonUSCode").hide();
        }
        else {
            if ($("#kidCountry").val() == "CA") {
                $(".usState").hide();
                $(".internationalAddress").hide();
                $(".caProvince").show();
                $(".caState").show();
                $(".nonUSCode").show();
            }
            else {
                $(".usState").hide();
                $(".internationalAddress").show();
                $(".caProvince").hide();
                $(".nonUSCode").show();
                $(".caState").hide();
            }
		}
	});
	
	if ($('#birthday').length > 0) {
		$("#birthday").datepicker({
			showOn: "focus", 
			buttonText: '',
		    hideIfNoPrevNext: true,
		    yearRange: '1960:2012',
		    showOtherMonths: false,
		    minDate: new Date(1960, 1 - 1, 1),
			maxDate: new Date(2012, 1 - 1, 1), 
			dateFormat: 'yy-mm-dd',
		    buttonImageOnly: true,
			changeYear: true 
		});
	}
		
	if ($("#applicantTypeID").val() != "") {
		$(".kidHiddenForm").show();
	} else {
		$(".kidHiddenForm").hide();
	}
		
	//Need Guardian Info			
	if ($("#applicantTypeID").val() == "1") {
		$(".guardianInfo").hide();
		$(".guardianQuestion").hide();				
	}	
		
	if ($("#applicantTypeID").val() > 2) {
		$(".guardianQuestion").show();
		$(".guardianInfo").show();				
	} else {
		if ($("#applicantTypeID").val() == 2) {
			$(".guardianInfo").show();
		}
		$(".guardianQuestion").hide();
	}
	
	$("#applicantTypeID").change(function() {
	   	if ($("#applicantTypeID").val() != "") {
			$(".kidHiddenForm").show();
		}else {
			$(".kidHiddenForm").hide();
		}
			
		//Need Guardian Info			
		if ($("#applicantTypeID").val() == "1") {
			$(".guardianInfo").hide();
			$(".guardianQuestion").hide();				
		}	
			
		if ($("#applicantTypeID").val() > 2) {
			$(".guardianQuestion").show();
			$(".guardianInfo").show();				
		} else {
			if ($("#applicantTypeID").val() == 2) {
				$(".guardianInfo").show();
			}
			$(".guardianQuestion").hide();
		}
			
	});
	
	//kid is legal guardian 
	if($("#isLegalGuardian1:checked")){
		$(".guardianInfo").hide();
	}
		
	$("#isLegalGuardian0").change(function(){
		if ($("#isLegalGuardian0").val() == "0") {
			$(".guardianInfo").show();
		}
	});
	
	$("#isLegalGuardian1").change(function(){
		if ($("#isLegalGuardian1").val() == "1") {
			$(".guardianInfo").hide();
		}
	});


}

	//event stuff
if ($('#eventAppContainer').length > 0) {	
	//yay phone formatting
	if ($("#organizerPrimaryPhone").length > 0) {
		$("#organizerPrimaryPhone").mask("(999) 999-9999");
	}
	
	if ($('ul#organizerPhoneList input:radio:checked').val() == '1') {
		$('#organizerPhoneWaiverContainer ul').show();
	}
	$('ul#organizerPhoneList input:radio').click(function() {
		if ($(this).val() == 1) {
			$(this).effect("transfer", { to: $("#organizerPhoneWaiverContainer") }, 500, function() {
				$('#organizerPhoneWaiverContainer ul').show();
			});
			
		} else {
			$('#organizerPhoneWaiverContainer ul').hide();
			$('#organizerPhoneWaiverContainer input').attr('checked', false);
		}
	});
	
	$("#organizedBeforeMostRecentEventDate").datepicker({ 
	    showOn: "focus", 
		buttonText: '',
	    hideIfNoPrevNext: true,
	    yearRange: '2006:2012',
	    showOtherMonths: false,
	    minDate: new Date(2000, 1 - 1, 1),
		maxDate: new Date(2012, 1 - 1, 1), 
		dateFormat: 'yy-mm-dd',
	    buttonImageOnly: true 
	});
	


	$(".whatCharity").hide();
	
	if ($("#organizedBefore").val() == "1") {
		$(".whatCharity").show();
	}
	
	$("#organizedBefore").change(function(){
		if ($("#organizedBefore").val() == "1") {
			$(".whatCharity").show();
		} else {
			$(".whatCharity").hide();
		}
	});
	
	
	$(".venueTypeIDOther").hide();
	if ($("#venueTypeID").val() == "7") {
		$(".venueTypeIDOther").show();
	}
	
	$("#venueTypeID").change(function(){
		if ($("#venueTypeID").val() == "7") {
			$(".venueTypeIDOther").show();
		} else {
			$(".venueTypeIDOther").hide();
		}
	});
	
	
	//Setup venue hide/show for event registration
   if ($("#venueCountry").val() == "US") {
        $(".usState").show();
        $(".internationalAddress").hide();
        $(".caProvince").hide();
        $(".caState").hide();
        $(".nonUSCode").hide();
    } else {
        if ($("#venueCountry").val() == "CA") {
            $(".usState").hide();
            $(".internationalAddress").hide();
            $(".caProvince").show();
            $(".caState").show();
            $(".nonUSCode").show();
        } else {
            $(".usState").hide();
            $(".internationalAddress").show();
            $(".caProvince").hide();
            $(".nonUSCode").show();
            $(".caState").hide();
        }
	}

	


	$("#venueCountry").change(function(){
	    if ($("#venueCountry").val() == "US") {
	        $(".usState").show();
	        $(".internationalAddress").hide();
	        $(".caProvince").hide();
	        $(".caState").hide();
	        $(".nonUSCode").hide();
	    }
	    else {
	        if ($("#venueCountry").val() == "CA") {
	            $(".usState").hide();
	            $(".internationalAddress").hide();
	            $(".caProvince").show();
	            $(".caState").show();
	            $(".nonUSCode").show();
	        }
	        else {
	            $(".usState").hide();
	            $(".internationalAddress").show();
	            $(".caProvince").hide();
	            $(".nonUSCode").show();
	            $(".caState").hide();
	        }
		}
	});

	if ($("#shippingCountry").length > 0) {
		//Setup shipping hide/show for event registration
		if ($("#shippingCountry").val() == "US") {
			$(".usState").show();
			$(".internationalAddress").hide();
			$(".caProvince").hide();
			$(".caState").hide();
			$(".nonUSCode").hide();
		}
		else {
			if ($("#shippingCountry").val() == "CA") {
				$(".usState").hide();
				$(".internationalAddress").hide();
				$(".caProvince").show();
				$(".caState").show();
				$(".nonUSCode").show();
			}
			else {
				$(".usState").hide();
				$(".internationalAddress").show();
				$(".caProvince").hide();
				$(".nonUSCode").show();
				$(".caState").hide();
			}
		}
		
		$("#shippingCountry").change(function(){
			if ($("#shippingCountry").val() == "US") {
				$(".usState").show();
				$(".internationalAddress").hide();
				$(".caProvince").hide();
				$(".caState").hide();
				$(".nonUSCode").hide();
			}
			else 
				if ($("#shippingCountry").val() == "CA") {
					$(".usState").hide();
					$(".internationalAddress").hide();
					$(".caProvince").show();
					$(".caState").show();
					$(".nonUSCode").show();
				}
				else {
					$(".usState").hide();
					$(".internationalAddress").show();
					$(".caProvince").hide();
					$(".nonUSCode").show();
					$(".caState").hide();
				}
		});
		
		//Event registration Shipping information hide/show
		if ($("#shipDifferentCheckbox").attr('checked') == true) {
		    $(".theShippingAddress").show();
		}
		else {
		    $(".theShippingAddress").hide();
		}
		
		$("#shipDifferentCheckbox").click(function(){
			if ($("#shipDifferentCheckbox").attr('checked') == true) {
				$(".theShippingAddress").show();
			}
			else {
				$(".theShippingAddress").hide();
			}
		});
		
	}
}

	$(".maxlength250").keydown(function(event){
		var key = event.which;
		//all keys including return.
		if(key >= 33 || key == 13) {
			var maxLength = 250; 
			var length = this.value.length;
			if(length >= maxLength) {
				event.preventDefault();
			}
		}
	});

});
