﻿/**
 * 在各城市间切换
 * 北京　济南　青岛　武汉　南京　上海
 * 长沙　厦门　深圳　广州　东莞
 */
var Citys = new Array();
Citys[0] = new CityClass("北京",new Date("16 Oct 2008,12:00:03 UTC+0800"),"十月十六","时间：2008.10.16  &nbsp; &nbsp;周四14：00-20：00<br />地点：北京市朝阳区京广中心新世界酒店三层（地铁10号线呼家楼站D出口）","img/11/pic15_bj.gif");
Citys[1] = new CityClass("济南",new Date("20 Oct 2008,12:00:03 UTC+0800"),"十月廿","时间：2008.10.20 &nbsp; &nbsp; 周一14：00-19：00<br />地点：济南市泺源大街66号索菲特银座大饭店六楼大宴会厅","img/11/pic15_jn.gif");
Citys[2] = new CityClass("青岛",new Date("22 Oct 2008,12:00:03 UTC+0800"),"十月廿二","时间：2008.10.22 &nbsp; &nbsp;周三14：00-19：00<br />地点：青岛丽晶大酒店","img/11/pic15_qd.gif");
Citys[3] = new CityClass("武汉",new Date("25  Oct 2008,12:00:03 UTC+0800"),"十月廿五","时间：2008.10.25 &nbsp; &nbsp;周六14：00-19：00<br />地点：武汉锦江国际大酒店","img/11/pic15_wh.gif");
Citys[4] = new CityClass("南京",new Date("29 Oct 2008,12:00:03 UTC+0800"),"十月廿九","时间：2008.10.29&nbsp; &nbsp; 周三15：00-20：00<br />地点：南京金陵饭店钟山厅","img/11/pic15_nj.gif");
Citys[5] = new CityClass("上海",new Date("27 Oct 2008,12:00:03 UTC+0800"),"十月廿七","时间：2008.10.27&nbsp; &nbsp; 周一14：00-19：00<br />地点：上海华亭宾馆2楼大宴会厅","img/11/pic15_sh.gif");
Citys[6] = new CityClass("长沙",new Date("31 Oct 2008,12:00:03 UTC+0800"),"十月三十一","时间：2008.10.31&nbsp; &nbsp; 周五14：00-19：00<br />地点：长沙运达喜来登酒店4楼","img/11/pic15_cs.gif");
Citys[7] = new CityClass("厦门",new Date("4 Nov 2008,12:00:03 UTC+0800"),"十一月四","时间：2008.11.04&nbsp; &nbsp; 周二14：00-19：00<br />地点：厦门市国际会展中心","img/11/pic15_xm.gif");
Citys[8] = new CityClass("深圳",new Date("2 Nov 2008,12:00:03 UTC+0800"),"十一月二","时间：2008.11.02&nbsp; &nbsp; 周日14：00-19：00<br />地点：五洲宾馆五洲厅","img/11/pic15_sz.gif");
Citys[9] = new CityClass("广州",new Date("1 Nov 2008,12:00:03 UTC+0800"),"十一月一","时间：2008.11.01&nbsp; &nbsp; 周六10：00-15：00<br />地点：广州花园酒店","img/11/pic15.jpg");
//Citys[10] = new CityClass("东莞",new Date("30 June 2008,12:00:03 UTC+0800"),"五月廿七","启德教育为了方便东莞对留学问题的咨询和解决，启德东莞于2007年11月5日隆重登陆东莞南城","http://www.eic.org.cn/exhibition/LWord/images/dg.jpg");
var Index_ = 0;
function ShowCityList()
{
	var h = "<table width='209' border='0' cellspacing='0' cellpadding='0'><tr>";
	for (var i=0;i<5;i++)
	{
		h += "<td width='32' bgcolor='#f2d1d3'><div align='center' class='heise'>";
		if (i == Index_)
		h += "<a href='#' onclick='ShowCityHTML("+i+");clearInterval(ttt_);return false;'><b>"+ Citys[i].CityName +"</b></a>　";
		else
		h += "<a href='#' onclick='ShowCityHTML("+i+");clearInterval(ttt_);return false;'>"+ Citys[i].CityName +"</a>　";
		h += "</div></td>";
		if (i<4)
		h += "<td width='13'>&nbsp;</td>";
	}
	h += "</tr></table>";
	document.getElementById("ShowList").innerHTML = h;
	h = "<table width='209' border='0' cellspacing='0' cellpadding='0'><tr>";
	for (var i=5;i<Citys.length;i++)
	{
		h += "<td width='32' bgcolor='#f2d1d3'><div align='center' class='heise'>";
		if (i == Index_)
		h += "<a href='#' onclick='ShowCityHTML("+i+");clearInterval(ttt_);return false;'><b>"+ Citys[i].CityName +"</b></a>　";
		else
		h += "<a href='#' onclick='ShowCityHTML("+i+");clearInterval(ttt_);return false;'>"+ Citys[i].CityName +"</a>　";
		h += "</div></td>";
		if (i<Citys.length-1)
		h += "<td width='13'>&nbsp;</td>";
	}
	h += "</tr></table>";
	document.getElementById("ShowList2").innerHTML = h;
}
ShowCityList();
ShowCityHTML(Index_);

function ShowCityHTML(i)
{
	
	Index_ = i;
	ShowCityList();
	
	if (new Date().getYear() < 2000) {
		document.getElementById("ShowDate").innerHTML = (Citys[i].DateTime.getYear()+1900).toString() + "年" + (Citys[i].DateTime.getMonth() + 1).toString() + "月";
	}
	else {
		document.getElementById("ShowDate").innerHTML = Citys[i].DateTime.getYear() + "年" + (Citys[i].DateTime.getMonth() + 1).toString() + "月";
	}
	var diffDay = dateDiff("D",Citys[i].DateTime,new Date());
	document.getElementById("ShowDays").innerHTML = diffDay;
	
	document.getElementById("ShowWeekday").innerHTML = getWeekDay(Citys[i].DateTime.getDay());
	document.getElementById("ShowDay").innerHTML = Citys[i].DateTime.getDate();
	document.getElementById("ShowChinaDate").innerHTML = Citys[i].ChinaDateTime;
	document.getElementById("ShowCity").innerHTML = Citys[i].CityName;
	document.getElementById("ShowInfo").innerHTML = Citys[i].Content;
	document.getElementById("ShowImg").src = Citys[i].Image;
}

function preCity()
{
	clearInterval(ttt_);
	Index_--;
	if (Index_<0)
	{
		return;
	}
	ShowCityList();
	ShowCityHTML(Index_);
}
function nextCity()
{
	clearInterval(ttt_);
	Index_++;
	if (Index_>Citys.length-1)
	{
		return;
	}
	ShowCityList();
	ShowCityHTML(Index_);
}

function nextCityRound()
{
	Index_++;
	if (Index_>Citys.length-1)
	{
		Index_ = 0;
	}
	ShowCityList();
	ShowCityHTML(Index_);
}

function forShow()
{
	ttt_ = window.setInterval('nextCityRound()',5000) ;
}
forShow();

function getWeekDay(i)
{
	switch (i)
	{
		case 1:
		return "周一";
		case 2:
		return "周二";
		case 3:
		return "周三";
		case 4:
		return "周四";
		case 5:
		return "周五";
		case 6:
		return "周六";
		case 0:
		return "周日";
	}
	return "周日";
}

function CityClass(CityName,DateTime,ChinaDateTime,Content,Image)
{
	this.CityName = CityName;
	this.DateTime = DateTime;
	this.ChinaDateTime = ChinaDateTime;
	this.Content = Content;
	this.Image = Image;
}

//计算时间差
function dateDiff(interval, date1, date2)
{
  var objInterval = {'D' : 1000 * 60 * 60 * 24, 'H' : 1000 * 60 * 60, 'M' : 1000 * 60, 'S' : 1000};
  interval = interval.toUpperCase();
  try
  {
   return Math.round((date1 - date2) / eval('(objInterval.' + interval + ')'));
  }
  catch (e)
  {
   return e.message;
  }
  objInterval = null;
}  
