$(function () {


  jQuery('.slider').jcarousel({
        scroll: 1,
		visible: 4,
		wrap: 'circular',
		animation: 'slow'
    });

	$('#nav1_drop .img_window img').attr('src',$('#nav1_drop .jcarousel-item:first-child span img').attr('src'));
	$('#nav2_drop .img_window img').attr('src',$('#nav2_drop .jcarousel-item:first-child span img').attr('src'));
	$('#nav3_drop .img_window img').attr('src',$('#nav3_drop .jcarousel-item:first-child span img').attr('src'));

	$('#nav1_drop .jcarousel-item img').click(function() {
		var src=$(this).next('span').find('img').attr('src');
		$('#nav1_drop .img_window img').attr('src',src);
	});
		$('#nav2_drop .jcarousel-item img').click(function() {
		var src=$(this).next('span').find('img').attr('src');
		$('#nav2_drop .img_window img').attr('src',src);
	});
	$('#nav3_drop .jcarousel-item img').click(function() {
		var src=$(this).next('span').find('img').attr('src');
		$('#nav3_drop .img_window img').attr('src',src);
	});



	$('.main_block .img_wrapper img').each(function() {
		$(this).click(function() {
			var main=$(this).parents().parents('.main_block');
			var cur=main.find('.main_nav_drop');
			if (cur.hasClass('show')) {return false;} else {
			$('.main_block').css('z-index','10');
			$('.main_nav_drop').removeClass('show');
			main.css('z-index','50');
			cur.addClass('show');
			}
		})
	});


  	$('.main_nav_drop .close').click(function() {
		$(this).parents().parents().parents('.main_block').css('z-index','10').find('.main_nav_drop').removeClass('show');
	});



	 $('.sub_drop_top ul li:last-child').css('background','none');
	 $('#vac_top ul li:last-child').css('background','none');

	 $(".sub_block, #top_nav ul li").hoverIntent({
	 over: show,
	 out: hide,
	 interval: 30,
	 timeout: 30,
	 sensitivity: 4
	 });

	function show() {
		 var current = $(this);
		 current.find(".sub_drop").show();
	 };
	 function hide() {
		 var current = $(this);
		 current.find("div.sub_drop").hide();
	 };

	 $('.tab_switch li').click(function() {
		var i=$('.tab_switch li').index(this)+1;
		$('.tab_switch li').removeClass('active');
		$(this).addClass('active');
		$('.visible').removeClass('visible');
		$('#tab_block'+i).addClass('visible');
	});

	 $('.contacts_drop_top table tr:first-child td').height('40px');

	 $('#contacts_drop .close').click(function() {
		$('#contacts_drop').css('visibility','hidden');
	})



	 $('#top_nav ul li:last-child').css('margin','0');

	 $('table.description tr:first-child td').css('border-top','none').css('background','#927852').css('color','#fff').height('50px');
	 $('table.description tr td:last-child').css('border-right','none');
	 $('table.description tr:last-child td').height('10px');

	 if ($.browser.mozilla) {

		 $('table.description tr td').height('22px');
		 $('table.description tr:first-child td').height('51px');
		 $('table.description tr:last-child td').height('10px');
	 }

//	$('#contacts').click(function() {
//		$('#contacts_drop').css('visibility','visible');
//	})

//	$('#qw1').click(function() {
//		window.open('new_contact.php?s','OpenWindow','resizable=no,scrollbars=no,width=640,height=500');
//	})

//	$('#qw2').click(function() {
//		window.open('new_contact.php?s','OpenWindow','resizable=no,scrollbars=no,width=640,height=500');
//	})

})

function fn () {
	window.open('new_contact.php','OpenWindow','resizable=no,scrollbars=no,width=640,height=500')
}
function cgf(id) {
	window.open('color.php?catalog='+id,'OpenWindow','resizable=no,scrollbars=no,width=680,height=550')
}
function ra(id) {
	window.open('article.php?catalog='+id,'OpenWindow','resizable=no,scrollbars=no,width=800,height=550')
}
function ctn() {
	document.getElementById('contacts_drop').style.visibility='visible';
}

function or_tbl(id){	if (document.getElementById(id).style.display=='none'){
		$("#"+id).show();
		$("#"+id+'m').attr('src','images/hide.png');
//		document.getElementById(id).style.display='';
	}
	else{
//		document.getElementById(id).style.display='none';
		$("#"+id).hide();
		$("#"+id+'m').attr('src','images/show.png');
   }}
function showall(){
	s=document.getElementById('orct').value;
   ss=s.split(";");
   for (st=0;st<(ss.length-1);st++){
     id="or_"+ss[st];
		$("#"+id).show();
   }
	$("#shord").hide();
	$("#hdord").show();
}
function hideall(){
	s=document.getElementById('orct').value;
   ss=s.split(";");
   for (st=0;st<(ss.length-1);st++){
     id="or_"+ss[st];
		$("#"+id).hide();
   }
	$("#hdord").hide();
	$("#shord").show();
}
function ssb()
{	document.getElementById('sb').submit();
//	form.sb.submit();}
function faq(){
	$("#faq").slideToggle("slow");
}
function _Check()
{
   if ((document.forms.name.value != '') && (document.forms.caption.value != '') && (document.forms.cods.value != '')) {
       return true;
   }
   else {
      alert('Вы не ввели обязательные поля!');
      return false;
   }
   return false;
}

$(document).ready(function() {
	var anch=location.href;
	if (anch.indexOf('#')>0){
		anch=anch.substring(anch.indexOf('#')+1);
		anchDist=$("a[name="+anch+"]:first").offset().top;
		$('html, body').stop().animate({scrollTop: anchDist-0}, 1000 );
	}
});

