/*
	Title: StudentCity.com Destinations Grid
	Date: 23 Jul 2008
	Author: TJ Kelly (www.tjkwebdesign.com), Ryan Zec
	Notes: This code will hide/show read_more box, dim inactive content

	(Edit)Ryan Zec-8/13/08 : Removed the if statement and the overlay div so that you can click on a different box while
	another one is showing
*/

$(document).ready(function(){
	$("a.expand").click(function(){

		//if ($(this).parents("li.dest_grid_item").hasClass("active")){

			$(".read_more_wrap").removeClass("show");
			$("li.dest_grid_item").removeClass("move_row").removeClass("active").css({"margin-top":"5px"});
			$("#foot_wrap").css({"margin-top":"0px"});
			$("#destination_grid #destination_grid_overlay").css("display", "none");
			//return false;

		//} else {

			var rel = $(this).attr("rel");
			var read_more_height = (parseInt($(this).parents("li.dest_grid_item:first").children(".read_more_wrap:first").height()) + 1);
			var element_id = $(this).parents("li.dest_grid_item:first").attr("id");
			var element_parts = element_id.split('_');
			var element_num = element_parts[(element_parts.length - 1)];
			var row_num;
//			if(element_num % 5 == 0) { row_num = 1; }
//			else if(element_num > 4 && element_num < 9) { row_num = 2; }
//			else if(element_num > 8 && element_num < 13) { row_num = 3; }
			row_num = parseInt(Math.abs(element_num - 1) / 4) + 1;
			var move_row = (row_num + 1);
			$(".read_more_wrap").removeClass("show");
			$("#destination_grid li.dest_grid_item").removeClass("active");
			$(this).parents("li.dest_grid_item").addClass("active");
			var height = parseInt($("#destination_grid").height()) + parseInt($("#" + rel + ".read_more_wrap").height());
			var css = {"display":"block","opacity":"0.7","height":height + "px"};
			//$("#destination_grid #destination_grid_overlay").css(css);
			$("#" + rel).css({"height":"0px"}).addClass("show");
			$("#" + rel).animate({"height":read_more_height}, 300);
			$("li.dest_grid_row_" + move_row).css({"margin-top":read_more_height});
			if(move_row == 5) { $("#foot_wrap").css({"margin-top":read_more_height}); }
			return false;

		//}

	});
	$("p.read_more_hide a").click(function(){
		$(".read_more_wrap").removeClass("show");
		$("li.dest_grid_item").removeClass("move_row").removeClass("active").css({"margin-top":"5px"});
		$("#foot_wrap").css({"margin-top":"0px"});
		$("#destination_grid #destination_grid_overlay").css("display", "none");
		return false;
	});
});