function getScrollY() {
  var scrOfX = 0, scrOfY = 0;
  if( typeof( window.pageYOffset ) == 'number' ) {
    //Netscape compliant
    scrOfY = window.pageYOffset;
    scrOfX = window.pageXOffset;
  } else if( document.body && ( document.body.scrollLeft || document.body.scrollTop ) ) {
    //DOM compliant
    scrOfY = document.body.scrollTop;
    scrOfX = document.body.scrollLeft;
  } else if( document.documentElement && ( document.documentElement.scrollLeft || document.documentElement.scrollTop ) ) {
    //IE6 standards compliant mode
    scrOfY = document.documentElement.scrollTop;
    scrOfX = document.documentElement.scrollLeft;
  }
  return [scrOfY];
 
  var ls= getScrollY();
	} 



function setScrollY() {
		var scx = readCookie("adminLastScroll");
	if (scx > 0){
			window.scrollTo(1000, scx);
			}
	} 


  function findPosY(obj)
  {
	  obj = document.getElementById(obj);
    var curtop = 0;
    if(obj.offsetParent)
        while(1)
        {
          curtop += obj.offsetTop;
          if(!obj.offsetParent)
            break;
          obj = obj.offsetParent;
        }
    else if(obj.y)
        curtop += obj.y;
    return curtop;
  }


var vscrollfrom = 0;
var vscrollto = 0;

function scr(obj){
vscrollfrom = parseFloat(getScrollY());
vscrollto = findPosY(obj);

if (vscrollfrom < vscrollto){
scrolluj();
} 

if (vscrollfrom > vscrollto){
scrollujSpat();
} 

}


function scrolluj(){
	curY = parseFloat(getScrollY());
//	alert (curY);
//	alert (vscrollto);
	var nextY = curY+((vscrollto-curY)/15)+2;
	if (curY < (vscrollto)) {window.scrollTo(0,nextY); setTimeout(scrolluj,8);}
//	document.title = nextY;
	
}

function scrollujSpat(){
	curY = parseFloat(getScrollY());
//	alert (curY);
//	alert (vscrollto);
//alert (curY);
//alert (vscrollto);
	var nextY = curY-((curY-vscrollto)/15)-2;
	if (curY > vscrollto+4) {window.scrollTo(0,nextY); setTimeout(scrollujSpat,8);}
//	document.title = nextY;
	
}



function umiestni(){
	x = findPos(document.getElementById('mainx'));
	
	document.getElementById('aktua').style.left = x[0] + 708 + "px";
	document.getElementById('aktua').style.top =  x[1] + 129 + "px";
	
}

function showaktual(){
	document.getElementById('aktua').style.opacity = 0;
	document.getElementById('aktua').style.display = "block";	
	fadeIn('aktua');
	
}

function showemail(id,foru){
$.fancybox('fancy-email.php?id='+id+'&typ='+foru,
		{	'padding'		: 0,
		'overlayOpacity'	:	0.4,
				'overlayColor'		:	'#000',
				'transitionIn'	: 'elastic',
				'transitionOut'	: 'elastic',
		       'type'				: 'iframe',
				'width'				: 600,
				'height'			: 450,

				'enableEscapeButton'  :	true


				

		}
	);	
}


function showjedalny(id){
$.fancybox('fancy-jedalny.php?id='+id,
		{	'padding'		: 0,
		'overlayOpacity'	:	0.4,
				'overlayColor'		:	'#000',
				'transitionIn'	: 'elastic',
				'transitionOut'	: 'elastic',
		       'type'				: 'iframe',
				'width'				: 621,
				'height'			: 521,

				'enableEscapeButton'  :	true


				

		}
	);	
}


function shownapojovy(id){
$.fancybox('fancy-napojovy.php?id='+id,
		{	'padding'		: 0,
		'overlayOpacity'	:	0.4,
				'overlayColor'		:	'#000',
				'transitionIn'	: 'elastic',
				'transitionOut'	: 'elastic',
		       'type'				: 'iframe',
				'width'				: 621,
				'height'			: 521,

				'enableEscapeButton'  :	true


				

		}
	);	
}





function vymazform(id){
	document.getElementById(id).value = "";
}

function refreshParent() {
  window.opener.location.href = window.opener.location.href;

  if (window.opener.progressWindow)
		
 {
    window.opener.progressWindow.close()
  }
  window.close();
}


function editrank(rankID){
openwin('edit_rank.php?id=' + rankID,'Rank_editor','width=500,height=500');
}

function openwin(theURL,winName,features) { 
  window.open(theURL,winName,features);
}

function editor(table, column, itemID){
openwin('edit_text.php?table=' + table +'&id=' + itemID +'&column=' + column,'Text_editor','width=700,height=500');
}

function richeditor(table, column, itemID){
openwin('edit_richtext.php?table=' + table +'&id=' + itemID +'&column=' + column,'Text_editor','width=700,height=700');
}

function editordatum(table, column, itemID){
openwin('edit_datum.php?table=' + table +'&id=' + itemID +'&column=' + column,'Datum_editor','width=400,height=200');
}

function optioneditor(table, column, itemID){
openwin('edit_option.php?table=' + table +'&id=' + itemID +'&column=' + column,'Option_editor','width=300,height=200');
}


function openwin(theURL,winName,features) { 
  window.open(theURL,winName,features);
}


function trim(value) {
  value = value.replace(/^\s+/,''); 
  value = value.replace(/\s+$/,'');
  return value;
}


function validate_rank(){
hodnotenie = document.getElementById('f_hodnotenie').value;
hodnotiaci = document.getElementById('f_hodnotiaci').value;
//xxx = (hodnotiaci*5);
//alert (hodnotenie);
if (hodnotiaci < (hodnotenie/5)){
alert("Hodnota hodnotenia nesmie byť väčšia ako 5 násobok počtu hodnotiacich.");
document.getElementById('f_hodnotenie').focus();
}
}




function validate(what, formm)	{

if (what == ""){
document.getElementById(formm).submit();
return;
}

var ff=what.split(",");
er = 0;

for (i = 0; i < ff.length; i++) {	

var ffx = ff[i].split(":");

xx = trim(document.getElementById(ffx[0]).value);

if (trim(xx) == "") {
er = 1 ;
document.getElementById(ffx[0]).focus();
alert("Prosím vyplňte toto pole");
break;
}

er2 = 0;
er3 = 0;
er4 = 0;

if (ffx[1] == "datum") {
numb = document.getElementById(ffx[0]).value;

if ((numb.substr(0,1) < "0") || (numb.substr(0,1) > "9")){er2 = 1;}
if ((numb.substr(1,1) < "0") || (numb.substr(1,1) > "9")){er2 = 1;}

if (numb.substr(2,1) != "."){er2 = 1;}

if ((numb.substr(3,1) < "0") || (numb.substr(3,1) > "9")){er2 = 1;}
if ((numb.substr(4,1) < "0") || (numb.substr(4,1) > "9")){er2 = 1;}

if (numb.substr(5,1) != "."){er2 = 1;}
if (numb.substr(6,1) != " "){er2 = 1;}

if ((numb.substr(7,1) < "0") || (numb.substr(7,1) > "9")){er2 = 1;}
if ((numb.substr(8,1) < "0") || (numb.substr(8,1) > "9")){er2 = 1;}
if ((numb.substr(9,1) < "0") || (numb.substr(9,1) > "9")){er2 = 1;}
if ((numb.substr(10,1) < "0") || (numb.substr(10,1) > "9")){er2 = 1;}

}


if (ffx[1] == "email") {
ema = document.getElementById(ffx[0]).value;
if (checkEmail(ema) == false){
	er3 = 1;
}
}




if (ffx[1] == "cas") {
datt = document.getElementById(ffx[0]).value;

//if (!(/(0[1-9]¦1[0-2]):[0-5][0-9]/.test(datt))){
	
if (!(/[0-2][0-9]:[0-5][0-9]/.test(datt))){
	er4 = 1;
//	alert('ZLE');
}

}




if (er2 == 1) {
er = 1 ;
document.getElementById(ffx[0]).focus();
alert("Nesprávny dátum. Napíšte dátum v tvare: 01.01. 2007 \n(pred rokom nezabudnite na medzeru)");
break;
}

if (er3 == 1) {
er = 1 ;
document.getElementById(ffx[0]).focus();
alert("Nesprávny tvar e-mailu. Napíšte email v tvare: jan.novak@mail.sk");
break;
}

if (er4 == 1) {
er = 1 ;
document.getElementById(ffx[0]).focus();
alert("Nesprávny tvar času. Napíšte čas v tvare: 24:00 alebo 02:35, atď. ");
break;
}

}


if (er == 0){
document.getElementById(formm).submit();
}

}


function checkEmail(myForm) {
if (/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(myForm)){
return (true)
}
//alert("Invalid E-mail Address! Please re-enter.")
return (false)
}



function submitForm(){
document.getElementById('filterform').submit();
}


function writeFlash(sSrc,nWidth,nHeight)	{
flashSrc = sSrc;
flashWidth = nWidth;
flashHeight = nHeight;
flash = '<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0" width="'+flashWidth+'" height="'+flashHeight+'" id="writenflash" align="middle">';
flash += '<param name="allowScriptAccess" value="sameDomain">'
flash += '<param name="movie" value="'+flashSrc+'">';
flash += '<param name="quality" value="high">';
flash += '<param name="wmode" value="transparent">';
flash += '<embed src="'+flashSrc+'" quality="high" width="'+flashWidth+'" height="'+flashHeight+'" name="writenflash" align="middle" allowScriptAccess="sameDomain" wmode="transparent" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer">';
flash += '</object>';
document.write(flash);
}


function findPos(obj) {
	var curleft = curtop = 0;
	if (obj.offsetParent) {
		curleft = obj.offsetLeft
		curtop = obj.offsetTop
		while (obj = obj.offsetParent) {
			curleft += obj.offsetLeft
			curtop += obj.offsetTop
		}
	}
	return [curleft,curtop];
}





var ii=0;
var tt_transparency = 0.7; //define tooltip div transparency 0.1 - 1
var tt_offsetright = -10;
var tt_offsettop = -8;
var tt_speed = 0.3;
var oldwhat;
var thiswhat;
var tt_workin=0;


function hide_tooltip(tooltipid) {
reset_ttips(tooltipid);
}


function reset_ttips(what) 
{
var browser=navigator.appName;
ii=0;
if (browser == "Netscape") {document.getElementById(what).style.opacity = ii;
}  else if  (browser == "Microsoft Internet Explorer") 
{document.getElementById(what).style.filter ="alpha(opacity="+ ii*100 + ")"; 
}  else if  (browser == "Opera") {document.getElementById(what).style.opacity = ii;
} else {
document.getElementById(what).style.opacity = ii;
}
document.getElementById(what).style.display = "none";
}

function show_tooltip(fieldid, tooltipid) {
document.getElementById(fieldid).style.zIndex = "1";

if (tt_workin == 1) {
 
reset_ttips(oldwhat);
}	
	
tt_workin=1;
thiswhat = tooltipid;

var obj = document.getElementById(fieldid);
//alert();
var coors = findPos(obj);

var otop = coors[1];
var oleft = coors[0];

//oleft = findPos(fieldid);
//alert (otop);
//alert (oleft);

//document.getElementById(tooltipid).style.top = otop+"px";
//document.getElementById(tooltipid).style.left = oleft+"px"; 

document.getElementById(tooltipid).style.top = otop + tt_offsettop + "px";
document.getElementById(tooltipid).style.left = -tt_offsetright + oleft + parseInt(document.getElementById(fieldid).style.width) + "px"; 

// OK
//document.getElementById(tooltipid).style.top = otop - (parseInt(document.getElementById(tooltipid).style.height)/2) + tt_offsettop + "px";
//document.getElementById(tooltipid).style.left = -tt_offsetright + oleft + parseInt(document.getElementById(fieldid).style.width) + "px"; 


//document.getElementById(tooltipid).style.top = "100px";
//alert (document.getElementById(tooltipid).style.top);
document.getElementById(tooltipid).style.display="block";
oldwhat = tooltipid;
//reset_ttips(tooltipid);
trans(tooltipid);
}

function trans(what) 
{

var browser=navigator.appName;
//document.getElementById("tf4").value=browser;
ii=ii+tt_speed;
//document.getElementById("div3").style.filter =":alpha(opacity="+ ii +")"; 
if (browser == "Netscape") {document.getElementById(what).style.opacity = ii;

}  else if  (browser == "Microsoft Internet Explorer") 
{document.getElementById(what).style.filter ="alpha(opacity="+ ii*100 + ")"; 

}  else if  (browser == "Opera") {document.getElementById(what).style.opacity = ii;

} else {
document.getElementById(what).style.opacity = ii;
}

if (ii < tt_transparency){
setTimeout("trans('" + what + "')", 100);
} else if (ii >= tt_transparency) {
	tt_workin=0;
	ii=tt_transparency;
	}

}


function hideSwitch(what) {  
if (document.getElementById(what).style.display=="none") {
	document.getElementById(what).style.display="block";
	} else {
	document.getElementById(what).style.display="none";
	}
}


function showme(what) {  
document.getElementById(what).style.display="block";
}

function hideme(what) {  
document.getElementById(what).style.display="none";
}

function focus_to(what) { 
document.getElementById(what).focus();
}

function ukaz(what) { 
document.getElementById(what).style.display="block";
}

function skry(what) { 
document.getElementById(what).style.display="none";
}



function nic(){
	
}


imarr = new Array();
var old_scroll = 0;
var new_scroll = 0;
var selected;

function scrolll(what,heightt){
//window.
//div.
//alert(document.getElementById(what).scrollTop);
old_scroll = document.getElementById(what).scrollTop;
new_scroll = heightt-250;
//document.getElementById(what).scrollTop = heightt;
//alert (document.getElementById(what).scrollTop);
//alert (document.getElementById(what).scrollHeight);
setTimeout("scroll_trans('" + what + "')", 10);
}

function redirect(url, seconds){
//url = decodeURIComponent(url.replace(/\+/g,  " "));
setTimeout("goTo('" + url + "')", seconds);

}

function goTo(url){
window.location = url;	
}







function createCookie(name,value,days) {
	if (days) {
		var date = new Date();
		date.setTime(date.getTime()+(days*24*60*60*1000));
		var expires = "; expires="+date.toGMTString();
	}
	else var expires = "";
	document.cookie = name+"="+value+expires+"; path=/";
}

function readCookie(name) {
	var nameEQ = name + "=";
	var ca = document.cookie.split(';');
	for(var i=0;i < ca.length;i++) {
		var c = ca[i];
		while (c.charAt(0)==' ') c = c.substring(1,c.length);
		if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
	}
	return null;
}

function eraseCookie(name) {
	createCookie(name,"",-1);
}

function A_lastScroll(type){
//var hscroll = (document.all ? document.scrollLeft : window.pageXOffset);
	if (type=="write"){

function getScrollY() {
  var scrOfX = 0, scrOfY = 0;
  if( typeof( window.pageYOffset ) == 'number' ) {
    //Netscape compliant
    scrOfY = window.pageYOffset;
    scrOfX = window.pageXOffset;
  } else if( document.body && ( document.body.scrollLeft || document.body.scrollTop ) ) {
    //DOM compliant
    scrOfY = document.body.scrollTop;
    scrOfX = document.body.scrollLeft;
  } else if( document.documentElement && ( document.documentElement.scrollLeft || document.documentElement.scrollTop ) ) {
    //IE6 standards compliant mode
    scrOfY = document.documentElement.scrollTop;
    scrOfX = document.documentElement.scrollLeft;
  }
  return [scrOfY];
}
	var ls= getScrollY();
	createCookie("adminLastScroll",ls,1);
	} 


	if (type=="read"){
		var scx = readCookie("adminLastScroll");
	if (scx > 0){
			window.scrollTo(1000, scx);
			createCookie("adminLastScroll",0,1);
			}
	} 

}

function checkList(list, zapisat){
document.getElementById(zapisat).value = ',';
for (var i = 0; i < document.getElementById(list).options.length; i++) {
	if (document.getElementById(list).options[i].selected == true){
		document.getElementById(zapisat).value = document.getElementById(zapisat).value + document.getElementById(list).options[i].value + ',';
	}
}
}


function checkList2(list, zapisat){
document.getElementById(zapisat).value = '';
for (var i = 0; i < document.getElementById(list).options.length; i++) {
	if (document.getElementById(list).options[i].selected == true){
		document.getElementById(zapisat).value = document.getElementById(zapisat).value + '#' + document.getElementById(list).options[i].value + '';
	}
}
}





var completedAction = 0;

function ajaxupdate (inputid, table, column, id) {
//alert ('ajax_update.php?id=' + id + '&table=' + table + '&what=' + column + '=' + document.getElementById(inputid).value);
//ajaxpage ('jano.html', 'ajaxUpdateContainer');
completedAction = "colorfade=0;colorFadeOut('" + inputid + "');";
hodnota = document.getElementById(inputid).value;
ajaxpage('ajax_update.php?id=' + id + '&table=' + table + '&what=' + column + '=' + hodnota, 'ajaxUpdateContainer');
//ajaxpage ('jano.php', 'ajaxUpdateContainer');
}


/***********************************************
* Dynamic Ajax Content- © Dynamic Drive DHTML code library (www.dynamicdrive.com)
* This notice MUST stay intact for legal use
* Visit Dynamic Drive at http://www.dynamicdrive.com/ for full source code
***********************************************/

var bustcachevar=1 //bust potential caching of external pages after initial request? (1=yes, 0=no)
var loadedobjects=""
var rootdomain="http://"+window.location.hostname
var bustcacheparameter=""

function ajaxpage(url, containerid){

var page_request = false
if (window.XMLHttpRequest) // if Mozilla, Safari etc
page_request = new XMLHttpRequest()
else if (window.ActiveXObject){ // if IE
try {
page_request = new ActiveXObject("Msxml2.XMLHTTP")
} 
catch (e){
try{
page_request = new ActiveXObject("Microsoft.XMLHTTP")
}
catch (e){}
}
}
else
return false
page_request.onreadystatechange=function(){
loadpage(page_request, containerid)
}
if (bustcachevar) //if bust caching of external page
bustcacheparameter=(url.indexOf("?")!=-1)? "&"+new Date().getTime() : "?"+new Date().getTime()
page_request.open('GET', url+bustcacheparameter, true)
page_request.send(null)
}

function loadpage(page_request, containerid){

if (page_request.readyState == 4 && (page_request.status==200 || window.location.href.indexOf("http")==-1)){
document.getElementById(containerid).innerHTML=page_request.responseText;
}
if (page_request.readyState == 4){
eval (completedAction);
}
}

function loadobjs(){
if (!document.getElementById)
return
for (i=0; i<arguments.length; i++){
var file=arguments[i]
var fileref=""
if (loadedobjects.indexOf(file)==-1){ //Check to see if this object has not already been added to page before proceeding
if (file.indexOf(".js")!=-1){ //If object is a js file
fileref=document.createElement('script')
fileref.setAttribute("type","text/javascript");
fileref.setAttribute("src", file);
}
else if (file.indexOf(".css")!=-1){ //If object is a css file
fileref=document.createElement("link")
fileref.setAttribute("rel", "stylesheet");
fileref.setAttribute("type", "text/css");
fileref.setAttribute("href", file);
}
}
if (fileref!=""){
document.getElementsByTagName("head").item(0).appendChild(fileref)
loadedobjects+=file+" " //Remember this object as being already added to page
}
}
}







function checkotvaracie (den){
	document.getElementById('f_'+den+'_od').value = '00:00';document.getElementById('f_'+den+'_do').value = '00:00';
	if (document.getElementById('f_'+den+'_check').checked == true){document.getElementById('f_'+den+'_div').style.display="block";} else {document.getElementById('f_'+den+'_div').style.display="none";};

	
}



var fade=0;
var fadexSpeed = 0.1;
var fadeWorkin=0;

function fadeIn(what) 
{
if (fadeWorkin == 0){
var browser=navigator.appName;
fade=fade+fadexSpeed;
//alert(fadexSpeed);
if (browser == "Netscape") {document.getElementById(what).style.opacity = fade;

}  else if  (browser == "Microsoft Internet Explorer") 
{document.getElementById(what).style.filter ="alpha(opacity="+ fade*100 + ")"; 
}  else if  (browser == "Opera") {document.getElementById(what).style.opacity = fade;
} else {
document.getElementById(what).style.opacity = fade;
}
if (fade < 1){
setTimeout("fadeIn('" + what + "')", 50);
} else if (fade >= 1) {
	fadeWorkin=1;
//	fade=1;
//	setTimeout("fadeOut('" + what + "')", 1000);
}
}
}

//alert(fade);

function fadeOut(what) 
{
var browser=navigator.appName;
fade=fade-fadexSpeed;
if (browser == "Netscape") {document.getElementById(what).style.opacity = fade;
}  else if  (browser == "Microsoft Internet Explorer") 
{document.getElementById(what).style.filter ="alpha(opacity="+ fade*100 + ")"; 
}  else if  (browser == "Opera") {document.getElementById(what).style.opacity = fade;
} else {
document.getElementById(what).style.opacity = fade;
}
if (fade > 0){
setTimeout("fadeOut('" + what + "')", 50);
} else if (fade <= 0) {
	fadeWorkin=0;
	fade=0;
	document.getElementById(what).style.display="none";
}

}
