//首页JS


function bindLeftShowListByShowType(showTypeId,typeName)
{
	var cityId=document.getElementById("cityId").value;
	var html='';
	jQuery.getJSON(server+'/index/getShowListByShowType.do?cityId='+cityId+'&showType='+showTypeId,function(data){
		jQuery.each(data.results,function(entryIndex,entry){
			 var showname=entry.showName;
			 if(showname.length>12){
				 showname=showname.substring(0,10)+'...'; 
			 }
			 html +=' <a href="'+server+'/index/getShowDetail.do?showID='+entry.showID+'&cityId='+cityId+'">'+showname+'</a> ';
		});
		//html +='<a class="more ALT" href="'+server+'/index/listInit.do?showTypeId='+showTypeId+'&cityId='+cityId+'">全部'+typeName+' »</a>';
		jQuery('#showTypeList'+showTypeId).append(html); 
	});
}
/**
 *
 */
function bindHome(){
//	var html='<ul id="list-spotlight">';
//	jQuery.getJSON(server+'/index/getRecomments.do',function(data){
//		jQuery.each(data.results,function(entryIndex,entry){
//             html+='<li class="spotlightentry" id="spotlightentry'+entryIndex+1+'"';
//             html+='style="cursor:pointer; background-image:url(/partner/public/front/img/pic1.gif);z-index: 5; background-color: #fff"> ';
//             html+=' <span class="shade-module" id="shade-module'+entryIndex+1+'"> ';
//             html+=' <span class="shade-overflow"> <b></b> ';
//             html+=' <span class="shade-text" id="shade-text'+entryIndex+1+'"> ';	
//             html+='<span> <a class="titlehref" alt="#" href="#">'+entry.title+'</a> </span> ';
//             html+=' <a class="shade-description" alt="#" href="#">'+entry.title+' </a> </span> '; 
//             html+='<a class="shade-button" alt="#" href="#">立刻订票</a> </span> </span> </li>';          
//		});
//		html+='</ul> <ul id="spotlight-buttons">';
//		jQuery.each(data.results,function(entryIndex,entry){
//			
//			html+='<li  id="spot_btn_'+entryIndex+1+'" class="selected"><a href="javascript://" id="rs-btn'+entryIndex+1+'" alt="#">'+entryIndex+1+' </a></li>';
//	            
//		});
//		html+=' <li id="spot_prev" style="margin-left:18px"><a href="javascript://" id="rs-prev" alt="prev">向左</a></li>';
//			html+=' <li id="spot_next"><a href="javascript://" id="rs-next" alt="next">向右</a></li>';
//		html+=' </ul> ';
//		jQuery('#spotlight-button-anchor').append(html); 
//	});
}


function newest(showTypeId){
	jQuery('#onsale_soon_data').empty();
	var cityId=$("#cityId").val();
	var html='';
	html +='<div id="onSaleList">';
	html +='<table border="0" cellpadding="0" cellspacing="0">';
	html +=' <tr>';
	html +='  <th>演出</th>';
	html +='  <th class="txtRt padH10">更新时间</th>';
	html +='  </tr>';
	jQuery.getJSON(server+'/index/getNewestList.do?cityId='+cityId+'&showType='+showTypeId,function(data){
		jQuery.each(data.results,function(entryIndex,entry){
			 var showname=entry.showName;
			 if(showname.length>20){
				 showname=showname.substring(0,20)+'...'; 
			 }
			 html +=' <tr>';
			 html +='   <td width="435" style="text-align:left;"><div class="pad10"> <a title="'+entry.showName+'" href="'+server+'/index/getShowDetail.do?showID='+entry.showID+'&cityId='+cityId+'" class="event">'+showname+'</a> </div></td>';
			 html +='  <td style="text-align:right;" width="150"><div class="pad10" style="font-size:12px;"> '+entry.updateTime.substring(0,16)+' </div></td>';
			 html +=' </tr>';
		});
		html +='</table>';
		html +='</div onSaleList>';
		jQuery('#onsale_soon_data').append(html); 
	});
//	if(showTypeId!=''){
//		window.location.hash='#toplist';
//	}
	pageViewList(showTypeId);
}

function pageViewList(showTypeId){
	$('#onsale_now_data').empty();
	var cityID = $("#cityId").val();
	var html='';
	html +='<div id="onSaleList">';
	html +='<table border="0" cellpadding="0" cellspacing="0">';
	html +=' <tr>';
	html +='  <th>演出</th>';
	html +='  <th class="txtRt padH10">点击数量</th>';
	html +='  </tr>';
	$.getJSON(server+'/index/getShowPageViewList.do?cityID='+cityID,function(data){
		$.each(data.results,function(entryIndex,entry){
			 var showname=entry.showName;
			 if(showname.length>20){
				 showname=showname.substring(0,20)+'...'; 
			 }
			 html +=' <tr>';
			 html +='  <td width="435" style="text-align:left;"><div class="pad10"> <a title="'+entry.showName+'" href="'+server+'/index/getShowDetail.do?showID='+entry.showID+'&cityId='+cityID+'" class="event">'+showname+'</a> </div></td>';
			 html +='  <td style="text-align:right;font-size:12px;" width="150"><div class="pad10"> '+entry.page_view+' </div></td>';
			 html +=' </tr>';
		});
		html +='</table>';
		html +='</div onSaleList>';
		$('#onsale_now_data').append(html); 
	});
}

function bindHotList(index){
	var cityID = $("#cityId").val();
    var address = server+'/index/getShowHotList.do?pageIndex=1&pageCount=4&cityID='+cityID;	
    $('#listThree').empty();
    var html='';
	$.getJSON(address,function(data){
		var imgPath = entry.imgPath ;
		if(imgPath==null||imgPath==''){
			imgPath = server+'/public/images/default.jpg';
		}
		$.each(data.results,function(entryIndex,entry){
			 html +='<li><img src="'+serverAddress+imgPath+'" width="120"></li>';
		});
		$('#listThree').append(html); 
	});
}

function bindSiteList(){
	var cityID = $("#cityId").val();
    var address = server+'/site/getIndexSite.do?limit_start=0&limit_count=5&cityID='+cityID;	
    $('#citydivList').empty();
    var html='';
	$.getJSON(address,function(data){
		$.each(data.results,function(entryIndex,entry){
			html +='<li><a href="'+server+'/site/getSiteInfoBySiteIdPBS.do?siteId='+entry.siteId+'&cityId='+cityID+'" style="float:left;">'+entry.siteName+'</a><span style="float:right; text-align:right;">近期<span style="width:10px;padding:0 5px;">'+entry.shwoCount+'</span>场演出>></span><br style="clear:both;" /></li>';
		});
		$('#citydivList').append(html); 
	});
}

function search(){
	var showName = $("#browse_area").val();
	var cityId = $("#cityId").val();
	showName = encodeURI(encodeURI(showName));
	var showType = $("#major_cat_dropdown").val();
	var timeType=$("#rdc_select_drop").val();
	var address = server+'/index/listInit.do?showName='+showName+'&showTypeId='+showType+'&timeType='+timeType+'&cityId='+cityId;
	window.location.href=address;
}

