// JavaScript Document
var seriesObj;
var entObj;
var topHObj;
var subHObj;
var searchObj;
var entAnchorObj;

var seriesPrevClassName;
var entPrevClassName;
var isSub = false;

var slideCount = 0;
var tempCount = 0;
var slideTime;
var slideObj;
var announcementCount = 0;
var countryCode = '';

function ShowMainHighlight(hId)
{
		
		if(!isSub)
		{
			ShowItem('highlight',hId);
			var tempP = hId.getElementsByTagName('li');
			if(tempP && tempP.length > 0)
			{
				subHObj = Action(tempP[0],subHObj,'highlightSubItem','hiddenHighlightSubItem');
			}					
		}
		else
			isSub = false;
}
	
function ShowItem(section, obj)
{
		switch(section)
		{
			case 'highlight':
				if(obj)
				{
						topHObj = Action(obj,topHObj,'highlightItem','hiddenHighlightItem');
				}
				break;
			case 'search':
				if(obj)
				{
					searchObj = Action(obj,searchObj,'searchMenuItem','hiddenSearchMenuItem');
				}
				break;
			case 'program':
				if(obj)
				{
					isSub = true;
					subHObj = Action(obj,subHObj,'highlightSubItem','hiddenHighlightSubItem');
				}
				break;
			case 'series':
				//obj = obj.getElementsByTagName('div');
				if(obj)
				{
					seriesObj = Action(obj,seriesObj,'seriesItemHolder','hiddenSeriesItemHolder');
				}
			break;
			case 'ent':
				//entAnchorObj = obj.getElementsByTagName('a');
				//obj = obj.getElementsByTagName('ul');
				//if(entAnchorObj)
				//{
					//entAnchorObj = entAnchorObj.length > 0 ? entAnchorObj[0] : undefined;
				//}
				if(obj)
				{
					//obj = obj.length > 0 ? obj[0] : undefined;
					entObj = Action(obj,entObj,'selTabItem','tabItem');
				}
			break;
		}
}

function Action(obj, selObj, showClass, hiddenClass)
{
	if(selObj)
	{
		selObj.className = hiddenClass;
		if(obj)
		{
			obj.className = showClass;
			selObj = obj;
		}
	}
	else if(obj)
	{
		selObj = obj;
		obj.className = showClass;
	}
	return selObj;
}

function StartAnnouncementSlideShow(sCount)
{
	setTimeout('SlideShowCaller()',1000);
}

function SlideShowCaller()
{
	announcementCount = 0;
	while(true)
	{
		if(document.getElementById('slide0' + announcementCount))
			announcementCount++;
		else
		{
			break;
		}
	}
	if(announcementCount && announcementCount > slideCount)
	{
		slideCount = announcementCount;
		slideTime = setInterval('ShowSlide()',3000);
	}
}

function ShowSlide()
{
	if(slideCount == tempCount) tempCount = 0;
	if(slideObj)
	{
		slideObj.className = 'hiddenAnnouncementItem';
		slideObj = document.getElementById('slide0' + tempCount);
		slideObj.className = 'announcementItem';
		tempCount ++;
	}
	else
	{
		slideObj = document.getElementById('slide0' + tempCount);
		slideObj.className = 'announcementItem';
		tempCount++;
	}
}

var defaultSiteText;
var defaultProgramText;

function WaterMark(mode,txt, evt)
{	
	switch(mode)
	{
		case 'site':
			if(txt.value.length == 0 && evt.type == "blur")
			{
				txt.style.color = "gray";
				txt.value = defaultSiteText;
			}
			if(txt.value == defaultSiteText && evt.type == "focus")
			{
				txt.style.color = "black";
				txt.value="";
			}
			break;
		case 'program':
			if(txt.value.length == 0 && evt.type == "blur")
			{
				txt.style.color = "gray";
				txt.value = defaultProgramText;
			}
			if(txt.value == defaultProgramText && evt.type == "focus")
			{
				txt.style.color = "black";
				txt.value="";
			}
			break;
	}
} 
		
//function CountryCode(){
//	var tempObj = document.getElementById('Spotlight_en_gb');
//	if(tempObj)
//	{
//		tempObj.SetVariable('ccode', countryCode); 
//	}
//	// document.getElementById('Spotlight_en_gb').SetVariable("ccode", countryCode); 
//}
window.onload = function CountryCode() {

				var obj = swfobject.getObjectById("Spotlight_en_gb");
				if (obj && typeof obj.SetVariable != "undefined") {
					obj.SetVariable("ccode", countryCode);
				}
				
				var obj = swfobject.getObjectById("SpotlightNew_en_gb");
				//alert(obj);
				if (obj && typeof obj.SetVariable != "undefined") {
					obj.SetVariable("ccode", countryCode);
				}
		
			    var obj = swfobject.getObjectById("Spotlight_ar_ae");
				if (obj && typeof obj.SetVariable != "undefined") {
					obj.SetVariable("ccode", countryCode);
				}
				
				var obj = swfobject.getObjectById("SpotlightNew_ar_ae");
				//alert(obj);
				if (obj && typeof obj.SetVariable != "undefined") {
					obj.SetVariable("ccode", countryCode);
				}

};

//function CountryCodeAr(){
//	var tempObj = document.getElementById('Spotlight_ar_ae');
//	if(tempObj)
//	{
//	tempObj.SetVariable('ccode', countryCode); 
//	}
//	//document.getElementById('Spotlight_ar_ae').SetVariable("ccode", countryCode); 
//}

//window.onload = function CountryCodeAr() {
//		var obj = swfobject.getObjectById("Spotlight_ar_ae");
//		if (obj && typeof obj.SetVariable != "undefined") {
//			obj.SetVariable("ccode", countryCode);
//		}
//};

