//
var tabs_api;
var ttimer;

$(function() {
    tabs_api = $(".page_box_table .center").tabs("div.right_box .tab_content > div",{
    	effect:'fade',
    	rotate: true,
    	api:true
    });

    tabs_api.onClick(function(){
    	sifr_refresh(); // update sIFR fonts
    });

    // Medium Tooltip
	$("#content .attribute_row li[title]").tooltip({
		tip:$('#tooltip_small'),
		effect:'toggle',
		position:'top center',
		offset:[0,40],
		predelay:0

	});

	$(".right_box .page_box a").bind('click',function(){
		clearTimeout(ttimer);
		ttimer = setTimeout("rotateTabs()",15000);
	});

	$("div.home_photo ul li span img").each(function(i){
		var img = $(this);
		var imgObj = new Image();
		imgObj.src = this.src;

		if(imgObj.width > imgObj.height){
			img.css("height","83px");
			img.css("width","auto");
		}
	});

	ttimer = setTimeout("rotateTabs()",10000);

	$("div.home_photo ul li span img").load(function(){
		var img = $(this);
		var imgObj = new Image();
		imgObj.src = this.src;

		if(imgObj.width > imgObj.height){
			img.css("height","83px");
			img.css("width","auto");
		}

	});

	$(".home_photo .add_hover span").bind("click",function(){
		window.location.href = $(this).parents(".add_hover").attr("href");
		return false;
	});
});

function rotateTabs(){
	tabs_api.next();
	ttimer = setTimeout("rotateTabs()",10000);
};


function countdown(timeStr){
	dd = timeStr;
	if(dd*1 < 0){
		$("#countdown1").hide().after("Time's up for this month!");
	}else{
		dday=Math.floor(dd/(60*60*24));
		dhour=Math.floor((dd%(60*60*24))/(60*60)*1);
		dmin=Math.floor(((dd%(60*60*24))%(60*60))/(60)*1);
		dsec=Math.floor((((dd%(60*60*24))%(60*60))%(60))/1);
		$("#countdown1 .days").html( dday );
		$("#countdown1 .hours").html( dhour );
		$("#countdown1 .minutes").html( dmin );
		dd -= 20;

		setTimeout("countdown(dd)",20000);
	}
};