function LoadTreeMenu(TreeID)
{
	makeAjaxRequest('GetUserControl.aspx?Name=InnerControls/ArticleListItem&TreeID=' + TreeID, ShowTreeMenu);
}

function ShowTreeMenu(html)
{
	setElementHtml('TreeMenuPane', html);
}

function ToggleVisibility(elementName)
{
	var element = document.getElementById(elementName);
	if (element)
		if (element.style.display == 'block')
			element.style.display = 'none';
		else
			element.style.display = 'block';
}

function OpenPopupAt(href, width, height, left, top)
{
	window.open(href, '', 'top=' + top + ', left=' + left + ', width=' + width + ', height=' + height + '');
}

function OpenPopup(href, width, height)
{
	var left = (screen.width - width) / 2;
	var top = (screen.height - height) / 2;
	OpenPopupAt(href, width, height, left, top);
}

function OpenHiddenPopup(href, width, height)
{
	//OpenPopup(href, width, height);
	OpenPopupAt(href, width, height, screen.width + 10, screen.height + 10);
}

function setElementText(elementName, elementText)
{
	var element = document.getElementById(elementName);
	if (element) element.innerText = elementText;
}

function SetImageSrc(elementName, elementImage)
{
	var element = document.getElementById(elementName);

	if (element)
	{
		element.src = elementImage;
		for(i = 0; i < 5; i++)
	{
		image = document.getElementById("Header1_MovieButtons1_DataList1_ctl0" + i + "_Image1");
		
		if(elementName != "Header1_MovieButtons1_DataList1_ctl0" + i + "_Image1")		
			image.src = "../Images/" + (i + 1) + ".jpg";
	}

	 }
}

function setElementHtml(elementName, elementHtml)
{
	var element = document.getElementById(elementName);
	if (element) element.innerHtml = elementHtml;
}

function FixActiveX(element)
{
	theObjects = element.getElementsByTagName('embed');
	for (var i = 0; i < theObjects.length; i++)
	{
		var childElement = theObjects[i];
		FixActiveXForObject(childElement);
	}
	//if (theObjects.length == 0) setTimeout("FixActiveX()", 3000);
}

function FixActiveXForObject(obj)
{
	obj.outerHTML = obj.outerHTML;
}

var visibleScheduleList;
var visibleScheduleButtonImage;

function ShowScheduleList(elementName, buttonImage, HotChannelNumber, YesChannelNumber)
{
	var element = document.getElementById(elementName);
	var button = document.getElementById(buttonImage);
	if (element)
	{
		if (visibleScheduleList) visibleScheduleList.style.display = 'none';
		if (visibleScheduleButtonImage)
			visibleScheduleButtonImage.src = visibleScheduleButtonImage.src.substring(0, visibleScheduleButtonImage.src.lastIndexOf('_on')) + '.jpg';
		visibleScheduleList = element;
		visibleScheduleList.style.display = 'inline';
		visibleScheduleButtonImage = button;
		visibleScheduleButtonImage.src = visibleScheduleButtonImage.src.substring(0, visibleScheduleButtonImage.src.lastIndexOf('.')) + '_on.jpg';
	}
	document.getElementById('HotChannelNumberSpan').innerText = HotChannelNumber;
	document.getElementById('YesChannelNumberSpan').innerText = YesChannelNumber;
}

function ShowScheduleListPageLoad(elementName, buttonImage, HotChannelNumber, YesChannelNumber)
{
	document.body.onload = function () { ShowScheduleList(elementName, buttonImage, HotChannelNumber, YesChannelNumber) };
}

