$(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(){ testLoc();return false; })
})

function testLoc() {
    $.post(
        "/location_test.php",
        {},
        testLocOK
    );
}
function testLocOK(data) {
    switch (data) {
        case "1":
            document.location.href = "http://nidan-int.cosmos.ru";
        break;
        default:
            showPopup('loginPopup');
    }
}

function showPopup(popup) {
    hght = (document.body.clientHeight < document.documentElement.clientHeight) ? document.documentElement.clientHeight : document.body.clientHeight;
    blackBack = $('<div id="blackBack"></div>');
    blackBack.height(hght).click(closePopup).appendTo('body');
//  iframeBack = $('<iframe id="iframeBack"></iframe>');
//  iframeBack.height(hght).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.offsetHeight;
    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();
}


