﻿//Vychozi hodnota ve stavovem radku
window.defaultStatus="euPortál.cz";

//Nastavi status okna prohlizece
function cs(msg)
{
	window.status=msg;
}

//Otevre nove okno
function open_window(width, height, url, name) 
{    
	popupWin = window.open(url, name, 'resizable=0,scrollbars=0,top=20,left=0,menubar=0,width=' + width + ',height=' + height);
}

//Spusti hodiny a vklada aktualni cas do elementu "hodiny"
function hodiny_start()
{
    today_cas+=1000;
	var today = new Date(today_cas);
	var display_value = today.getHours();
	if(today.getMinutes() < 10){
		display_value+=":0" + today.getMinutes();
	}
	else{
        display_value+=":" + today.getMinutes();
	}
	if (today.getSeconds() < 10){
		display_value+=":0" + today.getSeconds();
	}
	else{
		display_value+=":" + today.getSeconds();
	}
	document.getElementById('hodiny').innerHTML=display_value;
	timerID=setTimeout("hodiny_start()",1000);
} 

function URLEncode(plaintext)
{	
	var SAFECHARS = "0123456789" +					// Numeric
					"ABCDEFGHIJKLMNOPQRSTUVWXYZ" +	// Alphabetic
					"abcdefghijklmnopqrstuvwxyz" +
					"áÁčČďĎéÉěĚíÍňŇóÓřŘšŠťŤůŮúÚýÝžŽ"
					"-_.!~*'()";					// RFC2396 Mark characters
	var HEX = "0123456789ABCDEF";
	
	var encoded = "";
	for (var i = 0; i < plaintext.length; i++ ) {
		var ch = plaintext.charAt(i);
	    if (ch == " ") {
		    encoded += "+";				
		} else if (SAFECHARS.indexOf(ch) != -1) {
		    encoded += ch;
		} else {
		    var charCode = ch.charCodeAt(0);
			if (charCode > 255) {			   
				encoded += "+";
			} else {
				encoded += "%";
				encoded += HEX.charAt((charCode >> 4) & 0xF);
				encoded += HEX.charAt(charCode & 0xF);
			}
		}
	}	
	return encoded;
}

function URLDecode(encoded )
{   
   var HEXCHARS = "0123456789ABCDEFabcdef"; 
   var encoded = document.URLForm.F2.value;
   var plaintext = "";
   var i = 0;
   while (i < encoded.length) {
       var ch = encoded.charAt(i);
	   if (ch == "+") {
	       plaintext += " ";
		   i++;
	   } else if (ch == "%") {
			if (i < (encoded.length-2) 
					&& HEXCHARS.indexOf(encoded.charAt(i+1)) != -1 
					&& HEXCHARS.indexOf(encoded.charAt(i+2)) != -1 ) {
				plaintext += unescape( encoded.substr(i,3) );
				i += 3;
			} else {				
				plaintext += "%[ERROR]";
				i++;
			}
		} else {
		   plaintext += ch;
		   i++;
		}
	}    
   return plaintext;
}

//Zapinani hvezd v hodnoceni
function on(index) {
    if(index == 1) { turnOnOne(); }
    if (index ==2) { turnOnOne(); turnOnTwo(); }
    if (index ==3) { turnOnOne(); turnOnTwo(); turnOnThree(); }
    if (index ==4) { turnOnOne(); turnOnTwo(); turnOnThree(); turnOnFour(); }
    if (index ==5) { turnOnOne(); turnOnTwo(); turnOnThree(); turnOnFour(); turnOnFive(); }
}

//Vypinani hvezd v hodnoceni
function off(index) {
    if(index == 1) { turnOffOne(); }
    if (index ==2) { turnOffOne(); turnOffTwo(); }
    if (index ==3) { turnOffOne(); turnOffTwo(); turnOffThree(); }
    if (index ==4) { turnOffOne(); turnOffTwo(); turnOffThree(); turnOffFour(); }
    if (index ==5) { turnOffOne(); turnOffTwo(); turnOffThree(); turnOffFour(); turnOffFive(); }       
}

//Zobrazeni/skryti clanku podle autora
function ShowArtByAut() {
    /*if (document.getElementById('ArticlesByAuthor').style.display=='block')
    {
        document.getElementById('ArticlesByAuthor').style.display='none';
    }
    else
    {
        document.getElementById('ArticlesByAuthor').style.display='block';
    } */   
}

//Scroller
function scroller_Start()
{    
    var par = document.getElementById("scrollerBlock").getElementsByTagName("div");         
    for (var i = 0; i<par.length; i++) {
        if (par[i].style.display == "block")
        {                                 
            curr_obj = par[i];                      
            par[i].style.display = "none";
            if ((i+1) < par.length)
            {
                par[i+1].style.display="block";     
                curr_obj = par[i+1];
                fadeIn(0);                
                break;
            }
            else
            {
                par[0].style.display="block";                
                curr_obj = par[0];
                fadeIn(0);                
                break;
            }
        }        
    }
    var scroll = setTimeout("scroller_Start()", 10000);
}

var curr_obj;

function fadeIn(pos) {    
    if (pos == 4){
        curr_obj.style.color="#000000";
    return;
    }
    if (pos == 0) {
    curr_obj.style.color="#C0C0C0";
        setTimeout("fadeIn(1)", 200);
    }
    if (pos == 1){
    curr_obj.style.color="#808080";
        setTimeout("fadeIn(2)", 200);        
    }
    if (pos ==2){
    curr_obj.style.color="#404040";
        setTimeout("fadeIn(3)", 200);
    }
    if (pos ==3){
    curr_obj.style.color="#202020";
        setTimeout("fadeIn(4)", 200);
    }
}