$(document).ready(function(){
	change_menu();
	hover_menu();
	//tutorial
	//http://polymathworkshop.com/shoptalk/2010/01/02/jquery-serialscroll-tutorial/
	$('#slideshow').serialScroll({
		items:'li',
		prev:'#screen2 a.prev',
		next:'#screen2 a.next',
		offset:0, //when scrolling to photo, stop 230 before reaching it (from the left)
		step:1,
		start:0, //as we are centering it, start at the 2nd
		duration:1200,
		force:true,
		stop:true,
		lock:false,
		cycle:true, //don't pull back once you reach the end
		easing:'easeOutQuart', //use this easing equation for a funny effect
		jump: false/* , //click on the images to scroll to them !!!!!
		onBefore:function( e, elem, pane, items, pos ){
		alert(e+' '+elem+' '+pane+' '+items+' '+pos);
		//e.preventDefault();
		//if( this.blur )
		//this.blur();
		},
		onAfter:function( elem ){
		}*/
		});
	$('.slideshow_center').serialScroll({
		items:'li',
		prev:'a.btn_slider_left',
		next:'a.btn_slider_right',
		offset:0, //when scrolling to photo, stop 230 before reaching it (from the left)
		step:1,
		start:0, //as we are centering it, start at the 2nd
		duration:3000,
		force:true,
		stop:true,
		lock:false,
		cycle:true, //don't pull back once you reach the end
		easing:'easeOutQuart', //use this easing equation for a funny effect
		jump: false/* , //click on the images to scroll to them !!!!!
		onBefore:function( e, elem, pane, items, pos ){
		alert(e+' '+elem+' '+pane+' '+items+' '+pos);
		//e.preventDefault();
		//if( this.blur )
		//this.blur();
		},
		onAfter:function( elem ){
		}*/
		});
	$('.btn_div').pngFix(); 
});
function set_html() {
	
	return true;
}
function change_item_description()
{
	$('.item_preview a').hover(
		function(){
			var item_id = $(this).attr('class').split('item_preview_').join('');
			$('.cover_name li:visible').hide();
			$('#cover_name_' + item_id).fadeIn("slow");
		},
		function(){}
	);
}

function hover_menu()
{
	$('.main_menu li a').hover(
		function(){
			var menu_id = $(this).attr('href');	
			html_menu = $('.main_menu li:eq(' + menu_id + ') a').html();
			if(html_menu.length > 16){
				$('.main_menu li:eq(' + menu_id + ') a').addClass('two_lines');
			}
		},
		function(){
			var menu_id = $(this).attr('href');	
			html_menu = $('.main_menu li:eq(' + menu_id + ') a').html();
			if(!$('.main_menu li:eq(' + menu_id + ')').hasClass('active') && html_menu.length < 17){
				$('.main_menu li:eq(' + menu_id + ') a').removeClass('two_lines');
			}
		}
	);
}
function change_menu()
{
	$('.main_menu li a').click(function(){
		var menu_id = $(this).attr('href');
		
		html_menu = $('.main_menu li.active a').html();
		if(html_menu.length < 17){
			$('.main_menu li.active a').removeClass('two_lines');
		}
		
		$('.main_menu li.active').removeClass('active');
		$('.main_menu li:eq(' + menu_id + ')').addClass('active');
		$('div.bestseller:visible').hide();
		$('div.bestseller:eq(' + menu_id + ')').fadeIn("slow");
		
		menu = $('.main_menu li:eq(' + menu_id + ') a');
		html_menu = menu.html();
		if(html_menu.length > 16){
			if(!menu.hasClass('two_lines')){
				menu.addClass('two_lines');
			}
		}
	});
}
