    $(function() { init(); });
    function init ()
	{
		$('a[rel=lightbox]').fancybox({
            scrolling: 'yes',
            autoDimensions: false 
        });
		$('a[rel=screenshots]').fancybox({
            scrolling: 'yes',
            autoDimensions: false 
        });
        $('*[title]').tooltip({
			track:	true,
			delay:	300,
			showURL:false,
			fade: 	200
		});
		$("#top_menu").dropDownMenu ({timer: 1000, parentMO: "parent-hover", childMO: "child-hover1"});
		$("#user_menu").dropDownMenu({timer: 1000, parentMO: "parent-hover", childMO: "child-hover1"});
		
        var addthis_config = {
			ui_click: true,
			ui_language: 'ru'
		}
		addthis.toolbox ('#share_buttons');
		addthis.counter ('.addthis_counter');
        getStats ();
	}
    
    function getStats ()
    {
    	//
    	$.ajax ({
    		type: 		'post',
    		url:  		'/ajax/stats.php',
    		dataType:	'json',
    		success:	function (data)
    		{
    			// Cur user
    			$('#umessages').html(data.messages);
    			$('#uoutmessages').html(data.outmessages);
    			$('#uunread').html(data.unread);
    			$('#uratio').html(data.ratio);
    			$('#ubonus').html(data.bonus);
    			$('#uuped').html(data.uped);
    			$('#udowned').html(data.downed);
    			$('#uactiveseed').html(data.activeseed);
    			$('#uactiveleech').html(data.activeleech);
    			if (data.unread > 0)
    			{
    				$('#inboxpic').attr('title', "Есть новые сообщения");
    			 	$('#inboxpic').attr('src', 	 "pic/pn_inboxnew.gif");
    			} 
   				else
   				{
   					$('#inboxpic').attr('title', "Нет новых сообщений");
    			 	$('#inboxpic').attr('src', 	 "pic/pn_inbox.gif");
    			}
    			// Total
    			$('#last_reg').html(data.last_reg);
    			$('#who_online').html(data.who_online);
    			$('#ostaff').html(data.who_online_count.staff);
    			$('#ousers').html(data.who_online_count.users);
    			$('#oguests').html(data.who_online_count.guests);
    			$('#ototal').html(data.who_online_count.total);
    			
    			setTimeout ("getStats()", 5000);
    		}
    	});
    }
    
    function trim(str, chars) {
        return ltrim(rtrim(str, chars), chars);
    }
     
    function ltrim(str, chars) {
        chars = chars || "\\s";
            return str.replace(new RegExp("^[" + chars + "]+", "g"), "");
    }
     
    function rtrim(str, chars) {
        chars = chars || "\\s";
            return str.replace(new RegExp("[" + chars + "]+$", "g"), "");
    }
