				function loadCal(d,m,y,c) {
					 
	  			  loading();
				  var url = "cal_ajax.php";
				  xmlHttp.open("POST", url, true);
				  xmlHttp.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
				  
				  s = "d="+d+"&m="+m+"&y="+y;
				  
				  if(c){
				  	if(c['city']){
						s += "&city="+c['city'];
					}
					if(c['team']){
						s += "&team="+c['team'];
					}
					if(c['league'] && !c['league_all']){
						s += "&league="+c['league'];
					}
				  }
				  
				  xmlHttp.send(s);
				  xmlHttp.onreadystatechange = updateCal;
				}
				function btnloadCal (d,m,y,c) {
					document.location="#cal_frame";
					loadCal(d,m,y,c)
				}
				function updateCal() {
				  if (xmlHttp.readyState == 4) {
 
					  var response = xmlHttp.responseText;
					  var docum = document.getElementById("main_cal");
					  var next_btn = document.getElementById("next_btn");
					  var prev_btn = document.getElementById("prev_btn");
					  var title = document.getElementById("main_cal_title");
					  
					  response = response.split("<cal_data>");
					  docum.innerHTML = response[0];
					  title.innerHTML = response[3];// ;
					  if(response[6] != "()"){
					  	title.innerHTML += "<br><span class='match_list_condition'>(*只顯示符合條件的球賽 - <a href='javascript:cal_show_all()'><font color='#000000'>顯示全部</font></a>)</span>"
						
						//document.location="#cal_frame";
						
					  }
					  if(response[4] == 1){
					  	//eval("loadCal("+response[1]+",con)")
					  }
					  next_btn.onclick=function(){eval("loadCal("+response[1]+",c)")};
					  prev_btn.onclick=function(){eval("loadCal("+response[2]+",c)")};
					
					  now_cal_date = response[5];
					 // alert(now_cal_date)
					  document.getElementById("cal_frame").style.display='block'
				  }
				}
				
				function loadList(page,d,m,y,c) {
				  loadingList()
				  var url = "match_list_ajax.php";
				  xmlHttp.open("POST", url, true);
				  xmlHttp.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
				  
				  s = "page="+page+"&d="+d+"&m="+m+"&y="+y;
				  
				  if(c){
				  	if(c['city']){
						s += "&city="+c['city'];
					}
					if(c['team']){
						s += "&team="+c['team'];
					}
					if(c['league'] && !c['league_all']){
						s += "&league="+c['league'];
					}
				  }
				  
				//  now_cal_date = d+','+m+','+y
				 // alert('l:'+now_cal_date)
				  xmlHttp.send(s);
				  xmlHttp.onreadystatechange = updateList;
				}		
				function updateList() {
				  if (xmlHttp.readyState == 4) {
					  //alert(xmlHttp.responseText)
					  var response = xmlHttp.responseText;
					  var content="<table class='match_list_table'>"
					  var docum = document.getElementById("match_list_container");
					  var title = document.getElementById("match_list_title");
					  var cal = document.getElementById("cal_frame");
					  
					response = response.split("<match>");
					var search_result = response[0];
					//alert(response)
					var metadata_len = 6;
					if(response.length >= metadata_len+1){	
					
					content += "<tr>"
					
					if(search_result == 1){
					//content += "<td class='match_list_cell_header' width='16'></td>";
						content += "<td class='match_list_cell_header' width='80'>日期</td>";
						now_list_date = '0,0,0'
					}else{
						now_list_date = response[2];
					}

					content += "<td class='match_list_cell_header' width='100'>城市</td><td class='match_list_cell_header' width='50'>主隊</td><td class='match_list_cell_header' width='50'>客隊</td><td class='match_list_cell_header'>聯賽</td><td class='match_list_cell_header' width='80'>套票價錢</td>";  
					

					
					content += "<td class='match_list_cell_header' width='30'></td>";
						
					content += "</tr>";
		  
					for(i=metadata_len;i<response.length;i++){
					  	response[i] = response[i].split("<var>");
						
						content += "<tr>";
						
						
						
						if(search_result == 1){
							
						var temp_date = response[i][0].split("-");
						var temp_date_d = parseInt(temp_date[2],10);
						var temp_date_m = parseInt(temp_date[1],10);
						var temp_date_y = parseInt(temp_date[0],10);
						js_str = temp_date_d+','+temp_date_m+','+temp_date_y
						date_str = js_str;
						
						
						//content += "<td class='match_list_cell'></td>";
						content += "<td class='match_list_cell'><div class='cal_btn' onclick='btnloadCal("+js_str+",c)'><img src='../img/calendar.gif'>"+response[i][0]+"</div></td>";
						}
						
						content += "<td class='match_list_cell'>"+response[i][4]+"</td><td class='match_list_cell'>"+response[i][1]+"</td><td class='match_list_cell'>"+response[i][2]+"</td><td class='match_list_cell'>"+response[i][3]+"</td><td class='match_list_cell'>$"+response[i][5]+"起</td>";
						

						
						content += "<td class='match_list_cell'><a href='/form.php?match_id="+response[i][6]+"'><img src='img/app.gif'></a></td>";
						
						content += "</tr>";
					
						//<a href="javascript:switch_page(0,1)"></a>
						
}
					  
					  content += "</table>"
					  page = parseInt(response[3]);
					  total = parseInt(response[4]);
					  trace_msg = response[5];
					  
					  if(trace_msg != "")
					  	alert(trace_msg)
					  
					  if(total == 1){
						  
					  }else{
						
					  page_footer = '<div class="page_footer">';
					  
					  for(i=1;i<=total;i++){
						//alert(page + '==' + i +' =>'+(i == page+1))
						 if(i == page+1){
							page_footer += "<span class='current_page_tag'>"
					  		page_footer += i
						 }else{
							page_footer += "<span class='page_tag' onclick='switch_page(0,"+(i-1)+")'>"
						 	page_footer += i;
						 }
						 page_footer += "</span>"
					  }
					  
					  
					  page_footer += '</div">';
					  content += page_footer;
					  
					  }
					  	document.getElementById('list_remark').style.display='block'
					}else{
						document.getElementById('list_remark').style.display='none'
						var content = '<div class="match_list_msg">對不起！找不到符合條件的球賽</div>';
					}
					  docum.innerHTML =	content;
					  title.innerHTML =	response[1];
					  
					  if(search_result == 1){
					  cal.style.display='none'
					  }
					  
					  document.location="#match_list_frame";
					  

				  }
				}
				
				function loading(){
					var docum = document.getElementById("main_cal");
					loading_text = "now loading....."
					docum.innerHTML = loading_text;
				}
				function loadingList(){
					var docum = document.getElementById("match_list_container");
					loading_text = "<center>now loading.....</center>"
					docum.innerHTML = loading_text;
				}