$(document).ready(function(){
	//首页栏目高亮
	$('#headLanmu a').hover(
		function(){
			var obj=$(this).children('img');
			$(obj).attr('src',$(obj).attr('src').replace('image','image/lm'));
		},function(){
			var obj=$(this).children('img');
			$(obj).attr('src',$(obj).attr('src').replace('image/lm','image'));
		}
	);
	//底部高亮
	$('#hpBox a').hover(
		function(){
			var obj=$(this).children('img');
			$(obj).attr('src',$(obj).attr('src').replace('image/ft','image/ht'));
		},function(){
			var obj=$(this).children('img');
			$(obj).attr('src',$(obj).attr('src').replace('image/ht','image/ft'));
		}
	);
	//商品分类选择。
	$("#headCatalog").hover(
		function(){
			if($("#menuCatalog").is(":visible")) return;
			$("#menuCatalog").slideToggle(300);
			$('#selCat').html('全部分类');
			$('#catId').val(0);
		},function(){
			if(!$("#menuCatalog").is(":visible")) return;
			$("#menuCatalog").slideUp(300);
		}
	);
	$("#orderSel").hover(
		function(){
			if($("#orderBox").is(":visible")) return;
			$("#orderBox").slideToggle(300);
		},function(){
			if(!$("#orderBox").is(":visible")) return;
			$("#orderBox").slideUp(300);
		}
	);
	$('#menuCatalog li').click(function(){
		$('#selCat').html($(this).html());
		$('#catId').val($(this).attr('id'));
	});
});
//页面加载信息
function getAjax(str){
	var d=new Date();
	$.ajax({
		url: '/include/ajax.jsp?action='+str+'&t='+d.getTime(),
		type: 'GET',
		dataType: 'text',
		success: function(text){
			$('#'+str).html(text);
			$('#'+str).fadeIn('slow');
		}
	});
}
function getBanner(id){
	$.ajax({
		url: '/include/ajax.jsp?action=recGoods&id='+id,
		type: 'GET',
		dataType: 'text',
		success: function(text){
			$('#bannerGoods').fadeOut('slow',function(){
				$('#bannerGoods').html(text);
				$('#bannerGoods').fadeIn('slow');
			});
		}
	});
}
function gotoCart(){
	var d=new Date();
	$.ajax({
		url: '/include/ajax.jsp?action=goCart&t='+d.getTime(),
		type: 'GET',
		dataType: 'text',
		success: function(text){
			eval(text);
		}
	});
}
/*抢购商品*/
function goRush(id){
	window.location='/goods/detail-'+id+'.html';
}
function showRush(t,d){
	t=t-1;
	d=d-1;
	var m=parseInt(t/60)>=10?parseInt(t/60):"0"+parseInt(t/60);
	var s=(t%60)%60>=10?(t%60)%60:"0"+(t%60)%60;
	var _m=parseInt(d/60)>=10?parseInt(d/60):"0"+parseInt(d/60);
	var _s=(d%60)%60>=10?(d%60)%60:"0"+(d%60)%60;
	if(t>0){
		$('#rushClock').html("抢购中："+m+"'"+s+"\"");
	}else{
		$('#rushClock').html("倒计时："+_m+"'"+_s+"\"");
	}
	setTimeout("showRush("+t+","+d+");",1000);
}
/*显示隐藏*/
function showDiv(id){
	if($('#'+id).is(':visible')){
		$('#'+id).slideUp(300);	
	}else{
		$('#'+id).slideDown(300);	
	}
}
/*分类页面跳转*/
function goPage(urlStr){
	var num=parseInt($('#pageNum').val())>=1?parseInt($('#pageNum').val())-1:0;
	if(urlStr.indexOf('&')>0){
		window.location=urlStr+'&page='+num;
	}else if(urlStr.indexOf('?')>0){
		window.location=urlStr+'page='+num;
	}else{
		window.location=urlStr+num+'.html';
	}
}

