
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)	{

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("Musíte vyplniť toto pole");
break;
}

er2 = 0;
er3 = 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 (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 (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 + '';
	}
}
}


