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(){
	$('body').pngFix( );
//	$('.browse_square_name').dropShadow({left: 2, top: 2, opacity: 0.8, blur: 1});

//	$('.scroll-pane').jScrollPane({scrollbarWidth:15, showArrows:true, animateTo:true});

	$(".lightboxpopup a").fancybox();
	$('.ccol a').each(function(){
		link = $(this).attr('href');
		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 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();', 200);
		}
	);

	//	
	$('.popsm').hover(
		function()
		{
			need_hide = false;
		},
		function()
		{
			need_hide = true;
			setTimeout( 'hiding_pop();', 200);
		}
	);

	

	$('#b_browsecat_block_open').click(
		function()
		{
			$(this).fadeOut(200);
			$('#b_browsecat_block_close').fadeIn(200);
			$(this).parent().parent().next().show(300);
		}
	);

	$('#b_browsecat_block_close').click(
		function()
		{
			$(this).fadeOut(200);
			$('#b_browsecat_block_open').fadeIn(200);
			$(this).parent().parent().next().hide(300);
		}
	);

	$('.browse_square').hover(
		function()		
		{
			if(!$(this).hasClass('act'))
			{
				$(this).next().fadeIn(200);
				$(this).next().next().fadeIn(200);
				$('.browse_square_bg', this).addClass('hover');
			}
		},
		function()		
		{
			$(this).next().fadeOut(200);
			$(this).next().next().fadeOut(200);
			if(!$(this).hasClass('act'))
				$('.browse_square_bg', this).removeClass('hover');
		}
	);

	$('.browse_square').click(
		function()		
		{
			$(this).next().fadeOut(200);
			$(this).next().next().fadeOut(200);
			$(this).animate({"top":"-410px", "left":"315px", "width":"250px", "height":"270px" }, 200, "linear",
				function()
				{
					$(this).fadeOut(200);
					$('.browse'+$(this).attr('browse')).fadeIn(200);
					$('.browse'+$(this).attr('browse')).css({'z-index':'4'});
				}
			);
			$(this).addClass('act');
		}
	);



	$('.b_browse_square_info_close').click(
		function()
		{
			$(this).parent().parent().css({'z-index':'1'});
			$(this).parent().parent().fadeOut(300);
			square = $(this).parent().parent().prev().prev().prev();
			square.fadeIn(200);
			square.removeClass('act');
			$('.browse_square_bg', square).removeClass('hover');
			square.animate({"top":(square.attr('y'))+"px", "left":(square.attr('x'))+"px", "width":"31px", "height":"31px" }, 200, "linear");
		}
	);


		$(".roll_btn").click(function(){
		$(this).next("#roller").slideToggle("slow");
		$(this).toggleClass("roll_on");
	});
	
	//FancyBox
	$("a#fb").fancybox();

	$("a.group").attr('rel', 'fancybox').fancybox();

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

