eval("try {document.execCommand('BackgroundImageCache', false, true);} catch(e) {}");



var itemIdPodcast = "";



$(document).ready(function() {

	$("#how-listen a").bind("mouseout", function (){

		$("#how-listen-desc").text('');													

	});

	

	$("#hl-1").bind("mouseover", function (){

		$("#how-listen-desc").html(localHowListen1);

	});

	$("#hl-2").bind("mouseover", function (){

		$("#how-listen-desc").html(localHowListen2);													

	});

	$("#hl-3").bind("mouseover", function (){

		$("#how-listen-desc").html(localHowListen3);													

	});

	$("#hl-4").bind("mouseover", function (){

		$("#how-listen-desc").html(localHowListen4);													

	});

	

	

	$("#search-box #query").attr("value",localSearchQuery);

	$("#search-box #query").focus(function(){

		if($("#search-box #query").attr("value") == localSearchQuery){

			$("#search-box #query").attr("value","");				 

		}

	}).blur(function(){

		if($("#search-box #query").attr("value") == ""){

			$("#search-box #query").attr("value",localSearchQuery);				 

		}

	})

	

	$("#tabs").makeTabs();

	

	$(".index .box").click(function(event){

		var hasClick = $("h2 a", $(this)).attr("rel");

		if (hasClick) {

			$("h2 a", $(this)).click();

			return false;

		}

		window.location = $("h2 a", $(this)).attr("href");

	});

	$(".index .box").find("h2 a").click(function(event){

		event.stopPropagation();

	});

	

	$(".index .box").mouseover(function(){

		$(this).addClass("hover");	

	}).mouseout(function(){

		$(this).removeClass("hover");					 

	});

	

	$("#left-column .multimedia ul li").click(function(event){

		window.location = $("a", $(this)).attr("href");

	});

	

	if(getCookie("fontSize") && getCookie("fontSize") != "fs-2"){

		$("#"+getCookie("fontSize")).addClass("sel");

	}

	else {

		$("#fs-2").addClass("sel");

	}

	$("#fs-box a").bind("click", function(event){

		$("#fs-box a").removeClass("sel");

		$(this).addClass("sel");

		

		var index = $("#fs-box a").index(this)+1;

		var fontSize = getCookie("fontSize");

		if(fontSize){

			$("body").removeClass(fontSize);

		}

		$("body").addClass("fs-"+index);

		setCookie("fontSize", "fs-"+index, 365);

		event.stopPropagation();

		

		return false;

	});

	

});



/* prepinani poradu v boxu na HP */

function bindShowBoxReload() {

	$('#porady-list li a').bind('click', reload);

}

function reload() {

	var url = '/cs/porady-na-hp/' + $(this).attr('id') + '.shtml';

	$("#porady-content").css({height: $("#porady-content").get(0).offsetHeight});

	$("#porady-content").fadeOut("normal", function() {

		$("#porady-content").css({display: "block"});

		$(this).load(url, null, function() {

			bindShowBoxReload();

			$("#porady-content").css({height: "auto"});

			$("#porady-content").fadeIn("normal");

			$("#tabs").makeTabs();

		})

	});

	return false;

}



function hpTabs(id) {

	$(".media").hide();

	$("#block"+id).removeClass("hide");

	$("#block"+id).show();

}



/*

function switchFontSize (size) {

	$("#fs1").removeClass("sel");

	$("#fs2").removeClass("sel");

	$("#fs3").removeClass("sel");

	

	$("#fs"+size).addClass("sel");

	

	return false;

}

*/



/* Check for JQuery browser supporting */



function supportedBrowser() {

  try {

	var strVersion = $.browser.version;

	var index = strVersion.indexOf(".");

	if (index > -1) {

	  var index2 = strVersion.indexOf(".", index + 1);

	  if (index2 == -1) index2 = strVersion.length; 

	  strVersion = strVersion.substr(0, index2);

	}

	

	var version = parseFloat(strVersion);

	

	if ($.browser.msie && version >= 6) return true;

	if ($.browser.mozilla && version >= 1.5) return true;

	if ($.browser.opera && version >= 9) return true;

	if ($.browser.safari) return true;

  } catch (err) {

	return false;

  }

}



// Save cookie

function setCookie(name,value,days) {

	if (days != null || days != 0) {

		var today = new Date();

		var expire = new Date();

		expire.setTime(today.getTime() + 3600000*24*days);

		expire = "; expires=" + expire.toGMTString();

	} else { var expire = ""; }

	document.cookie = name + "=" + escape(value) + expire + "; path=/";

}

// Read cookie

function getCookie(Name) {

	var search = Name + "=";

	if (document.cookie.length > 0) { // if there are any cookies

		offset = document.cookie.indexOf(search);

		if (offset != -1) { // if cookie exists

			offset += search.length

			// set index of beginning of value

			end = document.cookie.indexOf(";", offset)

			// set index of end of cookie value

			if (end == -1)

				end = document.cookie.length

				return unescape(document.cookie.substring(offset, end))

		}

		else {

			return false;	

		}

	}

}



function toggleProgram (id) {

	$("h3[id^='a-day']").removeClass("actual");

	$("#a-day"+id).addClass("actual");

	manageWidget(id);

}



/* Hide / Show widgets */

function manageWidget(idWidget)	{

  if (supportedBrowser()) {

  	$("#widget-" + idWidget).show("fast");

  	$(".hide-widget").each(

      function(i){

        if (this.style.display != 'none' && this.style.id != "#" + idWidget) $(this).hide();

      }

    );

  	return false;

  }

}

/* */

function callActualF1() {

	if (supportedBrowser()) {

		var getOutCache = Math.random();

		$("#actual-info").load("/cs/_aktualni-informace.shtml?"+getOutCache);

	}

}

var sniffer = setInterval("callActualF1()", 15000);



function callContent(intoElementId, urlContent) {

	if (supportedBrowser()) {

		var getOutCache = Math.random();

		$("#"+intoElementId).load(urlContent+"&"+getOutCache);

	}

}



/* Taby */

$.prototype.makeTabs = function() {

	var tbItem;

	var tabs = $("#" + this.attr("id") + " li a");

	if(tabs.length == 0) return;

	for (var ti=0; ti < tabs.length; ti++)

	{

	    tbItem = $(tabs[ti]).attr("href");

	    

		$("div[class*='tabs-" + tbItem.substr(tbItem.indexOf("#")+1) + "']").hide();

		$(tabs[ti]).bind("click", function() {

			for (var tiin=0; tiin < tabs.length; tiin++)

			{

                tbItem = $(tabs[tiin]).attr("href");

				$(tabs[tiin]).removeClass("active");

				$("div[class*='tabs-" + tbItem.substr(tbItem.indexOf("#")+1) + "']").hide();

			}

			$(this).addClass("active");

			tbItem = $(this).attr("href");

			$("div[class*='tabs-" + tbItem.substr(tbItem.indexOf("#")+1) + "']").show();

			return false;

		});

	}



	$("#" + this.attr("id") + " li a:first").addClass("active");

	tbItem = $(tabs[0]).attr("href");

	$("div[class*='tabs-" + tbItem.substr(tbItem.indexOf("#")+1) + "']").show();

}



/* image mapy */

/*

 * vytvoreny objekt se musi jmenovat stejne, jako jeho prvni parametr (tedy jmeno/id mapy) - kvuli namapovani toggleArea na jednotlive arey mapy

 * priklad:

 * var imagemap1 = new ImageMap("imagemap1"...)

 * pridany tooltips - vse mezi /* ****** * /

 */



function ImageMap(id, mapWidth, mapHeight, bgrImg, hasTooltips, object) {

	this.id = id;

	this.map = $("img[usemap$='"+id+"']");

	this.mapH = mapHeight;

	this.mapW = mapWidth;

	this.toolTips = hasTooltips;

	

	this.overId = "IM-"+id;

	this.mapOver = null;



	this.init = function() {

		this.map.after('<img src="/img/u/spacer.gif" class="map-over png-fix" id="'+this.overId+'" style="width: '+this.mapW+'px; height: '+this.mapH+'px" alt="" usemap="#'+this.id+'" />');

		this.mapOver = $("#"+this.overId);

		this.mapOver.css("background-image", "url('"+bgrImg+"')");



		var mapAreas = $("map[name='"+this.id+"'] area");



		for (var i=0; i< mapAreas.length; i++) {

			$(mapAreas[i]).attr("rel", "area"+(i+1));

			mapAreas[i].onmouseover = function(e) {

				

				var areaCnt = $(this).attr("rel").substring(4);

				if (eval(id+".toolTips")) {

					if(object == "pocasi"){

						$("#toolTipBox #localName").html(teploty[areaCnt][0]);

						$("#toolTipBox #localDay").html(teploty[areaCnt][1]);

						$("#toolTipBox #localNight").html(teploty[areaCnt][2]);

						$("#toolTipBox .in").addClass(teploty[areaCnt][3]);

					}

					else if(object == "frekvence"){

						$("#toolTipBox #localName").html(frekvence[areaCnt][0]);

						$("#toolTipBox #localFrequence").html(frekvence[areaCnt][1]+" FM");

					}

					$("#toolTipBox").show();

				}



				eval(id+".toggleArea("+areaCnt+")");

			};

			mapAreas[i].onmouseout = function() {

				

				var areaCnt = $(this).attr("rel").substring(4);

				eval(id+".toggleArea(0)");

				if (eval(id+".toolTips")) {

					if(object == "pocasi"){

						$("#toolTipBox .in").removeClass(teploty[areaCnt][3]);

					}

					$("#toolTipBox").hide();

					

				}

			};

		}

	};



	this.toggleArea = function(area) {

		var posY = -1*(parseInt(area)*this.mapH);

		this.mapOver.css("background-position", "0px "+posY+"px");

	};



	this.init();

}



/* Obsluha podcastu */

function JWPlayer(JWFile, JWWidth, JWHeight, mediaPerex, mediaTitle, mediaTheme, mediaDate, mediaID, motive)	{

			var imgMotive = (motive) ? '/img/edee/u/podcast' + motive : '/img/u/podcast.gif';

			var flashvars = {

				file: JWFile,

				allowfullscreen: "true",

				allowscriptaccess: "always",

				backcolor: "#ffffff",  /* barva pozadi listy pod ovladanim */

				frontcolor: "#000000", /* ovladani */

				lightcolor: "#000000", /* barva volume */

				screencolor: "#000000", /* barva pod videem */

				image: imgMotive	/* obrázek pod videem */

			};

			var params = {

				wmode: "transparent"

			};

			swfobject.embedSWF('/swf/u/player.swf','player',JWWidth, JWHeight, "9.0.0","/swf/u/expressInstall.swf", flashvars, params);

			$('#multimedia-content').focus();

			$('#multimedia-box .tracking span').html(" <span class=\"sep\">&rsaquo;</span> "+mediaTheme);

			$('#multimedia-content h2').text(mediaTitle);

			$('#multimedia-content #podcast-date').text(mediaDate);

			$('#multimedia-content .file-info #podcast-theme').text(mediaTheme);

			initRating("podcast", mediaID);

			//var imgWidtRate = $("#podcastitem-"+mediaID+" a[rel]").attr("rel");

			var imgWidtRate = $("#podcastitem-"+mediaID+" span[title]").attr("title");

			if(imgWidtRate=="" || imgWidtRate==0){

				imgWidtRate="0px";

			}

			else{

				imgWidtRate=parseInt(imgWidtRate)+"%";

			}

			$("#multimedia-content .file-info .rating img").animate({

				width: imgWidtRate

			}, 500);

			RatingService.getRatingStatus([{name:"podcast", identifier:mediaID}], onRatingStatusResult);

            callActualComments(mediaID, mediaTitle);

			itemIdPodcast = mediaID;

}

/* Obsluha podcastu na HP */

function JWPlayerHp(JWFile, JWPlayerId, relatedXmlId)	{

			var imgMotive;

			if (JWFile.indexOf(".mp3") != -1) {

				imgMotive = "/img/u/ico-audio-hp-default.png";

			}

			else {

			    imgMotive = null;

			}

			var flashvars = {

				file: JWFile,

				allowfullscreen: "false",

				allowscriptaccess: "always",

				backcolor: "#ffffff",  /* barva pozadi listy pod ovladanim */

				frontcolor: "#000000", /* ovladani */

				lightcolor: "#000000", /* barva volume */

				screencolor: "#000000", /* barva pod videem */

    			image: imgMotive

			};

			

			var params = {

				wmode: "transparent"

			};



			if (relatedXmlId) {

				flashvars.plugins = '/swf/u/related';

				flashvars['drelated.dxmlpath'] = "/cs/porady-na-hp/_dalsi-videa-"+relatedXmlId+".xml";

				flashvars['drelated.dposition'] = 'center';

				flashvars['drelated.dskin'] = '/swf/u/grayskin.swf';

				flashvars['drelated.dtarget'] = '_self';

			}

			

			swfobject.embedSWF('/swf/u/player-w-related.swf',JWPlayerId, 247, 207, "9.0.0","/swf/u/expressInstall.swf", flashvars, params);

}
/* Obsluha podcastu v článcích */

function JWPlayerArticle(JWFile, JWWidth, JWHeight, JWPlayerId, relatedXmlId)	{

			var imgMotive;
			/*
			var JWWidth = 400;
			var JWHeight = 300;
			*/

			if (JWFile.indexOf(".mp3") != -1) {

				imgMotive = "/img/u/ico-audio-hp-default.png";

			}

			else {

			    imgMotive = null;

			}

			var flashvars = {

				file: JWFile,

				allowfullscreen: "false",

				allowscriptaccess: "always",

				backcolor: "#ffffff",  /* barva pozadi listy pod ovladanim */

				frontcolor: "#000000", /* ovladani */

				lightcolor: "#000000", /* barva volume */

				screencolor: "#000000", /* barva pod videem */

    			image: imgMotive

			};



			var params = {

				wmode: "transparent"

			};



			if (relatedXmlId) {

				flashvars.plugins = '/swf/u/related';

				flashvars['drelated.dxmlpath'] = "/cs/porady-na-hp/_dalsi-videa-"+relatedXmlId+".xml";

				flashvars['drelated.dposition'] = 'center';

				flashvars['drelated.dskin'] = '/swf/u/grayskin.swf';

				flashvars['drelated.dtarget'] = '_self';

			}



			swfobject.embedSWF('/swf/u/player-w-related.swf',JWPlayerId, JWWidth, JWHeight, "9.0.0","/swf/u/expressInstall.swf", flashvars, params);

}

function JWPlayer(JWFile, JWWidth, JWHeight, mediaPerex, mediaTitle, mediaTheme, mediaDate, mediaID, motive)	{

			var imgMotive = (motive) ? '/img/edee/u/podcast' + motive : '/img/u/podcast.gif';

			var flashvars = {

				file: JWFile,

				allowfullscreen: "true",

				allowscriptaccess: "always",

				backcolor: "#ffffff",  /* barva pozadi listy pod ovladanim */

				frontcolor: "#000000", /* ovladani */

				lightcolor: "#000000", /* barva volume */

				screencolor: "#000000", /* barva pod videem */

				image: imgMotive	/* obrázek pod videem */

			};

			var params = {

				wmode: "transparent"

			};

			swfobject.embedSWF('/swf/u/player.swf','player',JWWidth, JWHeight, "9.0.0","/swf/u/expressInstall.swf", flashvars, params);

			$('#multimedia-content').focus();

			$('#multimedia-box .tracking span').html(" <span class=\"sep\">&rsaquo;</span> "+mediaTheme);

			$('#multimedia-content h2').text(mediaTitle);

			$('#multimedia-content #podcast-date').text(mediaDate);

			$('#multimedia-content .file-info #podcast-theme').text(mediaTheme);

			initRating("podcast", mediaID);

			//var imgWidtRate = $("#podcastitem-"+mediaID+" a[rel]").attr("rel");

			var imgWidtRate = $("#podcastitem-"+mediaID+" span[title]").attr("title");

			if(imgWidtRate=="" || imgWidtRate==0){

				imgWidtRate="0px";

			}

			else{

				imgWidtRate=parseInt(imgWidtRate)+"%";

			}

			$("#multimedia-content .file-info .rating img").animate({

				width: imgWidtRate

			}, 500);

			RatingService.getRatingStatus([{name:"podcast", identifier:mediaID}], onRatingStatusResult);

            callActualComments(mediaID, mediaTitle);

			itemIdPodcast = mediaID;

}

/* Obsluha embedu jednoho viea */

function JWPlayerSingle(JWFile, JWPlayerId)	{
    var imgMotive;
    if (JWFile.indexOf(".mp3") != -1) {
        imgMotive = "/img/u/ico-audio-hp-default.png";
    } else {
        imgMotive = null;
    }
    var flashvars = {
        file: JWFile,
        allowfullscreen: "false",
        allowscriptaccess: "always",
        backcolor: "#ffffff",  /* barva pozadi listy pod ovladanim */
        frontcolor: "#000000", /* ovladani */
        lightcolor: "#000000", /* barva volume */
        screencolor: "#000000", /* barva pod videem */
        image: imgMotive
    };
    var params = {
        wmode: "transparent"
    };
    swfobject.embedSWF('/swf/u/player.swf',JWPlayerId, 400, 20, "9.0.0","/swf/u/expressInstall.swf", flashvars, params);
}

function changezIndexOnDimm(){

			$(".highslide-dimming").css("z-index", parseInt($(".imageHighslide").css("z-index"))+1);

};

function hideControl() {

	$(".highslide-previous, .highslide-next").hide();

}

function getParameter(name) {

	if(typeof document.parameters == "undefined") {

		setupParameters();

	}

	return document.parameters[name];

}

function setupParameters() {

	var parameters = new Object();

	if(window.location.search) {

		var paramArray = window.location.search.substr(1).split('&');

		var length = paramArray.length;

		for (var index = 0;index <length; index++ ) {

			var param = paramArray[index].split('=');

			var name = param[0];

			var value =

			typeof param[1] == "string"

				? decodeURIComponent(param[1].replace(/\+/g, ' '))

				: null;

			parameters[name] = value;

		}

	}

	document.parameters = parameters;

}

function init() {

	/* gallery on demand */

	var paramGallery = getParameter("gallery");

	if (typeof paramGallery != "undefined") {

		openHighslideGallery(paramGallery);

	}

}

function openHighslideGallery(id) {

	if ($("#"+id)) {

		var anch = document.getElementById(id);

		hs.expand(anch, { fadeInOut: false, wrapperClassName: 'wide-border imageHighslide'});

	}

}



function openGame(url) {

	gameF1 = window.open(url,'gameF1','width=1024,height=768,scrollbars=yes,toolbar=no,status=no,menubar=no,location=no,directories=no,resizable=no');

}



function wOpener (linkURL)	{

	if (window.opener && !window.opener.closed) {

		// odkazy z popupu smeruji do openeru, na opener se preda focus

		window.opener.location.href=linkURL;

		window.opener.focus();

	} else {

		// Pokud neexistuje opener, otevre se nove okno a to stavajici se zavre, aby nevznikala dalsi a dalsi okna...

		window.open(linkURL);

		window.close();

	}

	return false;

}



/**
 * funkce na zobrazení celého textu
 */
function showCompleteText(ele){
	$(ele).parent().next("div").show();
	$(ele).parent().hide();
}
function hideCompleteText(ele){
	$(ele).parent().prev("p").show();
	$(ele).parent().hide();
}