function externalLinks() {
 if (!document.getElementsByTagName) return;
 var anchors = document.getElementsByTagName("a");
 for (var i=0; i<anchors.length; i++) {
   var anchor = anchors[i];
   if (anchor.getAttribute("href") &&
       anchor.getAttribute("rel") == "external")
     anchor.target = "_blank";
 }
}

function float(el) {

	//$(el).css("top",-$("div#page").position().top);
	$(el+"L").css("top",-$("div#page").position().top+0);
}

window.onload = function() {

    externalLinks();
	$("#linkBuildData a").attr("target","_blank");

	$("ul#menu>li").prepend("<span class=\"roh\"></span>"); 

	$(window).scroll(function () { 
      float("div#sky");
    });
	$(window).resize(function () { 
      float("div#sky");
    });
	float("div#sky"); 

    $("ul#menu>li").mouseover(function(){ 
      $(this).addClass("over");
    }).mouseout(function(){    
      $(this).removeClass("over");
    });     
    
    jQuery(function($){
        $(".txtDate").datepicker({showOn: 'both', buttonImage: '/img/calendar.gif', buttonImageOnly: true});
        $(".txtDateS").datepicker({tipSobota: 'true', showOn: 'both', buttonImage: '/img/calendar.gif', buttonImageOnly: true});        
    }); 

	
	$('a[href*=#]').click(function() {
	    if (location.pathname.replace(/^\//,'') == this.pathname.replace(/^\//,'')
	    && location.hostname == this.hostname) {
	      var $target = $(this.hash);
	      $target = $target.length && $target 
	      || $('[name=' + this.hash.slice(1) +']');
	      if ($target.length) {
	        var targetOffset = $target.offset().top;
	        $('html,body')
	        .animate({scrollTop: targetOffset}, 1000);
	       return false;
	      }
	    }
	}); 	
}  

var lastGM = "gMapD";
var timeOutC = 1;

function gM(id,no,link) {
    $("#gUl>li").removeClass("active");
    $("#gm"+no).addClass("active");    
    
    if (id==lastGM) { 
		if (no==3) { window.location.href = link; }
		return; 
	}
    
	clearTimeout(tOut);

    $("#"+lastGM).css("zIndex",10);
    $("#"+id).css("zIndex",9);    
    $("#"+id).show();                
    $("#"+lastGM).fadeOut(500,function() { $(this).hide(); });    
    
    lastGM = id;
}

function nejChange() { 
	return 0;

	switch (timeOutC) {
	case 2:
		gM('gDop',1); timeOutC = 0; 
		break;
	case 1:
		gM('gNej',2); timeOutC = 2; 
		break;
	default:
		gM('gMapD',3,'{{gmMapLink}}'); timeOutC = 1; 
	} 


	tOut = setTimeout("nejChange()",4000);
}


function openWindow(path, name, width, height) {

   var winl = (screen.width - width) / 2;
   var wint = (screen.height - height) / 2;

   style = eval("'status=no,width="+width+",height="+height+",left="+winl+",top="+wint+",resizable=no,menubar=no,scrollbars=yes,toolbar=no'");
   window.open(path, name, style) ;
}   