/*
=O=----------------------------------=O=
	site:	http://templatica.ru
=O=----------------------------------=O=
	e-mail:	info@templatica.ru
=O=----------------------------------=O=
*/

$(document).ready(function () {

	$(".close").click(
		function () {
			$(this).parent().fadeTo(400, 0, function () {
				$(this).slideUp(400);
			});
			return false;
		}
	);

	$(".cart").hover(function(){
		$('.cart-open').slideToggle("fast");
	});

});

// tabs
(function($) {
	$(function() {

/*		$('ul.tabs').delegate('li:not(.current)', 'click', function() {
			$(this).addClass('current').siblings().removeClass('current')
			.parents('div.section').find('div.tbox').hide().eq($(this).index()).fadeIn(150);
		});
*/


		// nw | n | ne | w | e | sw | s | se
		$('.ttop').tipsy({fade: true, gravity: 's'});
	})
})(jQuery);

$(document).ready(function(){
	$('.section .tbox').hide();
	$('.section .tbox:first').show();
	$('.section .tabs li:first').addClass('active');

	$('.section .tabs li a').click(function(){
		$('.section .tabs li').removeClass('active');
		$(this).parent().addClass('active');
		var currentTab = $(this).attr('rel');
		$('.section .tbox').hide();
		$(currentTab).show();
		//$('.tabs li a[rel="'+document.location.hash+'"]').trigger('click');
		return false;
	});
});

// cat menu
(function($){
    $.fn.extend({

    accordion: function(options) {
        
		var defaults = {
			accordion: 'true',
			speed: 300,
			closedSign: '',
			openedSign: ''
		};

		var opts = $.extend(defaults, options);
 		var $this = $(this);

 		$this.find("li").each(function() {
 			if($(this).find("ul").size() != 0){
 				$(this).find("a:first").append("<span>"+ opts.closedSign +"</span>");

 				if($(this).find("a:first").attr('href') == "#"){
 		  			$(this).find("a:first").click(function(){return false;});
 		  		}
 			}
 		});

 		$this.find("li.active").each(function() {
 			$(this).parents("ul").slideDown(opts.speed);
 			$(this).parents("ul").parent("li").find("span:first").html(opts.openedSign);
 		});

  		$this.find("li a").click(function(e) {
  			if($(this).parent().find("ul").size() != 0){
				e.preventDefault();
  				if(opts.accordion){
  					if(!$(this).parent().find("ul").is(':visible')){
  						parents = $(this).parent().parents("ul");
  						visible = $this.find("ul:visible");
  						visible.each(function(visibleIndex){
  							var close = true;
  							parents.each(function(parentIndex){
  								if(parents[parentIndex] == visible[visibleIndex]){
  									close = false;
  									return false;
  								}
  							});
  							if(close){
  								if($(this).parent().find("ul") != visible[visibleIndex]){
  									$(visible[visibleIndex]).slideUp(opts.speed, function(){
  										$(this).parent("li").find("span:first").html(opts.closedSign);
  									});
  									
  								}
  							}
  						});
  					}
  				}
  				if($(this).parent().find("ul:first").is(":visible")){
  					$(this).parent().find("ul:first").slideUp(opts.speed, function(){
  						$(this).parent("li").find("span:first").delay(opts.speed).html(opts.closedSign);
  					});
  					
  					
  				}else{
  					$(this).parent().find("ul:first").slideDown(opts.speed, function(){
  						$(this).parent("li").find("span:first").delay(opts.speed).html(opts.openedSign);
  					});
  				}
  			}
  		});
    }
});
})(jQuery);

$(document).ready(function() {
	$("#CatNavi").accordion({
		accordion:true,
		speed: 500,
		closedSign: '',
		openedSign: ''
	});
});
