$(function() {

	$("#leftnav").hover(function(){
		$(this).stop().animate({left:"-25px",width:"40px"},100);
	},function(){
		$(this).stop().animate({left:"-20px",width:"35px"},100);
	});
	$("#rightnav").hover(function(){
		$(this).stop().animate({right:"-25px"},100);
	},function(){
		$(this).stop().animate({right:"-20px"},100);
	});
	$("a.ic").hover(function(){
		var a = $(this);
		var b = a.parents("div.post").find(".btnic");
		var pos = a.position();
		b.text(a.attr("title")).stop().css("opacity","0").show().css({left: (pos.left+160) +"px",top: (pos.top) +"px"}).animate({opacity:"1"},100);
		a.stop().animate({left:"5px"},100).attr("title","");
	},function(){
		var a = $(this);
		var b = a.parents("div.post").find(".btnic");
		a.stop().animate({left:"10px"},400).attr("title",b.text());
		b.stop().animate({opacity:"0"},400);
	});
	
	$("a.plus").click(function(){
		var id = $(this).attr("id");
		var dd = $("#item-"+id);
		// alert("#item"+id);
		if(dd.css("top")!="0px") dd.stop().animate({top:"0px"},200);
		else dd.stop().animate({top:"192px"},200);
		return false;
	});
	
	$("a.closevid").click(function(){
		$('#vidcontainer').text("loading...").hide();
		$('#vidvimeo').text("loading...").hide();
		$(this).hide();
		$('#header').css("opacity","1");
		$('#content .post').css("opacity","1");
		$('#footer').css("opacity","1");
		$('#leftnav').css("opacity","1");
		$('#rightnav').css("opacity","1");
		myid = $(this).attr("id");
		myid = myid.substr(9);
		if($('div#moviebox-plus-'+myid).length != 0) $.facybox({ div: '#moviebox-plus-'+myid });
		return false;
	});
	$("div.gallery a").fancybox({overlayOpacity : 0.7, overlayColor : '#000'});
	$("a.icphoto").click(function(){
		var tt = $(this).attr("href");
		$(tt+" a").trigger('click');
		return false;
	});
});
   
function vid(fic,path,id){
	$('a.close').trigger('click');
	if(fic.indexOf('vimeo.com/')!=-1){
		linkfic = fic.substr(17);
		$('#vidvimeo').html('<iframe id="player_1" src="http://player.vimeo.com/video/'+linkfic+'?autoplay=1&api=1&player_id=player_1&mid='+id+'" width="960" height="510" frameborder="0" webkitallowfullscreen></iframe>');
		$('#vidvimeo').css("z-index","1000").show();
	}else{	
		$('#vidcontainer').css("z-index","1000").show();
		jwplayer("vidcontainer").setup({
			file: fic,
			wmode: "opaque",
			width: "960",
			height: "510",
			autostart: true,
			players: [
				{ type: "html5" },
				{ type: "flash", src: path+"/jwplayer/player.swf" }
			]
		});
	}
	$('#header').stop().animate({opacity:0},700);
	$('#content .post').stop().animate({opacity:0},700);
	$('#footer').stop().animate({opacity:0},700);
	$('#leftnav').stop().animate({opacity:0},700);
	$('#rightnav').stop().animate({opacity:0},700);
	$('#closevid-'+id).css("z-index","1010").show();
}
