window.onload = function(){  
  $.ajax({
    type: "GET",
    url: "data/OnAirShows.xml",
	contentType:"application/xml;charset=utf-8",
    dataType: "xml",
    success: function(data){OnAir_itemAddCallback(data);},
	error:function(data){alert(data);}
  });  		
  OffAirshows();	
  SUBS_init();
}
function OnAir_itemAddCallback(data)
{

    // Simply add all items at once and set the size accordingly.
    //var items = data.split('|');
	var items = new Array();
	
  $(data).find("show").each(function()
  {
	var pItems = new Array();	
	pItems[0] = $(this).find("name").text();
	pItems[1] = $(this).find("image").text();
	pItems[2] = $(this).find("link").text();
	pItems[3] = $(this).find("showtimes").text();
	pItems[4] = $(this).find("channel").text();
	pItems[5] = $(this).find("desc").text();
	items.push(pItems);

  });
    for (i = 0; i < items.length; i++) {		
		$("#WCONTENT").append(OnAir_getItemHTML(items[i]));
    }
    
};

/**
 * Item html creation helper.
 */
function OnAir_getItemHTML(item)
{

   var str =  '<table width="100%" border="0" cellspacing="0" cellpadding="0"><tr>'+
              '<td width="172" align="left" valign="top"><img src="'+ item[1] +'" alt="'+ item[0] +'" width="172" height="85" border="0"/></td>'+
              '<td align="left" valign="top" style="padding-left:15px;"><span class="showHeading">' + item[0] +' </span><br />'+
              '<span><a href="'+item[2] +'" class="showHighlight" target="_blank">'+  item[2]+'</a></span><br />'+
              '<span class="showDescription">'+ item[5] +'</span><br /><br /><span class="showFeatured">Featured on:</span></td>'+
              '</tr><tr><td height="30" align="left" valign="top" class="showTiming">'+ item[3]+ '</td>'+
              '<td height="30" align="left" valign="top" class="showFeatured" style="padding-left:15px;">'+
			   item[4]+ '</td>'+
              '</tr><tr><td colspan="2" align="left" valign="top" class="showTiming" style="background:url(images/gray-dot.gif) repeat-x;">'+
			  '<img src="images/gray-dot.gif" width="2" height="1" /></td></tr></table><br/>';

    return str;
};

function OffAirshows()
{
	$.ajax({
    type: "GET",
    url: "data/RHS-OffAirShows.xml",
	contentType:"application/xml;charset=utf-8",
    dataType: "xml",
    success: function(data){mycarousel_itemAddCallback(data);}
  });  		

}
function mycarousel_itemAddCallback(data)
{

    // Simply add all items at once and set the size accordingly.
    //var items = data.split('|');
	var items = new Array();
	
  $(data).find("show").each(function()
  {
	var pItems = new Array();	
	pItems[0] = $(this).find("name").text();
	pItems[1] = $(this).find("image").text();
	pItems[2] = $(this).find("shortcode").text();
	pItems[3] = $(this).find("desc").text();
	items.push(pItems);

  });
    for (i = 0; i < items.length; i++) {
		$("#WTID").append(mycarousel_getItemHTML(items[i]));
    }
    
};

/**
 * Item html creation helper.
 */
function mycarousel_getItemHTML(item)
{

   var str =  '<div class="showSnapTd"><table width="100%" border="0" cellspacing="0" cellpadding="0"><tr>'+
              '<td width="52"><img src="' + item[1] + '" width="52" height="52" /></td>'+
              '<td class="showDescription" style="padding-left:5px;"><span class="showHeading">' +
		       item[0] +' -</span> <span class="showHighlight">'+ item[2] +'</span><br>'+
			   item[3] + '</td></tr></table></div>';

    return str;
};

function SUBS_init()
{
	 $.ajax({
    type: "GET",
    url: "data/Subscription.xml",
	contentType:"application/xml;charset=utf-8",
    dataType: "xml",
    success: function(data){SUBS_itemAddCallback(data);}
  });
		
}
function SUBS_itemAddCallback(data)
{

    // Simply add all items at once and set the size accordingly.
    //var items = data.split('|');
	var items = new Array();
	
  $(data).find("show").each(function()
  {
	var pItems = new Array();	
	pItems[0] = $(this).find("name").text();
	pItems[1] = $(this).find("image").text();
	pItems[2] = $(this).find("shortcode").text();
	pItems[3] = $(this).find("desc").text();
	items.push(pItems);

  });
    for (i = 0; i < items.length; i++) {
		$("#SUBS").append(SUBS_getItemHTML(items[i]));
    }
    
};

/**
 * Item html creation helper.
 */
function SUBS_getItemHTML(item)
{

   var str =  '<div class="showSnapTd"><table width="100%" border="0" cellspacing="0" cellpadding="0"><tr>'+
              '<td width="52"><img src="' + item[1] + '" width="52" height="52" /></td>'+
              '<td class="showDescription" style="padding-left:5px;"><span class="showHeading">' +
		       item[0] +' -</span> <span class="showHighlight">'+ item[2] +'</span><br>'+
			   item[3] + '</td></tr></table></div>';

    return str;
};

