var last = 3; 
var init = 0; 
var timer; 
var active;
var image_item = 0;

function sliderLoop(){
	active = $('#slider ul:eq(1) li:eq('+init+') a');
	content = $('#slider-images li:eq('+init+')');
	
	//RESET
	$('#slider ul:eq(1) li a').removeClass('active');
	$('#slider-images li').stop().animate({'opacity': 0}, 1000);
	active.addClass('active');
	content.stop().animate({'opacity': 1}, 1000);
	
	init = init+1;
	if(init > 3) init = 0;
	timer = setTimeout("sliderLoop()",5000);	
	
}

function stopLoop() {
	clearTimeout(timer);
}

$(function(){
	/* IE FIX */
	$('#prefooter ul li:eq(0), #prefooter ul li:eq(1), #prefooter ul li:eq(2), #prefooter ul li:eq(3), #prefooter ul li:eq(4)').css({'display':'block'});
	
	/* IE FIX */

	$('#product_list li').removeClass('ajax_block_product');
	
	$('#pagination li a').click(function() { 
			var thislink = $(this).attr('href');
			window.location.replace(thislink);
			$('#product_list *').stop();
		});

	var setheight = 0;
	$('#addresses #right-col .addresses ul').each(function(i) {				
		if(setheight < $(this).height()) setheight = $(this).height();
	});
	$('#addresses #right-col .addresses ul').css({'height':setheight+'px'});
	
	var catsetheight = 0;
	$('#subcategories ul li').each(function(i) {				
		if(catsetheight < $(this).height()) catsetheight = $(this).height();
	});
	$('#subcategories ul li').css({'height':catsetheight+'px'});
	
	var productsetheight = 0;
	$('#product_list li').each(function(i) {		
		if(productsetheight < $(this).height()) productsetheight = $(this).height();
	});
	$('#product_list li').css({'height':productsetheight+'px'});
	
	/*
	var catsetheight = 0;
	$('#addresses #right-col .addresses ul').each(function(i) {				
		if(setheight < $(this).height()) setheight = $(this).height();
	});
	$('#addresses #right-col .addresses ul').css({'height':setheight+'px'});
	*/
	
	$('#contact-form #right-col h1').html('Contact us <span>Send us you inquiries</span>');	

	//
	$('#categories_block_left ul.dhtml, header ul ul').show();
	$('header > ul > li > ul').hide();
	$('#product_list .discount').parent().children('div').children('.price').addClass('sale');
	$('#product_list .discount').hide();
	
	$('#views_block #view_scroll_left').removeClass('hidden') ;
	
	//PRODUCT LIST
	
	$('#product_list li').each(function(i) {
		$('.center_block > a', this).css({'background':'#fff url('+$('.center_block > a img', this).attr('src')+') center no-repeat'});
	});
	
	/* ADDED JULY 18 2011 START */
	/*
	$('#categories_block_left .block_content > ul > li > ul > li:gt(5)').hide();
	$('<li><a href="" class="cust_cat_more">more...</a></li>').insertAfter('#categories_block_left .block_content > ul > li > ul > li:eq(5)');
	
	$('#categories_block_left .block_content > ul > li > ul > li > ul > li:gt(2)').hide();
	$('<li><a href="" class="cust_cat_more">more...</a></li>').insertAfter('#categories_block_left .block_content > ul > li > ul > li > ul > li:eq(2)');
	
	*/
	
	//$('.cust_cat_more').attr('href', $(this).parent().parent().parent().children('a').attr('href'));
	/* ADDED JULY 18 2011 END */
	
	//CATEGORY	
	$('#categories_block_left .block_content ul li ul').hide();	
	
	$('#categories_block_left .block_content ul li li').each(function(i) {
		if($(this).has('ul').length === 0) $('a' ,this).css({'background-image':'none'});	
		if($(this).children('a').hasClass('cust_cat_more')) $(this).children('a').attr('href',$(this).parent().parent().children('a').attr('href'));
	}); 
	
	$('#subcategories .inline_list li').each(function(i) {
		$('a:eq(0)', this).css({'background':'#fff url('+$('a:eq(0) img', this).attr('src')+') center no-repeat'});
	});
	
	//CATEGORY
	
	$('#categories_block_left .block_content ul li ul').hide();
	$('#categories_block_left .block_content ul li a').hover(
			function() { 
					$(this).parent().children('ul').stop(true, true).show();
					if(!($(this).parent().children('ul').length == 0)) $(this).addClass('shover');
					}, 
			function() { 
					$(this).parent().children('ul').stop(true, true).hide();
					$(this).removeClass('shover');
					});
	$('#categories_block_left .block_content ul li ul').hover(
			function() { 
					$(this).stop().show();
					$(this).parent().children('a').addClass('shover');
					}, 
			function() { 
					$(this).stop().hide();
					$(this).parent().children('a').removeClass('shover');
					});
	
		
	$('#categories_block_left .block_content > ul > li > ul > li > ul').each(function(i) { 
		if($('li', this).size() > 10) { 
			$(this).parent().children('a').css({'background-image':'none'});
			$(this).html('');
		}
	});
	
	//BANNER HOME
	if($('body').attr('ID') == 'index') {
		$('#slider-images li').animate({'opacity': 0}, 0);
		
		$('#slider ul:eq(1) li a').click(function() {
			clearTimeout(timer);
			$('#slider ul:eq(1) li a').removeClass('active');
			$(this).addClass('active');
			init = $(this).parent().index();
			sliderLoop();
		});
		sliderLoop();
	}
	
	//pageformat
	var sliderH = $('#slider').height();
	var pfootW = $('#prefooter').width();
	
	$('#banner-nav dl').css({'height':(sliderH/3)-2});
	/*
	var logoCount = 0;
	var setmargin = 0;
	$('#prefooter li').each(function() {
		logoCount = logoCount + $(this, 'img').width() + 10;
		setmargin = ($(this, 'img').height()/2)/2;
		$(this, 'img').css({'margin-top':'-38px'})
		if(logoCount > pfootW) { 
			logoCount = logoCount - $(this, 'img').width();
			$(this).hide();
		}
		return true;
	});
	$('#prefooter nav').css({'width':logoCount, 'margin':'0 auto', 'border':'1px solid #000;'});
	
	//MANUFACTURER'S LIST
	
	$('#prefooter nav li').each(function(i) {
		$('a', this).css({'background':'#fff url('+$('a img', this).attr('src')+') center no-repeat', 'width':$('a img', this).width()+'px'});
	});
	
	$('#prefooter nav li a img').css({'display':'none'});
	*/
	
	//banner loop
	
	//navigation
	$('#header > ul > li > a').hover(function() {
		$(this).parent().has('ul').children('ul').show();		
	}, function() {
		$(this).parent().has('ul').children('ul').hide();		
	});
	
	$('#header > ul > li > ul').hover(function() { 
		$(this).show();
		$(this).parent().children('a').addClass('active');
	}, function() {
		$(this).hide();
		$(this).parent().children('a').removeClass('active');
	});
	
	//item-images
	
	//$('#search_query_top').focus();
	
	$('#search_query_top').click(function() {
		if($(this).val() == 'Search') $(this).val('');
	});
});

$(function(){var e=new Date();var d=e.getFullYear();if(d<2010){d=2010} $("#year").html(" | Copyright &#169; "+d);});

