$(document).ready(function() {
	$('#fmenu ul.l li:last').css({borderRight:0});
	$('#fmenu ul.r li:last').css({borderRight:0});
	$('#userMenu ul li:last').css({background:'none'});

	$('#fmenu').round({img: 'fmenu'});
	if (!$.browser.msie || $.browser.version>=7)
	{
		$('#news').round({img: 'news'});
		$('.voteQuestion').each(function() { $(this).round({img: 'vq'}) } );
		$('.grey_block').each(function() { $(this).round({img: 'grey'}) } );
	}

    $('.newsSlides').jCarouselLite({
        btnNext: '.newsNext',
        btnPrev: '.newsPrev',
		mouseWheel: true,
		visible:5,
		scroll: 1
    });    

	$('.advice').hover(
		function() {
			$(this).prepend('<div class="corner" id="adviceCorner"></div>');
		},
		function() {
			$('#adviceCorner').remove();
		}
	);

	$('#users #firstPlace #line').css({opacity:0.7});
	
	$('.limitlength').limitlength();

	$('#forumTabs').btabs();

	$('.fading').find('img').each(function() {
	    $(this).fadeTo(0, 0.5).hover(
	        function () {
	            $(this).fadeTo(200, 1);
	        },
	        function () {
	            $(this).fadeTo(200, 0.5);
	        }
	    ); 
    });
})

function print_email(prefix, postfix, user) {
    var str = prefix + '@' + postfix;
    if (!user || user == '') {
        user = str;
    }
    document.write('<a href="mailto:'+ str + '">'+ user +'</a>');
}

function open_win(loc,id,width,height,resize,scroll) {
    var top = (screen.height - height) / 2;
    var left = (screen.width - width) / 2;
    var win = window.open(loc,id,"width="+width+",height="+height+",left="+left+",top="+top+",scrollbars="+scroll+",resizable="+resize+",status=yes");
	win.focus();
}

function do_action(act,id,width,height,resize,scroll) {
    if (!width) {
        width = 512;
        height = 384;
        resize = "no";
        scroll = "no";
    }
    open_win(act,id,width,height,resize,scroll);
}

function do_action_2(id) {
    open_win("about:blank",id,"400","300","no","no");
}

function setCookie (name, value, expires, path, domain, secure)
{
      document.cookie = name + "=" + escape(value) +
        ((expires) ? "; expires=" + expires : "") +
        ((path) ? "; path=" + path : "") +
        ((domain) ? "; domain=" + domain : "") +
        ((secure) ? "; secure" : "");
}

function getCookie(name)
{    
	var cookie = " " + document.cookie;
	var search = " " + name + "=";
	var setStr = null;
	var offset = 0;
	var end = 0;
	if (cookie.length > 0)
	{
		offset = cookie.indexOf(search);
		if (offset != -1)
		{
			offset += search.length;
			end = cookie.indexOf(";", offset)
			if (end == -1)
			{
				end = cookie.length;
			}
			setStr = unescape(cookie.substring(offset, end));
		}
	}
	return(setStr);
}

