

$(document).ready(function(){

	$("a.comment_more_link").click(function(){
		$(this).hide();
		$(this).next().show();
		return false;
	});
	
	$("a.more_content_view").click(function(){
		$(this).hide();
		$(this).next().show();
		return false;
	});
	
	$('.confirmbox').click(function() {
        var confirmClicked = confirm("Are you sure you want to complete this action?");
        if (!confirmClicked) return false;
        else return true;
    });
    
    //force height to be a min of 400px
    var height = $('#content').height();
    if (height < 800) {
    	$('#content').height(800);
    }
    
    //javascript form validation
    /*$('.check_null_form').click(function() {
    	/*if ($(this).child('.check_null_required').val() == "") {
    		alert('null');
    		return false;
    	}
    	else {
    		alert('hi');
    		return false;
    	}
    	alert('click');
    	return false:
    });*/
    
    $("#chapter_dropdown_link").toggle(function() {
    	$(this).next().slideDown().css("display","block");
    	$(this).css("background-color","#F7F0D7");
    	
    },function() {
    	$(this).next().slideUp();
    	$(this).css("background-color","inherit");
    });
    
    $(".zend_form dd").after("<br style='clear:both'>");
    
    /*image switcher*/
    $("#imageswitcher .smimage").click(function(){
    	var curimage = $("#imageswitcher #lgimage").css("background-image");
    	var bgimage = $(this).css("background-image");
    	$("#imageswitcher #lgimage").css("background-image","url(/images/static/ajax-loader.gif)");
    	$("#imageswitcher #lgimage").css("background-image",bgimage);
    	$(this).css("background-image",curimage);
    });
    
    /*end image switcher*/
	
	if ($.browser.msie) {
		var curpathname = document.location.pathname
		if (curpathname.match("map")) {
			var newhtml = "<div id='regwrapper'>" +
				"<div class='regcolumns'><a href='/northeast'>Northeast</a><br/>" + 
					"<a href='/northerntier'>Northern Tier</a><br/>" + 
					"<a href='/northwest'>Northwest</a><br/>" + 
					"<a href='/philadelphia'>Philadelphia</a><br/>" + 
					"<a href='/southcentral'>South Central</a><br/>" + 
					"</div>" + 
					"<div class='regcolumns'>" + 
					"<a href='/southeast'>Southeast</a><br/>" + 
					"<a href='/southernmountains'>Southern Mtns</a><br/>" + 
					"<a href='/southwest'>Southwest</a><br/>" + 
					"<a href='/valleys'>Valleys</a><br/>" + 
					"<a href='/wilds'>Wilds</a><br/>" + 
					"</div>" + 
				"</div>";
			$("#regiondropdown").html(newhtml);
		}
	}
    
});

function hide_elements_with_showmore_link(class, hide_after, show_all_text, non_link_text) {
	var elcount = $("." + class).size();
	
	//if the element count is less than or equal to the amount we should hide after
	//there is nothing to be done, return
	if (elcount <= hide_after) return;
	else {
		
		var cur_elcount = 0;
		$("." + class).each(function(){
			cur_elcount++;
			
			if (cur_elcount > hide_after) {
				$(this).css("display","none");
			}
			
			if (cur_elcount == elcount) {
				//now add "show" text
				$(this).after("<div class='" + class + "_showall showalldiv'>" + non_link_text + " <a href='#'>" + show_all_text + "</a></div>");
				
				$("." + class + "_showall a").click(function(){
					$("." + class).css("display","block");
					
					$(this).parent().css("display","none");
					
					return false;
				});
			}
		});
		
		
		
		
	}
}

