/*Main menu*/
$(document).ready(function(){
     $("#main_menu ul.menu li.parrent").mouseover(function() {
             
        $(this).children("div").slideDown('fast').show(); 
 
        $(this).hover(function() {
        }, function(){ 
            $(this).children("div").slideUp('fast'); 
        });
        });
        
});

/*kontent menu*/
$(document).ready(function(){
     $("#content_box ul.menu li.level1.parrent,#tabber ul.menu li.level1.parrent,#top_modules_wrap ul.menu li.level1.parrent,#bottom ul.menu li.level1.parrent").mouseover(function() {
             
        $(this).children("div").slideDown('fast').show(); 
 
        $(this).hover(function() {
        }, function(){ 
            $(this).children("div").slideUp('fast'); 
        });
        });
        
});

//top_tab
$(function(){
	$('div#top_tab li a')
	.click(function(){
		tabbox = 'div#top_tab'; 
		tabs = '.panels'; 
		actclass = 'active'; 
		speed = 500; 
		thisLink = $(this);
		if($(this.hash).css('display')=='none'){
			thisLink.parent().parent().find('a').removeClass(actclass);
			thisLink
			.addClass(actclass)
			.parents(tabbox)
			.find(tabs).hide().end()
			.find(this.hash).animate({opacity:'show'},speed);
		}
		return false;
	});
});

//tabber
$(function(){
	$('div#tabber div#tabber_switcher a')
	.click(function(){
		tabbox = 'div#tabber'; 
		tabs = 'div.tabber_tab'; 
		actclass = 'active'; 
		speed = 500; 
		thisLink = $(this);
		if($(this.hash).css('display')=='none'){
			thisLink.parent().parent().find('a').removeClass(actclass);
			thisLink
			.addClass(actclass)
			.parents(tabbox)
			.find(tabs).hide().end()
			.find(this.hash).animate({opacity:'show'},speed);
		}
		return false;
	});
});


//logo
$(document).ready(function(){
    $("#logo").hover(function() {
        $(this).find("#logo_info").animate({opacity: "show", top: "30", right: "-50"}, "fast");
		$(this).find("#logo_url").animate({opacity: "show", bottom: "50", left: "0"}, "fast");
    	$(this).find("#logo_rss").animate({opacity: "show", top: "25", left: "0"}, "fast");
	}, function() {
        $(this).find("#logo_info").animate({opacity: "hide", top: "70", right: "50"}, "fast");
		$(this).find("#logo_url").animate({opacity: "hide", bottom: "90", left: "20"}, "fast");
		$(this).find("#logo_rss").animate({opacity: "hide", top: "50", left: "30"}, "fast");
    });
});

//user_tip
$(document).ready(function(){
    $(".new_user_list div.new_user_item").hover(function() {
        $(this).find(".new_user_title").animate({opacity: "show", top: "0"}, "fast");
	}, function() {
        $(this).find(".new_user_title").animate({opacity: "hide", top: "-30"}, "fast");
    });
});



//latest uc
$(document).ready(function(){
	$('div.uc_latest_tab_swicher span a,div.uc_popular_tab_swicher span a,div.new_user_tab_swicher span a,div.uc_random_tab_swicher span a,div.mod_userfiles_tab_swicher span a')
	.click(function(){
		tabbox = '.uc_latest_list,.uc_popular_list,.new_user_list,.uc_random_list,.mod_userfiles_list'; 
		tabs = '.uc_latest_tab,.uc_popular_tab,.new_user_tab,.uc_random_tab,.mod_userfiles_tab'; 
		actclass = 'active'; 
		speed = 500; 
		thisLink = $(this);
		if($(this.hash).css('display')=='none'){
			thisLink.parent().parent().find('a').removeClass();
			thisLink
			.addClass(actclass)
			.parents(tabbox)
			.find(tabs).hide().end()
			.find(this.hash).animate({opacity:'show'},speed);
		}
		return false;
	});
});


//album_desc
$(document).ready(function(){
     $(".photo_album_tumb").hover(function() {
        $(this).children("div.photo_txt").children("ul").children("li.photo_album_desc").show({opacity: "show", top: "0"}, "fast");
    }, function() {
        $(this).children("div.photo_txt").children("ul").children("li.photo_album_desc").hide({opacity: "hide", top: "0"}, "fast");
    });
 
});


//colapced blocks
 jQuery.cookie = function (key, value, options) {
        if (arguments.length > 1 && (value === null || typeof value !== "object")) {
            options = jQuery.extend({}, options);
            if (value === null) {
                options.expires = -1;
            }
            if (typeof options.expires === 'number') {
                var days = options.expires, t = options.expires = new Date();
                t.setDate(t.getDate() + days);
            }
            return (document.cookie = [
                encodeURIComponent(key), '=',
                options.raw ? String(value) : encodeURIComponent(String(value)),
                options.expires ? '; expires=' + options.expires.toUTCString() : '',
                options.path ? '; path=' + options.path : '',
                options.domain ? '; domain=' + options.domain : '',
                options.secure ? '; secure' : ''
            ].join(''));
        }
        options = value || {};
        var result, decode = options.raw ? function (s) { return s; } : decodeURIComponent;
        return (result = new RegExp('(?:^|; )' + encodeURIComponent(key) + '=([^;]*)').exec(document.cookie)) ? decode(result[1]) : null;
    };


    $(document).ready(function(){
        $(".usr_wall_header").addClass("active");
        var l = $('.usr_wall_header').length;
        var blocks = $("div.toogled");
        for (c=0;c<=l;c++){
            var cvalue = $.cookie('blocks' + c);
            if ( cvalue == 'closed' + c ) {
                $(blocks).eq(c).css({display:"none"});
                $(blocks).eq(c).prev().removeClass('active').addClass('inactive');
            };
        };
        $(".usr_wall_header.active").toggle(
            function () {
                var num = $("div.usr_wall_header").index(this);
                var cookieName = 'blocks' + num;
                var cookieValue = 'closed' + num;
                $(this).next("div.toogled").slideUp(300);
                $(this).removeClass('active');
				$(this).addClass("inactive");
                $.cookie(cookieName, cookieValue, { path: '/', expires: 10 }); 
            },
            function () {
                var num = $("div.usr_wall_header").index(this);
                var cookieName = 'blocks' + num;
                $(this).next("div.toogled").slideDown(300);
                $(this).addClass("active");
				$(this).removeClass('inactive');				
                $.cookie(cookieName, null, { path: '/', expires: 10 });
            }
        );

        $(".usr_wall_header.inactive").toggle(
            function () {
                var num = $("div.usr_wall_header").index(this);
                var cookieName = 'blocks' + num;
                $(this).next("div.toogled").slideDown(300);
                $(this).addClass("active");
                $(this).removeClass('inactive');       
                $.cookie(cookieName, null, { path: '/', expires: 10 });
            },
            function () {
                var num = $(".usr_wall_header").index(this);
                var cookieName = 'blocks' + num;
                var cookieValue = 'closed' + num;
                $(this).next("div.toogled").slideUp(300);
                $(this).removeClass('active');
				$(this).addClass("inactive");
                $.cookie(cookieName, cookieValue, { path: '/', expires: 10 }); 
            }
        );

    });

	
//cart_buttons
$(document).ready(function() {
	var opacity = 0.7, endopacity = 1.0, duration = 250;
    $('div#cart_buttons div#cart_buttons1 a:first').addClass('button1').css('opacity', '0.7');
	$('div#cart_buttons div#cart_buttons1 a:last').addClass('button2').css('opacity', '0.7');
    $('div#cart_buttons2 a:first').addClass('button1').css('opacity', '0.7');
    $('div#cart_buttons div#cart_buttons2 a:last').addClass('button2').css('opacity', '0.7');      
	$('div#cart_buttons a,div#cart_buttons2 a').hover(function() {
		$(this).fadeTo(duration,endopacity);
		}, function() {
		$(this).fadeTo(duration,opacity);
		}
	);
});
  

