$(function(){

	if(document.getElementById("count_down")){
		var times = ["201005061500", "201005071500", "201005081500", "201005091500", "201005101500", "201005111500", "201005121500", "201005131500", "201005141500", "201005151500", "201005161500", "201005171500", "201005181500", "201005191500", "201005201500", "201005211500", "201005221500", "201005231500", "201005241500", "201005251500", "201005261500", "201005271500", "201005281500", "201005291500", "201005301500", "201006010100", "201006011500", "201006021500", "201006031500", "201006041500", "201006051500", "201006061500", "201006071500", "201006081500", "201006091500", "201006101500", "201006111500", "201006121500", "201006131500", "201006141500", "201006151500", "201006161500", "201006171500", "201006181500", "201006191500", "201006201500", "201006211500", "201006221500", "201006231500", "201006241500", "201006251500", "201006261500", "201006271500", "201006281500", "201006291500", "201006301500", "201006311500", "201007011500", "201007021500", "201007031500", "201007041500", "201007051500", "201007061500", "201007071500", "201007081500", "201007091500", "201007101500", "201007111500", "201007121500", "201007131500", "201007141500", "201007151500", "201007161500", "201007171500", "201007181500", "201007191500", "201007201500", "201007211500", "201007221500", "201007231500", "201007241500", "201007251500", "201007261500", "201007271500", "201007281500", "201007291500", "201007301500", "201007310045", "201007311500", "201008010045", "201008011500", "201008020045", "201008021500", "201008031500"];
		var d = new Date();
		var time = [d.getFullYear(), d.getUTCMonth(), d.getUTCDate(), d.getUTCHours(), d.getUTCMinutes()]
		for(var i = 1; i<time.length; i++) time[i] = (time[i]+"").replace(/^([0-9])$/, "0$1");
		time = time.join("");
		var count_down_file;

		if(time >= "201008021300"){
			count_down_file = "thank_you.gif";
		}else{
			for(var i = 0; i<times.length-1; i++){
				if(time >= times[i] && time < times[i+1]){
					count_down_file = times[i]+".gif";
					break;
				}
			}
		}

/*
		$("#count_down p").html("<a href=\"./application/\" title=\"クリックすると受講お申し込みページに移動します。\"><img id=\"count_down_image\" src=\"./images/piece/count_down/"+count_down_file+"\" /></a>");
*/
		switch(count_down_file){
			case "201007301500.gif" : var countdown_href = "./schedule/all.html"; break;
			case "201007310045.gif" : var countdown_href = "./schedule/day1.html"; break;
			case "201007311500.gif" : var countdown_href = "./schedule/day2.html"; break;
			case "201008010045.gif" : var countdown_href = "./schedule/day2.html"; break;
			case "201008011500.gif" : var countdown_href = "./schedule/day3.html"; break;
			case "201008020045.gif" : var countdown_href = "./schedule/day3.html"; break;
			default : var countdown_href = "./application/"; break;
		}

		if(count_down_file =="thank_you.gif"){
			$("#count_down p").html("<a href=\"http://twitter.com/search?q=cedec\" target=\"_blank\" title=\"Twitter - cedec のリアルタイム結果\"><img id=\"count_down_image\" src=\"./images/piece/count_down/"+count_down_file+"\" /></a>");
		}else{
			$("#count_down p").html("<a href=\"http://twitter.com/search?q=%23cedec2010\" target=\"_blank\" title=\"Twitter #cedec2010 のリアルタイム結果\"><img id=\"count_down_image\" src=\"./images/piece/count_down/"+count_down_file+"\" /></a>");
		}

		$("#count_down_image").load(function(){$("#count_down p").fadeIn();});
	}

});

