// JavaScript Document
var hoteljson=[{"citycode":"SZX","hotel":[
{"hotelName":"东华嘉悦酒店","hotelid":"1E39N","hotelprice":328.0},
{"hotelName":"深圳中南海逸酒店","hotelid":"1EBGS","hotelprice":428.0},
{"hotelName":"海景奥思廷酒店","hotelid":"1E3BT","hotelprice":498.0},
{"hotelName":"深圳凯宾斯基酒店","hotelid":"1E63M","hotelprice":1136.0},
{"hotelName":"华侨城洲际大酒店","hotelid":"1E5P4","hotelprice":1481.0}]},                     
	{"citycode":"PEK","hotel":[{"hotelName":"北京远通维景国际大酒店","hotelid":"1E7BY","hotelprice":214.0},
	                           {"hotelName":"太姥山国际商务酒店","hotelid":"1E6BB","hotelprice":298.0},
	                           {"hotelName":"京瑞温泉国际大酒店(原京瑞大厦)","hotelid":"1E2FO","hotelprice":498.0},
	                           {"hotelName":"强强北京国际商务酒店","hotelid":"1E6N8","hotelprice":169.0},
	                           {"hotelName":"临空皇冠假日酒店 ","hotelid":"1E8FT","hotelprice":999.0}]},
	{"citycode":"SHA","hotel":[{"hotelName":"上海神旺大酒店","hotelid":"1E7LU","hotelprice":508.0},
	                          {"hotelName":"天禧嘉福璞缇客酒店","hotelid":"1E66I","hotelprice":888.0},
	                          {"hotelName":"上海巴黎春天大酒店","hotelid":"1E2UO","hotelprice":558.0},
	                          {"hotelName":"汉庭快捷酒店（上海虹桥机场店）","hotelid":"1E6GL","hotelprice":399.0},
	                          {"hotelName":"上海虹桥美爵酒店","hotelid":"1E7KK","hotelprice":600.0}]},
   {"citycode":"CAN","hotel":[{"hotelName":"广州白云机场铂尔曼大酒店（原广州诺富特白云机场大酒店）","hotelid":"1E644","hotelprice":598.0},
	                          {"hotelName":"白云宾馆","hotelid":"1E074","hotelprice":560.0},
	                          {"hotelName":"广州翡翠皇冠假日酒店","hotelid":"1E8S7","hotelprice":430.0},
	                          {"hotelName":"广东南洋长胜酒店","hotelid":"1E53Y","hotelprice":300.0},
	                          {"hotelName":"白天鹅宾馆","hotelid":"1E077","hotelprice":660.0}]},
	{"citycode":"HGH","hotel":[{"hotelName":"浙江世贸君澜大饭店","hotelid":"1E11J","hotelprice":718.0},
	                          {"hotelName":"杭州望湖宾馆","hotelid":"1E112","hotelprice":350.0},
	                          {"hotelName":"君亭.西湖四季酒店(原世贸西湖四季都市酒店-湖滨店","hotelid":"1E50V","hotelprice":308.0},
	                          {"hotelName":"杭州香格里拉饭店","hotelid":"1E11I","hotelprice":1553.0},
	                          {"hotelName":"杭州欧陆风情假日酒店","hotelid":"1E5B0","hotelprice":238.0}]},
	{"citycode":"CSX","hotel":[{"hotelName":"华天大酒店","hotelid":"1E0EJ","hotelprice":350.0}]}]

var today = new Date();
var tomorrow = new Date(today.valueOf()+1*24*60*60*1000);
function orderdate(d){
	var xyear=d.getFullYear();
	var xmonth=d.getMonth()+1;
	var xdate=d.getDate();
	var text=xyear+"-";
	if (xmonth<10){text+="0"}
	text+=xmonth+"-";
   if (xdate<10){text+="0"}
	text+=xdate;
	return text;
}

function changeTab(obj){
	var menuitems=obj.parentNode.getElementsByTagName("div");
	for(var i=0;i<menuitems.length;i++ ){
		if(menuitems[i].className=="tjjp1"){
		menuitems[i].className="tjjp2";
		}
		obj.className="tjjp1";
		}
	}

function showgjtj(group){
	var roll=document.getElementById("gjpriceroll");
	var table1=document.getElementById("gjpriceroll1");
	var otb=table1.getElementsByTagName("table")[0];
	var table2=document.getElementById("gjpriceroll2");
	var trClass="jp_item3";
	var otr;
	var otd;
	for(var i=otb.rows.length-1;i>=0;i--) {
	 otr=otb.deleteRow(i);
	}
	for(var i=0;i<json.length;i++){
		if (json[i].group==group||group=="全部"){
			otr=otb.insertRow(-1);
		otr.className=trClass;
			if (trClass=="jp_item3"){
				trClass="jp_item4";}
			else
				{trClass="jp_item3";}
			otd=otr.insertCell(-1);
			otd.innerHTML="<a href=\"http://www.cococ.cc/TempusTicket/booking/booking_ticketsgj.jsp\">"+json[i].board+"</a>";
			otd.className="voyage";
			otd=otr.insertCell(-1);
			otd.innerHTML=json[i].rtow;
			otd.className="type";
			otd=otr.insertCell(-1);
			otd.innerHTML=json[i].youxiaoqi;
			otd.className="valid";
			otd=otr.insertCell(-1);
			otd.innerHTML=json[i].sellenddate;
			otd.className="deadline";
			otd=otr.insertCell(-1);
			otd.className="dashedborder red";
			otd.innerHTML=json[i].price+" 起";
			
			otd = otr.insertCell(-1);
			//otd.style.textAlign="right";
			otd.className="buy";
			otd.innerHTML="<a href=\"http://chat16.live800.com/live800/chatClient/chatbox.jsp?companyID=101232&jid=5779940222"+
								"&enterurl=file%3A%2F%2FD%3A%5CProgram+Files%5CTomcat+6%2E0%5Cwebapps%5CCococ%5Ccc%5Ca%5Fchat%2Ehtm"+
								"l&tm=1282291489109\" onClick=\"return checkConfirm()\" target=\"_blank\"><img src=\"skin/images/icon1.gif\"></a>";
			
		}
		if(otb.offsetHeight>=roll.offsetHeight){
			table2.innerHTML=table1.innerHTML;}
		else{
			table2.innerHTML=""+1;}
	}
}

//客服中心部分，对话框中只能显示”全部“栏目中的航班
function  checkConfirm(){		
		var rowElement = event.srcElement.parentElement.parentElement.parentElement;//行元素
		var cellList = rowElement.childNodes;
		var aHref = cellList[0];
		aHrefText = aHref.innerText;
		return confirm("\n确定选择 "+aHrefText+" 航班？\n\n点击确定将转到在线客服中心。");
}

function rollGjprice(){
	var speed=750;
	var roll=document.getElementById("gjpriceroll");
	var table1=document.getElementById("gjpriceroll1");
	var otb=table1.getElementsByTagName("table")[0];
	var table2=document.getElementById("gjpriceroll2");
	table2.innerHTML=table1.innerHTML;
	function MarqueeGj(){
		if(table2.offsetHeight-roll.scrollTop<=0){
		roll.scrollTop-=table1.offsetHeight;}
		else{
		roll.scrollTop+=25;
		}
	}
	var MyMar1=setInterval(MarqueeGj,speed);
	roll.onmouseover=function() {clearInterval(MyMar1)};
	roll.onmouseout=function() {MyMar1=setInterval(MarqueeGj,speed)};
}
function rollCar(){
	var speed=3000;
	var roll=document.getElementById("car");
	var table1=document.getElementById("car1");
	var table2=document.getElementById("car2");
	table2.innerHTML=table1.innerHTML;
	function MarqueeGj(){
		if(table2.offsetHeight-roll.scrollTop<=0){
		roll.scrollTop-=table1.offsetHeight;}
		else{
		roll.scrollTop+=95;
		}
	}
	var MyMar1=setInterval(MarqueeGj,speed);
	roll.onmouseover=function() {clearInterval(MyMar1)};
	roll.onmouseout=function() {MyMar1=setInterval(MarqueeGj,speed)};
}

function showHoteltj(city){
	var otb=document.getElementById("hotelpricetable");
//		var str='<div class="jp_pic"><a target="_blank" href="http://hotel.cococ.cc:8888/HotelSystem/HSServlet.do?searchmode=simplehotelsearch&hotelid='+eval('hotelpicjson.'+city+'1')+'&indate='+todaydate+'&outdate='+tomorrowdate+'" title=""><img src="ad/'+city+'1.jpg" width="215" height="62" alt="" title="" /></a></div>'
		var str='<div class="jp_pic"><a target="_blank" href="http://www.cococ.cc/Cococ/cc/hotel.jsp" title=""><img src="ad/SZX1.gif" width="215" height="62" alt="" title="" /></a></div>'
//		str+='<div class="jp_pic"><a target="_blank" href="http://hotel.cococ.cc:8888/HotelSystem/HSServlet.do?searchmode=simplehotelsearch&hotelid='+eval('hotelpicjson.'+city+'2')+'&indate='+todaydate+'&outdate='+tomorrowdate+'" title=""><img src="ad/'+city+'2.jpg" width="215" height="62" alt="" title="" /></a></div>'
		str+='<div class="jp_pic"><a target="_blank" href="help15.jsp" title=""><img src="ad/SZX2.gif" width="215" height="62" alt="" title="" /></a></div>'
	for(var i=0;i<hoteljson.length;i++){
		if (hoteljson[i].citycode==city){
		for(var j=0;j<hoteljson[i].hotel.length&&j<6;j++){
		str+='<div class="jd_item1" title="'+hoteljson[i].hotel[j].hotelName+'"><div class="book"><a target="_blank" href="/HotelSystem/HSServlet.do?searchmode=simplehotelsearch&hotelid='+hoteljson[i].hotel[j].hotelid+'&checkInDate='+todaydate+'&checkOutDate='+tomorrowdate+'" title="">预定</a></div><div class="jd_price">￥'+hoteljson[i].hotel[j].hotelprice+'起</div>'+hoteljson[i].hotel[j].hotelName+'</div>'
		}
		}
	}
	otb.innerHTML=str;
}

function showTopad(file){
	var topad=document.getElementById("topad");
	topad.innerHTML='<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0" width="655" height="198"><param name="movie" value="flash/tmgg.swf" /><param name="quality" value="high" /><param name="BGCOLOR" value="#D4D0C8" /><param name="wmode" value="transparent" /><embed src="flash/tmgg.swf" width="655" height="198" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" bgcolor="#D4D0C8" wmode="transparent"></embed></object>';
	topad.style.backgroundImage="url('"+file+"')";
}
function showNews(){
	var newsblock;
	var tourblock;
	var hkgblock;
	for(var i=0;i<newsjson.length;i++){
		if (newsjson[i].ClassName=="新闻"){
			newsblock='<div class="hotnews_p"><a target="_blank" href="http://msg.cococ.cc/news_view.asp?id='+newsjson[i].News[0].NewsId+'" ';
			newsblock+='title="'+newsjson[i].News[0].title+'"><img src="'+newspic+'"  title="'+newsjson[i].News[0].title+'" width="88" height="66"></a></div>';
			newsblock+='<div class="mian31_tt"><h5><a target="_blank" href="http://msg.cococ.cc/news_view.asp?id='+newsjson[i].News[0].NewsId+'" ';
			newsblock+='title="'+newsjson[i].News[0].title+'">'+newsjson[i].News[0].title+'</a></h5><p>'+newsjson[i].FirstNews+'</p>';
			newsblock+='</div><div class="clear"></div><div class="line4"></div><div class="clear"></div>';
			newsblock+='<ul class="list03">';
			for(var j=1;j<newsjson[i].News.length&&j<8;j++){
			newsblock+='<li><a target="_blank" href="http://msg.cococ.cc/news_view.asp';
			newsblock+='?id='+newsjson[i].News[j].NewsId+'" title="'+newsjson[i].News[j].title+'">'+newsjson[i].News[j].title+'</a></li>';
			}
			newsblock+='</ul>';
			document.getElementById("newsblock").innerHTML=newsblock;
		}
		
		if (newsjson[i].ClassName=="旅游"){
		    tourblock='<div class="hotnews_p"><img src="'+tourpic+'" alt="" title="" /></div>';
			tourblock+='<div class="hotnews"><h5><a target="_blank" href="http://msg.cococ.cc/article_view.asp?id='+newsjson[i].News[0].NewsId+'" ';
			tourblock+='title="'+newsjson[i].News[0].title+'">'+newsjson[i].News[0].title+'</a></h5>'+newsjson[i].FirstNews+'</div>';
			tourblock+='<div class="clear"></div><ul class="list01">';
			for(var j=1;j<newsjson[i].News.length&&j<6;j++){
				tourblock+='<li><a target="_blank" href="http://msg.cococ.cc/article_view.asp?id='+newsjson[i].News[j].NewsId+'" ';
				tourblock+='title="'+newsjson[i].News[j].title+'">'+newsjson[i].News[j].title+'</a></li>';
				}
			tourblock+='</ul>';
			document.getElementById("tourblock").innerHTML=tourblock;
		}
		
		if (newsjson[i].ClassName=="香港"){
		    hkgblock='<div class="hotnews_p"><img src="'+hkgpic+'" alt="" title="" /></div>';
			hkgblock+='<div class="hotnews"><h5><a target="_blank" href="http://msg.cococ.cc/hkarticle.asp?id='+newsjson[i].News[0].NewsId+'" ';
			hkgblock+='title="'+newsjson[i].News[0].title+'">'+newsjson[i].News[0].title+'</a></h5>'+newsjson[i].FirstNews+'</div>';
			hkgblock+='<div class="clear"></div><ul class="list01">';
			for(var j=1;j<newsjson[i].News.length&&j<6;j++){
				hkgblock+='<li><a target="_blank" href="http://msg.cococ.cc/hkarticle.asp?id='+newsjson[i].News[j].NewsId+'" ';
				hkgblock+='title="'+newsjson[i].News[j].title+'">'+newsjson[i].News[j].title+'</a></li>';
				}
			hkgblock+='</ul>';
			document.getElementById("hkgblock").innerHTML=hkgblock;
		}
	}
}

function checkHotel(){
	if(document.hotelform.citycode.value == ""){
		alert("您没有输入城市名称,请输入！");
		return false;
	}
	if(document.hotelform.checkindate.value == ""){
		alert("您还没有输入住日期,请输入（日期格式：YYYY-MM-DD）!");
		return false;
	}
	if(document.hotelform.checkoutdate.value == ""){
	  alert("您还没有输入离店日期,请输入（日期格式：YYYY-MM-DD）!");
	  return false;
	}
	if(todate(document.hotelform.checkindate.value) >= todate(document.hotelform.checkoutdate.value)){
	   alert("离店日期不能小于入住日期,请检查重输入!");
	   return false;
	} 
	document.hotelform.submit();
	return true     
}

function showGldc(){
	document.getElementById("rdate").disabled="true";
//	document.getElementById("rdate").style.backgroundColor="#EEE";
	document.getElementById("transit").style.display="none";
	document.getElementById("return_date").style.display="none";
	document.getElementById("sdate").value=todaydate;
}
function showGlwfc(){
	document.getElementById("rdate").disabled="";
	document.getElementById("transit").style.display="none";
//	document.getElementById("rdate").style.backgroundColor="#FFF";
	document.getElementById("return_date").style.display="";
	document.getElementById("rdate").value=tomorrowdate;
}

function checkGuonei(){
	if(document.gnform.scity.value == ""){
		alert("您没有输入出发城市名称,请输入！");
		document.getElementById('city1').focus();
		return false;
	}
	if(document.gnform.ecity.value == ""){
		alert("您没有输入到达城市名称,请输入！");
		document.getElementById('city2').focus();
		return false;
	}
		if(document.gnform.scity.value == document.gnform.ecity.value){
		   alert("出发城市和到达城市不能相同!");
			document.getElementById('city1').focus();
	   return false;
		} 
	
	if(document.gnform.sdate.value == ""){
		alert("您还没有输入出发日期,请输入!");
		document.getElementById('sdate').focus();
		return false;
	}
	if(document.getElementById("returnFlight").checked){
		if(document.gnform.rdate.value == ""){
			alert("您还没有输入返程日期,请输入!");
		document.getElementById('rdate').focus();
			return false;
		}
		if(todate(document.gnform.sdate.value) >= todate(document.gnform.rdate.value)){
		   alert("返程日期不能小于或等于出发日期,请检查重输入!");
		document.getElementById('sdate').focus();
		   return false;
		} 
	}
	if(document.getElementById("transitFlight").checked){
        var cityth=document.gnform.city3.value ;
	    if(cityth=="" || cityth=="中文/拼音"){
			alert("中转城市不能为空,请输入!");
		    document.getElementById('city3').focus();
			return false;
		}
        if(todate(document.gnform.sdate.value) > todate(document.gnform.zzrq.value)){
		   alert("中转日期不能小于出发日期,请检查重输入!");
		   document.getElementById('zzrq').focus();
		   return false;
		} 
	}
	document.gnform.submit();
	return true     

}
function rollHuabao()
{
	var Picspeed=15;
	var rol=document.getElementById("roll");
	var rol1=document.getElementById("roll1");
	var rol2=document.getElementById("roll2");
	rol2.innerHTML=rol1.innerHTML;
	function Marquee1(){
	if(rol2.offsetWidth-rol.scrollLeft<=0){
	rol.scrollLeft-=rol1.offsetWidth;}
	else{
	rol.scrollLeft++;
	}
	}
	var MyMar1=setInterval(Marquee1,Picspeed);
	rol.onmouseover=function() {clearInterval(MyMar1)};
	rol.onmouseout=function() {MyMar1=setInterval(Marquee1,Picspeed)};
}

function todate(sourstr){
  var result=sourstr.match(/^(\d{1,4})(-|\/)(\d{1,2})\2(\d{1,2})$/);
  if(result==null) return false;
  var d=new Date(result[1], result[3]-1, result[4]);
  return d;
}

function orderdate(d){
	var xyear=d.getFullYear();
	var xmonth=d.getMonth()+1;
	var xdate=d.getDate();
	var text=xyear+"-";
	if (xmonth<10){text+="0"}
	text+=xmonth+"-";
   if (xdate<10){text+="0"}
	text+=xdate;
	return text;
}

function showgntj(){
	   	display(spacieldata,string,threecode); 
    	intervalID=setInterval("display(spacieldata,string,threecode);",5000);
}
function changeTab2(obj){
	//alert("ok");
	var menuitems=obj.parentNode.getElementsByTagName("div");
	
	for(var i=0;i<menuitems.length;i++ ){
		if(menuitems[i].className=="tjjp1"){
		menuitems[i].className="tjjp2";
		}
	}
		obj.className="tjjp1";
		var tagname=obj.innerText;
		
		handleClick(tagname);
		
}
	
function handleClick(tagname) {
        if (intervalID != 0){
		window.clearInterval(intervalID);  
		}
        //var Tabsname=YAHOO.util.Event.getTarget(e);
		//alert(YAHOO.util.Dom.get(Tabsname).innerHTML);
		if (tagname=="全部"){
		threecode="ALL";
		}else{
		threecode=getThreeWordByCity(tagname);
		 
        }
		 
		spacieldata = new specialdatahandle(); 
		spacieldata.threecode=threecode;
		var XML=spacieldata.init();		
	    string=spacieldata.buildString(XML);
	   	display(spacieldata,string,threecode); 
        intervalID=setInterval("display(spacieldata,string,threecode);",5000);		
}