
 var regexpNoScript = /NoScript/;
 var regexpShowNotStarted = /ShowNotStarted/;
 var regexpShowsOver = /ShowsOver/;
 
 
function onair() {

	var VideoFeed = "standard";
	if ($('videoFeed') != null)
	{
		var VideoFeed = $('videoFeed').value;
	}

	if (VideoFeed == "standard")
	{
		var url = "/OnAir/Product.aspx?type=onair&item=onair";
		new Ajax(url, {
				    method: 'get',
				    update: $('onairitem')
			    }).request();
	}
	else if (VideoFeed == "alternate")
	{
		var url = "/OnAir/Product.aspx?type=secondlivefeed&item=onair";
		new Ajax(url, {
				    method: 'get',
				    update: $('onairitem')
			    }).request();	
			    
		//Check to see if the script is coming back. If not we redirect to the Error page
				 
		 if($('onairitem').innerHTML.match(regexpNoScript))
		 {		   
		    window.location = "http://www.qvc.com/OnAir/LiveShow.aspx?config=VideoUnavailable";		    
		 }
		 else if($('onairitem').innerHTML.match(regexpShowNotStarted))
		 {		    
		    //They are hear early
		    window.location = "http://www.qvc.com/OnAir/LiveShow.aspx?config=ShowNotStarted"; 
		 }
		 else if($('onairitem').innerHTML.match(regexpShowsOver))
		 {		   
		    window.location = "http://www.qvc.com/OnAir/LiveShow.aspx?config=ShowOver";		    
		 }		 
	}
}

function refresh() {
	var url = "/OnAir/ShowTitleRefresh.aspx";
	var request = new Json.Remote(url, 
		{
			method: 'get',
			onComplete: function(myJSONObject) 
			{
				$('ctl00_cphHead_liveshow_ShowTitle').setHTML(myJSONObject.showTitle);
				$('ctl00_cphHead_liveshow_RemindMe').setAttribute("href",myJSONObject.showHyperlink);
			}
		}).send();
}
	
window.addEvent('load', function()
{
	onair.periodical(5000);
	
	var RefreshShowTitle = null;
	if ($('refreshShowTitle') != null)
	{
		var RefreshShowTitle = $('refreshShowTitle').value;
	}
	
	if ((RefreshShowTitle == null) || (RefreshShowTitle == true))
	{
		refresh.periodical(60000);
	}
}
);
