/**
 * A rootImgUrl változó a képek rootja. A c6.js használata előtt be kell állítani.
 */
if(typeof rootImgUrl == 'undefined') {
	alert("A 'rootImgUrl' változó nincs beállítva (c6.js)");
}

/**
 * Főmenüsor kezelése.
 */
var activeMenuHide = 0;
var activeMenu = 0;
var activeMenuLevel = 0; // 0 - off, 1 - over menu, 2 - over submenu line

function menuOver(id) {
	if(activeMenu != 0) {
		menuOff(activeMenu);
	}
	menuOn(id);
	activeMenu = id;
	activeMenuLevel = 1;
}

function menuOut(id) {
	activeMenuLevel = 0;
	setTimeout("menuOutTimed(" + (++activeMenuHide) + "," + id + ")", 400);
}

function menuOutTimed(cnt, id) {
	if(cnt == activeMenuHide && activeMenuLevel == 0 && activeMenu == id) {
		menuOff(id);
		activeMenu = 0;
	}
}

function submenuOver() {
	activeMenuLevel = 2;
}

function submenuOut() {
	activeMenuLevel = 0;
	if(activeMenu != 0) {
		setTimeout("menuOutTimed(" + (++activeMenuHide) + ',' + activeMenu + ")", 700);
	}
}

function menuOn(id) {
/*
	document.getElementById('menu' + id + 'left').src = rootImgUrl + "/c6hd-menu-sel1.gif";
	document.getElementById('menu' + id + 'right').src = rootImgUrl + "/c6hd-menu-sel3.gif";
	document.getElementById('menu' + id).className = "menuitem_hover";
*/
	document.getElementById('menu' + id).className = "hd_menuitem_h";

	var line = document.getElementById('menu' + id + 'subline');
	if(typeof line != 'undefined' && line != null) {
		line.className = "show";
	}
}

function menuOff(id) {
/*
	document.getElementById('menu' + id + 'left').src = rootImgUrl + "/spacer.gif";
	document.getElementById('menu' + id + 'right').src = rootImgUrl + "/spacer.gif";
	document.getElementById('menu' + id).className = "menuitem";
*/
	document.getElementById('menu' + id).className = "hd_menuitem";

	var line = document.getElementById('menu' + id + 'subline');
	if(typeof line != 'undefined' && line != null) {
		line.className = "hide";
	}
}

function clearInput(input, val) {
	if(input.htCleared != true && input.value == val) {
		input.htCleared = true;
		input.value = "";
	}
}

function openImagePopup(img, w, h) {
	var fix = true;
	if(!w) {
		fix = false;
		w = 300;
	}
	if(!h) {
		fix = false;
		h = 300;
	}

	var s = '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">\n';
	s += '<html xmlns="http://www.w3.org/1999/xhtml">\n';
	s += '<head></head><body style="margin:0;background-color:#000000;"><a href="javascript:window.close()"><img src="' + img + '" alt="" style="border:0;';
	if(fix) s += 'width:' + w + 'px;height:' + h + 'px';
	s += '"/></a></body></html>';
	var p = window.open('about:blank', '_blank', "width=" + w + ",height=" + h + ",screenX=1,screenY=1,status=0,resizable=" + (fix ? '0' : '1'));
	p.document.write(s);
	p.document.close();

	return false; // onclickk miatt.
}

function openGallery(gname, link) {
	var href;
	if(typeof link != 'undefined') href = link.href;
	else href = 'http://www.c6.hu/c6-java/galery-popup.jsp?g=' + gname;
	window.open(href, 'C6GalleryPopup', 'width=810,height=730,resizable=0,scrollbars=0');

	return false; // onclickk miatt.
}

function updateCityParameter() {
	var f = document.forms['fregister'];
	var o = f['d_params[cim.orszag].d_value'];
	var c0 = f['d_params[cim.varos].d_value'];
	var c1 = f['d_params[cim.varos_plain].d_value'];

	if(o.value == 'Magyarország') {
		c0.disabled = false;
		c0.className = '';
		c1.disabled = true;
		c1.className = 'itext_dis';
	} else {
		c0.disabled = true;
		c0.className = 'iselect_dis';
		c1.disabled = false;
		c1.className = 'itext';
	}
}

function initCityParameter() {
	var o = document.forms['fregister']['d_params[cim.orszag].d_value'];
	o.onchange = updateCityParameter;
	updateCityParameter();
}

function radioStart(url) {
	window.open('http://www.c6.hu:8000/listen.pls', '_blank');
	document.location.href = url;
}

function radioPlsInfo(id) {
	var inf = document.getElementById('plsitem' + id);
	var lnk = document.getElementById('plslink' + id);
	if(lnk.className == 'on') {
		lnk.className = 'off';
		inf.style.display = 'none';
	} else {
		lnk.className = 'on';
		inf.style.display = '';
	}
}

function chatPopup() {
	window.open('http://www.c6.hu/chat/new-2.0/popup.html', 'C6ChatPopup', 'width=800,height=600,resizable=1');
}

function chatStart(url) {
	chatPopup();
	document.location.href = url;
}

function mainSartpg(e) {
	e.style.behavior = 'url(#default#homepage)';
	e.setHomePage('http://www.c6.hu');
}

function mainFav() {
	if(window.external) {
		try {
			window.external.AddFavorite(location.href, document.title);
		} catch(e) { }
	}
}

function playlistImageInit() {
	var imre = /(\.(jpg|gif|jpeg|png)$)/i;

	for(var i = 0; i < document.images.length; i++) {
		var img = document.images[i];
		var o = img.attributes.getNamedItem("orig");
		if(o) {
			img.src = rootImgUrl + '/radio/tn_' + o.value.replace(imre, ".gif");
		}
	}
}

