function EuroCalc(form){
    var e = document.getElementById('result');
    if(e !== undefined){
        var kurz = 30.1260;
        var mena = (form.mena.value == 1) ? "EUR" : "Sk";
        var suma = form.suma.value;
        suma = suma.replace(",",".");
        suma = (form.mena.value == 1)
            ? suma / kurz
            : suma * kurz;
        
        e.innerHTML = "<strong>" + form.suma.value + ((form.mena.value == 1) ? " Sk" : " EUR") + " = " + (Math.round(suma * 100) / 100) + " " + mena + "</strong><br />";
    }
}

function ShowBlock(id,eLI){
    eUL = document.getElementById('blocks');
    if(eUL != undefined){
        child = eUL.childNodes;
        if(child.length){
            for (var i = 0 ; i < child.length ; i++){
                if(child[i].nodeName == 'LI'){
                    child[i].className = '';
                    document.getElementById('block'+(i+1)).style.display = 'none';
                }
            }
        }
        eLI.className = 'active';
        document.getElementById('block'+id).style.display = 'block';
    }
}

function setTypImage(id){
    document.getElementById('typ_image').src = WEBROOT + '/files/images/typ/image'+id+'.jpg';
}

function ScrollInfo(){
    var arrayPageSize = getPageSize();
    var arrayPageScroll = getPageScroll();
    var obj = document.getElementById('float_info');
    if(obj != undefined){
        var top = arrayPageSize[3] + arrayPageScroll[1] - 150;
        if(top > 650){
            obj.style.display = 'block';
            obj.style.top = top + 'px';
            obj.style.left = ((arrayPageSize[0] / 2) - 240) + 'px';
        } else {
            obj.style.display = 'none';
        }
    }
}
function AllowScroll(){ 
    window.onscroll = ScrollInfo;  
    //or document.onscroll = moveMenuBar; 
    //or document.body.onscroll = moveMenuBar;  
    //or document.documentElement.onscroll = moveMenuBar; 
}

addLoadEvent(AllowScroll);



function DisplayFields(pocet){
    if(pocet > 1){
        var now = new Date();
        var rok = getFullYear(now);
        var text =
        '<table cellpadding="0" cellspacing="0" class="osoby">' +
            '<tr>' +
                '<th class="column1">Spolucestujúci</th>' +
                '<th class="column2">Meno a priezvisko</th>' +
                '<th class="column3">Dátum narodenia</th>' +
            '</tr>';
        for(var i=1; i<pocet; i++){
            text += 
            '<tr>' +
                '<td class="column1">* Osoba č.'+i+':</td>' + 
                '<td class="column2"><input type="text" name="spolucestujuci_meno['+i+']" value="" size="20"/></td>' +
                '<td class="column3">'
                    + numList('den['+i+']',1,31,'den')
                    + numList('mes['+i+']',1,12,'mes')
                    + numList('rok['+i+']',1900,rok,'rok')
                '</td>' +
            '</tr>';
        }
        text += '</table>';
        document.getElementById('fields').innerHTML = text;
    } else {
        document.getElementById('fields').innerHTML = '';
    }
}

function getFullYear(date) {
	x = date.getYear();
	var y = x % 100;
	y += (y < 38) ? 2000 : 1900;
	return y;
}

function numList(name,x,y,className){
    var select = 
    '<select name="' + name + '" class="'+ className +'">' +
    '<option value="">--</option>';
    for(var i = x; i<= y; i++){
        select += '<option value="' + i + '">' + i + '</option>';
    }
    select += '</select>';
    return select;
}

function info() {
	document.getElementById("info").style.display="block";
	document.getElementById("info2").style.display="block";
	document.getElementById("terminy").style.display="none";
	document.getElementById("fotogaleria").style.display="none";
}

function terminy(lang) {
	if(document.getElementById("terminy").style.display == "block") {
		document.getElementById("terminy").style.display = "none";
        document.getElementById("details").style.display = "block";
        document.getElementById("image").src = WEBROOT + "/files/images/terminy-" + lang + ".gif";
	} else {
		document.getElementById("terminy").style.display="block";
        document.getElementById("details").style.display="none";
        document.getElementById("image").src = WEBROOT + "/files/images/informacie-" + lang + ".gif";
	}
}

function fotogaleria() {
	document.getElementById("info").style.display="none";
	document.getElementById("info2").style.display="none";
	document.getElementById("terminy").style.display="none";
	document.getElementById("fotogaleria").style.display="block";
}


NewWindow1 = null;
    function ShowWin(href, w, h){
    	if(NewWindow1){ NewWindow1.close(); }
    	if(NewWindow1==null || NewWindow1.closed){
    		var top = screen.height/2 - h/2;
    		var left = screen.width/2 - w/2;
    		var settings =
    	 		"left=" + left + "px,"
    			+"top=" + top + "px,"
    			+"width=" + w + "px,"
    			+"height=" + h + "px,"
    			+"toolbar=yes,"
    			+"location=no,"
    			+"directories=no,"
    			+"status=yes,"
    			+"menubar=yes,"
    			+"scrollbars=yes,"
    			+"resizable=yes";
    		NewWindow1 = window.open(href,'okno',settings);
    	}
    	NewWindow1.focus();
    }
    
    NewWindow2 = null;
	function ShowPage(href, w, h){
		if(NewWindow2){ NewWindow2.close(); }
		if(NewWindow2==null || NewWindow2.closed){
			var top = screen.height/2 - h/2;
			var left = screen.width/2 - w/2;
			var settings =
		 		"left=" + left + "px,"
				+"top=" + top + "px,"
				+"width=" + w + "px,"
				+"height=" + h + "px,"
				+"toolbar=no,"
				+"location=no,"
				+"directories=no,"
				+"status=no,"
				+"menubar=no,"
				+"scrollbars=yes,"
				+"resizable=yes";
			NewWindow2 = window.open(href,'okno',settings);
		}
		NewWindow2.focus();
	}
    
    timer = null;
	IMG = null;
	NewWindow3 = null;           
	function ViewImage(Isrc,title) {
		IMG = new Image;
		IMG.src = Isrc;
		if (typeof(title)=="undefined" || title=="") title="Gallery";
		if (NewWindow3) { NewWindow3.close(); }
		if (NewWindow3==null || NewWindow3.closed) {
			settings=
			 "left="+50+","
			 +"top="+50+","
			 +"width="+640+","
			 +"height="+480+","
			 +"toolbar=no,"
			 +"location=no,"
			 +"directories=no,"
			 +"status=no,"
			 +"menubar=no,"
			 +"scrollbars=no,"
			 +"resizable=yes"
			 NewWindow3 = window.open("",'Gallery',settings);
		}
		NewWindow3.document.open();
		NewWindow3.document.clear();
		NewWindow3.document.write(
		 	"<html><head><title>"+ title +"</title>"
			+"</head>\n"
			+"<body topmargin=0 leftmargin=0 onclick=\"window.close();\">\n"
			+"<table border=\"0\" cellpadding=\"0\" cellspacing=\"0\" style=\"margin:10px;\"><tr><td align=\"center\" valign=\"middle\"><img src=" + IMG.src + " border=0 alt=\""+title+"\" /></td></tr></table>\n"
			+"</body>\n"
			+"</html>"
		);
		NewWindow3.document.close();
		NewWindow3.focus();
		timer = setInterval("resize()",250);
	}

	function resize() {
    	if(!IMG.complete){ return; }
	    clearInterval(timer);
		resizeWindowTo(NewWindow3,(IMG.width-18+80),(IMG.height-18+100));
		IMG = null;
	}

	function resizeWindowTo(WindowObject,w,h) {
		if (parseInt(navigator.appVersion)>3) {
			if (navigator.appName=="Netscape") {
				WindowObject.outerWidth=w;
				WindowObject.outerHeight=h;
			} else {
                WindowObject.resizeTo(w,h);
            }
		}
	}
