/* this prevents dom flickering, needs to be outside of dom.ready event: */
document.documentElement.className += 'js_active';
/*end dom flickering =) */
jQuery.noConflict();
jQuery(document).ready(function($) {
  $('#f_navigate-foot a').click(function(){
 
 location.href = $(this).attr('href');
  	 });
							
  $('.featured-block-foot').cycle({
        fx: 'fade', 
		timeout: 3000,
	    speed: 3000,
        pause: 1,
		containerResize: 0, 
		before:	function(currSlideElement, nextSlideElement, options, forwardFlag) { 
                 
 				}	,
	    after:	function(currSlideElement, nextSlideElement, options, forwardFlag) { 
		
				 }	,
 		cleartype: 1, 
     	pagerEvent: 'mouseover',
 	    fastOnEvent: true,
        pager:  '#f_navigate-foot',
        slideExpr: 'div.hentry',
        pauseOnPagerHover: true,
        pagerAnchorBuilder: function(idx, slide) { 
	         var goods = $(slide).find('img:first').attr('src');
			 var h1 = $(slide).find('h1.page_title a').html();
	         var h1href = $(slide).find('h1.page_title a').attr('href');
  			 return '<li><a href = "'+h1href+'"><img src = "'+goods+'" width="56" height="45"  border="0" alt="'+idx+'" title="'+h1+'" /></a></li>'; 
 
			 
			 }
			 
			 }) ;
  $('.featured-block').cycle({
        fx: 'fade', 
		timeout: 3000,
	    speed: 3000,
        pause: 1,
		containerResize: 0, 
 		before:	function(currSlideElement, nextSlideElement, options, forwardFlag) { 
                 
 				}	,
	    after:	function(currSlideElement, nextSlideElement, options, forwardFlag) { 
		
				 }	,
 		cleartype: 1, 
     	pagerEvent: 'mouseover',
 	    fastOnEvent: true,
        pager:  '#f_navigate',
        slideExpr: 'div.hentry',
        pauseOnPagerHover: true,
        pagerAnchorBuilder: function(idx, slide) { 
	         var goods = $(slide).find('img:first').attr('src');
			 var h1 = $(slide).find('h1 a').html();
  			 return '<li><img src = "'+goods+'" width="56" height="45"  border="0" alt="'+idx+'" title="'+h1+'" /></li>'; 
		}
			 }) ;

    $('.menu li').mouseover(function() {
	if($(this).children('ul')){		
	
  $(this).children('ul').show();
	}
  }).mouseout(function() {
 $(this).children('ul').hide();
  }); 
	
	var catarray = $('.tab-body li.cat-item');
	
   $.each(catarray, function() {
        $($(this).find('ul.children').parent()).find('a:first').after('<span class="parent"><</span>');
	 
   });
//    $('.drop-cats').mouseover(function() {
//	if($(this).children('ul')){	
//	$('.drop-cats h3').addClass('hoveractive');
//  $(this).children('ul').show();
// 	}
//  }).mouseout(function() {
// $(this).children('ul').hide();
// $('.drop-cats h3').removeClass('hoveractive');
// 
//  }); 
    $('.drop-com').mouseover(function() {
	if($(this).children('ul')){	
	$('.drop-com h3').addClass('hoveractive');
  $(this).children('ul').show();
 	}
  }).mouseout(function() {
 $(this).children('ul').hide();
 $('.drop-com h3').removeClass('hoveractive');
 
  }); 
	
   $('.tab-body li.cat-item').mouseover(function() {
	if($(this).children('ul')){								
  $(this).children('ul').show();
 	}
  }).mouseout(function() {
 $(this).children('ul').hide();
 
  }); 
   $('input#searchsubmit').mouseover(function() {
	$(this).addClass('hoveractive');
   }).mouseout(function() {
	$(this).removeClass('hoveractive');
   }); 
   
   /*-- login form --*/
$("#login-form").mouseover(function(){
	$("#loginform").show().css('visibility','visible').fadeTo("slow", 1);
	$("#loginform").parent().find('span.close').show().css('visibility','visible').fadeTo("slow", 1);
});
$("#loginform").parent().find('span.close').click(function(){
	$(this).fadeTo("slow", 0).hide("slow");
	$('#loginform').fadeTo("slow", 0).hide("slow");
});


/*--// login form --*/
/*-- sidebar tabbed content --*/
$('.tabMenu-a > li').click(function(){

    if (!$(this).hasClass('selected')) {    
    $('.tabMenu-a > li').removeClass('selected');
    $(this).addClass('selected');
    $('.box-a .boxBody div.news-roll').slideUp().removeClass('show').hide();
    $('.box-a .boxBody div:eq(' + $('.tabMenu-a > li').index(this) + ').news-roll').addClass('show').slideDown();
   }

  }).mouseover(function() { 
    $(this).addClass('mouseover');
    $(this).removeClass('mouseout');   
    
  }).mouseout(function() { 
    $(this).addClass('mouseout');
    $(this).removeClass('mouseover');    
    
  });
$('.tabMenu-b > li').click(function(){

    if (!$(this).hasClass('selected')) {    
    $('.tabMenu-b > li').removeClass('selected');
    $(this).addClass('selected');
    $('.box-b .boxBody div.news-roll').slideUp().removeClass('show').hide();
    $('.box-b .boxBody div:eq(' + $('.tabMenu-b > li').index(this) + ').news-roll').addClass('show').slideDown();
  

   }

  }).mouseover(function() { 
    $(this).addClass('mouseover');
    $(this).removeClass('mouseout');   
    
  }).mouseout(function() { 
    $(this).addClass('mouseout');
    $(this).removeClass('mouseover');    
    
  });

/*  $('.boxBody #category li').mouseover(function() {

    $(this).css('color','#666');

  }).mouseout(function() {

  });  
*/	
  $('.boxBody li').click(function(){
    window.location = $(this).find("a").attr("href");
  }).mouseover(function() {
  }).mouseout(function() {
  });  	
/*--// sidebar tabbed content --*/
jQuery('#wrapper').kriesi_image_preloader({delay:500, callback:removeloader});	// activates preloader for non-slideshow images
});

// -------------------------------------------------------------------------------------------
// The Image preloader
// -------------------------------------------------------------------------------------------

function removeloader()
{
	 jQuery('.preloading_background').removeClass('preloading_background');
}

(function($)
{
	$.fn.kriesi_image_preloader = function(variables) 
	{
		var defaults = 
		{
			fadeInSpeed: 600,
			delay:500,
			callback: ''
		};
		
		var options = $.extend(defaults, variables);
		
		return this.each(function()
		{	
			var imageContainer = jQuery(this),
				images = imageContainer.find('img').css({opacity:0, visibility:'hidden',display:'block'}),
				imagesParent = images.parent().addClass('preloading_background').css({display:'block'}),
				imagesToLoad = images.length;				
				
				
				imageContainer.operations =
				{	
					preload: function()
					{	
						var stopPreloading = true;
												
						images.each(function(i, event)
						{	
							var image = $(this);							
							if(event.complete == true)
							{	
								imageContainer.operations.showImage(image);
							}
							else
							{	
								image.bind('error load',{currentImage: image}, imageContainer.operations.showImage);
								
							}
 
 image.parent('a').addClass('preloading_background');
 

						});
						
						return this;
					},
					
					showImage: function(image)
					{	
						imagesToLoad --;
						if(image.data.currentImage != undefined) { image = image.data.currentImage;}
													
						if (options.delay <= 0) image.css('visibility','visible').animate({opacity:1}, options.fadeInSpeed);
											 
						if(imagesToLoad == 0)
						{
							if(options.delay > 0)
							{
								images.each(function(i, event)
								{	
									var image = $(this);
									setTimeout(function()
									{	
										image.css('visibility','visible').animate({opacity:1}, options.fadeInSpeed, function()
										{
											$(this).parent().removeClass('preloading_background');
										});
									},
									options.delay*(i+1));
								});
								
								if(options.callback != '')
								{
									setTimeout(options.callback, options.delay*images.length);
								}
							}
							else if(options.callback != '')
							{
								(options.callback)();
							}
							
						}
						
					}

				};
				
				imageContainer.operations.preload();
		});
		
	};
})(jQuery);
