(function ($) {

function ClickF(ind) {		
				
		$(".frame:visible").hide();
			
		f = $(".frame").eq(ind);
		//f.css('display', 'none');
		
		//f.find('.button').hide();
		f.fadeIn(800,function() {
			//f.find('.button').show();
		});		
		
		
		$(".minibuttons ul li").removeClass('active');
		$(".minibuttons ul li").eq(ind).addClass('active');	
}

$(document).ready(function() {
	if ($.browser.msie && $.browser.version < 7) {
		DD_belatedPNG.fix('img, div, ul, li, a');
	}
	
	if ($('a.nyroModal').length>0) {
		$.nyroModalSettings({
			processHandler: function(settings) {
			var from = settings.from;
				if (from && from.href && from.href.indexOf('http://www.youtube.com/watch?v=') == 0) {
			$.nyroModalSettings({
			type: 'swf',
			height: 355,
			width: 425			
        });
     } 
    }
  });
	}
	
	var timerId = 0;
			
	timerId =  window.setInterval(function()
	{
		var ind = $(".minibuttons ul li.active").index()+1;			
		
		count = $(".minibuttons ul li").length;
		if (ind==count) {
			ind = 0;
			}
		ClickF(ind);
				
	}, 8000);

	$(".minibuttons ul li").click(function () {
		
		window.clearInterval(timerId);
		ind = $(this).index();
		ClickF(ind);
			
	});
	
	$('.maincontent .productlist .feachlist li, .hlp').mousemove(function(e) {
				
				tl = $(this).find('.title');
												
				tl.css('left',e.pageX-$('.maincontent .work').offset().left+5);				
				//tl.css('display','block');
				

					tl.css('top',e.pageY-$('.maincontent .work').offset().top-tl.height()-15);					
					//tl.stop(true,true).animate({opacity: "show"}, "slow");
					tl.show();	

	
	
	});
	
	$('.maincontent .productlist .feachlist li, .hlp').mouseout(function() {
				tl= $(this).find('.title');
				//tl.stop(true,true).animate({opacity: "hide"}, "slow");				
				tl.hide();
		
	});

  
	$('.maincontent .faqs .q .h').click(function() {
    
		$(this).parent().find('.a').toggle();
		
		if ($(this).parent().find('.a').is(':hidden'))
		$(this).find('.z').html('+')
		else
		$(this).find('.z').html('-')
		
	});

	if ($('.rev').length > 0)
	$('.rev').click(function() {
		
		$(this).parent().find('.content').toggle();
		
		if ($(this).parent().find('.content').is(':hidden')) {
			$(this).html('—Показать отзыв');
		}
		else {
			$(this).html('—Скрыть отзыв');
		}
		
		return false;
	});
		
	$(window).resize(function(){	
		h = $(window).height() - $(document.body).height();
		if ($.browser.msie) {
			if (h>0) {
				$('.maincontent').css("margin-bottom", h+30);				
			}
			}
		else {
			$('.maincontent').css("min-height", h+'px');
		}
	});
	
	
	$(window).resize();
	
		
	if ($('#tabs1').length>0) {
		
		$('#tabs1').tabs();		
						
	}
	
	if ($('#tabs2').length>0) {
		$('#tabs2').tabs();
		
	}
  
  	
/* auth modal form */
	
	$('.modal__openlink').live('click', function(event) {
		event.preventDefault();

		$(this).nyroModalManual({});
		
	});
	
});

}(jQuery));


