function IEPngFix(pngimg, gifimg, width, height)
{
	var code = '<img src="'+ gifimg +'" width="' + width + '" height="' + height + '" border="0" style="background:url('+pngimg+') no-repeat 0px 0px;"/>';
	if( navigator.userAgent.indexOf("Opera") > 1 ) document.write(code);
	else
		if( navigator.userAgent.indexOf("MSIE 6") > 1 ) document.write('<img src="'+gifimg+'" width="' + width + '" height="' + height + '" border="0" style="filter: progid:DXImageTransform.Microsoft.AlphaImageLoader (src=' + pngimg + ' , sizingMethod=crop );"/>');
		else
			if(navigator.userAgent.indexOf("MSIE 5") != -1) document.write(code);
			else document.write(code);
}


function gotolink(link){
	document.location=link;
}

var need_hide = true;
var now_sm_opened = "";


function hiding_pop()
{
	if(need_hide)
	{
		$('.model_sm').fadeOut(1);
	}
}



$(document).ready(function(){


	$('.ccol a').each(function(){
		link = $(this).attr('href');
		if( ($(this).attr("target")) && ( (link.indexOf('.jpg') > 0) || (link.indexOf('.JPG') > 0) ) ) $(this).lightbox();
		if( ($(this).attr("target")) && ( (link.indexOf('.png') > 0) || (link.indexOf('.PNG') > 0) ) ) $(this).lightbox();
//		if( ($(this).attr("target")) && (link.indexOf('.jpg') > 0) ) $(this).fancybox();
		//if( ($(this).attr("target")) && ( (link.indexOf('.jpg') > 0) || (link.indexOf('.JPG') > 0) ) ) $(this).fancybox();
	});


	$('img').hover(
		function()
		{
			if( (!$(this).hasClass('act')) && ($(this).attr('hover')) )
			{
				tmp = $(this).attr('src');
				$(this).attr('src', $(this).attr('hover'));
			}
		},
		function()
		{
			if( (!$(this).hasClass('act')) && ($(this).attr('hover')) )
			{
				$(this).attr('src', tmp);
			}
		}
	);

	$('img').each(function(){
		if( ($(this).hasClass('act')) && ($(this).attr('hover')) )
		{
			$(this).attr('src', $(this).attr('hover'));
		}
	});


	$('.menu li.toggle a').click(
		function()
		{
			sm = $(this).attr('sm_name');
			if(sm){
				if($('#'+sm)){
					$('.menu ul.submenu').each(function(){ $(this).hide(); } );
					$('.menu li').each(function(){
						$(this).removeClass('act');
					});

					$('#'+sm).show();
					$(this).parent().addClass('act');
					$(this).blur();
				}
			}
			return false;
		});


	$('.sliders li a').click(function(){

		$('#'+$(this).attr('block')).toggle(200);
		return false;
	});




	$('.model_menu a').hover(
		function()
		{
			need_hide = false;
			sm = $(this).attr('sm_name');
			if(sm)
			{
				if(sm != now_sm_opened)
				{
					if(now_sm_opened!="")$('.'+now_sm_opened).fadeOut(1);
					now_sm_opened = sm;
				}
				if($('.'+sm))
				{
					$('.'+sm).fadeIn(1);
				}
			}
		},
		function()
		{
			need_hide = true;
			setTimeout( 'hiding_pop();', 100);
		}
	);
	
	$('.model_sm div').hover(
		function()
		{
			need_hide = false;
		},
		function()
		{
			need_hide = true;
			setTimeout( 'hiding_pop();', 100);
		}
	);


	$('.link_but').click(function(){
		$('.bltp').each(function(){
			$(this).hide();
		});
		$('.link_but').each(function(){
			$(this).removeClass('selected');
		});
		
		$('#'+$(this).attr('show_bl')).show();
		$(this).addClass('selected');



		return false;
	});

/*
//меню
		$(".model_menu li").hover(function () {
		//$(this).has('div').children("a").addClass("on");
		$(this).children("ul.model_sm").stop(true, true).slideDown('fast');		  		 
		 }, function() {
		 $(this).children("ul.model_sm").css({"display":"none"});
		// $(this).children("a").removeClass("on");
		 })	
	*/
});




