//****************************************** METODY *****************************************************************

//*************************************** J Q U E R Y ****************************************************************
$(document).ready(function() {
	  
	if(document.getElementById("mapCanvas")){
		initializeMap();
    }
	
	$(".Facebook").click(function(){
	    
        var newWindow = window.open('https://www.facebook.com/pages/Fit-Hany-bany-Brno-Lesn%C3%A1/233336540084813', '_blank');
        newWindow.focus();
        return false;
        
    });
    $("#google-mapa").click(function(){
    
        var newWindow = window.open('http://maps.google.cz/maps?f=q&source=s_q&hl=cs&geocode=&q=Arbesova+12+Brno+Lesn%C3%A1+&sll=48.861207,16.052506&sspn=0.00511,0.009645&ie=UTF8&hq=&hnear=Arbesova+12,+638+00+Brno-sever&ll=49.226251,16.627572&spn=0.005248,0.013733&t=h&z=17', '_blank');
        newWindow.focus();
        return false;
        
    });
    
});

function subList(){
	$("td.subList ul").toggle("slow");
}

function clock()
{
    var currentTime = new Date();    
    var currentHours = currentTime.getHours ( );
      var currentMinutes = currentTime.getMinutes ( );
      var currentSeconds = currentTime.getSeconds ( );

       currentMinutes = ( currentMinutes < 10 ? "0" : "" ) + currentMinutes;
      currentSeconds = ( currentSeconds < 10 ? "0" : "" ) + currentSeconds;
    
    var time=currentHours+':'+currentMinutes+':'+currentSeconds;
    $('#H_time').text(time);
    
}

function date()
{
    var currentTime = new Date();    
    var day = currentTime.getDate();
      var month = currentTime.getMonth()+1;
      var year = currentTime.getFullYear();

    
    var time=day+'/'+month+'/'+year;
    $('#H_datum ').append(time);
}

function addBanner(bannerName,width,height,element){
    html = '<embed wmode="transparent" width="'+width+'" height="'+height+'" quality="high" name="mymovie" id="mymovie" style="" src="'+bannerName+'" type="application/x-shockwave-flash"/>';
    $(element).append(html);
                
}

function openInNewWindow(thisClick) {
	 // Change "_blank" to something like "newWindow" to load all links in the same new window
	 var newWindow = window.open($(thisClick).attr("href"), "_blank");
	 newWindow.focus();
	 return false;
	}


function printBanner(width,height,type,file,link,text){
	
	text = decodeURIComponent(text);
     newWidth  = parseInt(width) + 20;
    newHeight = parseInt(height) + 40;

    var documentHeight = parseInt($(document).height());
    var documentWidth  = parseInt($(document).width());
    
    var marginLeft     = ((documentWidth - newWidth)/2);
    var marginTop      = 50;
        
     html  = '<div id="overlay"></div>';
    html += '<div id="overlayContent" style="width:'+newWidth+'px;margin-left:'+marginLeft+'px;margin-top:'+marginTop+'px;">';
    html += '    <script type="text/javascript" src="/Public/player/swfobject.js"></script> ';
    html += '    <div class="closeDiv"><a class="close" href="javascript:void(0);" title="" onclick="closeWindow()"></a></div>';
    if(type == 'swf'){
        html += ' <div id="banner" style="width:'+width+'px;height:'+height+'px;"><div>';
    }else{
         html += ' <div class="advImage"><a href="'+link+'"><img src="/Public/Images/Advertisement/'+file+'" /></a><div>';
    }
    html += '</div>';
    
     $("body").append(html);
     if(type == 'swf'){
          var so = new SWFObject('/Public/Images/Advertisement/'+file+'','mpl1',width,height,'10');
          so.addParam('allowscriptaccess','always');
         so.addParam('wmode','transparent');
          so.write('banner');
     }
     $('#overlayContent').append('<div class="text">'+text+'</div>');
     //countDownBanner();
	}
	
	function closeWindow(){
	
	     $("div#overlay").fadeOut(600, function() { $(this).remove(); });
	    $("div#overlayContent").fadeOut(600, function() { $(this).remove(); });
	}
	
	var second = 15;
	function countDownBanner(){
	
	     second -= 1;
	     $("div#overlayContent div.closeDiv p").html("Okno se zavře za "+second+" vteřin. ")
	     if(second > 0)setTimeout(countDownBanner,1000);
	     if(second == 0){
	          closeWindow();
	     }
	}

