$(document).ready(function() {
	$("a[rel=group]").fancybox({
		'hideOnContentClick': false,
		'transitionIn'	:	'elastic',
		'transitionOut'	:	'elastic',
		'speedIn'		:	600, 
		'speedOut'		:	200, 
		'overlayShow'	:	true
	});
/*	$("a.fb").fancybox({
		'hideOnContentClick': false,
		'transitionIn'	:	'elastic',
		'transitionOut'	:	'elastic',
		'speedIn'		:	600, 
		'speedOut'		:	200, 
		'overlayShow'	:	false
	});*/
});

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)
	{
		$('.popsm').fadeOut(1);		
	}
}



$(document).ready(function(){


	$('.ccol a').each(function(){
		link = $(this).attr('href');
//		if( ($(this).attr("target")) && (link.indexOf('.jpg') > 0) ) $(this).lightbox();
		if( ($(this).attr("target")) && (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'));
		}
	});


	$('.color_picker').click(
		function()
		{
			$('.color_picker').each(function()
			{
				$(this).removeClass('clicked');
			});
			$('.color_name').each(function()
			{
				$(this).hide();
			});
			$(this).addClass('clicked');
			$('#color_block').attr('src', $(this).attr('link') );
			$('#cn'+$(this).attr('num')).show();
		});


	$('.gallery_picker').click(
		function()
		{
			$('.gallery_picker').each(function()
			{
				$(this).removeClass('clicked');
			});
			$(this).addClass('clicked');
			$('#gallery_block').attr('src', $(this).attr('link') );
		});


	$('.color_picker').hover(
		function()
		{
			
		},
		function()
		{
		}
	);





	$('.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);
		}
	);
	
	$('.popsm').hover(
		function()
		{
			need_hide = false;
		},
		function()
		{
			need_hide = true;
			setTimeout( 'hiding_pop();', 100);
		}
	);

	$('.modelDataTable .categoryHeadline').each(function(){
		$(this).children().attr("colspan","3");
	});

	


});




