jQuery(document).ready(function(){
	jQuery("#headercart").hover(function(){
		jQuery(".cart-content").fadeIn("show");
	},
	function(){		
		jQuery(".cart-content").hide();		
	});
	var compare = jQuery(".block-compare");
	var closes= jQuery(".block-compare .close");
	var contents= jQuery(".block-compare .block-content");
	
	closes.click(function(){
		compare.hide();		
	});
	
	if($('#compare-items .item').length){
		compare.show();
	}else{
		compare.hide();
	}
	$ = jQuery;
	
	$("#mainmenv").find('ul').find('li').hover(function(){	

		var menv2 = $(this).find('.menv2');
			$(this).find('a:first').addClass("over");
			menv2.show();
		
	var lev2 = $(this).find('.lev2');	
		if(lev2.length > 0){
			$(this).find('a:first').addClass("over");
			lev2.show();
		}
	},
	function(){
		var menv2 = $(this).find('.menv2');

			$(this).find('a:first').removeClass("over");
			menv2.hide();

		var lev2 = $(this).find('.lev2');
		if(lev2.length > 0){
			$(this).find('a:first').removeClass("over");
			lev2.hide();
		}
	});
	
	$(".lev2").find('li').hover(function(){		
			$(this).find('a:first').addClass("over");
			$(this).find('ul').show();
	},function(){
			$(this).find('a:first').removeClass("over");
			$(this).find('ul').hide();
		
	});
		
	//蛋糕
	$(".sendcity .select").click(function(){		
		$(this).toggleClass("on");
		$(".city_zxsn").toggle();

	})
	
	$(".sendcity").hover(function(){
	},
	function(){
		$(".sendcity .select").removeClass("on");
		$(".city_zxsn").hide();
	})
		
});

function SelectStyle(on,option){
	on = "." + on;
	option = "." + option;
	var currentSort = $(on).attr('id');
	var currentText = $(option+" li."+currentSort + " a").html();
	$(on + " .text").addClass(currentSort).html(currentText);
	
	$(".selectbox").hover(function(){
		$(option).show()
	},function(){		
		$(option).hide()
		
	})
}

function decorateDataList(el, option){
	//option; // ['odd','even','first','last']
	$(el).find('>:last-child').addClass('last');
	$(el).find('>:first-child').addClass('first');
	$(el).find('>:nth-child(even)').addClass('even');
	$(el).find('>:nth-child(odd)').addClass('odd');
	
}
function decorateList(el,hover){
	el = '#' + el;
	$(el).find('>:last-child').addClass('last');
	$(el).find('>:first-child').addClass('first');
	$(el).find('>:nth-child(even)').addClass('even');
	$(el).find('>:nth-child(odd)').addClass('odd');
	if(hover){
		$(el).find('>*').hover(function(){
			$(this).addClass('hover');
		},
		function(){
			$(this).removeClass('hover');
		});
		}
}
function decorateTable(el){
	el = '#' + el;
	$(el).find('tbody tr:nth-child(even)').addClass('even');
	$(el).find('tbody tr:nth-child(odd)').addClass('odd');
	$(el).find('tr:last-child').addClass('last');
	$(el).find('tr:first-child').addClass('first');
}


function popWin(url,win,para) {
    var win = window.open(url,win,para);
    win.focus();
}
function setLocation(url){
    window.location.href = url;
}

function hoverdiv(mc,oper){
	$(mc).hover(function(){
		$(this).addClass("hoverbg");
		$(this).find(oper).show()
	},
	function(){
		$(this).find(oper).hide()
		$(this).removeClass("hoverbg");
	});
	
}

function formatNumber(number) {
	var parts = number.toString().split('.');
	var integer = parts[0].split('');
	var decimal = parts[1];
	var start = integer.length % 3;
	var length = integer.length;
	if(start == 0) {
		start = 3;
	}
	while(start < integer.length) {
		integer.splice(start, 0, ',');
		start += 4;
	}
	return [integer.join(''), decimal].join('.');
}
