abcf = {};
abcf.Schedule = {
	color1: '#004C73',
	color2: '#666666',
	timeBox: 'time',
	monthBox: 'month',
	time: null,
	date: null,
	querystring: [],
	
	init: function() {
		abcf.Schedule.getQueryString();
		abcf.Schedule.sifr();
		abcf.Schedule.time = abcf.Schedule.querystring['t'] ? abcf.Schedule.querystring['t'] : '18:00-24:00';
		
		abcf.Schedule.timeBox = getTarget(abcf.Schedule.timeBox);
		abcf.Schedule.monthBox = getTarget(abcf.Schedule.monthBox);
		if ( abcf.Schedule.timeBox ) {
			addEvent(abcf.Schedule.timeBox, 'change', abcf.Schedule.setTime);
		}
		if ( abcf.Schedule.monthBox ) {
			addEvent(abcf.Schedule.monthBox, 'change', abcf.Schedule.setMonth);
		}
	},
	
	changeDate: function () {
		window.location = globalObj.pageHref + '?t=' + abcf.Schedule.time + '&d=' + abcf.Schedule.date;
	},
	
	getQueryString: function() {
		var qS = window.location.search;
		if ( !qS ) { 
			return false;
		}
		qS = qS.substring(1);
		var pairs = qS.split('&');
		for ( var index = 0; index < pairs.length; index++ ) {
			if ( pairs[index].indexOf('=') != -1 ) {
				abcf.Schedule.querystring.push(pairs[index].split('=')[0]);
				abcf.Schedule.querystring[pairs[index].split('=')[0]] = pairs[index].split('=')[1];
			}
		}
	},
	
	setMonth: function() {
		abcf.Schedule.date = abcf.Schedule.monthBox.value;
		abcf.Schedule.changeDate();
	},
	
	setTime: function() {
		abcf.Schedule.time = abcf.Schedule.timeBox.value;
		abcf.Schedule.changeDate();
	},
	
	sifr: function() {
		if ( sIFR ) {
			sIFR.replaceElement(named({sSelector:'#mainpane h1 em', sFlashSrc: globalObj.mediaServer + '/abcfamily/images/flash/abc.swf', sColor:abcf.Schedule.color2, sLinkColor:abcf.Schedule.color1, sBgColor:"#FFFFFF", sHoverColor:abcf.Schedule.color1, nPaddingTop:0, nPaddingBottom:0, sFlashVars:'textalign=left', sWmode:'transparent' }));
			sIFR.replaceElement(named({sSelector:'#mainpane label', sFlashSrc: globalObj.mediaServer + '/abcfamily/images/flash/abc.swf', sColor:abcf.Schedule.color2, sLinkColor:abcf.Schedule.color1, sBgColor:"#FFFFFF", sHoverColor:abcf.Schedule.color1, nPaddingTop:0, nPaddingBottom:0, sFlashVars:'textalign=left', sWmode:'transparent' }));
			sIFR.replaceElement(named({sSelector:'#mainpane #bottomPromos h1', sFlashSrc: globalObj.mediaServer + '/abcfamily/images/flash/abc.swf', sColor:abcf.Schedule.color2, sLinkColor:abcf.Schedule.color1, sBgColor:"#FFFFFF", sHoverColor:abcf.Schedule.color1, nPaddingTop:0, nPaddingBottom:0, sFlashVars:'textalign=left', sWmode:'transparent' }));
		}
	}
};
addEvent(document, 'readystatechange', abcf.Schedule.init);