/* <![CDATA[
	iPanel controls...
	(Requires jQuery)
	*/
	var d=new Date();
	var nocashe=d.getHours()+d.getMinutes()+d.getSeconds()+d.getMilliseconds();
	$(document).ready(function(){
							   

// VERTICALLY ALIGN FUNCTION
//http://www.seodenver.com/simple-vertical-align-plugin-for-jquery/
$.fn.vAlign = function() {
	return this.each(function(i){
	var ah = $(this).height();
	var ph = $(this).parent().height();
	var mh = (ph - ah) / 2;
	$(this).css('margin-top', mh);
	});
};

							   
		var WasOpenElement=""; var allOpen=false;
		$(".iP_content:not(.open)").hide();//hide anything not open
		$(".iP_itemCaption").vAlign();//center existing offer caption vertically
		
		$(".iP_content.open").slideDown("normal");//open everything that should be (bloomin ie needs this)
		$(".iP_itemCaption").vAlign();//vcenter offer caption
		
		$(".iP_actuator a").click(function(){				
			$(".iP_content:visible").slideUp("normal");//close all
			var iP_content = $(this).parent().next();
			if(iP_content.hasClass("open")){
				$(".iP_content:visible").removeClass("open");
				//iP_content.slideUp("normal");
				$("#nextOfferTmp").load("/includes/iPanel/iPanel.jsp?iP_show=none #nullContent");//call iPanel to save view state
				$(".iP_itemCaption").vAlign();//vcenter offer caption
			} else {
				$(".iP_content:visible").removeClass("open");
				iP_content.addClass("open");
				iP_content.slideDown("normal");//open clicked		
				$("#nextOfferTmp").load("/includes/iPanel/iPanel.jsp"+$(this).attr("href")+" #nullContent");//call iPanel to save view state
				$(".iP_itemCaption").vAlign();//vcenter offer caption
			}
			return false;
			});
		$(".iP_openClose").click(function(){
				$(".iP_content:visible").slideUp("normal");
				$(".iP_content").removeClass("open");
      		/*closeAction = ($(this).html()=="Close All");
			if(closeAction){
				$(".iP_content:visible").slideUp("normal");
				$(".iP_content").removeClass("open");
				allOpen=false;
			} else {
				$(".iP_content").slideDown("normal");
				$(".iP_content").addClass("open");
				allOpen=true;
			}			
			$(this).html((closeAction)?"Open All":"Close All");
			*/
			return false;
			});
		
		/*$("#nextOfferTmp").load("/offers.jsp #offer", {}, function(){
									 	$("#iP_offerContent").html($("#nextOfferTmp #offerImage").html());
									 	$(".iP_itemCaption").html($("#nextOfferTmp #offerTitle").html());									
									 });*/
		$(".iP_routeTitle").hover(function(){});
		$(".iP_routeTitle").click(function(){
										   if($(this).parent().hasClass("open")){
											   $(this).next().slideUp();$(this).parent().removeClass("open");
										   } else {
											   $(this).next().slideDown();$(this).parent().addClass("open");
										   }
										   return false;
										   });
										
										
		$(".iP_shuffle").click(function(){
										//$("#feeds").load("feeds.php", {limit: 25}, function(){})
									jam = $(this).parent().parent();	
									//jam.animate({opacity:0}, 500, function(){});	
									$("#iP_offerContent").animate({opacity:0}, 500);
									$(".iP_itemCaption").html("loading...");
									$(".iP_itemCaption").vAlign();//center vertically
										 $("#nextOfferTmp").load(""+$(this).attr("href")+"&"+nocashe+" #offer", {}, function(){
											$("#iP_offerContent").stop();
											$("#iP_offerContent").css("opacity","0");
											$("#iP_offerContent").html($("#nextOfferTmp #offerImage").html());
											$(".iP_itemCaption").html($("#nextOfferTmp #offerTitle").html());
											$(".iP_itemCaption").attr("href", $("#iP_offerContent a:first").attr("href"));
											$("#nextOfferTmp").html("");
											$("#iP_offerContent").animate({opacity:1}, 500);
											$(".iP_itemCaption").vAlign();//center vertically
											$("#content").tooltip();//re-apply tooltip script
										 });
									 return false;
									 });
	});
//]]>