// IE - fix blikajicich backgroundu 
eval("try {document.execCommand('BackgroundImageCache', false, true);} catch(e) {}");

daySeconds = 60*60*24;
hourSeconds = 60*60;
coutSeconds = 60;

function countDown() {
	days = Math.floor(countSecond / daySeconds);
	hours = Math.floor((countSecond - (daySeconds*days)) / (hourSeconds));
	minutes = Math.floor((countSecond - (daySeconds*days)-(hourSeconds*hours))/coutSeconds );
	seconds = countSecond - (daySeconds*days)-(hourSeconds*hours) - (coutSeconds *minutes);
	if (seconds < 10) {
		seconds = "0"+seconds;
	}
	if (minutes < 10) {
		minutes = "0"+minutes;
	}
	if (hours < 10) {
		hours = "0"+hours;
	}

	if ( days == 1) {
		daysText = "den";
	} else if (days == 0) {
		daysText = "dnů";
	} else {
		daysText = "dny";
	}

	if (hours <= 4 && hours >=2) {
		hoursText = "hodiny";
	} else if (hours == 1) {
		hoursText = "hodina";
	} else {
		hoursText = "hodin";
	}

	if (minutes <= 4 && minutes >=2) {
		minutesText = "minuty";
	} else if (minutes == 1) {
		minutesText = "minuta";
	} else {
		minutesText = "minut";
	}


	if (seconds <= 4 && seconds >=2) {
		secondsText = "sekundy";
	} else if (seconds == 1) {
		secondsText = "sekunda";
	} else {
		secondsText = "sekund";
	}

	$("#counter").html('<div id="days">'+days+'<br><span>'+daysText+'</span></div><div id="hours" class="dvojbodka">'+hours+'<br><span>'+hoursText+'</span></div><div class="dvojbodka">'+minutes+'<br><span>'+minutesText+'</span></div><div>'+seconds+'<br><span>'+secondsText+'</span></div>');
	countSecond--;
	if (countSecond > 0) {
		window.setTimeout("countDown()", 1000);
	}
}


var fulltextQuery = '';
var onlyInNews = false;
function fillFulltextQuery() {
	if (fulltextQuery != '') {
		document.forms[1].query.value=fulltextQuery;
	}
	if (onlyInNews == true) {
		document.forms[1].onlyInNews[1].checked = true;
	}
}

var imageOpener = new ImageOpener();

function paginationSubmit(frm)
{
	var no = frm.pageNo.value;
	if ( no != parseInt(no) || no < 1 )
	{
	  alert("Zadejte prosím celé číslo větší než 0.");
	  return false;
	}
	var url = window.location.href;
	url = url.substr(0, url.indexOf("/index") + 6) + "_" + ( no - 1 ) + ".shtml";
	if ( no == 1 ) url = url.replace("_0.shtml", ".shtml");
	window.location.href = url;
	return false;
}

function ImageOpener() {
	this.popImage = myPopImage;
	this.popImageWithText = myPopImageWithText;
	this.imageURL = "";
	this.imageTitle = "";
	this.onlyImage = false;
	this.windowTitle = "";
	this.showBars = false;
	this.pressroom = false;
	
	function myPopImage(imageURL, imageTitle, onlyImage) {
		this.imageURL = imageURL;
		this.imageTitle = imageTitle;
		this.onlyImage = onlyImage;
		this.windowTitle = ( lng == "cs" ? "Detail obrázku" : "Image detail" );
		this.closeText = ( lng == "cs" ? "Zavřít okno" : "Close window" );
		this.windowUrl = ( this.pressroom == true ? 'image-pressroom' : 'image' );
		openWin("spartaimage", "/" + this.windowUrl + ".html?rnd=" + new Date().valueOf(), 200, 200, this.showBars, false, false, false);
	}
	
	function myPopImageWithText(imageURL, imageTitle, onlyImage) {
		this.imageURL = imageURL;
		this.imageTitle = imageTitle;
		this.onlyImage = onlyImage;
		this.windowTitle = ( lng == "cs" ? "Detail obrázku" : "Image detail" );
		this.closeText = ( lng == "cs" ? "Zavřít okno" : "Close window" );
		this.windowUrl = 'imageShoes';
		openWin("spartaimage", "/" + this.windowUrl + ".html?rnd=" + new Date().valueOf(), 200, 200, this.showBars, false, false, false);
	}
}

function showGallery(url) {
	openHardWin("sparta_galelry", url, 700, 550, true);
}

function getCenterW(width) {
	return parseInt( eval( (screen.width-parseInt(width))/2 ) );
}

function getCenterH(height) {
	return parseInt( eval( (screen.height-parseInt(height))/2 ) );
}
function openWin( name, path, width, height, scrollB, getFocus, resize, center ) {
		path = getPathWithBaseHref(path);
		var scrollBar = (scrollB=='1') ? 'yes' : 'no';
		var attResize = ( resize == false ? "resizable=no,resize=no" : "resizable=yes,resize=yes" );
		var screenX = ( center != false ? getCenterW(width) : 0 );
		var screenY = ( center != false ? getCenterH(height) : 0 );

		var win=window.open(path,name,'scrollbars=' + scrollBar + ',' + attResize + ',width='+width+',height='+height+',screenX=' + screenX + ',screenY=' + screenY + ',top=' + screenY + ',left=' + screenX + ',locationbar=no,directories=no' );

		if ( getFocus == true ) win.focus();
}
function openHardWin( name, path, width, height, scrollB, center ) {
		path = getPathWithBaseHref(path);
		var scrollBar = (scrollB=='1') ? 'yes' : 'no';
		var screenX = ( center != false ? getCenterW(width) : 0 );
		var screenY = ( center != false ? getCenterH(height) : 0 );

		var win=window.open(path,name,'scrollbars=' +scrollBar+ ',resizable=no,resize=no,width='+width+',height='+height+',screenX=' + screenX + ',screenY=' + screenY +',top=' + screenY + ',left=' + screenX + ',locationbar=no,directories=no' );
		win.focus();
}

//function adds base href to path when base href is present
//should be called on every window.open and window.location
function getPathWithBaseHref(path) {
	if(path.indexOf('http://') == -1) {
		var bh = document.getElementsByTagName('base');
 		if (bh && bh[0] && bh[0].href) {
  		if (bh[0].href.substr(bh[0].href.length-1) == '/' && path.charAt(0) == '/')
    		path = path.substr(1);
  			path = bh[0].href + path;
 		}
 	}
 	return path;
}

function mobilContent(path) {
	//pokud url obsahuje parametr melodie - otevre se vetsi popup okno se scrollbarem
	if (path.indexOf('melodie') == -1) {
	openHardWin('mobilContent',path,580,290,0,true);
	}
	else {
	openHardWin('mobilContent',path,690,580,1,true);
	}
}

function go2URL(url, w) {
	if (url == "#") return false;
	if (!w) w = window.self;
	url = getPathWithBaseHref(url);
	w.location.href = url;
	//w.focus();
} 

function popImage(imageURL, imageTitle, onlyImage) {
	imageOpener.popImage(imageURL, imageTitle, onlyImage);
}

function popImageBar(imageURL, imageTitle, onlyImage) {
	imageOpener.pressroom = true;
	imageOpener.showBars = true;
	imageOpener.popImage(imageURL, imageTitle, onlyImage);
}

function popImagePaging(sectionId, messageId, position, language) {
	openWin("spartaimage", "/srv/www/"+language+"/football/gallery/pagingDetail.do?messageId="+messageId+"&sectionId="+sectionId+"&position="+position, 200, 200, false, false, false, false);
}

function popImage2(imageURL) {
	var AutoClose = true;
	var PositionX = 10;
	var PositionY = 10;
	var defaultWidth  = 800;
	var defaultHeight = 600;

	var imgWin = window.open('','sparta_image','scrollbars=1,resizable=1,width='+defaultWidth+',height='+defaultHeight+',left='+PositionX+',top='+PositionY);
	if( !imgWin ) { return true; } //popup blockers should not cause errors
		imgWin.document.write('<!DOCTYPE HTML PUBLIC "-\/\/W3C\/\/DTD HTML 4.01 Transitional\/\/EN" "http:\/\/www.w3.org\/TR\/html4\/loose.dtd"><html><head><title>Detail obrázku<\/title><script type="text\/javascript">\n'+
			'function resizeWinTo(type) {\n'+
			'if( !document.images.length ) { document.images[0] = document.layers[0].images[0]; }'+
			'var oH = document.images[0].height, oW = document.images[0].width;\n'+
			'if( !oH || window.doneAlready ) { return; }\n'+ //in case images are disabled
			'window.doneAlready = true;\n'+ //for Safari and Opera
			'var x = window; x.resizeTo( oW + 200, oH + 200 );\n'+
			'var myW = 0, myH = 0, d = x.document.documentElement, b = x.document.body;\n'+
			'if( x.innerWidth ) { myW = x.innerWidth; myH = x.innerHeight; }\n'+
			'else if( d && d.clientWidth ) { myW = d.clientWidth; myH = d.clientHeight; }\n'+
			'else if( b && b.clientWidth ) { myW = b.clientWidth; myH = b.clientHeight; }\n'+
			'if( window.opera && !document.childNodes ) { myW += 16; }\n'+
			'x.resizeTo( oW = oW + ( ( oW + 200 ) - myW ), oH = oH + ( (oH + 200 ) - myH ) );\n'+
			'var scW = screen.availWidth ? screen.availWidth : screen.width;\n'+
			'var scH = screen.availHeight ? screen.availHeight : screen.height;\n'+
			'if( !window.opera ) { x.moveTo(Math.round((scW-oW)/2),Math.round((scH-oH)/2)); }\n'+
			'}\n'+
			'<\/script>'+
			'<link rel="stylesheet" type="text\/css" href="\/css\/u\/base.css">'+
			'<link rel="stylesheet" type="text\/css" href="\/css\/u\/imagedetail2.css">'+
			'<\/head><body onload="resizeWinTo(0);"'+(AutoClose?' onblur="self.close();"':'')+'>'+
			//(document.layers?('<layer left="0" top="0">'):('<div style="position:absolute;left:0px;top:0px;">'))+
			'<img src='+imageURL+' alt="Otevírám obrázek ..." title="">'+
			//(document.layers?'<\/layer>':'<\/div>')+'<\/body><\/html>');
			'<\/body><\/html>');
		imgWin.document.close();
		if( imgWin.focus ) { imgWin.focus(); }
		return false;
}

function popImageOld(imageURL, imageTitle) {
	var AutoClose = true;
	var PositionX = 10;
	var PositionY = 10;
	var defaultWidth  = 800;
	var defaultHeight = 600;
	
	var lngText = "Zavřít okno";
	if(lng == "en") lngText = "Close window";

	var imgWin = window.open('','sparta_image','scrollbars=1,resizable=1,width='+defaultWidth+',height='+defaultHeight+',left='+PositionX+',top='+PositionY);
	if( !imgWin ) { return true; } //popup blockers should not cause errors
		imgWin.document.write('<!DOCTYPE HTML PUBLIC "-\/\/W3C\/\/DTD HTML 4.01 Transitional\/\/EN" "http:\/\/www.w3.org\/TR\/html4\/loose.dtd"><html><head><title>Detail obrázku<\/title><script type="text\/javascript">\n'+
			'function resizeWinTo(type) {\n'+
			'if( !document.images.length ) { document.images[0] = document.layers[0].images[0]; }'+
			'var oH = document.images[0].height, oW = document.images[0].width;\n'+
			'if( !oH || window.doneAlready ) { return; }\n'+ //in case images are disabled
			'window.doneAlready = true;\n'+ //for Safari and Opera
			'var x = window; x.resizeTo( oW + 160, oH + 70 );\n'+
			'var myW = 0, myH = 0, d = x.document.documentElement, b = x.document.body;\n'+
			'if( x.innerWidth ) { myW = x.innerWidth; myH = x.innerHeight; }\n'+
			'else if( d && d.clientWidth ) { myW = d.clientWidth; myH = d.clientHeight; }\n'+
			'else if( b && b.clientWidth ) { myW = b.clientWidth; myH = b.clientHeight; }\n'+
			'if( window.opera && !document.childNodes ) { myW += 16; }\n'+
			'x.resizeTo( oW = oW + ( ( oW + 200 ) - myW ), oH = oH + ( (oH + 200 ) - myH ) );\n'+
			'var scW = screen.availWidth ? screen.availWidth : screen.width;\n'+
			'var scH = screen.availHeight ? screen.availHeight : screen.height;\n'+
			'if( !window.opera ) { x.moveTo(Math.round((scW-oW)/2),Math.round((scH-oH)/2)); }\n'+
			'}\n'+
			'<\/script>'+
			'<link rel="stylesheet" type="text\/css" href="\/css\/u\/base.css">'+
			'<link rel="stylesheet" type="text\/css" href="\/css\/u\/imagedetail.css">'+
			'<\/head><body onload="resizeWinTo(0);"'+(AutoClose?' onblur="self.close();"':'')+'>'+
			//(document.layers?('<layer left="0" top="0">'):('<div style="position:absolute;left:0px;top:0px;">'))+
			'<img src='+imageURL+' alt="Otevírám obrázek ..." title="" xonload="resizeWinTo(1);" onclick="window.close();" style="cursor: pointer;">'+
			//(document.layers?'<\/layer>':'<\/div>')+'<\/body><\/html>');
			'<div class="text"><div class="close"><a href="#" onclick="window.close(); return false;">' + lngText + '<\/a><\/div>' + imageTitle + '</div>'+
			'<\/body><\/html>');
		imgWin.document.close();
		if( imgWin.focus ) { imgWin.focus(); }
		return false;
}

var showedNews = 1;

function showNewsHP(id,showedId) {
	var numSections = 6;
	var anchor_active = 'active'; var anchor_inactive = '';
	var news_active = 'dBlock'; var news_inactive = 'none';
	var last_anchor_class = 'last';
	
	if (id == numSections)
		anchor_active = anchor_active + ' ' + last_anchor_class;
	if (showedId == numSections)
		anchor_inactive = last_anchor_class;
	
	document.getElementById('news-hp-a-' + showedId).className = anchor_inactive;
	document.getElementById('news-hp-' + showedId).className = news_inactive;
	document.getElementById('news-hp-a-' + id).className = anchor_active;
	document.getElementById('news-hp-' + id).className = news_active;

	showedNews = id;
}

// zvyrazni polozku zpravy pri prejeti mysi
function highlightItem(eTR, state) {
	var space = new String;
	if ( eTR.className && eTR.className != 'over' )
		space = ' ';
	if ( state == true ) eTR.className += space + "over";
	else eTR.className = eTR.className.replace(space + "over", "");
}

// navigace vysledkovych tabulek 1. Gambrinus ligy
function writeScoreboardSelect(seasonId, lang) {
	document.write('<div class="matches-form">\n');
	if(lang == "en") document.write('Season'); else document.write('Sezóna'); document.write(': <select name="seasonId" class="middle" id="seasonId" >\n');
	document.write('	<option value="11"'); if(seasonId == 11) { document.write(' selected'); } document.write('>2010/2011</option>\n');
	document.write('	<option value="10"'); if(seasonId == 10) { document.write(' selected'); } document.write('>2009/2010</option>\n');
	document.write('	<option value="9"'); if(seasonId == 9) { document.write(' selected'); } document.write('>2008/2009</option>\n');
	document.write('	<option value="8"'); if(seasonId == 8) { document.write(' selected'); } document.write('>2007/2008</option>\n');
	document.write('	<option value="7"'); if(seasonId == 7) { document.write(' selected'); } document.write('>2006/2007</option>\n');
	document.write('	<option value="6"'); if(seasonId == 6) { document.write(' selected'); } document.write('>2005/2006</option>\n');
	document.write('	<option value="5"'); if(seasonId == 5) { document.write(' selected'); } document.write('>2004/2005</option>\n');
	document.write('	<option value="4"'); if(seasonId == 4) { document.write(' selected'); } document.write('>2003/2004</option>\n');
	document.write('	<option value="3"'); if(seasonId == 3) { document.write(' selected'); } document.write('>2002/2003</option>\n');
	document.write('	<option value="2"'); if(seasonId == 2) { document.write(' selected'); } document.write('>2001/2002</option>\n');
	document.write('	<option value="1"'); if(seasonId == 1) { document.write(' selected'); } document.write('>2000/2001</option>\n');
	document.write('</select>\n');
	document.write('<img src="/img/' + lang + '/btn/choose.gif" width="67" height="23" alt="'); if(lang == "en") document.write('Choose'); else document.write('Vybrat'); document.write('" title="'); if(lang == "en") document.write('Choose'); else document.write('Vybrat'); document.write('" onclick="changeScoreboard(document.getElementById(\'seasonId\').value, \'' + lang + '\', \'\');" class="top">\n');
	document.write('</div>\n');
}

// navigace vysledkovych tabulek CFL
function writeScoreboardSelectCFL(seasonId, lang) {
	document.write('<div class="matches-form">\n');
	if(lang == "en") document.write('Season'); else document.write('Sezóna'); document.write(': <select name="seasonId" class="middle" id="seasonId" >\n');
	document.write('	<option value="8"'); if(seasonId == 8) { document.write(' selected'); } document.write('>2007/2008</option>\n');
	document.write('	<option value="7"'); if(seasonId == 7) { document.write(' selected'); } document.write('>2006/2007</option>\n');
	document.write('</select>\n');
	document.write('<img src="/img/' + lang + '/btn/choose.gif" width="67" height="23" alt="'); if(lang == "en") document.write('Choose'); else document.write('Vybrat'); document.write('" title="'); if(lang == "en") document.write('Choose'); else document.write('Vybrat'); document.write('" onclick="changeScoreboard(document.getElementById(\'seasonId\').value, \'' + lang + '\', \'cfl\');" class="top">\n');
	document.write('</div>\n');
}

// navigace vysledkovych tabulek 2 liga
function writeScoreboardSelect2L(seasonId, lang) {
	document.write('<div class="matches-form">\n');
	if(lang == "en") document.write('Season'); else document.write('Sezóna'); document.write(': <select name="seasonId" class="middle" id="seasonId" >\n');
	document.write('	<option value="11"'); if(seasonId == 11) { document.write(' selected'); } document.write('>2010/2011</option>\n');
	document.write('	<option value="10"'); if(seasonId == 10) { document.write(' selected'); } document.write('>2009/2010</option>\n');
	document.write('	<option value="9"'); if(seasonId == 9) { document.write(' selected'); } document.write('>2008/2009</option>\n');
	document.write('	<option value="6"'); if(seasonId == 6) { document.write(' selected'); } document.write('>2005/2006</option>\n');
	document.write('</select>\n');
	document.write('<img src="/img/' + lang + '/btn/choose.gif" width="67" height="23" alt="'); if(lang == "en") document.write('Choose'); else document.write('Vybrat'); document.write('" title="'); if(lang == "en") document.write('Choose'); else document.write('Vybrat'); document.write('" onclick="changeScoreboard(document.getElementById(\'seasonId\').value, \'' + lang + '\', \'2L\');" class="top">\n');
	document.write('</div>\n');
}

function changeScoreboard(seasonId, lang, type) {
	var pathPrefix = "";
	if (type == "cfl") {
		if(lang == "en") {
			pathPrefix = "/en/matches/cfl_table";
		} else {
			pathPrefix = "/cs/zapasy/cfl_tabulka";
		}
	}
	else if (type == "2L") {
		if(lang == "en") {
			pathPrefix = "/en/matches/reserves_table";
		} else {
			pathPrefix = "/cs/zapasy/2-liga_tabulka";
		}
	}
	else {
		if(lang == "en") {
			pathPrefix = "/en/matches/gambrinus-league_table";
		} else {
			pathPrefix = "/cs/zapasy/gambrinus-liga_tabulka";
		}
	}
	if(seasonId == 1) {
		go2URL(pathPrefix + "_2000-01.shtml");
	} else if(seasonId == 2) {
		go2URL(pathPrefix + "_2001-02.shtml");
	} else if(seasonId == 3) {
		go2URL(pathPrefix + "_2002-03.shtml");
	} else if(seasonId == 4) {
		go2URL(pathPrefix + "_2003-04.shtml");
	} else if(seasonId == 5) {
		go2URL(pathPrefix + "_2004-05.shtml");
	} else if(seasonId == 6) {
		go2URL(pathPrefix + "_2005-06.shtml");
	} else if(seasonId == 7) {
		go2URL(pathPrefix + "_2006-07.shtml");
	} else if(seasonId == 8) {
		go2URL(pathPrefix + "_2007-08.shtml");
	} else if(seasonId == 9) {
		go2URL(pathPrefix + "_2008-09.shtml");
	} else if(seasonId == 10) {
		go2URL(pathPrefix + "_2009-10.shtml");
	}
	else {
		go2URL(pathPrefix + "_2010-11.shtml");
	}
}

/* flash */

function isFlash(ver) {
	var state = false;
	var plugin = (navigator.mimeTypes && navigator.mimeTypes["application/x-shockwave-flash"]) ? navigator.mimeTypes["application/x-shockwave-flash"].enabledPlugin : false;
	if (plugin) {
		state = (parseInt(plugin.description.substring(plugin.description.indexOf(".")-1)) >= ver)? true : false;
	}
	else if (navigator.appName == "Microsoft Internet Explorer" && navigator.appVersion.indexOf("MSIE 4") == -1 && navigator.appVersion.indexOf("Macintosh") == -1 && navigator.appVersion.indexOf("68K") == -1) {
		eval('try { var flash = new ActiveXObject("ShockwaveFlash.ShockwaveFlash." + ver); state = true; } catch(e) {  }');
	}
	return state;
}

function writeFlash(path,par,w,h,clickthru) {
	var track = '/swf';
	document.writeln('<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0" width="'+w+'" height="'+h+'" id="navig">');
	if (par)	{document.writeln('	<param name="movie" value="'+track + path +'?clickthru=' + clickthru +'&track='+ track+'">');}
	else		{document.writeln('	<param name="movie" value="'+track + path +'?clickthru=' + clickthru +'">');}
	document.writeln('	<param name="quality" value="high">');
	document.writeln('	<param name="menu" value="false">');
	document.writeln('	<param name="scale" value="noscale">');
	document.writeln('	<param name="wmode" value="transparent">');
	document.writeln('	<param name="bgcolor" value="#FFFFFF">');
	if (par)	{document.writeln('	<embed src="'+ track + path+'?clickthru=' + clickthru +'&track='+ track+'"')}
	else		{document.writeln('	<embed src="'+ track + path+'?clickthru=' + clickthru +'"');}
	document.writeln('	 width="'+w+'" height="'+h+'" quality="high" scale="noscale" bgcolor="#FFFFFF" name="navig" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer"></embed><br>');	
	document.writeln('</object>');
}

function writeFlashHeader(path,w,h) {
	var track = '';
	document.writeln('<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0" width="'+w+'" height="'+h+'" id="header">');
	document.writeln('	<param name="movie" value="'+track + path +'">');
	document.writeln('	<param name="quality" value="high">');
	document.writeln('	<param name="menu" value="false">');
	document.writeln('	<param name="scale" value="noscale">');
	document.writeln('	<param name="wmode" value="transparent">');
	document.writeln('	<param name="bgcolor" value="#FFFFFF">');
	document.writeln('	<embed src="'+ track + path+'"');
	document.writeln('	 width="'+w+'" height="'+h+'" quality="high" wmode="transparent" scale="noscale" bgcolor="#FFFFFF" name="header" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer"></embed>');
	document.writeln('</object>');
}

/* /flash */

// funkce nabidne uzivateli nastaveni domovske stranky
function setHP(eA) {
	if ( window.navigator.appName == "Netscape" ) return;
	eA.style.behavior = "url(#default#homepage)";
	eA.setHomePage('http://www.sparta.cz/');
}

// funkce nabidne uzivateli pridat stranku k oblibenym polozkam
function add2Favorites() {
	if ( (navigator.appVersion.indexOf("MSIE") > 0 ) && ( parseInt(navigator.appVersion) >= 4) ) {
		window.external.AddFavorite("http://www.sparta.cz/", "Sparta");
	}
}

function getIframeHeight(iframe) {
	var iframeH = 0, scrollHeight, offsetHeight;
	if (iframe.height) iframeH = iframe.height;
	else if (iframe.body) {
		if (iframe.body.scrollHeight) iframeH = scrollHeight = iframe.body.scrollHeight;
		if (iframe.body.offsetHeight) iframeH = offsetHeight = iframe.body.offsetHeight;
		if (scrollHeight && offsetHeight) iframeH = Math.max(scrollHeight, offsetHeight);
	}
	return iframeH;
}

function setIframeHeight(iframe) {
  var Win = window.frames[iframe];
  var El = document.getElementById? document.getElementById(iframe): document.all? document.all[iframe]: null;
  if ( El && Win ) {
    El.style.height = "auto";   
    var iframeH = getIframeHeight(Win.document);
    if (iframeH) El.style.height = iframeH + "px";
    //alert(iframeH);
  }
}


// Cookie functions
function qSet_Cookie( name, value, expires, path, domain, secure ) {
	// set time, it's in milliseconds
	var today = new Date();
	today.setTime( today.getTime() );
	
	/*
	if the expires variable is set, make the correct 
	expires time, the current script below will set 
	it for x number of days, to make it for hours, 
	delete * 24, for minutes, delete * 60 * 24
	*/
	if ( expires )
	{
	expires = expires * 1000 * 60 * 60 * 24;
	}
	var expires_date = new Date( today.getTime() + (expires) );
	
	document.cookie = name + "=" +escape( value ) +
	( ( expires ) ? ";expires=" + expires_date.toGMTString() : "" ) + 
	( ( path ) ? ";path=" + path : "" ) + 
	( ( domain ) ? ";domain=" + domain : "" ) +
	( ( secure ) ? ";secure" : "" );
}

// this function gets the cookie, if it exists
function Get_Cookie( name ) {
	var start = document.cookie.indexOf( name + "=" );
	var len = start + name.length + 1;
	if ( ( !start ) &&
	( name != document.cookie.substring( 0, name.length ) ) )
	{
	return null;
	}
	if ( start == -1 ) return null;
	var end = document.cookie.indexOf( ";", len );
	if ( end == -1 ) end = document.cookie.length;
	return unescape( document.cookie.substring( len, end ) );
}
// this deletes the cookie when called
function Delete_Cookie( name, path, domain ) {
	if ( Get_Cookie( name ) ) document.cookie = name + "=" +
	( ( path ) ? ";path=" + path : "") +
	( ( domain ) ? ";domain=" + domain : "" ) +
	";expires=Thu, 01-Jan-1970 00:00:01 GMT";
}	

function obj(id) {
	return document.getElementById(id);
}
function getElementsByClassName(oElm, strTagName, strClassName){
	var arrElements = (strTagName == "*" && oElm.all)? oElm.all : oElm.getElementsByTagName(strTagName);
	var arrReturnElements = new Array();
	strClassName = strClassName.replace(/\-/g, "\\-");
	var oRegExp = new RegExp("(^|\\s)" + strClassName + "(\\s|$)");
	var oElement;
	for (var i=0; i<arrElements.length; i++) {
		oElement = arrElements[i];
		if (oRegExp.test(oElement.className)) {
			arrReturnElements.push(oElement);
		}
	}
	return (arrReturnElements);
}

//zobrazí novinku (obrázek, perex) podle id aktuálního elementu
function showNewsById(elementId) {
	var newsItems = getElementsByClassName(obj("news-list"), "div", "news-item");
	var subItemImg, subItemPerex;
	var i;

	if (newsItems.length) {
		newsItemsCount = newsItems.length;
		// schovani vsech polozek - zobrazeni pouze tech, ktere odpovidaji aktualnimu id elementu
		for (i = 0; i < newsItemsCount; i++) {
			subItemImg = getElementsByClassName(newsItems[i],"div","img");
			subItemPerex = getElementsByClassName(newsItems[i],"div","perex");
			if (subItemImg.length) {
			    if ((i+1) == elementId) {
       				subItemImg[0].className = "img";
				}
				else {
       				subItemImg[0].className = "img none";
				}
			}
			if (subItemPerex.length) {
			    if ((i+1) == elementId) {
       				subItemPerex[0].className = "perex";
				}
				else {
       				subItemPerex[0].className = "perex none";
				}
			}
		}
	}
}
