
   window.onload = function(){
	 $.ajax({
    type: "GET",
    url: "data/news.xml",
	contentType:"application/xml;charset=utf-8",
    dataType: "xml",
    success: function(data){news_itemAddCallback(data);}
  });
  OffAirshows();
  SUBS_init();			
}
function news_itemAddCallback(data)
{

    // Simply add all items at once and set the size accordingly.
    //var items = data.split('|');
	var items = new Array();
	
  $(data).find("news").each(function()
  {
	var pItems = new Array();	
	pItems[0] = $(this).attr("id");
	pItems[1] = $(this).find("headline").text();
	pItems[2] = $(this).find("publicationdate").text();
	pItems[3] = $(this).find("desc").text();
	items.push(pItems);

  });

    for (i = 0; i < items.length; i++) {
		$("#newsdiv").append(news_getItemHTML(items[i]));
    }
    
};

/**
 * Item html creation helper.
 */
function news_getItemHTML(item)
{

   var str =  '<div id="container" class="letestNewsTd">  <strong>'+item[1]+'</strong><br>'+ item[3] + '</div>'
    return str;
};
function OffAirshows()
{
	$.ajax({
    type: "GET",
    url: "data/RHS-OnAirShows.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;
};


