//--------------------------------------------------

function yunsuan(num,obj){
	document.getElementById(obj).value= num==1? parseInt(document.getElementById(obj).value)+1:parseInt(document.getElementById(obj).value)-1;
}

$(document).ready(function(){
		
		$('.hoverbox').addClass('gallery_demo');
		
		$('ul.gallery_demo').galleria({
			history   : true, 
			clickNext : true, 
			insert    : '#main_image', 
			onImage   : function(image,caption,thumb) { 
				
				

				caption.css('display','none').fadeIn();
				
				
				var _li = thumb.parents('li');
				
				
				_li.siblings().children('img.selected').fadeTo(500,0.3);
				
				
				thumb.fadeTo('fast',1).addClass('selected');
				
				
				image.attr('title','View full image >>');
			},
			onThumb : function(thumb) { 
				
				
				var _li = thumb.parents('li');
				
				
				var _fadeTo = _li.is('.active') ? '1' : '0.3';
				
				
				thumb.css({display:'none',opacity:_fadeTo}).fadeIn(1500);
				
				
				thumb.hover(
					function() { thumb.fadeTo('fast',1); },
					function() { _li.not('.active').children('img').fadeTo('fast',0.3); } 
				)
			}
		});
	});

$(document).ready(function(){
		var a = new Array();
		var b = new Array();
		var t;var s;
		$("#scroll_down").mouseover(function() {	
		  if(a == 1) {
		   a = [];
		   if(t == 1) t = 0; else return;
		  } 			  
	      $(".product_cate_list_item").scrollTo('+=20px');
	      a.push($(".product_cate_list_item").get(0).scrollTop);
	      if(a.length < 2 || (a[a.length-1] != a[a.length-2])) {
	        setTimeout(function(){$("#scroll_down").mouseover();},100);
	      } else {
	        a = [];t = 1;
	      }
	    }).mouseout(function() {
	      a = 1;
	    }).click(function() {
	      return false;
	    });
	    
	    $("#scroll_up").mouseover(function() {	
		  if(b == 1) {
		   b = [];
		   if(s == 1) s = 0; else return;
		  } 			  
	      $(".product_cate_list_item").scrollTo('-=20px');
	      b.push($(".product_cate_list_item").get(0).scrollTop);
	      if(b.length < 2 || (b[b.length-1] != b[b.length-2])) {
	        setTimeout(function(){$("#scroll_up").mouseover();},100);
	      } else {
	        b = [];s = 1;
	      }
	    }).mouseout(function() {
	      b = 1;
	    }).click(function() {
	      return false;
	    });
	    
	    $('a.ajax_view_product[rel="time"]').parent().addClass('menu_current');
	    
	    $("a.ajax_view_product").mouseover(function() {
	      var div = $('#hot_products_area')[0];
	      var sort = $(this).attr('rel');
	      
	      $("div.ready_to_go").each(function() {
	        if($(this).attr('rel') == sort) {
	          $(this).show();
	        } else if($(this).css('display') != 'none') {
	          $(this).hide();
	        }
	     });
	      
	      $("a.ajax_view_product").each(function() {
	        var li = $(this).parent();
	        if($(this).attr('rel') == sort) {
	          if(!$(li).hasClass('menu_current')) $(li).addClass('menu_current');
	        } else if($(li).hasClass('menu_current')) {
	          $(li).removeClass('menu_current');
	        }
	     });
	      
	     /* while(p) {
	        top += parseInt(p.offsetTop);
	        left += parseInt(p.offsetLeft);
	        p = p.offsetParent;
	      }
	      
	      $("<div id='op_div' class='opacity_layer'></div>")
	        .css({position : 'absolute', width : div.offsetWidth, height : div.offsetHeight, left : left, top : top, zIndex : 800})
	        .appendTo('body');
	        
	      $("<div id='op_image'><img src='/static/ajax-loader.gif' /></div>")
	        .css({position : 'absolute', left : left + div.offsetWidth/2, top : top + div.offsetHeight/2, zIndex : 850})
	        .appendTo('body');
	        
	      $.get('/util/fetch_tag.php', {insertName : 'product_list', cid : 0, sortBy : sort, perLine : 4, 
	                                    num : 4, view : 'design_product_list_top', igOwner : 1}, 
	            function(data) {
	              $('#hot_top5_prods').html(data);
	              $.get('/util/fetch_tag.php', {insertName : 'product_list', sortBy : sort, num : '4,5', perLine : 5,
	                                            view : 'Design_product_list_pleft', igOwner : 1},
	                    function(data) {
	                        $('#hot_top10_prods').html(data);
	                        if($('#op_div')[0]) $('#op_div').remove();
	                        if($('#op_image')[0]) $('#op_image').remove();
	                    }       
	              );
	      });*/
	
	      return false;
	    });
						   
		$(".product_list_pleft_item").hover(function(){$(this).addClass("product_list_pleft_item_hover");},function(){$(this).removeClass("product_list_pleft_item_hover");})				   
						   
		$("#showcart").mouseover(function(){
								if ($(this).hasClass('cartTitleOver') == false){
									$(this).addClass('cartTitleOver');$(this).corner("7px");
									setTimeout("$('#showcart').removeClass('cartTitleOver');",10000);}
								})	
		$("#showcart").click(function(){
								$("#cartCtn").show();})	
		$("p.recommend").click(function(){
								$(".recommendCtn").show();})
		$("p.comment").click(function(){
								$(".commentCtn").show(); if ($(".commentCtn div:first-child").hasClass("precomment")){setTimeout("$('.commentCtn').hide('slow');",3000);}})
		$("#product_recommend>.close").click(function(){
								$(".recommendCtn").fadeOut();})	
		$(".commentform>.close").click(function(){
								$(".commentCtn").fadeOut();})	
		$("#numTip").click(function(){
								$(".fav_cart_productNum").show();})
		$("a.productTip").hover(function(){
								$(".introCtn").show();},
								function(){
								$(".introCtn").hide();})
						     					   
        $(".info_plist tr").mouseover(function(){  
          
                $(this).addClass("over");}).mouseout(function(){ 
                             
                $(this).removeClass("over");})
		
        $(".info_plist tr:even").addClass("alt");
                
		$(".usercp_title tr").mouseover(function(){  
                
                $(this).addClass("hot");})
		                     .mouseout(function(){ 
               
                $(this).removeClass("hot");})

		$(".registerCtn :input.member_id,.registerCtn :input.password").focus(function(){
                                  $(this).addClass("highlight");})
		                       .blur(function(){ 
                                  $(this).removeClass("highlight");})						 
				
    	$(".page_usercp :input").focus(function(){
                                  $(this).addClass("hot");})
		                       .blur(function(){ 
                                  $(this).removeClass("hot");})
		$('#helpTitle1').click(function(){
	                     			$('.helpCtn1').slideToggle('slow');})
		$('#helpTitle2').click(function(){
	                     			$('.helpCtn2').slideToggle('slow');})
			   
		$('.turn_left').click(function(){
									   $('.hoverbox li:hidden:last').slideToggleWidth('slow');
									   if(!$('.hoverbox li:first').hasClass("active")){ $.galleria.prev();}})
		$('.turn_right').click(function(){
										if ($('.hoverbox li:visible').length > 4){
											$('.hoverbox li:visible:first').slideToggleWidth('slow');}
										if(!$('.hoverbox li:last').hasClass("active")){
											$.galleria.next();}})
		$('#form1 input[name=keyword]').mouseover(function(){$(this).focus().select();})
												.click(function(){$(this).attr('value','');})
		$('#info_search').click(function(){$(this).parents('#form1').attr('action', '/info/search.php');$('#frm_search').attr('value', $(this).text());})
		$('#product_search').click(function(){$(this).parents('#form1').attr('action', '/product/search.php');$('#frm_search').attr('value', $(this).text());})
        $('#keywordA').click(function(){
									  $('.keyword_moreA').slideToggle('fast');
									  $('.keyword_moreB').hide();})
		$('#keywordB').click(function(){
									  $('.keyword_moreB').slideToggle('fast');
									  $('.keyword_moreA').hide();})
		$('#frm_search').focus(function(){$(".product_search").addClass("product_search_hot")})
		                .blur(function(){$(".product_search").removeClass("product_search_hot")}) 
		$(".product_list_top_img,.product_list_middle_img").mouseover(function(){$(this).children(".product_list_tip").show();})
		                          .mouseout(function(){$(".product_list_tip").hide();})
	//	$(".comp_arrow").hover(function(){$(".arrow_move").show();setTimeout(function(){$('.arrow_move').hide()},8000);})
	    $('.productName').mouseover( function(){$(this).siblings("div.cartpicShow").hide();$(this).next('div.cartpicShow').show();})
		if ($(".messageTip")){
			setTimeout(function(){$(".messageTip").slideUp('slow');},8000);
		}
	   
});



