/**********************************************************************************
* Author : Jeremy Foster
* Contains objects to control the Station Schedule and Calendar objects
*
*
***********************************************************************************/
/*********************************************
* Object used to display the full schedule
**********************************************/
var default_SlideCount = 6;


var GlobalStationScheduleControl = function (scheduleWindowDiv, scheduleDiv, startColumn, columnWidth, slideCount, slideDelay, columns) {
	var ScheduleWindowDiv; // Div that holds the sliding Div
	var ScheduleDiv; // Sliding Div that contains the schedule events
	var StartColumn; // 38 = 7:00PM
	var ColumnWidth; // 120 default
	var SlideCount = default_SlideCount; // 6 default
	var SlideDelay; // 750 default
	var Timer;
	var PixelForgiveness;
	var Columns; // 48 for a 24 hours

	this.init(scheduleWindowDiv, scheduleDiv, startColumn, columnWidth, slideCount, slideDelay, columns);

	return true;
}

// Initialize object
GlobalStationScheduleControl.prototype.init = function(scheduleWindowDiv, scheduleDiv, startColumn, columnWidth, slideCount, slideDelay, columns) {
	if(!startColumn)startColumn=0;
	if(!columnWidth)columnWidth=120;
	if(!slideCount)slideCount=default_SlideCount;
	if(!slideDelay)slideDelay=750;
	if(!columns)columns=48;
	this.ScheduleWindowDiv = jQuery("#" + scheduleWindowDiv);
	this.ScheduleDiv = jQuery("#" + scheduleDiv);
	this.StartColumn = startColumn;
	this.ColumnWidth = columnWidth;
	this.SlideCount = slideCount;
	this.SlideDelay = slideDelay;
	this.PixelForgiveness = 6;
	this.Columns = columns;

	// Slide the schedule over to the start column.
	this.ScheduleDiv.css({position:'relative'}).animate({left:"-=" + (columnWidth * startColumn) + "px"}, 0);
	// Display the SlideRight button in the top right column
	this.checkOverflow();
}

GlobalStationScheduleControl.prototype.slideLeft = function() {
	if (this.StartColumn > 0)
	{
		window.clearTimeout(this.Timer);
		this.clearOverflow();
		var slide = default_SlideCount; //this.SlideCount;
		if (this.StartColumn - 6 < 0) slide = default_SlideCount;
		this.ScheduleDiv.css({position:'relative'}).animate({left:"+=" + this.ColumnWidth * slide + "px"}, this.SlideDelay);
		jQuery("#ScheduleSlideRight" + (this.StartColumn + 6)).find(".STBRight").hide();
		this.StartColumn -= slide;
		window.setTimeout("CDMGlobalStationScheduleControl.checkOverflow()", this.SlideDelay + 15);
		styleLinks();
	}
}

GlobalStationScheduleControl.prototype.slideRight = function() {
	if (this.StartColumn < this.Columns - 7)
	{
		window.clearTimeout(this.Timer);
		this.clearOverflow();
		var slide = default_SlideCount; //this.SlideCount;
		
		if (this.StartColumn + 6 >= this.Columns - this.SlideCount) slide = default_SlideCount;
		this.ScheduleDiv.css({position:'relative'}).animate({left:"-=" + this.ColumnWidth * slide + "px"}, this.SlideDelay);
		jQuery("#ScheduleSlideRight" + (this.StartColumn + 6)).find(".STBRight").hide();
		this.StartColumn += slide;
		window.setTimeout("CDMGlobalStationScheduleControl.checkOverflow()", this.SlideDelay + 15);
		styleLinks();
	}
}

GlobalStationScheduleControl.prototype.showRightButton = function(startColumn) {
	jQuery("#ScheduleSlideRight" + (startColumn)).find(".STBRight").show();
}

GlobalStationScheduleControl.prototype.checkOverflow = function() {
	this.showRightButton(this.StartColumn + 6);
	var window_left = this.ScheduleWindowDiv.position().left; // Schedule window left
	var window_right = this.ScheduleWindowDiv.position().left + this.ScheduleWindowDiv.outerWidth(); // Schedule window right
	var pixel_forgive = this.PixelForgiveness;
	// Loop through and add overlap
	this.ScheduleWindowDiv.find(".ScheduleEvent").each(function() {
		var event = jQuery(this);
		if((event.offset().left < window_left - pixel_forgive
			&& event.offset().left + event.outerWidth() > window_left + pixel_forgive)
			|| (event.offset().left + event.outerWidth() > window_right
			&& event.offset().left < window_right))
		{
			event.toggleClass("ScheduleEventOverlap");

			event.find(".ScheduleColumnContent").each(function() {
				var content = jQuery(this);
				if (event.offset().left < window_left)
				{
					var new_left = window_left - event.offset().left;
					var new_width = content.outerWidth() - new_left;
					content.css({position:"relative",left:(new_left+"px"),width:(new_width+"px")});
				}
				else if ((event.offset().left + pixel_forgive) < window_right && (event.offset().left + event.outerWidth() + pixel_forgive) > window_right)
				{
					var new_width = content.outerWidth() - (content.offset().left + content.outerWidth() - window_right + pixel_forgive);
					content.css({position:"relative",width:(new_width+"px")});
				}
			});
		}
	});
}

GlobalStationScheduleControl.prototype.clearOverflow = function() {
	// Loop through and remove overlap
	this.ScheduleWindowDiv.find(".ScheduleEventOverlap").each(function() {
		var event = jQuery(this);
		var left = event.offset().left;
		event.toggleClass("ScheduleEventOverlap");
		event.unbind();
		event.find(".ScheduleColumnContent").each(function() {
				var content = jQuery(this);
				var width_mod = content.offset().left - left;
				var new_width = content.outerWidth() + width_mod;
				content.css({position:"relative",left:"0px",width:""});
			});
	});
}

/*********************************************
* Object used to control the StationCalendar
**********************************************/
var GlobalCalendar = function(selectedDate, firstDayAvailable, lastDayAvailable, uniqueId, objectName) {
	var Selected;
	var Month;
	var FirstDayAvailable;
	var LastDayAvailable;
	var UniqueId; // A uniqueId that is a part of the id's within the calendar control
	var Increment;
	var ObjectName; // The name of the variable for this GlobalCalendar (i.e. var CMDGlobalCalendar = new GlobalCalendar)

	// Text objects
	var SelectedDayTitle;
	var SelectedMonthTitle;
	var SelectedCalendarTitle;

	this.init(selectedDate, firstDayAvailable, lastDayAvailable, uniqueId, objectName);

	return true;
}

// Initialize object
GlobalCalendar.prototype.init = function(selectedDate, firstDayAvailable, lastDayAvailable, uniqueId, objectName) {
	this.Selected = new Date(selectedDate);
	this.Month = selectedDate.firstDayInMonth();
	this.FirstDayAvailable = firstDayAvailable;
	this.LastDayAvailable = lastDayAvailable;
	this.UniqueId = uniqueId;
	if (!uniqueId) this.UniqueId = "Calendar";
	this.ObjectName = objectName;
	this.Name = objectName;
	this.Increment = 1;
	this.AJAXReplacements; // DivId or Array of DivId's to be replaced by the AJAX call

	// Initialize Text objects
	this.SelectedDayTitle = jQuery("#" + this.UniqueId + "Day");
	this.SelectedMonthTitle = jQuery("#" + this.UniqueId + "Date");
	this.SelectedCalendarTitle = jQuery("#" + this.UniqueId + "Top");

	this.display();
}

// Display the month
GlobalCalendar.prototype.display = function(calendarMonth) {
	if (calendarMonth) this.Month = new Date(calendarMonth);

	var dt = this.startDate();
	var enddate = new Date(new Date(dt).setDate(dt.getDate() + 42)); // There are 42 calendar cells
	var cell = 0;

	this.SelectedDayTitle.html(this.Selected.format("dddd"));
	this.SelectedMonthTitle.html(this.Selected.format("mmmm d, yyyy"));
	this.SelectedCalendarTitle.html("<strong>" + this.Month.format("mmmm") + "</strong>, " + this.Month.format("yyyy"));

	// Loop through calendar cells
	while (dt <= enddate)
	{
		// Change the cell contents
		if (dt.getFullYear() == this.Selected.getFullYear() && dt.getMonth() == this.Selected.getMonth() && dt.getDate() == this.Selected.getDate())
			jQuery("#" + this.UniqueId + "Cell" + cell).html("<a class=\"Live\" href=\"javascript:void(0);\" onclick=\"" + this.Name + ".display();\">" + dt.getDate() + "</a>");
		else if (dt >= this.FirstDayAvailable && dt <= this.LastDayAvailable)
			jQuery("#" + this.UniqueId + "Cell" + cell).html("<a href=\"javascript:" + this.Name + ".selectDate(new Date(" + dt.getFullYear() + "," + dt.getMonth() + "," + dt.getDate() + ")); " + this.Name + ".display();\">" + dt.getDate() + "</a>");
		else
			jQuery("#" + this.UniqueId + "Cell" + cell).html(dt.getDate());

		cell++;
		dt = new Date(dt.getFullYear(), dt.getMonth(), dt.getDate()+1);
	}
}

// Display the next month
GlobalCalendar.prototype.next = function(months) {
	if (!months) months=this.Increment;

	this.display(new Date(this.Month.setMonth(this.Month.getMonth() + months)));
}

// Display the prior month
GlobalCalendar.prototype.previous = function(months) {
	if (!months) months=this.Increment;

	this.display(new Date(this.Month.setMonth(this.Month.getMonth() - months)));
}

// Calculates the 1st day to display on the calendar
GlobalCalendar.prototype.startDate = function(calendarMonth) {
	if (calendarMonth) this.Month = new Date(calendarMonth);

	var start = new Date(this.Month.firstDayInMonth());
	var sub = -1 * start.getDay();
	if (sub!=0) start = new Date(start.setDate(start.getDate() + sub));
	return start;
}

// Changed the selected date
GlobalCalendar.prototype.selectDate = function(selectedDate) {
	this.Selected = selectedDate;
	this.update(CDMGlobal.SelectedRegion.CallSign);
}

// Updates the schedule after making an AJAX call
GlobalCalendar.prototype.update = function(callSign, replaceDivId)
{
	var href = window.location.pathname + "?callsign=" + callSign + "&date=" + this.Selected.format("yyyy") + "/" + this.Selected.format("mm") + "/" + this.Selected.format("dd");
	if (!replaceDivId && this.AJAXReplacements) replaceDivId = this.AJAXReplacements; // Default replaceDivId's
	CDMGlobal.selectRegion(callSign); // Save the selected value
	CDMGlobal.fetchSchedule(href, replaceDivId);
}

/*********************************************
* Object to maintain region information for the page
**********************************************/
var GlobalStation = function(callSign) {
	var SelectedRegion;
	var Regions; // Array of GlobalStationRegion
	var UniqueId; // The unique Id used in various components on the page.
	var LoadingGif; // The image that will display when an AJAX call is made

	this.init(callSign);

	return true;
}

// Initialize object
GlobalStation.prototype.init = function(callSign) {
	this.Regions = [
		new GlobalStationRegion("CIHF", "Atlantic-Maritimes"), 
		new GlobalStationRegion("CHAN", "British Columbia"), 
		new GlobalStationRegion("CHBC", "Okanagan"),
		new GlobalStationRegion("CICT", "Calgary"),
		new GlobalStationRegion("CITV", "Edmonton"),
		new GlobalStationRegion("CISA", "Lethbridge"),
		new GlobalStationRegion("CKND", "Manitoba"),
		new GlobalStationRegion("CIII", "Ontario"),
		new GlobalStationRegion("CHFD", "Thunder Bay"),
		new GlobalStationRegion("CKMI", "Quebec"),
		new GlobalStationRegion("CFRE", "Regina"),
		new GlobalStationRegion("CFSK", "Saskatoon")];

	if (!callSign) this.selectRegion("CIII"); // Default to Ontario
	else this.selectRegion(callSign);
}

// Add a GlobalStationRegion to the array
GlobalStation.prototype.addRegion = function(callSign, name) {
	var region = new GlobalStationRegion(callSign, name);
	this.Regions.push(region);
	return region;
}

// Find the region through the callsign
GlobalStation.prototype.selectRegion = function(callSign, replaceDivId, href) {
	for(i=0; i<this.Regions.length; i++)
	{
		if (this.Regions[i].CallSign == callSign)
		{
			if (this.SelectedRegion && callSign != this.SelectedRegion.CallSign)
			{
				this.SelectedRegion = this.Regions[i];
				this.fetchSchedule(href, replaceDivId);
			}
			else this.SelectedRegion = this.Regions[i]
			return this.Regions[i];
		}
	}
	return false;
}

// Makes AJAX call to fetch data
GlobalStation.prototype.fetchSchedule = function (href, replaceDivId) {
    if (replaceDivId) {
        if (!href) {
            var date = queryString("date");
            if (date && date.length > 0) date = "&date=" + date;

            href = removeParamterFromURL(window.location, "callsign|date");
            if (href.toString().indexOf("?") < 0)
                href += "?";
            else
                href += "&";
            href += "callsign=" + this.SelectedRegion.CallSign + date;
            //href = window.location.pathname + "?callsign=" + this.SelectedRegion.CallSign + date;

            //added by Omer, on the search page, changing region removes the q parameter.. we should add it back

        }
        window.location = href;
        // For some reason IE6/7 and others can't handle jQuery(data) evaluating HTML...
        //jQuery.get(href,  function(data){CDMGlobal.update(data, replaceDivId);}, "html");
        if (this.LoadingGif) this.LoadingGif.show();
    }
}

/* ECK 3_24_2011 - Added Specifically for TodayOnGlobal Widget */
// Find the region through the callsign
GlobalStation.prototype.selectRegionOverride = function (callSign, replaceDivId, href) {
    for (i = 0; i < this.Regions.length; i++) {
        if (this.Regions[i].CallSign == callSign) {
            if (this.SelectedRegion && callSign != this.SelectedRegion.CallSign) {
                this.SelectedRegion = this.Regions[i];
                this.fetchScheduleOverride(href, replaceDivId);
            }
            else this.SelectedRegion = this.Regions[i]
            return this.Regions[i];
        }
    }
    return false;
}

/* ECK 3_24_2011 - Added Specifically for TodayOnGlobal Widget */
// Makes AJAX call to fetch data
GlobalStation.prototype.fetchScheduleOverride = function (href, replaceDivId) {
    if (replaceDivId) {
        if (!href) {

            href = removeParamterFromURL(window.location, "callsign");
            if (href.toString().indexOf("?") < 0) {
                href += "?";
            }
            else {
                href += "&";
            }
            href += "callsign=" + this.SelectedRegion.CallSign;
            //href = window.location.pathname + "?callsign=" + this.SelectedRegion.CallSign + date;

            //added by Omer, on the search page, changing region removes the q parameter.. we should add it back
        }
        window.location = href;
        // For some reason IE6/7 and others can't handle jQuery(data) evaluating HTML...
        //jQuery.get(href,  function(data){CDMGlobal.update(data, replaceDivId);}, "html");
        if (this.LoadingGif) this.LoadingGif.show();
    }
}


// Initializes the dropdown list for the regions
GlobalStation.prototype.setupDropdown = function(dropdown, replaceDivId, loadingGifId) {
	if (loadingGifId) this.LoadingGif = jQuery("#" + loadingGifId);
	if (!dropdown.options) dropdown = jQuery("#" + dropdown);
	if (dropdown)
	{
		for(i=0; i<this.Regions.length; i++)
		{
			var new_option = document.createElement('option');
			new_option.value = this.Regions[i].CallSign;
			new_option.innerHTML = this.Regions[i].Name;
			
			if (this.SelectedRegion.CallSign == this.Regions[i].CallSign) // Default callsign is provided, select it from the dropdown
			{
				this.SelectedRegion = new GlobalStationRegion(this.Regions[i].CallSign, this.Regions[i].Name);
				new_option.selected = true;
			}
			dropdown.append(new_option);
		}
		return true;
	}
	return false;
}

// Update the page with the new calendar data.
GlobalStation.prototype.update = function(data, replaceDivId) {
	if (replaceDivId)
	{
		if (typeOf(replaceDivId) == "array")
		{
			// Loop through divs to be replaced with the returned data.
			for(i=0; i<replaceDivId.length; i++)
			{
				if (!replaceDivId[i]) break; // Issue occurs when the place this code originated is replaced by the AJAX call
				var section = jQuery("#" + replaceDivId[i]);
				if (!section.html()) break;

				var new_section = jQuery(data).find("#" + replaceDivId[i]);
				section.html(new_section.html());
			}
		}
		else
		{
			var s = jQuery(data).find("#" + replaceDivId);
			jQuery("#" + replaceDivId).html(s.html());
		}
		// This is required for the tab style to work correctly.
		// If someone can come up with a shorter way to do this it would be better.
		eval(function(p,a,c,k,e,d){e=function(c){return(c<a?'':e(parseInt(c/a)))+((c=c%a)>35?String.fromCharCode(c+29):c.toString(36))};if(!''.replace(/^/,String)){while(c--){d[e(c)]=k[c]||e(c)}k=[function(e){return d[e]}];e=function(){return'\\w+'};c=1};while(c--){if(k[c]){p=p.replace(new RegExp('\\b'+e(c)+'\\b','g'),k[c])}}return p}('m $j=1o.21();(5($){$.20.1O=5(o){o=$.23({I:F,M:F,18:F,1T:P,1t:F,16:2e,17:F,N:P,Q:1x,J:3,S:0,n:1,1b:F,1p:F},o||{});l 6.15(5(){m b=P,R=o.N?"1C":"C",1i=o.N?"p":"K";m c=$(6),q=$("q",c),11=$("1N",q),1P=11.1M(),v=o.J;9(o.Q){q.2c(11.10(1P-v-1+1).1Q()).26(11.10(0,v).1Q());o.S+=v}m f=$("1N",q),u=f.1M(),k=o.S;c.8("1h","J");f.8({1K:"1k",1E:o.N?"1d":"C"});q.8({1u:"0",1Y:"0",1L:"1R","27-28-29":"1d","z-1U":"1"});c.8({1K:"1k",1L:"1R","z-1U":"2",C:"1c"});m g=o.N?p(f):K(f);m h=g*u;m j=g*v;f.8({K:f.K(),p:f.p()});q.8(1i,h+"L").8(R,-(k*g));c.8(1i,j+"L");9(o.I)$(o.I).B(5(){l E(k-o.n)});9(o.M)$(o.M).B(5(){l E(k+o.n)});9(o.18)$.15(o.18,5(i,a){$(a).B(5(){l E(o.Q?o.J+i:i)})});9(o.1T&&c.1V)c.1V(5(e,d){l d>0?E(k-o.n):E(k+o.n)});9(o.1t)2b(5(){E(k+o.n)},o.1t+o.16);5 1s(){l f.10(k).10(0,v)};5 E(a){9(!b){9(o.1b)o.1b.1y(6,1s());9(o.Q){9(a<=o.S-v-1){q.8(R,-((u-(v*2))*g)+"L");k=a==o.S-v-1?u-(v*2)-1:u-(v*2)-o.n}T 9(a>=u-v+1){q.8(R,-((v)*g)+"L");k=a==u-v+1?v+1:v+o.n}T k=a}T{9(a<0||a>u-v)l;T k=a}b=1x;q.1w(R=="C"?{C:-(k*g)}:{1C:-(k*g)},o.16,o.17,5(){9(o.1p)o.1p.1y(6,1s());b=P});9(!o.Q){$(o.I+","+o.M).U("1B");$((k-o.n<0&&o.I)||(k+o.n>u-v&&o.M)||[]).O("1B")}}l P}})};5 8(a,b){l 25($.8(a[0],b))||0};5 K(a){l a[0].24+8(a,\'1Z\')+8(a,\'2a\')};5 p(a){l a[0].2L+8(a,\'2N\')+8(a,\'2H\')}})(1o);1o.17={2I:5(x,t,b,c,d){l c*(t/=d)*t+b},1S:5(x,t,b,c,d){9(t<d/2)l 2*c*t*t/(d*d)+b;m Z=t-d/2;l-2*c*Z*Z/(d*d)+2*c*Z/d+c/2+b},1J:5(x,t,b,c,d){l-c*t*t/(d*d)+2*c*t/d+b},2F:5(x,t,b,c,d){l c*t/d+b}};$j(y).D(5(){$j(\'.1D .1G\').Y();$j(\'.1D .1g\').B(5(){m w=\'#\'+$j(6).G().G().G().A(\'V\');$j(w+\' .1G\').2D(\'1F\');9(!$j(6).2J(\'s\')){$j(w+\' .1g\').U(\'s\');$j(6).O(\'s\');$j(w+\' .\'+$j(6).A(\'19\')).2K(\'1F\')}T{$j(w+\' .1g\').U(\'s\')}})});$j(y).D(5(){$j(\'.1f .1e\').Y();$j(\'.1f .1e-1H\').1m();$j(\'.1f .12-1H\').O(\'s\');$j(\'.12 a\').B(5(){m w=\'#\'+$j(6).G().G().G().A(\'V\');$j(w+\' .12\').U(\'s\');$j(6).G().O(\'s\');$j(w+\' .1e\').Y();$j(w+\' \'+$j(6).A(\'19\')).1m()})});$j(y).D(5(){m 13=$j(\'#r\').p();5 1j(14){14=14||2m;$j(\'#1I\').8(\'1h\',\'1k\');$j(\'#X a\').O(\'s\');$j(\'#r\').1m().1w({p:13+\'L\'},14,\'1J\')}5 1r(){$j(\'#X a\').U(\'s\');$j(\'#r\').1W().Y();$j(\'#1I\').8(\'1h\',\'J\')}$j(\'#r .12 a\').B(5(){13=$j(\'#r \'+$j(6).A(\'19\')).p()+2l;$j(\'#r\').1W().p(13)});$j(\'#X a\').B(5(){9($j(\'#r\').8(\'2h\')==\'1d\'){$j(\'#r\').8(\'C\',(($j(2i).K()-2q)/2)+\'L\').p(\'1c\');1j(2r)}});$j(\'#X a\').2y(1r);$j(\'#r\').2A(1j,1r)});$j(y).D(5(){m W=2x 2w;$j(\'1q.1l\').15(5(){W[$j(6).A(\'V\')]=$j(6).H()});$j(\'1q.1l\').2s(5(){9($j(6).H()==W[$j(6).A(\'V\')]){$j(6).H(\'\')}});$j(\'1q.1l\').2t(5(){9(!$j(6).H()){$j(6).H(W[$j(6).A(\'V\')])}})});$j(y).D(5(){$j("#1n #2v").1O({M:"#1n .2G",I:"#1n .2u",16:2z,17:"1S",J:4,n:4})});$j(y).D(5(){$j(\'#2j 2g\').2k(5(){y.2p=$j(6).H()})});m 1X=1v.2o.2C();9(1X.2n(\'2B\')>-1){m 1A=1v.2M.2f("2E");m 1z=22(1A[1]);9(1z==7){$j(y).D(5(){$j(\'2d\').15(5(){9($j(6).8(\'1E\')==\'C\'&&$j(6).8(\'1u-1a\')!=\'1c\'){$j(6).8(\'1Y-1a\',$j(6).8(\'1u-1a\'))}})})}}',62,174,'|||||function|this||css|if|||||||||||curr|return|var|scroll||height|ul|GlobalShowsNav|on||itemLength||idParent||document||attr|click|left|ready|go|null|parent|val|btnPrev|visible|width|px|btnNext|vertical|addClass|false|circular|animCss|start|else|removeClass|id|stbInstructions|GlobalHeaderNav_Shows|hide|ts|slice|tLi|tab|pxHeight|lenAnimation|each|speed|easing|btnGo|title|bottom|beforeStart|0px|none|tabcontent|tabbox|head|visibility|sizeCss|showNav|hidden|SearchTextBox|show|GFooterSliderWrapper|jQuery|afterEnd|input|hideNav|vis|auto|margin|navigator|animate|true|call|version|arVersion|disabled|top|accordion|float|slow|children|01|playerFrame|easeout|overflow|position|size|li|jCarouselLite|tl|clone|relative|easeinout|mouseWheel|index|mousewheel|stop|detectAgent|padding|marginLeft|fn|noConflict|parseFloat|extend|offsetWidth|parseInt|append|list|style|type|marginRight|setInterval|prepend|div|200|split|select|display|window|CanadaNetworkContainer|change|125|250|indexOf|userAgent|location|959|500|focus|blur|ScrollBlogPrevious|GFooterSliderWindow|Array|new|mouseleave|1500|hover|msie|toLowerCase|slideUp|MSIE|linear|ScrollBlogNext|marginBottom|easein|hasClass|slideDown|offsetHeight|appVersion|marginTop'.split('|'),0,{}));
	}
	if (this.LoadingGif) this.LoadingGif.hide();
}

/*********************************************
* Object contains station region information
**********************************************/
var GlobalStationRegion = function(callSign, name) {
	var CallSign;
	var Name;

	this.init(callSign, name);

	return true;
}

// Initialize object
GlobalStationRegion.prototype.init = function(callSign, name) {
	this.CallSign = callSign;
	this.Name = name;
}

/*********************************************
* Handy methods
**********************************************/
// Returns a query string parameter value
function queryString( name ){  name = name.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]");  var regexS = "[\\?&]"+name+"=([^&#]*)";  var regex = new RegExp( regexS );  var results = regex.exec( window.location.href );  if( results == null )    return "";  else    return results[1];}

// Better way to determine the typeof a variable
function typeOf(value) {    var s = typeof value;    if (s === 'object') {        if (value) {            if (value instanceof Array) {                s = 'array';            }        } else {            s = 'null';        }    }    return s;}

// Removes show links that we don't have information for
function styleLinks(){
	var primetimeStart = 38; //column 38
	if(CDMGlobalStationScheduleControl){
		var timeNow = CDMGlobalStationScheduleControl.StartColumn;
	} else if(queryString("StartHour")){
		var timeNow = queryString("StartHour")*2;//2 cols per hour
	} else {
		timeNow = 38;
	}
	//alert(timeNow);
	if(timeNow >= primetimeStart){
		jQuery("#CalendarPrimeTime").addClass("currentTime");
		jQuery("#CalendarDayTime").removeClass("currentTime");
	} else {
		jQuery("#CalendarPrimeTime").removeClass("currentTime");
		jQuery("#CalendarDayTime").addClass("currentTime");
	}
}
function addTodayLink(){
	var today = new Date();
	var todayLinkHref = "javascript:CDMCalenderGlobalCalendar.selectDate(new Date("
	+ today.getFullYear() + "," 
	+ today.getMonth() + "," 
	+ today.getDate() + ")); CDMCalenderGlobalCalendar.display();";
	jQuery('<a href="' + todayLinkHref + '">Today</a>').appendTo("#CalenderBottom");
}
/*********************************************
* Initialize Stuff
**********************************************/
var CDMGlobal = new GlobalStation();


