window.onerror = function(){
  return true;
}

$(document).ready(function(){ 
	$(document).pngFix( );
	$("a[rel='lightbox']").fancybox();
	$("#centercolum #top img").parent("a:not(.thumb)").fancybox();
	//$("#centercolum #top a img").parent().attr({'rel':'lightbox'});
	//$("#centercolum .gallery a img").parent().attr({'rel':'not_lightbox'});
	

	$('li').hover(
        function() {
        	$(this).addClass("jshover");
	    	$(this).find('ul').fadeIn("normal");
        },
        function() {
            $(this).removeClass("jshover");        
            $(this).find('ul').fadeOut("fast");
        }
    );

	$("#icons img").hover(
        function() {
			$(this).attr("src",$(this).attr("src").replace(".","_active."));

		},
        function() {
        	$(this).attr("src",$(this).attr("src").replace("_active",""));
		}
    );
    
    /*1111*/
    $(".topmenu img").each(
        function() {
			if ($(this).attr("src").indexOf('_active.') + 1){
				$("#under_header .section").html("<img src='"+$(this).attr('alt')+"' align='left' />"+$(this).attr('rel')+"");
			}
		}
    );
    /*1111*/

	$(".topmenu img").hover(
        function() {
        	if (($(this).attr("src").indexOf('_active.') + 1)==false){
        		$(this).attr("src",$(this).attr("src").replace(".","_active."));
        		tmp=true;
        	}else{
        		tmp=false;
        	};
        	alt=($(this).attr('alt'));
        	$(this).attr('alt',"");
			$("#under_header .section").html("<img src='"+alt+"' align='left' />"+$(this).attr('rel')+""); 
		},
        function() {
        	if (tmp==true){
        	  $(this).attr("src",$(this).attr("src").replace("_active",""));
        	  tmp=false;
        	}
        	$(this).attr('alt',alt);
		}
    );

/*Аксессуары*/
	$("#left_section a").hover(
		function(){
			/*alert($(this).attr('rel'));*/
			$("#left_section .center img").attr('src',$(this).attr('rel'));
		},
		function(){
		}
	);
/*Конец обработки аксессуаров*/
    
	$("#catalog_table table td").hover(
        function() {
			$(this).css("background-repeat","repeat-y");
			$(this).css("background-image","url(images/catalog_selection.jpg)");
			a = $(this).children().attr("title");
			b = $(this).children().attr("alt");
			
			$("#im"+a).attr("src", b);
		},
        function() {
        	$(this).css("background","none");
		}
    );

	$("#catalog_links_sec td").hover(
        function() {
			$(this).css("background-repeat","repeat-y");
			$(this).css("background-image","url(images/catalog_selection.jpg)");
			a = $(this).attr("title");
			b = $(this).attr("alt");
			
			$("#im").attr("src", b);
		},
        function() {
        	$(this).css("background","none");
		}
    );
	
	$("#order input").click(
        function() {
			if ($(this).attr("id")!="button")
				$(this).attr("value","");

		}
    );
	
	$("#order textarea").click(
        function() {
				$(this).attr("value","");

		}
    );
	
	
var onMouseOutOpacity = 0.67;
 $('#thumbs-adv ul.thumbs li').css('opacity', onMouseOutOpacity)
 .hover(
 function () {
 $(this).not('.selected').fadeTo('fast', 1.0);
 },
 function () {
 $(this).not('.selected').fadeTo('fast', onMouseOutOpacity);
 }
 );


			var galleryAdv = $('#gallery-adv').galleriffic('#thumbs-adv', {
				 delay: 2000,
				 numThumbs: 12,
				 preloadAhead: 10,
				 enableTopPager: true,
				 enableBottomPager: true,
				 imageContainerSel: '#slideshow-adv',
				 controlsContainerSel: '#controls-adv',
				 captionContainerSel: '#caption-adv',
				 loadingContainerSel: '#loading-adv',
				 renderSSControls: true,
				 renderNavControls: true,
				 playLinkText: 'Слайдшоу',
				 pauseLinkText: 'Остановить Слайдшоу',
				 prevLinkText: '&lsaquo; Назад',
				 nextLinkText: 'Вперед &rsaquo;',
				 nextPageLinkText: 'Вперед &rsaquo;',
				 prevPageLinkText: '&lsaquo; Назад',
				 enableHistory: true,
				 autoStart: false,
				 onChange: function(prevIndex, nextIndex) {
				 $('#thumbs-adv ul.thumbs').children()
				 .eq(prevIndex).fadeTo('fast', onMouseOutOpacity).end()
				 .eq(nextIndex).fadeTo('fast', 1.0); 
				 },
				 onTransitionOut: function(callback) {
				 $('#slideshow-adv, #caption-adv').fadeOut('fast', callback);
				 },
				 onTransitionIn: function() {
				 $('#slideshow-adv, #caption-adv').fadeIn('fast');
				 },
				 onPageTransitionOut: function(callback) {
				$('#thumbs-adv ul.thumbs').fadeOut('fast', callback);
				
				 },
				 onPageTransitionIn: function() {
				 $('#thumbs-adv ul.thumbs').fadeIn('fast');
				 }
				 
		 });
		 
	
});

				 
