$(document).ready(function(){
	$('ul.midMenu > li').not('li.active').hover(function(){
		$(this).addClass('hovered');
		//$(this).find('div.subMidMenu').slideDown(100);
	},function(){
		$(this).removeClass('hovered');
		//$(this).find('div.subMidMenu').stop().hide();
	})
	if ($('ul.midMenu > li.active').hasClass('active')) {
		c = $('ul.midMenu > li.active').find('li').not('li.sep').length;
		x = parseInt(c/3);
		x += (x < c/3) ? 1 : 0;
		activeMenuHeight = ($.browser.msie) ? (28*x)+30 : (28*x)+15;
		$('div#menus').css({height:activeMenuHeight+66});
	}
	$('a.enterTheNetworkInTheNameOfChampionJuice').click(function(){ showPopup('loginPopup');return false; })
})

function showPopup(popup) {
	blackBack = $('<div id="blackBack"></div>');
	blackBack.height(document.body.clientHeight).click(closePopup).appendTo('body');
	iframeBack = $('<iframe id="iframeBack"></iframe>');
	iframeBack.height(document.body.clientHeight).appendTo('body');
	currentOffset2 = 0;
	currentOffset = document.documentElement.scrollTop || document.body.scrollTop;
	var windowHeight;
	windowHeight = document.documentElement.clientHeight;
	if (windowHeight < $('#'+popup).height()) {
		currentOffset = (currentOffset + 10);
	} else {
		currentOffset2 = parseInt((windowHeight - $('#'+popup).height()) / 2);
	}
	pLeft = (document.body.clientWidth - $('#'+popup).width()) / 2;
	$('#'+popup).css({top:currentOffset+currentOffset2,left:pLeft}).show();
}

function closePopup() {
	$('#iframeBack').remove();
	$('#blackBack').remove();
	$('.popup').hide();
}

function setCenter(item) {
	windowHeight = document.documentElement.clientHeight;
	currentOffset = document.documentElement.scrollTop || document.body.scrollTop;
	currentOffset = currentOffset + parseInt((windowHeight - $(item).height()) / 2);
	pLeft = (document.body.clientWidth - $(item).width()) / 2;
	$(item).css({top:currentOffset,left:pLeft}).show();
}


