$(document).ready(function() {
/*--------------*/  
  $(".post").hover(function() {
        $(this).find("span.overlay").animate({ opacity: "0.3" }, 400);
		if($.cookie('displayMod')=="grid-Mod"){
			$(this).find('span.facebook-like').stop(true, true).animate({opacity: 1, left: 85},400);
			$(this).find('span.twitter-tweet').stop(true, true).animate({opacity: 1, right: 85},400);
		}else{
			$(this).find('span.facebook-like').stop(true, true).animate({opacity: 1, left: 45},400);
			$(this).find('span.twitter-tweet').stop(true, true).animate({opacity: 1, right: 45},400);
		}
    },function(){
        $(this).find("span.overlay").animate({ opacity: "0" }, 300);
		$(this).find('span.facebook-like').stop(true, true).animate({opacity: 0, left: 0},300);
		$(this).find('span.twitter-tweet').stop(true, true).animate({opacity: 0, right: 0},300);
	}); 
/*--------------*/
	$(".tab_content").hide();
	$("ul.tabs li:first").addClass("active").show();
	$(".tab_content:first").show(); 
	$("li.tabs").click(function() {
		$("ul.tabs li").removeClass("active");
		$(this).addClass("active");
		$(".tab_content").hide();
		var activeTab = $(this).find("a").attr("href");
		$(activeTab).fadeIn();
		return false;
	});
/*--------------*/
	$(".cats_content").hide();
	$(".widget_cats .widget-top h3:first").addClass("not-active").show();
	$(".cats_content:first").show(); 
	$(".widget_cats .widget-top h3").click(function() {
		$(".widget_cats .widget-top h3").addClass("not-active");
		$(this).removeClass("not-active");
		$(".cats_content").hide();
		var activeTab1 = $(this).find("a").attr("href");
		$(activeTab1).fadeIn();
		return false;
	});
/*--------------*/
	$("#buttons li").each(function(){	
		var $sublist = $(this).find('ul:first');		
		$(this).hover(function(){	
			$sublist.stop().css({overflow:"hidden", height:"auto", display:"none"}).slideDown(300, function(){
				$(this).css({overflow:"visible", height:"auto"});
			});	
		},
		function(){	
			$sublist.stop().slideUp(300, function()	{	
				$(this).css({overflow:"hidden", display:"none"});
			});
		});	
	});
/*--------------*/	
	$("#loopedSlider").css("display", "none");
	setTimeout(function(){
		$("#Slider-loading").fadeOut(000,function(){
			$("#loopedSlider").slideDown(400);	
		});
	},3000);
/*--------------*/	
	if($.cookie('displayMod'))
		$(".display-mods").attr('id',$.cookie('displayMod'));
	
	if($.cookie('displayMod')=="grid-Mod"){
		$(".display-options a").removeClass("active");
		$(".display-options a.grid").addClass("active");
	}
	$(".display-options a.normal").click(function() {
		$(".display-options a").removeClass("active");
		$(this).addClass("active");
		$(".display-mods").slideUp(0);
		$(".display-mods").slideDown(1000);
		$(".display-mods").attr('id',"normal-Mod");
		$.cookie("displayMod", "normal-Mod", { expires: 300 });
	});
	$(".display-options a.grid").click(function() {
		$(".display-options a").removeClass("active");
		$(this).addClass("active");
		$(".display-mods").slideUp(0);
		$(".display-mods").slideDown(1000).attr('id',"grid-Mod");
		$.cookie("displayMod", "grid-Mod", { expires: 300 });
	});
/*--------------*/	
	$(function(){
		 $('a[href*=#top]').click(function() {
		if (location.pathname.replace(/^\//,'') == this.pathname.replace(/^\//,'') 
			&& location.hostname == this.hostname) {
				 var $target = $(this.hash);
				 $target = $target.length && $target || $('[name=' + this.hash.slice(1) +']');
				 if ($target.length) {
					 var targetOffset = $target.offset().top;
					 $('html,body').animate({scrollTop: targetOffset}, 700);
					 return false;
				 }
			 }
		 });
	 });	
			
});
/*--------------*/
jQuery.cookie = function(name, value, options) {
    if (typeof value != 'undefined') { 
        options = options || {};
        if (value === null) {
            value = '';
            options.expires = -1;
        }
        var expires = '';
        if (options.expires && (typeof options.expires == 'number' || options.expires.toUTCString)) {
            var date;
            if (typeof options.expires == 'number') {
                date = new Date();
                date.setTime(date.getTime() + (options.expires * 24 * 60 * 60 * 1000));
            } else {
                date = options.expires;
            }
            expires = '; expires=' + date.toUTCString();
        }
        var path = options.path ? '; path=' + (options.path) : '';
        var domain = options.domain ? '; domain=' + (options.domain) : '';
        var secure = options.secure ? '; secure' : '';
        document.cookie = [name, '=', encodeURIComponent(value), expires, path, domain, secure].join('');
    } else {
        var cookieValue = null;
        if (document.cookie && document.cookie != '') {
            var cookies = document.cookie.split(';');
            for (var i = 0; i < cookies.length; i++) {
                var cookie = jQuery.trim(cookies[i]);
                if (cookie.substring(0, name.length + 1) == (name + '=')) {
                    cookieValue = decodeURIComponent(cookie.substring(name.length + 1));
                    break;
                }
            }
        }
        return cookieValue;
    }
};
