/**
 * jQuery v1.2.3
 * Click an anchor and the selected element fades from 1 to 0 The backgreound 
 * changes to a specified color and then back again on click.
 */
$('document').ready(function(){ //jQuery domready (can also do $j(function(){})
	var timer ;
	var do_timer = true;
	
	
      $("#ul-list-cat li a").click(function(){return false;});
	$("#ul-list-cat li").hover(
		function () {
		  $("#ul-list-cat li").removeClass('active');
		  $(this).addClass('active');
		  $('.hier_page').addClass('hidden').hide();
		  a = $(this).find('a').attr("rel");
		  $($("#"+a)).fadeIn('medium');
		}, 
		function () {
		  
		}
	  );
	$('#box').hover(function(){
		timer.stop();
		do_timer = false;
	})
	
	$(".num").click(function () { 
		rel = $(this).attr('rel');
		split_rel = rel.split("_");
		if(rel != "zero"){
		  $('#hier_'+split_rel[1]).find('.crumple').hide();
		  $("#"+rel).fadeIn('fast');
		}
		return false;
    });

    timer = $.timer(5000, next_one);
    
    function next_one()
	{
	
		if (do_timer)
		{
			  id = 0;
			nid = id + 1;
			length1 = $("#ul-list-cat li").length;
			$("#ul-list-cat li").each(function(el){
			  if($(this).hasClass('active')){
			  id = el;
			  next_id = el+1;
				if(next_id >= length1)
					next_id = 0;
			  }
			})
			next = $("#ul-list-cat li")[next_id];
			$("#ul-list-cat li").removeClass('active');
			$(next).addClass('active');
			$('.hier_page').addClass('hidden').hide();
			a = $(next).find('a').attr("rel");
				 $($("#"+a)).fadeIn('medium');
		}
    
    }
	
	//var origBG = $j('#testElementjQ').css('background-color');
	//var fadeColor = '#DFD1D1';
	//$j('#clickMejQ').toggle(function(){
	//	$j('#testElementjQ').fadeTo('slow', 0).css({
	//		'background' : fadeColor
	//	});
	//	return false;
	//}, function(){
	//	$j('#testElementjQ').fadeTo('slow', 1).css({
	//		'background' : origBG
	//	});
	//	return false;
	//});
	
	
});
