$(document).ready(function(){
    // font size
    fontResizer('12px','14px','16px');

    // search box
    $("#searchBox").focus(function(){
        if($(this).val() == 'I\'m looking for...') $(this).val('');
    }).blur(function(){
        if($(this).val() == "") $(this).val('I\'m looking for...');
    })

    // forms
    $(".short").focus(function(){
        if($(this).val() == 'Area Code') $(this).val('');
    }).blur(function(){
        if($(this).val() == "") $(this).val('Area Code');
    })

    // forms
    $(".dd").focus(function(){
        if($(this).val() == 'DD') $(this).val('');
    }).blur(function(){
        if($(this).val() == "") $(this).val('DD');
    })
    // forms
    $(".mm").focus(function(){
        if($(this).val() == 'MM') $(this).val('');
    }).blur(function(){
        if($(this).val() == "") $(this).val('MM');
    })
    // forms
    $(".yyyy").focus(function(){
        if($(this).val() == 'YYYY') $(this).val('');
    }).blur(function(){
        if($(this).val() == "") $(this).val('YYYY');
    })
    
    //style checkbox
    // check for what is/isn't already checked and match it on the fake ones
    $("input:checkbox").each( function() {
        (this.checked) ? $("#fake"+this.id).addClass('fakechecked') : $("#fake"+this.id).removeClass('fakechecked');
    });
    // function to 'check' the fake ones and their matching checkboxes
    $(".fakecheck").click(function(){
		if($(this).hasClass('fakechecked')){
			
			if($(this).attr('id') == 'taxpayerfake'){
				$('#taxpayer').attr('value','No');
			}else{
				$('#on_mailing_list').attr('value','No');
			}
			
			$(this).removeClass('fakechecked');
		}else{
			
			if($(this).attr('id') == 'taxpayerfake'){
				$('#taxpayer').attr('value','Yes');
			}else{
				$('#on_mailing_list').attr('value','Yes');
			}
			
			$(this).addClass('fakechecked');
		}
		
        $(this.hash).trigger("click");
        return false;
    });
    
    // social bookmarks share button
    $("#share").click(function(){
        $("#share-detail").toggleClass("sd");
    })
    // print page
    $("#print").click(function(){
        window.print();return false;
    })
    // send this page
    $("#etp").fancybox({
    'hideOnContentClick': false
    });
	$('.email').fancybox({
		'hideOnContentClick': false
	})
    
    
    // accordion
    $('.accordion .accontent').hide();
    $('.accordion:first .accontent').show();
    $('.accordion:first').addClass('active');
    $('.accordion h2').click(function(){
        // active toggle
        if ($(this).parent().hasClass('active')) {
            $(this).parent().removeClass('active');
        } else {
            // check others for active and close
            $('.accordion.active .accontent').slideUp('slow');
            $('.accordion.active').removeClass('active');
            $(this).parent().addClass('active');
        }

        $(this).parent().find('.accontent').slideToggle('slow');
    })
    
    $("a.group").fancybox({
        'hideOnContentClick': false
    });

var family=new Array('refinf','sibsup','rav');
var professional=new Array('refinf','sibsup','wp','rav');
var fundraiser=new Array('iie','jac','rasaav','play','racb');
var other=new Array();

$("#form_type").change(function(){
	$('#boxes').children().hide();
	if (this.value != '') {
		var arr = eval(this.value);
		for (var i=0;i<arr.length;i++) {
			$('#form_'+arr[i]).parent().show();
		}
		$('#boxes .hr2').show();
		$('#form_message').parent().show();
	}
});



$("#form_type").change();
  
	$(".errorjs").hide();
	
	// external Links
    $("a[rel='external']").click(function(){
        window.open($(this).attr("href"));
        return false;
    });
	
	//events filter
	$("#submit_filter_events").click(function(){
		var category_options = $("#category_options").val();
		var location_options = $("#location_options").val();
		
		var category_string = "."+category_options;
		var location_string = "."+location_options;
		
		if(category_options == 0 && location_options == 0){
			$(".reset_de").show();
			$(".errorjs").hide();
		}else if (category_options == 0) {
			$(".reset_de").hide();
			$(".errorjs").hide();
			if($(location_string).size() == 0){
				$(".errorjs").show();
			}else{
				$(location_string).show();
			}
		}else if (location_options == 0){
			$(".reset_de").hide();
			$(".errorjs").hide();
			if ($(category_string).size() == 0) {
				$(".errorjs").show();
			}else {
				$(category_string).show();
			}
		}else {
			$(".reset_de").hide();
			$(".errorjs").hide();
			if ($(category_string + location_string).size() == 0) {
				$(".errorjs").show();
			}else {
				$(category_string + location_string).show();
			}
		}
	})
	
});