/*
$(document).ready(function () {

	var id = 0;
	var minDiv = 10000;
	//collapse all tenders to the height of the h3
	$("div.tender").each(function() {
		//remember the height of the smallest div. use as yardstick later to tell whether div have been closed or not
		$(this).attr({ref:$(this).height()});
		//set the height for this tender
		thisHeight = $(this).children("h3").height();
		//set height for this div and hide content
		$(this).css({height:thisHeight+"px",overflow:"hidden"});
		//set styles for the heading - to be used as show/hide link
		$(this).children("h3").css({cursor:"pointer",backgroundImage:"url(/production/img/tender-show.gif)",backgroundRepeat:"no-repeat",backgroundPosition:"top right"}).attr("value", id + 1);
		
		//function to show
		$("div.tender h3").click(function() {
			var headerHeight = $(this).height();
			var divHeight = $(this).parent("div.tender").attr("ref");
			var divHeightCurrent = $(this).parent("div.tender").height();
			//check to see if this div is closed, if so, open it
			if (divHeight > divHeightCurrent) {
				$(this).parent("div.tender").css({height:divHeight});
				$(this).css({backgroundImage:"url(/production/img/tender-hide.gif)"});
			} else {
				//it's already open, close it
				$(this).parent("div.tender").css({height: headerHeight+"px"});
				$(this).css({backgroundImage:"url(/production/img/tender-show.gif)"});
			};
		});
	});

});
*/

$(document).ready(function () {
	//wrap tender content in a div
	$("div.tender").wrapInner("<div class='wrap'></div)");
	//iterate each tender div and move the h3 to the outside
	$("div.tender").each(function() {
		//grab contents of h3
		var thisH3 = "<h3 style='cursor:pointer;background-image:url(/production/img/tender-show.gif);background-repeat:no-repeat;background-position:top right;'>"+$(this).children("div.wrap").children("h3").html()+"</h3>";
		//add h3 to outside div.wrap
		$(this).prepend(thisH3);
		//remove original h3
		$(this).children("div.wrap").children("h3").remove();
		//hide div.wrap
		$(this).children("div.wrap").css({display:"none"});
	});
	
	//click function for hide.reveal
	$("div.tender h3").click(function(){
		$(this).next("div.wrap").slideToggle();
	});
});
