$(function() {

// For Each Package Wrapper add a Toggle Function if Neccessary
	$("div.package-wrapper").each(function() {
	// Div for the Toggler to be Held
	$(this).find(".package-details").append("<div class=\"package-toggle\">");

		// If this is a package that is going to be expanded
		// add a control for it
		if( $(this).is(".package-expandable") ) {
			// Since this is expandable hide the details
			$(this).find("div.package-long").hide();
			// Add the Control
			if ( $(this).hasClass("noBook") ){
				$(this).find(".package-toggle").append("<span class=\"link\"><img src=\"images/fall/view-details-and-book-now-btn.jpg\" /></span>");
			}else{
				$(this).find(".package-toggle").append("<span class=\"link\"><img src=\"images/summer/view-details-and-book-now-btn.jpg\" /></span>");
			}
		}
		
	//$(this).find(".package-content").append("<div class=\"clear\"></div>");
	
	});
	$("div.package-wrapper-bottom").each(function() {
	// Div for the Toggler to be Held
	$(this).append("<div class=\"package-toggle-bottom\" style=\"clear:both;\">");

		// If this is a package that is going to be expanded
		// add a control for it
		if( $(this).is(".package-expandable-bottom") ) {
			// Since this is expandable hide the details
			$(this).find("div.package-long-bottom").hide();
			// Add the Control
			$(this).find(".package-toggle-bottom").append("<a href=\"#\">View Details</a>");
		}
	});


// Once the Package Toggler Control is clicked
// Toggle the details and chance the text
	$("div.package-toggle span").toggle(function() {
		$(this).parents("div.package-wrapper").find("div.package-long").animate({
			height: 'show'
		}, 'slow');
		// Changes the Text of the Control
		if (typeof($(this).parents('div.noBook').attr('class')) != "undefined"){
			$(this).html("<img src=\"images/fall/hide-details-and-book-now-btn.jpg\" />");
		}else{
			$(this).html("<img src=\"images/summer/hide-details-and-book-now-btn.jpg\" />");
		}
	}, function() {
		$(this).parents("div.package-wrapper").find("div.package-long").animate({
			height: 'hide'
		}, 'slow');
		// Changes the Text of the Control
		if (typeof($(this).parents('div.noBook').attr('class')) != "undefined"){
			$(this).html("<img src=\"images/fall/view-details-and-book-now-btn.jpg\" />");
		}else{
			$(this).html("<img src=\"images/summer/view-details-and-book-now-btn.jpg\" />");
		}
	});


});