/*-------------------------GLOBALS-------------------------*/

var CurrentPage;
/*---------------------------------------------------------------*/
function getResults(Category,Language,TimeSpan,PageSize,PageNo) {
	var myAjax = new Ajax.Request(
			'get_results.asp?Category='+Category+'&Language='+Language+'&TimeSpan='+TimeSpan+'&PageSize='+PageSize+'&PageNo='+PageNo, 
			{
				method: 'get', 
				parameters: '',
				asynchronous: false,  
				onComplete: function(response) {
					currentPage = eval('(' + response.responseText + ')');
					drawTable(currentPage, $('view'));
				}
			});
}


/*---------------------------------------------------------------*/

function drawTable(page, contain) {
	contain.innerHTML = '';
	logoPath='';

	table = '<table width=600 border=0 cellspacing=5 cellpadding=2 class="background-list" style="height:90px;" onMouseOver="this.className=\'background-list-mouseover\'"  onMouseOut="this.className=\'background-list\'">';
	for(i = 0; i < page['shows'].length; i++) {
	
	logoPath = page['shows'][i].Channel_Logo;
	
	var videoTR = "";
	if (!page['shows'][i].Show_Time){
		videoTR  =  '<span class="text eleven bold">ADDED:&nbsp;&nbsp;</span><span class="text eleven">' + page['shows'][i].Show_Date + '</span><br />';
		videoTR +=  '<span class="text eleven bold">VIDEOS:&nbsp;&nbsp;</span><span class="text eleven">' + page['shows'][i].Show_Clips_Count + '</span></td>';
		}
	else
		{
		videoTR =  '<span class="text eleven bold">STARTS:&nbsp;&nbsp;</span><span class="text eleven">' + page['shows'][i].Show_Date + ' , ' + page['shows'][i].Show_Time + '</span><br />';
		videoTR += '<span class="text eleven bold">ENDS:&nbsp;&nbsp;</span><span class="text eleven">' + page['shows'][i].Show_End_Date + ' , ' + page['shows'][i].Show_End_Time + '</span></td>';
		}
		
	table = '<table width=600 border=0 cellspacing=5 cellpadding=2 class="background-list" style="height:90px;" onMouseOver="this.className=\'background-list-mouseover\'" onMouseOut="this.className=\'background-list\'">';
		table +=		'<tr onClick="location.href=(' + '\'../../' + page['shows'][i].Channel_Name_Internal + '/index.asp?Show_ID=' + page['shows'][i].Show_ID + '\''  +');">' +
		//table +=		'<tr onClick="location.href=(' + '\'../../' + page['shows'][i].Channel_Name_Internal + '/\''  +');">' +
                        '<td width="143" bgcolor="#555555"><div style="width:35px; height:20px; position:absolute; z-index:4567" class="' + page['shows'][i].Show_Class + '">&nbsp;</div><a href="../../' + page['shows'][i].Channel_Name_Internal + '?Show_ID=' + page['shows'][i].Show_ID + '"><img src="' + logoPath + '" alt="Open Show : ' + page['shows'][i].Show_Name + '" title="Open Show : ' + page['shows'][i].Show_Name + '" width="143" height="80" border="0" style="position:relative"></a></td>'+
                        //'<td width="143" bgcolor="#555555"><div style="width:35px; height:20px; position:absolute; z-index:4567" class="' + page['shows'][i].Show_Class + '">&nbsp;</div><a href="../../' + page['shows'][i].Channel_Name_Internal + '"><img src="' + logoPath + '" alt="Open Show : ' + page['shows'][i].Show_Name + '" title="Open Show : ' + page['shows'][i].Show_Name + '" width="143" height="80" border="0" style="position:relative"></a></td>'+
						'<td width="1"></td>'+
                        '<td width="305" valign="top">'+
                		'<span class="text twelve bold">SHOW:&nbsp;&nbsp;</span><span class="text twelve bold white">' + page['shows'][i].Show_Name + '</span><br>'+
                        '<span class="text eleven bold">CHANNEL:&nbsp;&nbsp;</span><span class="text eleven">' + page['shows'][i].Channel_Name + '</span><br>'+
						videoTR +

						'<td width="110" valign="top" style="padding-left:10px; border-left:solid #555555 1px">'+
                  		'<div class="text ten bold white" style="height:15px; padding-bottom:5px">' + page['shows'][i].Category_Name + '</div>'+
                        '<div class="text ten" style="height:15px; padding-bottom:5px"><img src="../graphics/icon_viewers-now.png" alt="Viewers Watching Now : ' + page['shows'][i].Show_Watching + '" title="Viewers Watching Now : ' + page['shows'][i].Show_Watching + '" width="17" height="12" border="0">&nbsp;&nbsp;&nbsp;' + page['shows'][i].Show_Watching + '</div>'+
                        '<div class="text ten" style="height:15px; padding-bottom:5px"><img src="../graphics/icon_popularity.png" alt="Popularity : ' + page['shows'][i].Show_Views + '" title="Popularity : ' + page['shows'][i].Show_Views + '" width="17" height="12" border="0">&nbsp;&nbsp;&nbsp;' + page['shows'][i].Show_Views + '</div>'+
                        '<div class="text ten" style="height:15px;"><img src="../graphics/icon_rating.png" alt="Average Viewer Rating : ' + page['shows'][i].Show_Rating + ' / 5" title="Average Viewer Rating : ' + page['shows'][i].Show_Rating + ' / 5" width="17" height="12" border="0">&nbsp;&nbsp;&nbsp;' + page['shows'][i].Show_Rating + ' / 5</div></td>'+
						'</tr>';
	table += '</table>';
	table += '<div style="height:8px; width:100%"></div>';
	contain.innerHTML += table;
	}

}