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

var need_hide = true;
var now_sm_opened = "";

var	nav_need_hide = true;
var nav_now_sm_opened = "";


function hiding_pop()
{
	if(need_hide)
	{
		$('.sm').fadeOut(1);		
		$('#page_h').fadeIn(1);
		$('#logoya').fadeIn(1);
	}
}
function hiding_pop2()
{
	if(nav_need_hide)
	{
		$('.nav_pop').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('.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 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))
				{
					$('#page_h').fadeOut(1);
					$('#logoya').fadeOut(1);
					$('.'+sm).fadeIn(1);
				}
			}
		},
		function()
		{
			need_hide = true;
			setTimeout( 'hiding_pop();', 100);
		}
	);
	
	$('.sm').hover(
		function()
		{
			need_hide = false;
		},
		function()
		{
			need_hide = true;
			setTimeout( 'hiding_pop();', 100);
		}
	);



	$('.tabs td').click(
		function()
		{
			if($(this).hasClass('cell'))
			{
				$('.tabs td').removeClass('act');
				$(this).addClass('act');
				$('.tab_cat_info').hide();
				$("#"+$(this).attr('doc_cat')).show();
			}
		}
	);


	$('.complbase_check').click(
		function()
		{
			if($(this).attr('checked'))
			{
				$('#complbase'+$(this).attr('compl_id')+'_name').show();
				$('.complbase'+$(this).attr('compl_id')+'_cell').show();
			}
			else
				{
					$('#complbase'+$(this).attr('compl_id')+'_name').hide();
					$('.complbase'+$(this).attr('compl_id')+'_cell').hide();
				}
		}
	);


	$('.compladd_check').click(
		function()
		{
			if($(this).attr('checked'))
			{
				$('#compladd'+$(this).attr('compl_id')+'_name').show();
				$('.compladd'+$(this).attr('compl_id')+'_cell').show();
			}
			else
				{
					$('#compladd'+$(this).attr('compl_id')+'_name').hide();
					$('.compladd'+$(this).attr('compl_id')+'_cell').hide();
				}
		}
	);
	
	$('.b_rmbcolse img').click(
		function()
		{
			$('.rmbaner').fadeOut(300);
			$(this).fadeOut(300);
		}
	);

	$('.open_form').click(
		function()
		{
			num = $(this).attr('num');
			$('#fid'+num).toggle(200);
		}
	);

	$('.sm').hover(
		function()
		{
			need_hide = false;
		},
		function()
		{
			need_hide = true;
			setTimeout( 'hiding_pop();', 100);
		}
	);





	$('.nav_string td table td a').hover(
		function()
		{
			nav_need_hide = false;
			sm = $(this).attr('pop_name');
			if(sm)
			{
				if(sm != nav_now_sm_opened)
				{
					if(nav_now_sm_opened!="")$('.'+nav_now_sm_opened).fadeOut(1);
					nav_now_sm_opened = sm;
				}
				if($('.'+sm))
				{
					$('.'+sm).fadeIn(1);
				}
			}
		},
		function()
		{
			nav_need_hide = true;
			setTimeout( 'hiding_pop2();', 100);
		}
	);


	$('.nav_pop').hover(
		function()
		{
			nav_need_hide = false;
		},
		function()
		{
			nav_need_hide = true;
			setTimeout( 'hiding_pop2();', 100);
		}
	);

	



});




