/*
$(document).ready(function(){
	$.ajax({
		type: "post",
		dataType: "json",
		url: "/com_27zb/shopping/configlist.action",
		success: getGoldConfig		
	});					   
});
*/
/*得到今日金价方法*/
/*
function getGoldConfig(date){
	
	document.getElementById('glod').innerHTML = '<img src="/com_27zb/mall/images/ico/div_load.gif" border="0" width="32" height="32"/>';
	
	if(date.length>0){
		var str = "";
		for(var i=0;i<date.length;i++){
			if(i == date.length){
			  str += '<dl style="border:none;">';
			  str += '<dt>'+date[i].configName+'</dt>';
			  str += '<dd>'+date[i].configPara1+'</dd>';
			  str += '<dd>'+date[i].configPara2+'</dd>';
			  str += '</dl>';
			}else{
			  str += '<dl>';
			  str += '<dt>'+date[i].configName+'</dt>';
			  str += '<dd>'+date[i].configPara1+'</dd>';
			  str += '<dd>'+date[i].configPara2+'</dd>';
			  str += '</dl>';				
			}
		}
		document.getElementById('glod').innerHTML = str;
	}
}
*/

/*商品分类*/
$(document).ready(function(){
	document.getElementById('goods_catalog').innerHTML = '<img src="/com_27zb/mall/images/ico/div_load.gif" border="0" width="32" height="32"/>';						   
	$.ajax({
		type: "post",
		dataType: "json",
		url: "/goods/parent_json.action",
		success: getGoodsParent		
	});		
});

function getGoodsParent(date){
	if(date.length>0){
		var str = "";
		for(var i=0;i<date.length;i++){	
			if(date[i].parentId == 0){
				var page = ''
				switch(date[i].ptypeId){
					case 1009:
						page = 'zs';break;
					case 1086:
						page = 'ss';break;
					case 1016:
						page = 'fc';break;
					case 1034:
						page = 'bs';break;
					case 1000:
						page = 'hj';break;
					case 1052:
						page = 'scp';break;
				}
				str += '<dl>';
				str += '<dt><a href="/product/type/'+page+'/'+date[i].ptypeId+'">'+date[i].ptypeName+'</a></dt>';
				str += '<dd>';
				for(var j=0;j<date.length;j++){
					if(date[i].ptypeId == date[j].parentId){
						str += '<a href="/product/typeid/'+date[j].ptypeId+'">'+date[j].ptypeName+'</a>';
					}
				}
				str += '</dd>';
				str += '</dl>';
			}
		}
	}
	document.getElementById('goods_catalog').innerHTML = str;	
}

/*投票*/
function pollVote(){
	var ids = getCheckId();
	$.ajax({
		type: "post",
		dataType: "json",
		data: {ids:ids},
		url: "/vote/poll.action",
		success: resultVoteClass		
	});
		//alert("投票成功！");
}
//$(window).height();
function resultVoteClass(date){
	if(date.retcode == 0){
		alert("投票失败！");
	}else{
		//window.location = '/mall/vote.jsp';
		alert("投票成功！")
	}
}

function showResult(id){
	$.ajax({
		type: "post",
		dataType: "json",
		data: {id:id},
		url: "/vote/show.action",
		success: resultShowClass		
	});	
}

function resultShowClass(date){
	var bW = $(window).width();
	var bH = $(window).height();				
	var sW = $("#showVoteRs").width();
	var sH = $("#showVoteRs").height();
	
	var str="";
	if(date.length>0){
		for(var i=0;i<date.length;i++){
			str += '<li>'+(i+1)+'.'+date[i].name+'<span>('+date[i].count+')</span></li>';
		}
		document.getElementById('showResult').innerHTML = str;
	}
	
	$("#showVoteRs").show(300);
			//"top":bH/2 - sH/2 - 720,
	$("#showVoteRs").css({"left":bW/2 - sW/2});
	$("#close_showVoteRs").click(function(){
		$("#showVoteRs").hide(300);								  
	});	
}

/*
$(function(){
	$("#votebtn").click(function(){
			var bW = $(window).width();
			var bH = $(window).height();				
			var sW = $("#showVoteRs").width();
			var sH = $("#showVoteRs").height();
			$("#showVoteRs").show(300);
			//"top":bH/2 - sH/2 - 720,
			$("#showVoteRs").css({"left":bW/2 - sW/2});		
			$("#close_showVoteRs").click(function(){
				$("#showVoteRs").hide(300);								  
				});								 
			});
	});
*/
/*复选框值*/
function getCheckId(){
	var ids = document.getElementsByName('RadioGroup1');
	var values = "";
	for(var i=0;i<ids.length;i++){
		if(ids[i].checked == true){
			values += ids[i].value;
			values += ","
		}
	}
	return values;
}

/*搜索商品类别下拉列表*/
$(document).ready(function(){
	$.ajax({
		type: "post",
		dataType: "json",
		url: "/shopping/typelist.action",
		success: resultClass	
	});
});

function resultClass(date){
	if(date.length>0){
		for(var i=0;i<date.length;i++){
			document.getElementById("type").options.add(new Option(date[i].name,date[i].typeid));
		}
	}else{
		//alert("json is wrong");
	}
}

/*搜索商品品牌下拉立标*/
$(document).ready(function(){
	$.ajax({
		type: "post",
		dataType: "json",
		url: "/shopping/brandjson.action",
		success: resultBrand	
	});	
});

function resultBrand(date){
	if(date.length>0){
		for(var i=0;i<date.length;i++){
			//alert(date[i].parentId);
			if(date[i].parentId == 0){
				document.getElementById("brand").options.add(new Option(date[i].name,date[i].id));
				for(var j=0;j<date.length;j++){
					if(date[j].parentId == date[i].id){
							document.getElementById("brand").options.add(new Option('├ '+date[j].name,date[j].id));					
						}
					}
				}
			//document.getElementById("brand").options.add(new Option(date[i].name,date[i].id));
		}
	}else{
		//alert("json is wrong");
	}	
}

/*黄金专栏*/
/*
$(document).ready(function(){
	$.ajax({
		type: "post",
		dataType: "json",
		url: "/com_27zb/goods/select_column.action?id=1000",
		success: getGoldColumn		
	});	
})

function getGoldColumn(date){
	document.getElementById('gold_column').innerHTML = '<img src="/com_27zb/mall/images/ico/div_load.gif" border="0" width="32" height="32"/>';	
	if(deat.length>0){
		
	}
}
*/
