jQuery(document).ready(function($) {
$(document).ready(function(){

	$('#home div.slideshow img').css("visibility", "visible");

	$('.slideshow').cycle({
	fx: 'fade' // choose your transition type, ex: fade, scrollUp, shuffle, etc...
	});

	$("#category_list li").hover(function () {
        $(this).css({'background-color': '#ccc'});
	}, 
	function () {
        $(this).css({'background-color': 'white'});
	});

	//Set height of the Camp Details container if it is smaller than the image
	//$('#camp_details').each(function(){
	//var height1 = $('.campImage').innerHeight();
	//imgPos = imgPos.top;
	//var height1 =$("#camp_body img:first").css('height');
	//var height2 = $('#camp_details').css('height');
	//alert(height1);
	//	alert(height2);
	//if (height1 > height2) {
	//	alert(height1);
	//	alert(height2);
	//	//$('#camp_details').css({'height' : height1 + 'px'});
	//	$('#camp_details').height(height1);
	//	} 
	//document.write (height1);
	//document.write (height2);
	//});
	
	$("#camp_body img:first").remove();
	
	$(".camp_details br").remove();

	
	var altText = $('.campImage').attr("alt");
	$('.campImage').attr('alt', altText);

	var cookies = get_cookies_array();
	
	$('.addFav').each(function(){
	var favId = $(this).attr("id");
		if ($.cookie(favId)){
			$(this).css("display", "none");
		}
	});

	$('.addFav').live("click", function(){
	var favId = $(this).attr("id");
	var postLink = $(this).attr("rel");
	//var favId = (favId.substring(4));
	var favTitle = $(this).attr("title");
        $('#favArea').prepend("<li class=\"mycamps_item\" id=\"" + favId + "\"><a id=\"del_" + favId + "\" class=\"removeFav " + favId + "\" href=\"#\"></a><a class=\"post-link\" href=\"/" + postLink + "\">" + favTitle + "</a></li>");
	$.cookie(favId, favTitle, {expires: 7, path: '/', domain: 'mainecamps.org'});
	$(this).css("display", "none");

		if ($(".mycamps_item").length > 0){
			$("#mycamps_list").removeClass('hidden');
			var title 	= "";
			var link 	= "";
			var baseUrl 	= 'http://mainecamps.org';
			var myhtml 	= "";
			$("#favArea li a.post-link").each(function() {
				title = $(this).html();
				link = baseUrl + $(this).attr('href');
				myhtml = myhtml + '\n' + title + '\n' + link + '\n';
				$("#mycamps_email_results #mycamps_values").attr('value',myhtml);
			});
		}
	
	return false;
    	});

	$(".removeFav").live("click", function(){
		var favId = $(this).attr("id");
		var favId = (favId.substring(4));
		$(this).parent().remove();
		$.cookie(favId, null, {path: '/', domain: 'mainecamps.org'});
		$('#' + favId).css("display", "inline");

		if ($(".mycamps_item").length < 1){
			$("#mycamps_list").addClass('hidden');
		}

			var title 	= "";
			var link 	= "";
			var baseUrl 	= 'http://mainecamps.org';
			var myhtml 	= "";
			$("#favArea li a.post-link").each(function() {
				title = $(this).html();
				link = baseUrl + $(this).attr('href');
				myhtml = myhtml + '\n' + title + '\n' + link + '\n';
				$("#mycamps_email_results #mycamps_values").attr('value',myhtml);
			});
		
	return false;
    	});

	//alternate backgrounds on camp search results
	$(".camp_details:even").css("background-color", "#e1ebf5");


	//$("#catSubmit").click(function() {
	//if($('input[name^=session]:checked').size() == 0){
	
	//alert('Please Make A Selection for session length.');
	//return false;
	//}
	//});

	//Business Members list
	$('div#show_hide > div > div.entry').hide();  
	$('div#show_hide > div > span.toggler').click(function() {
		$(this).toggleClass('opened');
		$(this).next('div').slideToggle('fast')
		.siblings('div:visible').slideUp('fast');
		$(this).siblings('h3.opened').removeClass('opened');
		});

	//alternate backgrounds on business member results
	$(".bm_list_item:even").css("background-color", "#e1ebf5");

	$("#jmg_form br").remove();

	$("img.campImage").removeAttr("style");

	$('#jsddm li a:last').addClass('last');

	if ($(".mycamps_item").length > 0){
			$("#mycamps_list").removeClass('hidden');
			var title 	= "";
			var link 	= "";
			var baseUrl 	= 'http://mainecamps.org';
			var myhtml 	= "";
			$("#favArea li a.post-link").each(function() {
				title = $(this).html();
				link = baseUrl + $(this).attr('href');
				myhtml = myhtml + '\n' + title + '\n' + link + '\n';
				$("#mycamps_email_results #mycamps_values").attr('value',myhtml);
			});
		}


	// Clear input fields on focus
	$("input[type=text], textarea").focus(function() {
		if( this.value == this.defaultValue ) {
			this.value = "";
		}
	}).blur(function() {
		if( !this.value.length ) {
			this.value = this.defaultValue;
		}
	});

	
});
});	

