$(document).ready( function() {
	
//count check boxes
	$(".classname").find(":checkbox").click(function () {
		var max = 4;
		var checked = $("input:checked").length;
		if( checked > max ){		
			$(this).attr('checked', false);	
			$(".message1").text("You are only allowed 4 choices.");
		}
	});
		
//define custom select boxes
try {
	$(".custSelect").selectbox({
		width: 160
	});
} catch(e) {}
	
//fix for target blank	
	$("a.external").attr({ target: "_blank" });	
	$("#popUp a").attr({ target: "_blank" });	
	
		
//simulate login popup
	popUp();

	
	//alert($("#header").height());
	$(".additionalOptions").hide("");
	$(".additional").click(function(){
		if($(this).is(":checked")){
			$(".additionalOptions").slideDown("slow");	
		}else{
			$(".additionalOptions").slideUp("slow");	
		}	
	});
});

//popup image viewer
function popupViewer() {
		
	$(".image").hide("");
	$(".image:first").show("");
	$(".thumb:first").addClass("active");

	$(".image").attr("id", function (number) {
          return "image" + number;
    });
	    
    $(".thumb").attr("id", function (number) {
          return "thumb" + number;
    });

	$(".thumb").click(function(event){							
		var id = this.id.replace("thumb" , 'image');	
		if($(this).hasClass("active")){
		//do nothing	
		}else{	
		$(".image").fadeOut("slow");
		$("#" + id).fadeIn("slow");		
		$(".thumb").removeClass("active");
		$(this).addClass("active");	
		}
	});
	
}

//loginPopup
function popUp () {
	
	$(".blackOut, .login").hide("");
	$(".blackOut, .login").fadeIn("fast");
	
}




function checkDirectorySearchOptions() {
	
	var input = document.getElementById('catoption');
	var selectedIndex = input.selectedIndex;	
	
	if(input[selectedIndex].value < 1) {	
		alert('Please select: By Category');
		return false;
	} 
	
	var input = document.getElementById('countyoption');
	var selectedIndex = input.selectedIndex;	
	
	if(input[selectedIndex].value < 1){
		alert('Please select: By County');
		return false;
	}
		
	return true;
}