jQuery(window).load(function(){
	if (jQuery.browser.msie) {
		jQuery("._shadows").remove();
		jQuery("#weeks-grid").css({borderLeft:"1px solid #CCCCCC",borderBottom:"1px solid #CCCCCC"});
	}
	var nsh = (jQuery.browser.msie) ? -10 : 30;

	var contentHeight = jQuery("#content-main").height()+nsh;
	jQuery("._shadows").eq(0).css({height:contentHeight+"px"});
})

jQuery(document).ready(function() {
	
	jQuery(".review-link, a.biglink, .meta a").click(function(e){
		var link = jQuery(this)[0];
		launchReview(link);
		return false;
	})
	
	jQuery("#overlay-bg,a.overlay-close-btn").click(function(){
		closeReview();
	})
	
	jQuery('.week-entry').bind("click", function(){
		var link = jQuery(".review-link",this)[0];
		launchReview(link);
		return false;
	})
	
	jQuery('#wrapper .fc-thumb').bind("click", function(){
		var link = jQuery(this)[0];
		window.location.href = link;
		return false;
	})	
	
	
	
	jQuery(".featured").each(function(id,el){
		jQuery(el).bind("mouseover",function(){
			selectFeatured(id);
		})

	})
	
	jQuery(".authors-logo").each(function(id,el){
		jQuery(el).bind("mouseover",function(){
			selectFeatured(id);
		})		
	})	
	
	
	jQuery(".fc-thumb").hover(
		function() {
			jQuery(".fc-thumb-overlay",this).show();
		},
		function() {
			jQuery(".fc-thumb-overlay",this).hide();
		}
	)
	
	jQuery('.exp-area-header').click(function(){
		jQuery(this).parent().eq(0).toggleClass("open");
		window.location.hash = (jQuery(this).parent().eq(0).hasClass("open")) ? "#"+jQuery(this)[0].id : "#";
	})
	
	jQuery("#trackback-url").focus(function(){
		jQuery(this).select();
	})
	
	jQuery(".nofollow").each(function(id,el){
		$(el).attr("target","_top");
	})
	
	selectFeatured(0);
})

var sttt;
function addToHistory(page) {
//	alert(window.location.hash);
	sttt = setTimeout(function(){
		jQuery(function($){
			$.history.add(page);		
		})		
	},1000);
}

jQuery(function($){
	$(window).history(function(e, page) {
		if (page=="") closeReview();
    });

	$(window).historyadd(function(e, page) {
		
    });
})

var curselect,curseltm;
function selectFeatured(id) {
	if (curselect==id) return;
	if (curselect==null) curselect = 0;
	jQuery("#featured-area").stop();
	jQuery(".author-arrowup").eq(curselect).hide();
	jQuery(".featured").eq(curselect).removeClass("featuredOn");
	
	jQuery(".author-arrowup").eq(id).show();
	jQuery(".featured").eq(id).addClass("featuredOn");
	var svalue = id*960;
	jQuery("#featured-area").stop().animate({scrollLeft:svalue},250);
	curselect = id;
}

function closeFeatured() {
	if (curselect!=null) {
		jQuery(".author-arrowup").eq(curselect).hide();
		jQuery(".featured").eq(curselect).removeClass("featuredOn");
	}
}

function launchReview(link) {
	var nh = jQuery(document).height();
	jQuery("#overlay-bg").css({height:nh+"px"});
	jQuery("#review-overlay")[0].src = link;
	jQuery("#overlay-loading").hide();
	jQuery("#overlay").show();
	jQuery("#overlay-bg").show();
	jQuery("#overlay .overlay-wrapper").show();
	jQuery("#overlay-loading").hide();
	if (window.location.hash!="#open") addToHistory("open");
}

function closeReview() {
	window.location.href="http://www.fancast.com/ourtvpicks";
	/*
	jQuery("#review-overlay")[0].src = "";
	jQuery("#overlay").hide();
	jQuery("#overlay-bg").hide();
	jQuery("#overlay .overlay-wrapper").hide();
	*/
}

function postComment() {
	jQuery("#commentform").submit();
}

function refreshCommentsNum() {
	
}