
SAF2010 = {
	isToday : (function() {
		today = { O: new Date };
		today.M = today.O.getMonth() + 1;
		today.D = today.O.getDate();
		return (today.M == 4 && today.D == 1);
	})(),
	modules : {}
}



SAF2010.modules.WanzaiNow = {
	Now : "",
	ARS : 0, // Auto Refreshing System :)
	Set : function() {
		var P_CLASS = SAF2010.isToday ? "on-air" : "off-air";
		var STRONG_HTML = SAF2010.isToday ? "On Air" : "Off Air";
		sML.write('<div class="ticker" id="wanzai-now"><p class="' + P_CLASS + '"><strong class="uppercase">' + STRONG_HTML + '</strong> <em>' + this.Now + '</em></p></div>');
		if(this.ARS) setTimeout(this.Ref, 1000*10);
	},
	Ref : function() {
		var WanNow = document.getElementById("wanzai-now");
		var EMElem = WanNow.getElementsByTagName("em")[0];
		var EMText = EMElem.innerHTML;
		var SCRIPT = document.createElement("script");
		SCRIPT.type = "text/javascript", SCRIPT.src = "/2010/now/wanzai-now.js";
		WanNow.appendChild(SCRIPT);
		if(SAF2010.modules.WanzaiNow.Now != EMText) {
			EMElem.innerHTML = SAF2010.modules.WanzaiNow.Now;
			if(SAF2010.modules.WanzaiNow.ARS) setTimeout(SAF2010.modules.WanzaiNow.Ref, 1000*60*10);
		} else if(SAF2010.modules.WanzaiNow.ARS) setTimeout(SAF2010.modules.WanzaiNow.Ref, 1000*10);
	}
}



SAF2010.modules.USTREAM = {
	Set : function() {
//		var IDs = SAF2010.isToday ? { oID: "utv505497", mID: "3560993" } : { oID: "utv740011", mID: "3560435" };
		var IDs = { oID: "utv505497", mID: "3560993" };
		sML.fp.set("ustream", IDs.oID, "http://www.ustream.tv/flash/mediastream/" + IDs.mID, 479, 584, 8, {
			bgcolor : "#000000",
			allowfullscreen : "true",
			allowscriptaccess : "always",
			flashvars : "autoplay=false&amp;brand=embed&amp;cid=" + IDs.mID
		});
	}
}


SAF2010.modules.Archive = {
	Set : function() {
		sML.write('<div class="archive"><a rel="external" href="http://www.youtube.com/user/SINAPmovies">YouTube: 当日の様子 録画一覧 &raquo;</a></p></div>');
	}
}



SAF2010.modules.comments = {
	Prep : function() {
		sML.write(
			'<div id="comment_pagination"></div>',
			'<div id="comment_view"></div>',
			'<div id="comment_pagination2"></div>'
		);
	}
}



SAF2010.modules.FlickrSlideshow = {
	Set : function() {
		Src = 'http://www.flickr.com/photos/sinapinc/sets/72157623559157929/show/with/4480586000/';
		sML.write('<iframe align="center" src="' + Src + '" frameBorder="0" scrolling="no"></iframe>');
	}
}



sML.onRead.addEventListener(function() {

	var BODY = document.getElementsByTagName("body")[0];

	SAF2010.PageName = BODY.id;

	sML.setButtonInteractions([document.getElementById("global-nav")], ["_hover", "_active", "_hover"]);

	foreach(BODY.getElementsByTagName("a"), function(A) {
		if(A.getAttribute("rel") == "external") A.onclick = A.onkeypress = function() {
			open(this.href);
			return false;
		}
	});

	if(SAF2010.PageName == "home") SAF2010.modules.USTREAM.Set();

});
