﻿// Injectincg Random Flash Objects with SWF Object - preferované reseni r. 2010
function randomSwfObject(fContainer,fObjectId,fMovieCSV,fWidth,fHeight,version,bgColor) {

	// fMovieCSV - string with semicolon separated swf filenames
	var regexpRemLastSemicolon=/^(.+);$/;
	fMovieCSV = fMovieCSV.replace(regexpRemLastSemicolon,"$1"); //odstranit strednik z konce retezece, konci-li retezec strednikem
	var fMovieArray = fMovieCSV.split(";");
	var fMovie = fMovieArray[Math.floor(Math.random()*fMovieArray.length)];

	var fMovieUrl;
	if(location.hostname=='iportal.cezdata.corp')  {
		fMovieUrl = "/edee/content/"+fMovie;
	} else {
		fMovieUrl = "http://www.cez.cz/edee/content/"+fMovie;
	}; 	
	var so = new SWFObject(fMovieUrl, fObjectId, fWidth, fHeight, version, bgColor);	
    so.write(fContainer);
	
}

// gup() - for Get URL Param (cat = category)
function gup(name){
	name = name.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]");
	var regexS = "[\\?&]"+name+"=([^&#]*)";
	var regex = new RegExp(regexS);
	var results = regex.exec(window.location.href);
	if (results == null) {
		return '';
	} else {
		return results[1];
	}
}


// Injectincg Flash Objects
function writeFlash(fId,objectId,fMovie,fW,fH,paramArray,classId) {
	var flashCode = '<object type="application/x-shockwave-flash"  width="'+fW+'" height="'+fH+'"  data="'+fMovie+'"';
	if (classId) {
		flashCode += ' class="'+classId+'" ';
	}
	if (objectId) {
		flashCode += ' id="'+objectId+'" ';
	}
	flashCode += '>';
	flashCode += '<param name="movie" value="'+fMovie+'" />';
    flashCodeParam = '';
	for (i=0;i<paramArray.length;i++) {
		flashCode += '<param name="'+paramArray[i][0]+'" value="'+paramArray[i][1]+'" />';
    	flashCodeParam += ' ' + paramArray[i][0] + '="'+paramArray[i][1] + '"';
	}
	if (document.getElementById(fId+'-noscript')) {
		flashCode += document.getElementById(fId+'-noscript').innerHTML;
	}
    flashCode += '<embed src="'+fMovie+'" bgcolor="#000" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="'+fW+'" height="'+fH+'" '+flashCodeParam+'\>\<\/embed\>';
	flashCode += '</object>';
	if (document.getElementById(fId)) {
		document.getElementById(fId).innerHTML = flashCode;
	}
}

// Injectincg Random Flash Objects - inserts random item of an array of swf files
function writeRandomFlash(fId,objectId,fMovieCSV,fW,fH,paramArray,classId) {

	// fMovieCSV - string with semicolon separated swf filenames
	var regexpRemLastSemicolon=/^(.+);$/;
	fMovieCSV = fMovieCSV.replace(regexpRemLastSemicolon,"$1"); //odstranit strednik z konce retezece, konci-li retezec strednikem
	var fMovieArray = fMovieCSV.split(";");
	var fMovie = fMovieArray[Math.floor(Math.random()*fMovieArray.length)];

//	alert(fMovie);
	
	var reParseFMovie=/(.+?)\?clickthru=(.+)/;
	var	reGetFileExt=/(.+?)\.(.+)/;	
	
	if( parsedFMovie=fMovie.match(reParseFMovie) ) { // nazev souboru nasledovaný částí "?clickthru=odkaz"
	
//		alert("parsedFMovie: "+parsedFMovie);
		
		var bannerFile=parsedFMovie[1];
		var bannerLink=parsedFMovie[2];
	
		bannerFileExt=bannerFile.replace(reGetFileExt,"$2");
	} else {
		bannerFileExt=fMovie.replace(reGetFileExt,"$2");
	};

	
//	alert(bannerFileExt);		
	
	if(bannerFileExt=="swf") { // flash banner
		var bannerCode = '<object type="application/x-shockwave-flash"  width="'+fW+'" height="'+fH+'"  data="'+fMovie+'"';
		if (classId) {
			bannerCode += ' class="'+classId+'" ';
		}
		if (objectId) {
			bannerCode += ' id="'+objectId+'" ';
		}
		bannerCode += '>';
		bannerCode += '<param name="movie" value="'+fMovie+'" />';
		for (i=0;i<paramArray.length;i++) {
			bannerCode += '<param name="'+paramArray[i][0]+'" value="'+paramArray[i][1]+'" />';
		}
		if (document.getElementById(fId+'-noscript')) {
			bannerCode += document.getElementById(fId+'-noscript').innerHTML;
		}
		bannerCode += '</object>';
	} else { // non-flash banner (e.g. .jpg or .gif)
		var openInNewWindow=( /^http:/.test(bannerLink)  )?'target="_blank"':''; // pokud URL odkazu začíná na http:, bude se odkaz otvírat do nového okna
		var bannerCode  = '<div>';
		bannerCode += '<a href="'+bannerLink+'" '+openInNewWindow+'>';
		bannerCode += '<img src="'+bannerFile+'" alt="" />';
		bannerCode += '</a></div>';
	};

	// Flash detection (requires AC_OETags.js)
	var requiredMajorVersion = 6; // Major version of Flash required
	var requiredMinorVersion = 0; // Minor version of Flash required
	var requiredRevision = 0; // Minor revision of Flash required
  var hasReqestedVersion = DetectFlashVer(requiredMajorVersion, requiredMinorVersion, requiredRevision);

	if (document.getElementById(fId) && hasReqestedVersion) {
		document.getElementById(fId).innerHTML = bannerCode;
	}
}



// IE img blink disabled
eval("try {document.execCommand('BackgroundImageCache', false, true);} catch(e) {}");

// StringBuffer object
function StringBuffer() {
	this.buffer = "";
	this.append = new Function("str", "this.buffer += str;");
	this.getString = new Function("return this.buffer");
}





/***************************************/

jQuery(document).ready( /* jQuery no conflict block */
	function($) {


  /* Zalozkovy box - tabs */
  // prototype
  $.prototype.makeTabs = function() {
  	var tabs = $("#" + this.attr("id") + " li a");
  	if(tabs.length == 0) return;
  	for (var ti=0; ti < tabs.length; ti++)
  	{
  		$("div[class*='tabs-box-" + $(tabs[ti]).attr("id").substring(1) + "']").css("visibility","hidden");
  		$(tabs[ti]).bind("mouseover", function() {
  			for (var tiin=0; tiin < tabs.length; tiin++)
  			{
  				$(tabs[tiin]).removeClass("active");
  				$("div[class*='tabs-box-" + $(tabs[tiin]).attr("id").substring(1) + "']").css("visibility","hidden");
  			}
  			$(this).addClass("active");
  			$("div[class*='tabs-box-" + $(this).attr("id").substring(1) + "']").css("visibility","visible");
  			return false;
  		});
  	}
  	$("#" + this.attr("id") + " li a:eq(1)").addClass("active");
  	//$("div[class*='tabs-box-" + $(tabs[0]).attr("id").substring(1) + "']").css("visibility","visible");
	$("#tbblok2").css("visibility","visible");
  }
  // bind
	$("#tabs-box").makeTabs();

  /* END - Zalozkovy box - tabs */



})




/* rating */

var yourRating = 0;
var postRatedCount = 0;
var ratingContainer = "";

/**
 * volá se při loadu stránky, zjistí, zda uživatel může hlasovat a podle toho připraví hlasovací odkazy
 **/
function onRatingStatusResult(ratingStatus) {
	if (typeof(ratingStatus) != "object") return;

	var canVote = ratingStatus.allowed;
	var postRating;
	for (var i = 0; i < ratingStatus.ratingResults.length; i++) {
		var result = ratingStatus.ratingResults[i];
		postRating = result.rating;
		postRatedCount = result.totalVotes;
	}
	writeRatingControls(canVote, postRating, postRatedCount);
}

/**
 * samotné zahlasování
 **/
function rate(rating, category, idArticle) {
	// započtení hlasu k článku
	yourRating = rating;
	$("#"+ratingContainer).html("");
	$("#"+ratingContainer).css( { 'background-position' : '0px -120px' } );
	var contents = [{name:category, identifier:idArticle}];
	RatingService.rate(contents, rating, onRatingResult);
}

/**
 * zavolá se po odhlasování (poté, co proběhne funkce rate(). Zpracování výsledků, zákaz dalšího hlasování
 **/
function onRatingResult(ratings){
	if (typeof(ratings) != "object") return;
	var canVote = false;
	var postRating;

	for (var i = 0; i < ratings.length; i++) {
		var rating = ratings[i];
		var postRating = rating.rating;
		var postRatedCount = rating.totalVotes;
	}
	writeRatingControls(canVote, postRating, postRatedCount);
	$("#rateResult").addClass("infos");
	$("#rateResult").text("Děkujeme za hlas. Vaše hodnocení je "+yourRating+", celkový průměr je "+Math.round(postRating)+".");
	$("#rateResult").show();
}

function initRating(strIdentificator, idArticle) {
	var sb = new StringBuffer();

	sb.append('<div class="rating">');
	sb.append('	<h3>Hodnocení</h3>');
	sb.append('	<p>Líbí se Vám tento projekt? Máte možnost ocenit jeho kvalitu.</p>');
	sb.append('	<p id="rateArticle">');
	sb.append('		<a href="#1" class="rate1" title="Udělit 1 hvězdičku" onclick="rate(1, \''+strIdentificator+'\', \''+idArticle+'\'); return false;"><span>1/5</span></a><span> | </span>');
	sb.append('		<a href="#2" class="rate2" title="Udělit 2 hvězdičky" onclick="rate(2, \''+strIdentificator+'\', \''+idArticle+'\'); return false;"><span>2/5</span></a><span> | </span>');
	sb.append('		<a href="#3" class="rate3" title="Udělit 3 hvězdičky" onclick="rate(3, \''+strIdentificator+'\', \''+idArticle+'\'); return false;"><span>3/5</span></a><span> | </span>');
	sb.append('		<a href="#4" class="rate4" title="Udělit 4 hvězdičky" onclick="rate(4, \''+strIdentificator+'\', \''+idArticle+'\'); return false;"><span>4/5</span></a><span> | </span>');
	sb.append('		<a href="#5" class="rate5" title="Udělit 5 hvězdiček" onclick="rate(5, \''+strIdentificator+'\', \''+idArticle+'\'); return false;"><span>5/5</span></a>');
	sb.append('	</p>');
	sb.append('	<p id="rateResult"></p>');
	sb.append('</div>');
	$(document).ready(function() {
		$("#content #left").append(sb.getString());
		ratingContainer = "rateArticle";
		$("#"+ratingContainer+" a").each( function() {
			$(this).hover(
				function() { var no = this.className.substr(4); $("#"+ratingContainer).css( { 'background-position' : '0px ' + (-20*no) + 'px' } ); },
				function() { $("#"+ratingContainer).css( { 'background-position' : '0px 0px' } ); }
			);
		});
	});
}

function writeRatingControls(boolCanVote, intPostRating, intPostRatedCount) {
	if (!boolCanVote) {
		// nastaveni bgr hvezdicek na aktualni stav
		var tmp = -20*Math.round(intPostRating*1);
		$("#"+ratingContainer).css( { 'background-position' :'0px '+tmp+'px' } );
		// nastavení popisku hvezdickam
		$("#"+ratingContainer).attr("title", "Tento článek jste již hodnotil/a - aktuální stav hodnocení: " + Math.round(intPostRating*1) + "/5");
		$("#"+ratingContainer).html("");
	}
	$("#"+ratingContainer).show();
	$("#rateResult").addClass("note");
	$("#rateResult").css( { 'font-weight' : 'bold' } );
	if (intPostRatedCount <= 0) {
		$("#rateResult").text("Článek nebyl prozatím hodnocen.");
	} else {
		$("#rateResult").text("Celkové hodnocení je "+Math.round(intPostRating*1)+", článek hodnocen celkem "+intPostRatedCount+"x.");
	}
	$("#rateResult").show();
}

/* aut. nastaveni vysky frame s anketou */
function setIframeHeight(h,f) {
	$("#"+f).attr({
           height: h
     });
}

var crRegions = new Array();
crRegions = ["", "karlovarsky", "plzensky", "ustecky", "praha", "stredocesky", "jihocesky", "liberecky", "vysocina", "kralovehradecky", "pardubicky", "jihomoravsky", "olomoucky", "zlinsky", "moravskoslezsky"];

function GOOGLEMAP_ActivateRegion(regionId) {
	$("#flash-map-cr").fadeOut("normal", function(){ $("#apimap").css( { "visibility" : "visible" } ); });
	$("#flash-map-cr").css( { "visibility" : "hidden" } );
	GOOGLEMAP_ZoomToRegion(regionId);
	GOOGLEMAP_Controls.activate();
}

function GOOGLEMAP_ZoomToRegion(regionId) {
	switch(regionId) {
		case 1:
			map.setCenter(new GLatLng(50.08783778, 14.42413194), 10);	// karlovarsky kraj
			break;
		case 2:
			map.setCenter(new GLatLng(49.74747583, 13.37758722), 10);	// plzensky
			break;
		case 3:
			map.setCenter(new GLatLng(50.66070472, 14.03227194), 10); 	// ustecky
			break;
		case 4:
			map.setCenter(new GLatLng(50.08783778, 14.42413194), 13);	// praha
			break;
		case 5:
			map.setCenter(new GLatLng(50.08783778, 14.42413194), 10);	// stredocesky
			break;
		case 6:
			map.setCenter(new GLatLng(48.97446917, 14.47434083), 10);	// jihocesky
			break;
		case 7:
			map.setCenter(new GLatLng(50.76711278, 15.05619167), 10);	// liberecky
			break;
		case 8:
			map.setCenter(new GLatLng(49.39610111, 15.59124472), 10);	// vysocina
			break;
		case 9:
			map.setCenter(new GLatLng(50.20922944, 15.83276833), 10);	// kralovehradecky
			break;
		case 10:
			map.setCenter(new GLatLng(50.04075167, 15.77659083), 10);	// pardubicky
			break;
		case 11:
			map.setCenter(new GLatLng(49.19519083, 16.59968889), 10);	// jihomoravsky
			break;
		case 12:
			map.setCenter(new GLatLng(49.59386972, 17.25087083), 10);	// olomoucky
			break;
		case 13:
			map.setCenter(new GLatLng(49.226655, 17.66633389), 10);	// zlinsky
			break;
		case 14:
			map.setCenter(new GLatLng(49.83464611, 18.28204417), 10); 	// moravskoslezsky
			break;
		default:
			break;
	}
}

var GOOGLEMAP_Controls = {

	// conf
	categoriesCount : 8,
	categoriesTransform : ['', 'hriste', 'nemocnice', 'kultura', 'pomoc', 'cyklostezka', 'energie', 'vzdelani', 'podpora'], // moznost pouzit, pokud nevyhovuji id 1-x
	debug : 0,
	
	// system vars
	mapContainerId : "",
	selectedAll : false,
	selectedCategories : new Array(),
	activated : false,

	init : function(str, autoStart) {
		this.mapContainerId = "#"+str;		// ulozeni id map containeru
		$(this.mapContainerId + " .btn-header li a").each( function(intIndex) { $(this).attr("rel", ++intIndex); });		// kazdy link kategorie dostane svuj rel=1,2...
		autoStart ? this.activate() : this.deactivate();	//pokud je autostart, aktivuje se ovladani kategorii projektu
		for (i = 0; i <= this.categoriesCount; i++) { this.selectedCategories[i] = false; }
	},

	activate : function() {

		if (this.activated) return;
		// zprovozneni funkcnosti kliku na zahlavi
//		$(this.mapContainerId + " .btn-header").css({"cursor" : "pointer"}).attr("title", "Kliknutím zapnete/vypnete všechny kategorie").bind("click", function(event) { GOOGLEMAP_Controls.toggleAllCategories(this,event); });
		// funkcnost kliku jednotlivych odkazu kategorii
		$(this.mapContainerId + " .btn-header li a").bind("click", function() { GOOGLEMAP_Controls.toggleCategory(this); return false; });
		$(this.mapContainerId + " .in").removeClass("disabled");

		if (this.debug) {
			sb = new StringBuffer();
			sb.append("<strong>DEBUG - Vybrané sekce:</strong><br/>");
			sb.append(this.getSelectedCategories());
			$(this.mapContainerId + " #debug").html(sb.getString());
		}

		this.activated = true;
	},

	deactivate : function() {
		// zakazani kliku na zahlavi i na odkazy
		$(this.mapContainerId + " .btn-header").css({"cursor" : "default"}).attr("title", "").unbind("click");
		$(this.mapContainerId + " .btn-header li a").unbind("click").bind("click", function() { return false; }).removeClass("activated");
//		$(this.mapContainerId + " .in").removeClass("active-all");
		for (i = 0; i <= this.categoriesCount; i++) { this.selectedCategories[i] = false; }
		$(this.mapContainerId + " .in").addClass("disabled");
		this.selectedAll = false;

		if (this.debug) {
			sb = new StringBuffer();
			sb.append("<strong>DEBUG - Vybrané sekce:</strong><br/>");
			sb.append(this.getSelectedCategories());
			$(this.mapContainerId + " #debug").html(sb.getString());
		}

		this.activated = false;
	},

	toggleAllCategories : function(obj,event) {
	// alert('toggleAllCategories');
    event || (event = window.event);
    var tagName = event.target.tagName.toLowerCase();
    if (tagName == "select" || tagName == "option") {    
       //alert(event.target.tagName); 
      return;
    }    
//    alert('OK');
    log(event.target.tagName);
		if (!this.selectedAll) {
//			$(".in", obj).addClass("active-all");
			$(this.mapContainerId + " .btn-header li a").addClass("activated");
			
			
			for (i = 1; i <= this.categoriesTransform.length; i++) {
				show(this.categoriesTransform[i]);
			}
			
			// alert("Zde v mapě zobrazit všechny projekty všech kategorií");

			for (i = 0; i <= this.categoriesCount; i++) { this.selectedCategories[i] = true; }
			this.selectedAll = true;
		} else {
//			$(".in", obj).removeClass("active-all");
			$(this.mapContainerId + " .btn-header li a").removeClass("activated");

			for (i = 1; i <= this.categoriesTransform.length; i++) {
				hide(this.categoriesTransform[i]);
			}
			// alert("Zde všechny projekty z mapy schovat.");

			for (i = 0; i <= this.categoriesCount; i++) { this.selectedCategories[i] = false; }
			this.selectedAll = false;
		}
		if (this.debug) {
			sb = new StringBuffer();
			sb.append("<strong>DEBUG - Vybrané sekce:</strong><br/>");
			sb.append(this.getSelectedCategories());
			$(this.mapContainerId + " #debug").html(sb.getString());
		}
	},
	toggleCategory : function(btn) {
	    var clickedBtn = $(btn).attr("rel");
		$(btn).toggleClass("activated");
		if (this.selectedAll) {
//			$(this.mapContainerId + " .in").removeClass("active-all");
			this.selectedAll = false;
		}
		this.selectedCategories[clickedBtn] = !this.selectedCategories[clickedBtn];
		if (this.selectedCategories[clickedBtn]) {
   
			show(this.categoriesTransform[clickedBtn]);//	 alert("Tady zapnout danou kategorii: " + this.categoriesTransform[clickedBtn] );

		} else {
			
			hide(this.categoriesTransform[clickedBtn]);// alert("Tady vypnout danou kategorii: " + this.categoriesTransform[clickedBtn] );

		}

		if (this.debug) {
			sb = new StringBuffer();
			sb.append("<strong>DEBUG - Vybrané sekce:</strong><br/>");
			sb.append(this.getSelectedCategories());
			$(this.mapContainerId + " #debug").html(sb.getString());
		}
	},
	getSelectedCategories : function() {
		var sb = new StringBuffer();
		for (i = 1; i <= this.categoriesCount; i++) {
			sb.append("Sekce " + i + " (" + this.categoriesTransform[i] + "): " + this.selectedCategories[i] + "<br />");
		}
		return sb.getString();
	}

};

// FHL - parse QueryString (www.cilichili.cz/?param=value)
// parameter script by www.datashaman.com + FHL corrections
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 getParameter(name) {
	if(typeof document.parameters == "undefined") {
		setupParameters();
	}
	return document.parameters[name];
}


/* startup */
$(document).ready(function() {
	$("#p-menu li").hover(
		function() {    
			$(this).addClass("hover");
		},
		function(){    
		  $(this).removeClass("hover");
		}
	);
	
	/* sumbit miniform using ajax */		
		$("#error404noticeForm").submit( function() {
			actionUrl=$(this).attr("action");
			error404urlValue=$("input[name='error404url']",this).val();
                        error404urlreferrerValue=$("input[name='error404urlreferrer']",this).val();
			error404langValue=$("input[name='error404lang']",this).val();
	//		thanksMsg="Upozornění bylo odesláno. Děkujeme.";
                        thanksMsg=$("input[name='error404thanks']",this).val();

			$.get(actionUrl,
				 { go: "1", error404url: error404urlValue, error404lang: error404langValue, error404urlreferrer: error404urlreferrerValue },
				  function(data){
				    alert(thanksMsg);
					$("#error404noticeForm").hide(); // hide form to prevent multiple submits
				  }			 
			  );
		} );

});


function isRadioChecked(inputObject) {
	for (i=0;i<inputObject.length;i++){
		if (inputObject[i].checked==true){
			return true;
		};
	};
	return false;
}








function alternate(id){
 if(document.getElementsByTagName){  
   var table = document.getElementById(id);  
   var rows = table.getElementsByTagName("tr");  
   for(i = 0; i < rows.length; i++){          
 //manipulate rows
     if(i % 2 == 0){
       rows[i].className = "even";
     }else{
       rows[i].className = "odd";
     }      
   }
 }
}






  // this function is needed to work around a bug in IE related to element attributes
  function hasClass(obj) {
     var result = false;
     if (obj.getAttributeNode("class") != null) {
         result = obj.getAttributeNode("class").value;
     }
     return result;
  }   

 function stripe(id) {
    // the flag we'll use to keep track of  whether the current row is odd or even
    var even = false;
  
    // if arguments are provided to specify the colours of the even & odd rows, then use the them;
    // otherwise use the following defaults:
    var evenColor = arguments[1] ? arguments[1] : "#fff";
    var oddColor = arguments[2] ? arguments[2] : "#eee";
  
    var table = document.getElementById(id);			      // obtain a reference to the desired table, if no such table exists, abort
    if (! table) { return; }
    // by definition, tables can have more than one tbody element, so we'll have to get the list of child &lt;tbody&gt;s 
    var tbodies = table.getElementsByTagName("tbody");

    for (var h = 0; h < tbodies.length; h++) {		    	  // and iterate through them...
    
      var trs = tbodies[h].getElementsByTagName("tr");		  // find all the &lt;tr&gt; elements... 
      
      for (var i = 0; i < trs.length; i++) {	      	      // ... and iterate through them

        if (! hasClass(trs[i]) &&				   	          // avoid rows that have a class attribute or backgroundColor style
            ! trs[i].style.backgroundColor) {
          var tds = trs[i].getElementsByTagName("td");        // get all the cells in this row...
          var ths = trs[i].getElementsByTagName("th");        // get all the cells in this row...		  
          for (var j = 0; j < tds.length; j++) {	          // and iterate through them...
            var mytd = tds[j];
            if (! hasClass(mytd) &&							  // avoid cells that have a class attribute or backgroundColor style
                ! mytd.style.backgroundColor) {
                mytd.style.backgroundColor =
                even ? evenColor : oddColor;
            }
          }
          for (var j = 0; j < ths.length; j++) {	          // and iterate through them...
            var myth = ths[j];
            if (! hasClass(myth) &&							  // avoid cells that have a class attribute or backgroundColor style
                ! myth.style.backgroundColor) {
                myth.style.backgroundColor =
                even ? evenColor : oddColor;
            }
          }
        }
        even =  ! even;								          // flip from odd to even, or vice-versa
      }
    }
  }


// $("div").click(function () {
//      $(this).toggleClass("otazkaIn");
// });

function ShowHide0(){
     $("#nulty").animate({"height": "toggle"}, { duration: 100 });
}
function ShowHide1(){
     $("#prvni").animate({"height": "toggle"}, { duration: 100 });
}
function ShowHide2(){
     $("#druhy").animate({"height": "toggle"}, { duration: 100 });
}
function ShowHide3(){
     $("#treti").animate({"height": "toggle"}, { duration: 100 });
}
function ShowHide4(){
     $("#ctvrty").animate({"height": "toggle"}, { duration: 100 });
}
function ShowHide5(){
     $("#paty").animate({"height": "toggle"}, { duration: 100 });
}
function ShowHide6(){
     $("#sesty").animate({"height": "toggle"}, { duration: 100 });
}
function ShowHide7(){
     $("#sedmy").animate({"height": "toggle"}, { duration: 100 });
}
function ShowHide8(){
     $("#osmy").animate({"height": "toggle"}, { duration: 100 });
}
function ShowHide9(){
     $("#devaty").animate({"height": "toggle"}, { duration: 100 });
}
function ShowHide10(){
     $("#desaty").animate({"height": "toggle"}, { duration: 100 });
}
function ShowHide11(){
     $("#jedenacty").animate({"height": "toggle"}, { duration: 100 });
}
function ShowHide12(){
     $("#dvanacty").animate({"height": "toggle"}, { duration: 100 });
}
function ShowHide13(){
     $("#trinacty").animate({"height": "toggle"}, { duration: 100 });
}


function checkSoutez(myform) {
	errorMsg="";

	// get form values
	email=myform['email'].value;
        souhlas=myform['souhlas'].checked;
	otazka1=myform['otazka1'];
	otazka2=myform['otazka2'];	
	otazka3=myform['otazka3'];
	otazka4=myform['otazka4'];
	otazka5=myform['otazka5'];
	otazka6=myform['otazka6'];
	otazka7=myform['otazka7'];
	otazka8=myform['otazka8'];
	otazka9=myform['otazka9'];
	otazka10=myform['otazka10'].value;
	
	if(!isRadioChecked(otazka1)) {
		errorMsg+="<span>- Vyberte prosím <strong>odpověď na otázku č.1</strong></span><br />";
	};
	if(!isRadioChecked(otazka2)) {
		errorMsg+="<span>- Vyberte prosím <strong>odpověď na otázku č.2</strong></span><br />";
	};
	if(!isRadioChecked(otazka3)) {
		errorMsg+="<span>- Vyberte prosím <strong>odpověď na otázku č.3</strong></span><br />";
	};
	if(!isRadioChecked(otazka4)) {
		errorMsg+="<span>- Vyberte prosím <strong>odpověď na otázku č.4</strong></span><br />";
	};
	if(!isRadioChecked(otazka5)) {
		errorMsg+="<span>- Vyberte prosím <strong>odpověď na otázku č.5</strong></span><br />";
	};
	if(!isRadioChecked(otazka6)) {
		errorMsg+="<span>- Vyberte prosím <strong>odpověď na otázku č.6</strong></span><br />";
	};
	if(!isRadioChecked(otazka7)) {
		errorMsg+="<span>- Vyberte prosím <strong>odpověď na otázku č.7</strong></span><br />";
	};
	if(!isRadioChecked(otazka8)) {
		errorMsg+="<span>- Vyberte prosím <strong>odpověď na otázku č.8</strong></span><br />";
	};
	if(!isRadioChecked(otazka9)) {
		errorMsg+="<span>- Vyberte prosím <strong>odpověď na otázku č.9</strong></span><br />";
	};
	if(otazka10=='') {
		if(!errorMsg) { myform['otazka10'].focus(); };
		errorMsg+="<span>- Vyplňte prosím <strong>odpověď na tipovací otázku.</strong></span><br />";
	};

	regexpemail=/^[a-zA-Z0-9._-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,6}$/;
	if (email=='' || !regexpemail.test(email) ) {
		if(!errorMsg) { myform['email'].focus(); };
		if(email=='')  {
      		errorMsg+="<span>- Zadejte prosím <strong>Váš e-mail.</strong></span><br />";
		jQuery("input[name='email']").css("border","1px solid red");
		} else {
			errorMsg+="<span>- Zadaná e-mailová adresa je ve <strong>špatném tvaru.</strong></span><br />";
              		jQuery("input[name='email']").css("border","1px solid red");
		};
	};
	
	if(!myform.souhlas.checked) {
		errorMsg+="<span>- Zaškrtněte prosím <strong>souhlas s podmínkami.</strong></span><br />";
	};


	if(errorMsg) {
             jQuery("#check").html("<div class='messageBox'><p class='alert'>"+errorMsg+"</p></div>");		
		return false;
	} else {
		return true;
	};
}




function checkEmail(myform) {
	errorMsg="";
	okMsg=myform['okMsg'].value;
	// get form values
	email=myform['email'].value;
	
	regexpemail=/^[a-zA-Z0-9._-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,6}$/;
	if (email=='' || !regexpemail.test(email) ) {
		if(!errorMsg) { myform['email'].focus(); };
		if(email=='')  {
      		errorMsg+="<span>Zadejte prosím <strong>Váš e-mail.</strong></span><br />";
		jQuery("input[name='email']").css("border","1px solid red");
		} else {
			errorMsg+="<span>Zadaná e-mailová adresa je ve <strong>špatném tvaru.</strong></span>";
		};
	} else {
		jQuery("input[name='email']").css("border","1px solid #B3B3B3");
	};
		
	if(errorMsg) {
    jQuery("#check").html("<div class='messageBox-shp'><p class='alert'>"+errorMsg+"</p></div>");		
		return false;
	} else {
		alert(okMsg);
		return true;
	};
}


 function log() {

    if (window.console) {
        if (window.console.debug) {
            // use firebug console
            window.console.debug.apply(console, arguments);
        } else {
            // ie
            window.console.log([].join.apply(arguments, [' ']));
        }
    } else {
        // use alert window
        alert([].join.apply(arguments, [' ']));
    }
}


/* vyskakovací okno pro soutezni pravidla */
function helpWindow_souteze(url, windowName) {
	return !window.open(url, windowName, "width=700,height=560,scrollbars=yes,menubar=no,resizable=yes,left=10,top=100");	
} 

function playMedia(url,containerEl,embedId,width,height) {

		domena = location.hostname;
      if(domena=='iportal.cezdata.corp')
      {
        var so = new SWFObject('/edee/content/sysutf/rg2/swf/JW_player.swf',embedId,width,height,'9.0.16.0'); 
		so.addVariable("skin", "/edee/content/sysutf/rg2/swf/CEZ_JW_player_skin.swf");
      } else if(domena=='www.cezregionum.cz') {
        var so = new SWFObject('http://www.cezregionum.cz/edee/content/sysutf/rg2/swf/JW_player.swf',embedId,width,height,'9.0.16.0');  
		so.addVariable("skin", "http://www.cezregionum.cz/edee/content/sysutf/rg2/swf/CEZ_JW_player_skin.swf");		
      } else {
        var so = new SWFObject('http://www.cez.cz/edee/content/sysutf/rg2/swf/JW_player.swf',embedId,width,height,'9.0.16.0');  
		so.addVariable("skin", "http://www.cez.cz/edee/content/sysutf/rg2/swf/CEZ_JW_player_skin.swf");		
      }; 
      
    so.addParam("wmode","transparent");
    so.addVariable('file',url);
		so.addParam("allowfullscreen","true");
		so.addVariable('fullscreen','true');
		so.addVariable("javascriptid", "JW");
		so.addVariable("autostart","false");
		so.addVariable("width",width);
		so.addVariable("height",height);
		so.addVariable('controlbar','over');
		so.addVariable('dock','false');
		so.addVariable('plugins','false');
		so.write(containerEl);

}

function playMedia2(url) {

		domena = location.hostname;
      if(domena=='iportal.cezdata.corp')
      {
        var so = new SWFObject('/edee/content/sysutf/www/swf/JW_player.swf','player','320','240','9.0.16.0'); 
        so.addVariable("skin", "/edee/content/sysutf/www/swf/CEZ_JW_player_skin.swf");
      } else {
        var so = new SWFObject('http://www.cez.cz/edee/content/sysutf/www/swf/JW_player.swf','player','320','240','9.0.16.0'); 
		so.addVariable("skin", "http://www.cez.cz/edee/content/sysutf/www/swf/CEZ_JW_player_skin.swf");				
      }; 
      
    so.addParam("wmode","transparent");
    so.addVariable('file',url);
		so.addParam("allowfullscreen","true");
		so.addVariable('fullscreen','true');
		so.addVariable("javascriptid", "JW");
		so.addVariable("autostart","false");
		so.addVariable("width","320");
		so.addVariable("height","240");
		so.addVariable('controlbar','over');
		so.addVariable('dock','false');
		so.addVariable('plugins','false');
		so.write('mediaspace');
}

/**
 * SWFObject v1.5: Flash Player detection and embed - http://blog.deconcept.com/swfobject/
 *
 * SWFObject is (c) 2007 Geoff Stearns and is released under the MIT License:
 * http://www.opensource.org/licenses/mit-license.php
 *
 */

if(typeof deconcept=="undefined"){var deconcept=new Object();}if(typeof deconcept.util=="undefined"){deconcept.util=new Object();}if(typeof deconcept.SWFObjectUtil=="undefined"){deconcept.SWFObjectUtil=new Object();}deconcept.SWFObject=function(_1,id,w,h,_5,c,_7,_8,_9,_a){if(!document.getElementById){return;}this.DETECT_KEY=_a?_a:"detectflash";this.skipDetect=deconcept.util.getRequestParameter(this.DETECT_KEY);this.params=new Object();this.variables=new Object();this.attributes=new Array();if(_1){this.setAttribute("swf",_1);}if(id){this.setAttribute("id",id);}if(w){this.setAttribute("width",w);}if(h){this.setAttribute("height",h);}if(_5){this.setAttribute("version",new deconcept.PlayerVersion(_5.toString().split(".")));}this.installedVer=deconcept.SWFObjectUtil.getPlayerVersion();if(!window.opera&&document.all&&this.installedVer.major>7){deconcept.SWFObject.doPrepUnload=true;}if(c){this.addParam("bgcolor",c);}var q=_7?_7:"high";this.addParam("quality",q);this.setAttribute("useExpressInstall",false);this.setAttribute("doExpressInstall",false);var _c=(_8)?_8:window.location;this.setAttribute("xiRedirectUrl",_c);this.setAttribute("redirectUrl","");if(_9){this.setAttribute("redirectUrl",_9);}};deconcept.SWFObject.prototype={useExpressInstall:function(_d){this.xiSWFPath=!_d?"expressinstall.swf":_d;this.setAttribute("useExpressInstall",true);},setAttribute:function(_e,_f){this.attributes[_e]=_f;},getAttribute:function(_10){return this.attributes[_10];},addParam:function(_11,_12){this.params[_11]=_12;},getParams:function(){return this.params;},addVariable:function(_13,_14){this.variables[_13]=_14;},getVariable:function(_15){return this.variables[_15];},getVariables:function(){return this.variables;},getVariablePairs:function(){var _16=new Array();var key;var _18=this.getVariables();for(key in _18){_16[_16.length]=key+"="+_18[key];}return _16;},getSWFHTML:function(){var _19="";if(navigator.plugins&&navigator.mimeTypes&&navigator.mimeTypes.length){if(this.getAttribute("doExpressInstall")){this.addVariable("MMplayerType","PlugIn");this.setAttribute("swf",this.xiSWFPath);}_19="<embed type=\"application/x-shockwave-flash\" src=\""+this.getAttribute("swf")+"\" width=\""+this.getAttribute("width")+"\" height=\""+this.getAttribute("height")+"\" style=\""+this.getAttribute("style")+"\"";_19+=" id=\""+this.getAttribute("id")+"\" name=\""+this.getAttribute("id")+"\" ";var _1a=this.getParams();for(var key in _1a){_19+=[key]+"=\""+_1a[key]+"\" ";}var _1c=this.getVariablePairs().join("&");if(_1c.length>0){_19+="flashvars=\""+_1c+"\"";}_19+="/>";}else{if(this.getAttribute("doExpressInstall")){this.addVariable("MMplayerType","ActiveX");this.setAttribute("swf",this.xiSWFPath);}_19="<object id=\""+this.getAttribute("id")+"\" classid=\"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\" width=\""+this.getAttribute("width")+"\" height=\""+this.getAttribute("height")+"\" style=\""+this.getAttribute("style")+"\">";_19+="<param name=\"movie\" value=\""+this.getAttribute("swf")+"\" />";var _1d=this.getParams();for(var key in _1d){_19+="<param name=\""+key+"\" value=\""+_1d[key]+"\" />";}var _1f=this.getVariablePairs().join("&");if(_1f.length>0){_19+="<param name=\"flashvars\" value=\""+_1f+"\" />";}_19+="</object>";}return _19;},write:function(_20){if(this.getAttribute("useExpressInstall")){var _21=new deconcept.PlayerVersion([6,0,65]);if(this.installedVer.versionIsValid(_21)&&!this.installedVer.versionIsValid(this.getAttribute("version"))){this.setAttribute("doExpressInstall",true);this.addVariable("MMredirectURL",escape(this.getAttribute("xiRedirectUrl")));document.title=document.title.slice(0,47)+" - Flash Player Installation";this.addVariable("MMdoctitle",document.title);}}if(this.skipDetect||this.getAttribute("doExpressInstall")||this.installedVer.versionIsValid(this.getAttribute("version"))){var n=(typeof _20=="string")?document.getElementById(_20):_20;n.innerHTML=this.getSWFHTML();return true;}else{if(this.getAttribute("redirectUrl")!=""){document.location.replace(this.getAttribute("redirectUrl"));}}return false;}};deconcept.SWFObjectUtil.getPlayerVersion=function(){var _23=new deconcept.PlayerVersion([0,0,0]);if(navigator.plugins&&navigator.mimeTypes.length){var x=navigator.plugins["Shockwave Flash"];if(x&&x.description){_23=new deconcept.PlayerVersion(x.description.replace(/([a-zA-Z]|\s)+/,"").replace(/(\s+r|\s+b[0-9]+)/,".").split("."));}}else{if(navigator.userAgent&&navigator.userAgent.indexOf("Windows CE")>=0){var axo=1;var _26=3;while(axo){try{_26++;axo=new ActiveXObject("ShockwaveFlash.ShockwaveFlash."+_26);_23=new deconcept.PlayerVersion([_26,0,0]);}catch(e){axo=null;}}}else{try{var axo=new ActiveXObject("ShockwaveFlash.ShockwaveFlash.7");}catch(e){try{var axo=new ActiveXObject("ShockwaveFlash.ShockwaveFlash.6");_23=new deconcept.PlayerVersion([6,0,21]);axo.AllowScriptAccess="always";}catch(e){if(_23.major==6){return _23;}}try{axo=new ActiveXObject("ShockwaveFlash.ShockwaveFlash");}catch(e){}}if(axo!=null){_23=new deconcept.PlayerVersion(axo.GetVariable("$version").split(" ")[1].split(","));}}}return _23;};deconcept.PlayerVersion=function(_29){this.major=_29[0]!=null?parseInt(_29[0]):0;this.minor=_29[1]!=null?parseInt(_29[1]):0;this.rev=_29[2]!=null?parseInt(_29[2]):0;};deconcept.PlayerVersion.prototype.versionIsValid=function(fv){if(this.major<fv.major){return false;}if(this.major>fv.major){return true;}if(this.minor<fv.minor){return false;}if(this.minor>fv.minor){return true;}if(this.rev<fv.rev){return false;}return true;};deconcept.util={getRequestParameter:function(_2b){var q=document.location.search||document.location.hash;if(_2b==null){return q;}if(q){var _2d=q.substring(1).split("&");for(var i=0;i<_2d.length;i++){if(_2d[i].substring(0,_2d[i].indexOf("="))==_2b){return _2d[i].substring((_2d[i].indexOf("=")+1));}}}return "";}};deconcept.SWFObjectUtil.cleanupSWFs=function(){var _2f=document.getElementsByTagName("OBJECT");for(var i=_2f.length-1;i>=0;i--){_2f[i].style.display="none";for(var x in _2f[i]){if(typeof _2f[i][x]=="function"){_2f[i][x]=function(){};}}}};if(deconcept.SWFObject.doPrepUnload){if(!deconcept.unloadSet){deconcept.SWFObjectUtil.prepUnload=function(){__flash_unloadHandler=function(){};__flash_savedUnloadHandler=function(){};window.attachEvent("onunload",deconcept.SWFObjectUtil.cleanupSWFs);};window.attachEvent("onbeforeunload",deconcept.SWFObjectUtil.prepUnload);deconcept.unloadSet=true;}}if(!document.getElementById&&document.all){document.getElementById=function(id){return document.all[id];};}var getQueryParamValue=deconcept.util.getRequestParameter;var FlashObject=deconcept.SWFObject;var SWFObject=deconcept.SWFObject;



jQuery(document).ready( /* jQuery no conflict block */
	function($) {

$(".flvPlay").each(function(i){
  url=$(this).find("span").html();  
  var playerId = "flv-player"+i;
  $(this).attr("id",playerId); 
  $(this).removeAttr("rel");
  playMedia(url,playerId,playerId,'320','240');
});

$(".flvPlay-small").each(function(i){
  url=$(this).find("span").html();  
  var playerId = "flv-player"+i;
  $(this).attr("id",playerId); 
  $(this).removeAttr("rel");
  playMedia(url,playerId,playerId,'220','165');
});

$(".mediaspace").each(function(i){
  //url=$(this).find("span").html();  
  url=$(this).find("a").attr('href'); 
  var playerId = "flv-player"+i;
  $(this).attr("id",playerId); 
  $(this).removeAttr("rel");
  playMedia(url,playerId,playerId,'320','240');
});

});
