$(document).ready(function() {
	
	//css
	$("#body.singlePage .articleThumbnail").bind("mouseover",function(){
		$("#body.singlePage .articleThumbnail #socialButtons").stop().animate({bottom:5},100);
	});
	$("#body.singlePage .articleThumbnail").bind("mouseout",function(){
		$("#body.singlePage .articleThumbnail #socialButtons").stop().animate({bottom:-100});
	});
	//ribbon
	$('.newRebbon a').bind("mouseover",function(){
		$(this).stop().animate({"background-position": -126},100);
		$('.oldRebbon a').stop().animate({"background-position": 60},100);
	});
	$('.newRebbon a').bind("mouseout",function(){
		$(this).stop().animate({"background-position": -141},100);
		$('.oldRebbon a').stop().animate({"background-position": 45},100);
	});
	$('.oldRebbon a').bind("mouseover",function(){
		$(this).stop().animate({"background-position": 30},100);
		$('.newRebbon a').stop().animate({"background-position": -156},100);
	});
	$('.oldRebbon a').bind("mouseout",function(){
		$(this).stop().animate({"background-position": 45},100);
		$('.newRebbon a').stop().animate({"background-position": -141},100);
	});
/*
	//facebook
	setTimeout(function(){
		$("header .fbpage-like").stop().animate({bottom:35,opacity:1},1000);
		setTimeout(function(){
			$("header .fbpage-like").stop().animate({bottom:100,opacity:0},1000);
		}, 3000);
	}, 2000);
	setTimeout(function(){
	}, 7000);
*/
	$("header .fbpage-like").css("opacity","0");
	$('.fbook,.fb-like-box').bind("mouseover",function(){
		$("header .fbpage-like").stop().animate({bottom:35,opacity:1},300);
	});
	$('#header').bind("mouseout",function(){
		$("header .fbpage-like").stop().animate({bottom:100,opacity:0},1000);
	});
	
	//search
	$(".searchtext").bind("mouseover",function(){
		$(".searchsubmit").stop().animate({"left": 200},400,"swing");
	});
	$(".searchtext").bind("mouseout",function(){
		if ($(".searchtext").is(":focus")) {
			$(".searchsubmit").stop().animate({"left": 200},400,"swing");
			return false;
		}
		$(".searchsubmit").stop().animate({"left": 16},300,"swing");
		$(".searchtext").stop().animate({"background": rgba(255, 255, 255, 0.5)},300,"swing");
	});
	$(".searchtext").blur(function(){
		$(".searchsubmit").stop().animate({"left": 16},300,"swing");
	});
	
	//sidebar
/*
	$("#sidebar").animate({"right": -160});
	$("#sidebar").bind("mouseover",function(){
		$("#sidebar").stop().animate({"right": 0},100);
	});
	$("#sidebar").bind("mouseout",function(){
		$("#sidebar").stop().animate({"right": -160});
	});
*/	
	//resizeSize
	var resizeTimer = null;
	var articleWidth = "200";
//	var headerH1 = $("#header .hgroup h1");
//	headerH1.hide();
	$(window).bind('resize', function() {
	if (resizeTimer) clearTimeout(resizeTimer);
		resizeTimer = setTimeout(resizeContainer, 300);
	});
	
	resizeContainer();
	function resizeContainer() {
		containerWidth = Math.floor(($(window).width()-40)/articleWidth)*205;
		if ($(window).width() < 1100){
			$("#wrap").animate({"width": 820});
			$("#copyrights").animate({"width": 820});
			$("#recommend").animate({"width": 820});
			$("#body.singlePage #rightContainer #excerpt p").hide();
			$("#more").hide();
//			headerH1.animate({"width": 820}).fadeIn(1000);
			return false;
		}
		if ($(window).width() > 1100){
			$("#wrap").animate({"width": 1025});
			$("#copyrights").animate({"width": 1025});
			$("#recommend").animate({"width": 1025});
			$("#body.singlePage #rightContainer #excerpt p").show();
			$("#body.singlePage #rightContainer #excerpt > p").hide();
			$("#more").show();
//			headerH1.animate({"width": 1025}).fadeIn(1000);
			return false;
		}
//		headerH1.fadeOut(100, function(){
			$("#wrap").animate({"width": containerWidth});
//			});
		
//		headerH1.animate({"width": containerWidth}).fadeIn(1000);
	};
/*
		if ($(window).width() < 860){
			$("#wrap").animate({"width": 820});
			headerH1.animate({"width": 820}).fadeIn(1000);
			return false;
		}
		if ($(window).width() > 1065){
			if ($(window).width() < 1155){
				$("#wrap").animate({"left": 0});
				$("#sidebar").animate({"right": -120});
			}
			if ($(window).width() > 1155){
				$("#wrap").animate({"left": -55});
				$("#sidebar").animate({"right": 0});
			}
			$("#wrap").animate({"width": 1025});
			headerH1.animate({"width": 1025}).fadeIn(1000);
			return false;
		}
		headerH1.fadeOut(100, function(){
			$("#wrap").animate({"width": containerWidth});
			});
		
		headerH1.animate({"width": containerWidth}).fadeIn(1000);
	};
*/
	//adCover
/*
	var adCover = $(".ad .adCover");
	adCover.show();
	$(".ad").hide();//$("#body.topPage article a,.ad .adCover").bind('mouseover', adCoverSwitch);
	function adCoverSwitch() {
		if ($(window).width() < 700){
			return false;
		}
		adCover.stop().fadeOut(function(){
			$(function(){
				setTimeout(function(){
					adCover.fadeIn();
				},3000);
			});
		});
	};
*/
});


