pngfix=function()
{
	var clear=blankImage;
	var els=document.getElementsByTagName('*');
	var ip=/\.png/i;
	var i=els.length;
	while(i-- >0)
	{
		var el=els[i];
		var es=el.style;
		if(el.src&&el.src.match(ip)&&!es.filter)
		{
			es.height=el.height;
			es.width=el.width;
			es.filter="progid:DXImageTransform.Microsoft.AlphaImageLoader(src='"+el.src+"',sizingMethod='crop')";
			el.src=clear;
		}
		else
		{
			var elb=el.currentStyle.backgroundImage;
			if(elb.match(ip))
			{
				var path=elb.split('"');
				var rep=(el.currentStyle.backgroundRepeat=='no-repeat')?'crop':'scale';
				es.filter="progid:DXImageTransform.Microsoft.AlphaImageLoader(src='"+path[1]+"',sizingMethod='"+rep+"')";
				es.height=el.clientHeight+'px';
				es.backgroundImage='none';
				var elkids=el.getElementsByTagName('*');
				if(elkids)
				{
					var j=elkids.length;
					if(el.currentStyle.position!="absolute")es.position='static';
					while(j-- >0)if(!elkids[j].style.position)elkids[j].style.position="relative";
				}
			}
		}
	}
}
menuSizeFix = function()
{
	var el = $('#menu a');
	var sz = 0;
	var i = 0;
	$.each(el,function(){
		//alert($(this).width());
		i++;
		sz += parseInt($(this).width());
	});
	sz += 390;
	sz = parseInt($('#menu').width()) - sz;
	sz -= 38;
	sz = parseInt(sz/i);
	$('#menu a').css({'margin':'0px 0px 0px ' + sz + 'px'});
}
contentSizeFix = function()
{
	if($('#lc').height() < $('#rc').height())
		$('#lc').height($('#rc').height());
	else
		$('#lc').height('100%');
	//$('#container').height($('#container').height());
	//setTimeout(function(){$('#footer').css({'bottom':'10px'});},1000);
}
sizeFix = function()
{
	if($('body').width() <= 1024)
		$('#container').width('1003px');
	else
		if($('body').width() >= 1280)
			$('#container').width('1280px');
		else
			$('#container').width('100%');
	menuSizeFix();
	contentSizeFix();
	window.onresize = sizeFix;
}
mainLoader = function()
{
	sizeFix();
	$('body').addClass($.os.name).addClass($.browser.name).addClass($.browser.className);
	if($.browser.className == 'msie6')pngfix();
};
$(document).ready(function(){
	mainLoader();
	$('img.p_hover').animate({opacity:0},0);//.stop().animate({opacity:1},500);
	$('#partners img').hover(function(){
		$(this).parent().find('img.p_hover').stop().animate({opacity:1},500);
	},function(){
		$(this).parent().find('img.p_hover').stop().animate({opacity:0},500);
	});
	var show = -1;
	$('.sub_menu').slideUp(0);
	if($('#menu .sel').attr('rel') != '')
	{
		$('.sub_menu' + $('#menu .sel').attr('rel')).slideDown(0);
		show = $('#menu .sel').attr('rel');
	}
	$('#menu a').click(function(){
		if($(this).attr('rel') != '')
		{
			if($(this).attr('rel') == show)
			{
				$('.sub_menu').slideUp(1000);
				$('#menu a').attr({'class':''});
				show = -1;
			}
			else
			{
				$('.sub_menu').slideUp(1000);
				$('#menu a').attr({'class':''});
				$(this).attr({'class':'sel'});
				$('.sub_menu' + $(this).attr('rel')).slideDown(1000);
				show = $(this).attr('rel');
			}
			return false;
		}
	});
	$.ajaxSetup({
		async:false
	});
	var intv;
	$('#menu a:last').css({'background':'url(/bitrix/templates/tpl_inc/images/seplst.png) repeat-x bottom'});//url("/bitrix/templates/tpl_inc/images/sep.png") repeat-x scroll left bottom transparent
	$('.sublevelshow').live('mouseover',function(){
		clearTimeout(intv);
		var offset = $(this).offset();
		var rel = $(this).attr('rel');
		var t = $(this);
		$('.popupblock').hide(0);
		if($('#pubw'+rel).attr('class') != 'popupblock')
		{
			$.post('/ccc.php?id=' + rel,function(data){
				if(data != '')
					$('body').append('<div id="pubw'+rel+'" class="popupblock"><div class="popupblock_in"><div class="popupblock_top"></div><div class="popupblock_text">'+data+'</div><div class="popupblock_bottom"></div></div></div>');
				else
					$('body').append('<div id="pubw'+rel+'" style="dispaly:none;" class="popupblock"></div>');
				$('#pubw'+rel).css({'left':offset.left+$(t).width()-20,'top':offset.top-20});
			});
		}else
		{
			$('#pubw'+rel).show(0);
		}
	});//offset.top//offset.left
	$('.sublevelshow,.popupblock').live('mouseout',function(){
		intv = setTimeout(function(){$('.popupblock').hide();},1000);
	});
	$('.popupblock').live('mouseover',function(){clearTimeout(intv);});
});