﻿function Get(getID){
	return document.getElementById(getID);
};

function Clock()
{
	var currentDate = new Date(new Date().getTime() + offsetDate);
	//
	hr = currentDate.getHours();
	min = currentDate.getMinutes();
	sec = currentDate.getSeconds();
	ext = '.png';
	path = applicationPath + '/imgs/clock/';
	//alert(path);
	//
	if (hr < 0)
		hr += 24;
	if (hr > 24)
		hr -= 24;
	if (hr <= '9') { hr = '0' + hr; } else { hr = '' + hr; }
	if (min <= '9') { min = '0' + min; } else { min = '' + min; }
	if (sec <= '9') { sec = '0' + sec; } else { sec = '' + sec; }
	//
	hrc = hr.substring(0, 1);
	hrd = hr.substring(1, 2);
	document.images.n0.src = path + hrc + ext;
	document.images.n1.src = path + hrd + ext;
	//
	minc = min.substring(0, 1);
	mind = min.substring(1, 2);
	document.images.n2.src = path + minc + ext;
	document.images.n3.src = path + mind + ext;
	//
	secc = sec.substring(0, 1);
	secd = sec.substring(1, 2);
	document.images.n4.src = path + secc + ext;
	document.images.n5.src = path + secd + ext;
	//
	setTimeout('Clock()', 1000);
};

function ScrollToSelectedNews(scroller)
{
	var container = scroller.content;
	if (container)
	{
		var as = container.getElementsByTagName('A');
		for (var i = 0; i < as.length; i++)
		{
			if (as[i].className == 'selected')
			{
				var item = as[i];
				scroller.PropertyAddValue(scroller.content.style, 'top', -item.offsetTop, -scroller.maxScroll, 0);
				scroller.UpdateArrows();
				//
				break;				
			}
		}
	}
};

function ShowMonth(IDmonth)
{
	//alert(IDmonth);
	var monthsMenuID = 'monthsMenu_' + IDmonth;
	var monthID = 'month_' + IDmonth;
	//
	HideAllMonths();
	//
	var monthsMenu = Get(monthsMenuID);
	if (monthsMenu != null)
		monthsMenu.className = 'selected';
	//
	var monthData = Get(monthID);
	//alert(monthData + ' ' + monthID);
	if (monthData != null)
		monthData.style.display = '';
};

function HideAllMonths()
{
	var monthsMenu = Get('otrCalendar');
	if(monthsMenu != null)
	{
		var monthsLinks = monthsMenu.getElementsByTagName('A');
		//alert(monthsLinks);
		if (monthsLinks.length != 0)
		{
			for(var i = 0; i < monthsLinks.length; i++)
			{
				monthsLinks[i].className = '';
			}
		}
	} 
	//
	//
	var monthsGroup = Get('otrMonths');
	if(monthsGroup != null)
	{
		var months = monthsGroup.getElementsByTagName('DIV');
		//alert(months);
		if (months.length != 0)
		{
			for(var i = 0; i < months.length; i++)
			{
				if (months[i].id.indexOf('month_') != -1)
				months[i].style.display = 'none';
			}
		}
	} 
};

function ShowCurrentMonth()
{	
	var currentDate = new Date();
	var currentMonth = (currentDate.getMonth() +1);
	//
	ShowMonth(currentMonth);
};

function ShowSwf(swfID)
{
	HideAllSwf();
	//
	var swfDivID = "flash_" + swfID;
	var liID = "li_" + swfID;
	//
	//
	var li = Get(liID);
	if (li != null)
		li.className = 'selected';
	//
	var swfDiv = Get(swfDivID);
	//alert(monthData + ' ' + monthID);
	if (swfDiv != null)
		swfDiv.style.display = '';
};

function HideAllSwf()
{
	var flashes = Get('otrFlash');
	if(flashes != null)
	{
		var flashesDiv = flashes.getElementsByTagName('DIV');
		//alert(monthsLinks);
		if (flashesDiv.length != 0)
		{
			for(var i = 0; i < flashesDiv.length; i++)
			{
				flashesDiv[i].style.display = 'none';
			}
		}
	}
	//
		var ul = Get('otrUpList');
	if(ul != null)
	{
		var li = ul.getElementsByTagName('LI');
		//alert(monthsLinks);
		if (li.length != 0)
		{
			for(var i = 0; i < li.length; i++)
			{
				li[i].className = '';
			}
		}
	} 
};

function Youtube(IDnode)
{
	var targetURL = applicationPath + '/YouTube.aspx?IDnode=' + IDnode;
	OpenWindow(targetURL, 640, 405);

};

function OpenWindow(targetURL, width, height)
{
	var init_width = (width != null)?width:840;
	var init_height = (height != null)?height:600;
	var init_left = Math.floor((screen.availWidth - init_width)/2);
	var init_top = Math.floor((screen.availHeight - init_height)/2);
	var newWin = window.open(targetURL, 
	'_new', 
	'width=' + init_width + ',height=' + init_height + ',top=' + init_top + ',left=' + init_left + ',resizable=yes,scrollbars=yes');
	//
	if (window.focus) 
		newWin.focus();
};

function GoToHomePage()
{
	var path = applicationPath + '/' + languageCode + '/home.aspx';
	document.location = path;
};
