function getInnerHeight(frame) {
     innerDoc = (frame.contentDocument) 
        ? frame.contentDocument 
        : frame.contentWindow.document;
        
     alert(innerDoc.body.scrollHeight + 5);
     
     return innerDoc.body.scrollHeight + 5 + 'px';
}
/*
function getInnerHeight(iframe){
    if (iframe.document.height) {
        var iframeElement = iframe;
        return iframe.document.height + 'px';
    } else if (document.all) {
        var iframeElement = iframe;
        if (iframe.document.compatMode && iframe.document.compatMode != 'BackCompat') {
            return iframe.document.documentElement.scrollHeight + 5 + 'px';
        } else {
            return iframe.document.body.scrollHeight + 5 + 'px';
        }
    }
    //alert(iframe);
    //var d = (iframe.contentWindow) 
    //    ? iframe.contentWindow.document 
    //    : iframe.contentDocument;
    //    
    //
    //
    //alert(d);
    //var h = 0;
    //if(d != undefined){
    //    if(d.body){
    //        h = d.body.scrollHeight;
    //    } else {
    //        if(d.documentElement){
    //            h = d.documentElement.scrollHeight;
    //        }
    //    }
    //}
    //return (h||380)+"px";
}
*/

function AjaxGetDestinacie(idDestinacia,eId){
    AjaxRequest.get(
		{
			'url':WEBROOT + '/files/getDestinacieKrajiny.php?ajax=1&id_destinacia='+idDestinacia
			,'onSuccess':function(req) { AjaxDisplayResult(eId,req.responseText); }
			,'onLoading':function(req) { }
			,'onLoaded':function(req) { }
			,'onError':function(req) { }
		}
	);
}

function AjaxDisplayResult(eID,result){
    var e = document.getElementById(eID);
    if(e != undefined){
        e.innerHTML = result;
    }
}

function displayBlock(id){
    var e = document.getElementById("pobyt_left");
    if(e != undefined){
        e.style.display = (id != 1) ? 'none' : 'block';
    }
    
    // HIDE ALL
    var i = 1;
    while((e = document.getElementById('block'+i)) != undefined){
        e.style.display = 'none';
        
        // CLASS BLUE
        if(document.getElementById("m1_block"+i) != undefined){
            document.getElementById("m1_block"+i).className = "m1";
            document.getElementById("m2_block"+i).className = "m2";
            document.getElementById("m3_block"+i).className = "m3";
        }
        
        i++;
    }
    
    // DISPLAY CURRENT
    var e = document.getElementById('block'+id);
    if(e != undefined){
        e.style.display = 'block';
        
        // CLASS ACTIVE
        document.getElementById("m1_block"+id).className = "m1n";
        document.getElementById("m2_block"+id).className = "m2n";
	    document.getElementById("m3_block"+id).className = "m3n";
    }
    
    // CLASS RED PRE TERMINY AK id != 2
    if(id != 2){
        document.getElementById("m1_block2").className = "red1";
        document.getElementById("m2_block2").className = "red2";
	    document.getElementById("m3_block2").className = "red3";
    }
}

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;
}

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);
            }
		}
	}
