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

//*************************************** J Q U E R Y ****************************************************************
$(document).ready(function() {

    
    $("#sortListBasic").sortable({

        revert:false,
        cursor: "move",
        dropOnEmpty: true,
        scroll:false,
        tolerance: 'pointer',
        helper: 'clone',
        'placeholder':'placeholder'

 	});
 	 	 	
 	$("#sortListNested").sortable({
 	

        revert:false,
        cursor: "move",
        dropOnEmpty: true,
        scroll:false,
        tolerance: 'pointer',
        helper: 'clone',
        items: 'li',
        'nested':'ul',
        'placeholder':'placeholder',
        'maxLevels':3,
        opacity:0.75,
        update: function(event, ui) { 
        
            var itemID = ui.item.attr("id");
            var parent = ui.item.parent().parent().attr("id");
        	var subPortal;
        	        	
        	if(parent == ""){
        	    subPortal = "0";
        	}else{
        	    subPortal = "1";
        	}
        	
        	$.ajax({
				type: "POST",
				url: "/admin/helper/updatesubportal",
				data: "itemid="+itemID+"&subportal="+subPortal+"&parrent="+parent,
				success: function(html){

				}

			});  
        	
        }
        

 	});
 	
 	$("#sortListBasic").disableSelection();	 	
 	$("#sortListNested").disableSelection();
 	          
	//Calculate the total width - sum of all sub-panels width  
	//Width is generated according to the width of #mask * total of sub-panels  
	$('#panel').width(parseInt($('#mask').width() * $('#panel div').length));  
	      
	//Set the sub-panel width according to the #mask width (width of #mask and sub-panel must be same)  
	$('#panel div').width($('#mask').width());  
	
	//Get all the links with rel as panel  
	$('a.active').click(function () {  
	      				
		//Set class for the selected item  
		$('li').removeClass('ui-state-active');  
		$(this).parent().addClass('ui-state-active');  
     
		//Scroll to the correct panel, the panel id is grabbed from the href attribute of the anchor  
		$('#mask').scrollTo($(this).attr('href'), 800);       
		     
	ids = $("div#panel object");    
		if(ids.length >= oldAId){

      idObj = ids.eq(oldAId-1).attr("id");
			var player = document.getElementById(idObj);
			player.sendEvent("PLAY","false");
			//alert("-");  
		}
		
		oldAId = $(this).attr('id').charAt(1);	

		return false;  
		
    });  
 
 
    $("cite").click(function() {
 	
 	    var position = $(this).position();
 	    var id = $(this).attr("id");
 	    var left = position.left;
 	    var top  = position.top;
 	    top += 20;
 	    

 	    $("div#citation"+id).css("top",top);
 	    $("div#citation"+id).css("left",left);
 	    
 	    $("div#citation"+id).slideToggle(400);
 	     	
 	});
 
 	
 	$("div.citation p.close").click(function() {
 	
 	    id = $(this).parent().attr("id"); 	  
 	    $("div#"+id).slideToggle(400);
 	    
 	    //alert(position.left+" - "+position.top);
 	
 	});
 	
 	$('.marqueText').marquee('pointer').mouseover(function () {
            $(this).trigger('stop');
        }).mouseout(function () {
            $(this).trigger('start');
        }).mousemove(function (event) {
            if ($(this).data('drag') == true) {
                this.scrollLeft = $(this).data('scrollX') + ($(this).data('x') - event.clientX);
            }
        }).mousedown(function (event) {
            $(this).data('drag', true).data('x', event.clientX).data('scrollX', this.scrollLeft);
        }).mouseup(function () {
            $(this).data('drag', false);
        })
 	
 	 	
});

var oldAId = 1;

function saveSortedList(controler,sortlist){
    
    var rowNumber = $('#'+sortlist+' li').size();
    var sort = new Array();
    
    for(i = 0;i < rowNumber;i++){
    
        sort[i] = $('#'+sortlist+' li').eq(i).attr("id");
         
    }
    
    $.ajax({
		type: "POST",
		url: "/admin/helper/savesortedlist",
		data: "sort="+sort+"& control="+controler,
		success: function(html){
		    
		    $('div.sortMessage').css("display","inline-block");
		    $('div.sortMessage').html("Pořadí úspěšně uloženo");
            
			}

	});    

}

function getVideos(url){

    $("div.animationVideo")
        .ajaxStart(function(){
            $(this).show();
        })
        .ajaxComplete(function(){
            $(this).hide();
        });
        
    $.ajax({
	    type: "POST",
		url: "/admin/helper/get-videos",
		data: "url="+url,
		success: function(html){    
	         
             location.reload(true); 

        }

		});     
	
	}

function regenerateImage(file,folder,id,trygenerate,footage,edit){

    $("div.animation"+id)
        .ajaxStart(function(){
            $(this).show();
        })
        .ajaxComplete(function(){
            $(this).hide();
        });

    var second;
    
    if(trygenerate){
        second = 5;
    }else{
        second = $(".getNewVideos input[name=second"+id+"]").val();
    }
    if(second != ""){
        
        if(second > 0){
        
            if(footage >= second || footage == ''){
            
			    $.ajax({
					type: "POST",
					url: "/admin/helper/regenerate-image",
					data: "second="+second+"&file="+file+"&folder="+folder+"&edit="+edit,
					success: function(html){    
				          
				        location.reload(true);          
			
			        }
			
				}); 
			
			}else{
				alert("Zadali jste počet sekund vyšší než je délka videa! Náhled nebude vygenerován! ");
			}
		
		}else{
		    alert("Počet sekund musí být větší jak 0!");
		}
		
	}else{
	    alert("Nezadali jste počet sekund k vytvoření náhledu!");
	}

}

function addPhoto(){
    
    id = $('.currentContent p.photos input:last').attr('id');
    id++;
    photo = "<label for=\"text\"> &nbsp; </label><input id=\""+id+"\" type=\"file\" name=\"photo"+id+"\" size=\"47\">";
    $('.currentContent p.photos').append(photo);
    $('.currentContent p input[name=hidden]').val(id);
    
    if(id == 5){
    
        $('#pridat_foto').css("display","none");   
    
    }

}

function getFotogallery(folder){

    $("div.loading")
        .ajaxStart(function(){
            $(this).show();
        })
        .ajaxComplete(function(){
            $(this).hide();
        });
    

    itemek = $('div.currentContent select').val();
    if(itemek == 0){
        itemek = folder;
    }
    $.ajax({
		type: "POST",
		url: "/admin/helper/fotogallery",
		data: "item="+itemek,
		success: function(html){
              
             $("div.contentItem").html(html);   

			}

	});

}


function getForm(item,parrentlevel,captcha,name,title,text,email){
    
    html =  '<center><div class="reaction"><p class="reaction"><label for="name">Jméno:</label><input id="name" type="text" name="nameReaction" value="'+name+'" />';
    html +=    '<label class="email" for="email">Email:</label><input id="email" type="text" name="emailReaction" value="'+email+'" />';
	html += '</p>';
	            
	html += '<p class="reaction"><label for="title"></label>Re: '+title+'<input id="title" type="hidden" name="titleReaction" value="Re:'+title+'" /></p>';
	html += '<p class="reaction"><label for="name">Text:</label><textarea id="text" name="textReaction">'+text+'</textarea></p>';
	html += '<p class="reaction"><input id="hidden" type="hidden" name="hiddenReaction" value="'+parrentlevel+'" /></p>';
	html += '<p><label></label><img src="/Public/Captcha/'+captcha+'" /><input type="text" name="hiddenCaptcha" /></p>';
	html += '<p class="reaction button"><input id="button" type="submit" name="addReaction" value="Přidat" /></p></div></center>';
	
    $("div.answer"+item).html(html);
    
    if($("div.answer"+item).css("display")=="block"){
        $("div.answer"+item).slideUp("slow");
    }else{
        $("div.answer"+item).slideDown("slow");
    }


}

function lan(lang){
    
    $.ajax({
		type: "POST",
		url: "/jazyk/index/",
		data: "lang="+lang,
		success: function(html){
              
             location.reload(true);   

			}

	});
    

}


    function startUpload(){
    
        $('p.upload_process').css("visibility",'visible');
        return true;

    }
    
    function stopUpload(success){
   
      var result = '';
      if (success == 1){
  
	      $('p#result').html('<span class="msg">Soubor úspěšně nahrán<\/span>');
	      $();
  
      }else {
      
          $('p#result').html('<span class="emsg">Došlo k chybě ři nahrávání!<\/span>');
          
      }
      $('p.upload_process').css("visibility",'hidden');
  
      return true;
  
      }
      
     function showAddedMp3(title){
         
         $('div.addedMp3').css('display','block');
         $('div.addedMp3').html(title);
         
         $('input[name = mp3Title]').val("");
         $('input[name = mp3]').val("");
     
     }
     
     function getCustValue(element,id)
	 {
	    title = $(element).text();
	    
	    html  = '<li id="'+id+'">';
	    html += '<div class="listTitleItem cross ">'+title+'</div>';				
		html += '<div class="listItem">';
		html += '    <a onclick="deleteCustValue('+id+');return false;" title="Smaž" href="/">';
		html += '        <img alt="Smaž" src="/Public/Images/Admin/delete.gif" />';
		html += '    </a>';
		html += '</div>';
		html += '<br id="endFloat" />';
	    html += '</li>';
	    
	    oldHtml = $('div.currentContent ul#sortList').html();
	    $('div.currentContent ul#sortList').html(html);
	    $('div.currentContent ul#sortList').append(oldHtml);
	        
	    $('div.cus_list ul li').hide();
	    $('div.cus_list').hide();
	    
	    
	    	    
	    
	 }

	function hideCust()
	{
	   $('div.cus_list ul li').hide();
	   $('div.cus_list').hide();
	}
	
	
	function deleteCustValue(id)
	 {

	    $('div.currentContent ul#sortList li#'+id).remove();

	 }
	 
	 function addPortal(){

	    html = $('p.portal').html();
	    $('p.portals').append(html);

	}
	
	function addCategory(){

	    html = $('p.ecentreCategory').html();
	    $('p.ecentreCategories').append(html);

	}
	
	function addText(){

        id = $("p input[name=hidden]").val();
        id++;
        html  = '<p><label for="title'+id+'">Nadpis '+id+': </label> <input id="title'+id+'" type="text" name="title[]" /></p>';
	    html += '<p><label for="text'+id+'">Text '+id+': </label> <textarea id="text'+id+'" name="text[]"> </textarea></p><script type="text/javascript">dispatchAlone("text'+id+'")</script>';
	    $('div.steps').append(html);
	    
	    $("p input[name=hidden]").val(id);

	}
	function dispatchAlone(id){

		var ed = new tinymce.Editor(id, {
		    mode : "textareas",
			theme : "advanced",
			language : "cs",
			plugin_insertdate_dateFormat : "%d.%m.%Y", 
			plugin_insertdate_timeFormat : "%H:%M:%S",
			plugins : "safari,spellchecker,pagebreak,style,layer,table,save,advhr,advimage,advlink,emotions,iespell,inlinepopups,insertdatetime,preview,media,searchreplace,print,contextmenu,paste,directionality,fullscreen,noneditable,visualchars,nonbreaking,xhtmlxtras,template",
			theme_advanced_buttons1 : "bold,italic,underline,strikethrough,|,justifyleft,justifycenter,justifyright,justifyfull,|,styleselect,formatselect",
			theme_advanced_buttons2 : "cut,copy,paste,pastetext,pasteword,|,search,replace,|,bullist,numlist,|,outdent,indent,blockquote,|,undo,redo,|,link,unlink,anchor,image,cleanup,help|,insertdate,inserttime,preview",
			theme_advanced_buttons3 : "tablecontrols,|,hr,removeformat,visualaid,|,sub,sup,|,charmap,media,absolute,template,fullscreen",
	
			theme_advanced_toolbar_location : "top",
			theme_advanced_toolbar_align : "left",
			theme_advanced_statusbar_location : "bottom",
			theme_advanced_resizing : true,
			file_browser_callback : "tinyBrowser",
			content_css : "/Public/Css/admin/tiny_mce_content.css",
			theme_advanced_blockformats : "p,h3",
			template_external_list_url : "js/template_list.js",
			
			template_cdate_classes : "cdate creationdate",
			template_mdate_classes : "mdate modifieddate",
			template_selected_content_classes : "selcontent",
			template_cdate_format : "%d.%m.%Y : %H:%M:%S",
			template_mdate_format : "%d.%m.%Y : %H:%M:%S",
			template_templates : [
				{
					title : "Tabulka",
					src : "/Public/Jscripts/tiny_mce/template/table.phtml",
					description : "Tabulka pro ecentre"
				},
				{
					title : "Nadpis",
					src : "/Public/Jscripts/tiny_mce/template/title.phtml",
					description : "Nadpis pro ecentre"
				},
				{
					title : "Seznam",
					src : "/Public/Jscripts/tiny_mce/template/list.phtml",
					description : "Seznam pro ecentre"
				}
			]
		});
		
		ed.render();
		
	}
	
	function getRelatedComodity(id){
	 
	    portalID = $("p select[name=portal]").val();
	
	    $.ajax({
		type: "POST",
		url: "/admin/helper/getrelatedcomodity",
		data: "portalID="+portalID+"&category=1",
		success: function(html){         
             $("div.relatedComodity").html(html);  
             var content = " ";
             $("p#uvodni").html(content);
        }

		});     
	
	}
	
	function getRelatedCategoryComodity(id){
	 
	    portalID = $("p select[name=portal[]]").val();
	    category = $("p select[name=ecentreCategory[]]").val();
	 
	    if(category == "2"){
	 
		    $.ajax({
			type: "POST",
			url: "/admin/helper/getrelatedcomodity",
			data: "portalID="+portalID+"&category=0&comodityID="+id,
			success: function(html){         
	             $("div.relatedComodity").html(html);  
	        }
	
			});  
		
		}   
	
	}
	
	function getRelatedComodityType(category,id,comodityID,portal){
	 
	    if(comodityID == '')comodityID = $("p select[name=comodity]").val();
 
	    $.ajax({
		type: "POST",
		url: "/admin/helper/getrelatedcomoditytype",
		data: "comodityID="+comodityID+"&category="+category+"&comodityTypeID="+id+"&portal="+portal,
		success: function(html){  
	      
             $("div.relatedComodityType").html(html);
             var content = " ";
             $("p#uvodni").html(content);  
        }

		});     
	
	}
	
	function getRelatedComodityTypeText(portalID){
	 
	 	comodityID     = $("p select[name=comodity]").val();
	    comodityTypeID = $("p select[name=comodityType]").val();

	    $.ajax({
		type: "POST",
		url: "/admin/helper/getrelatedcomoditytypetext",
		data: "portalID="+portalID+"&comodityID="+comodityID+"&comodityTypeID="+comodityTypeID,
		success: function(html){         
             $("div.relatedComodityTypeText").html(html);  
        }

		});     
	
	}
	
	function getOthersPortals(){
	 
	 	var comodityID     = $("select[name=comodity]").val();
	    var comodityTypeID = $("select[name=comodityType]").val();
        var portalID       = $("select[name=portals]").val();
                        
	    $.ajax({
		type: "POST",
		url: "/admin/helper/getothersportals",
		data: "portalID="+portalID+"&comodityID="+comodityID+"&comodityTypeID="+comodityTypeID,
		success: function(html){         
             $("div.othersPortals").html(html);  
             
        }

		});     
	
	}
	
	
	function getPortalContact(){
	 
	    portalID = $("p select[name=portal]").val();

	    $.ajax({
		type: "POST",
		url: "/admin/helper/getportalcontact",
		data: "portalID="+portalID,
		success: function(html){         
             $("div.portalContactText").html(html);  
        }

		});     
	
	}
	
	function getPortalBanner(){
	 
	    portalID = $("p select[name=portal]").val();

	    $.ajax({
		type: "POST",
		url: "/admin/helper/getportalbanner",
		data: "portalID="+portalID,
		success: function(html){         
             $("div.portalBanner").html(html);  
        }

		});     
	
	}
	
	function getPortalSelectionProcedureInfo(){
	 
	    portalID = $("p select[name=portal]").val();

	    $.ajax({
		type: "POST",
		url: "/admin/helper/getportalselectionprocedureinfo",
		data: "portalID="+portalID,
		success: function(html){         
             $("div.text").html(html);  
        }

		});     
	
	}
	
	function getPortalCatalog(){
	 
	    portalID = $("p select[name=portal]").val();

	    $.ajax({
		type: "POST",
		url: "/admin/helper/getportalcatalog",
		data: "portalID="+portalID,
		success: function(html){         
             $("div.portalCatalogText").html(html);  
        }

		});     
	
	}

	function getPortalAdvBoard(){
	 
	    portalID = $("p select[name=portal]").val();

	    $.ajax({
		type: "POST",
		url: "/admin/helper/getportaladvboard",
		data: "portalID="+portalID,
		success: function(html){         
             $("div.advBoard").html(html);  
        }

		});     
	
	}
	
	function getPortalAbout(){
	 
	    portalID = $("p select[name=portal]").val();

	    $.ajax({
		type: "POST",
		url: "/admin/helper/getportalabout",
		data: "portalID="+portalID,
		success: function(html){         
             $("div.about").html(html);  
        }

		});     
	
	}
	
	function getPortalSave(id){
	    var portalID;
	    if(id){
	        portalID = id;
	    }else{
	    	portalID = $("p select[name=portal]").val();
        }
	    $.ajax({
		type: "POST",
		url: "/admin/helper/getportalsave",
		data: "portalID="+portalID,
		success: function(html){    
	     
             $("div.portalSave").html(html);  

        }

		});     
	
	}
	
	function TogglePortals() {
	    $("#portal-select-submenu-wrap").toggle();
	    return false;
	}
	
	function ToggleLogin(){
	
	    $("#portal-select-login-wrap").toggle();
	    return false;
	
	}
	
	function auctionEnter(){
	    $("div.auctionEnter").toggle();
	    return false;
	}
	
	function getStep(id) {

	    $("div#step"+id).slideToggle(400,
	    
		    function () {

		            cl = $("div#elearning-content h4#s"+id).attr("class");
                    cl = cl.replace("  ",'');		
                                
		            if(cl == "opened"){
			        	$("div#elearning-content h4#s"+id).removeClass("opened");
				    	$("div#elearning-content h4#s"+id).addClass("closed");
				    }else{
				    
				        $("div#elearning-content h4#s"+id).removeClass("closed");
				    	$("div#elearning-content h4#s"+id).addClass("opened");
				    
				    }
				    
			});
	
	}
	
	function comodityToggle(id) {

	    $("ul.elearning-menu-items li ul#comodity"+id).slideToggle(400,
	    
		    function () {

		            cl = $("ul.elearning-menu-items li a#com"+id).attr("class");
                    cl = cl.replace("  ",'');		
                                
		            if(cl == "opened"){
		                //$(this).removeClass("opened");
				    	//$(this).addClass("closed");
			        	$("ul.elearning-menu-items li a#com"+id).removeClass("opened");
				    	$("ul.elearning-menu-items li a#com"+id).addClass("closed");
				    }else{
				    
				        //$(this).removeClass("closed");
				    	//$(this).addClass("opened");
				        $("ul.elearning-menu-items li a#com"+id).removeClass("closed");
				    	$("ul.elearning-menu-items li a#com"+id).addClass("opened");
				    
				    }
				    
			});
	
	}
	
	function categoryToggle(id) {

	    $("div.category"+id).slideToggle(400,
	    
		    function () {
          
		            if($("ul#tv-player-menu a#category"+id).hasClass('opened')){
		                //$(this).removeClass("opened");
				    	//$(this).addClass("closed");
			        	$("ul#tv-player-menu a#category"+id).removeClass("opened");
				    	$("ul#tv-player-menu a#category"+id).addClass("closed");
				    }else{
				    
				        //$(this).removeClass("closed");
				    	//$(this).addClass("opened");
				        $("ul#tv-player-menu a#category"+id).removeClass("closed");
				    	$("ul#tv-player-menu a#category"+id).addClass("opened");
				    
				    }
				    
			});
	
	}
	
	function regionsPortalsToggle(type,change,regport){
	
	    	
	    if($("ul."+type).css("display") != "block"){
	        
	        $("#portal-select-submenu ul#"+regport).slideUp();
	        
	        if(change && regport == "portal"){
	        	$("#portal-select-submenu ul#region li a#commercial").removeClass("minus");
	        	$("#portal-select-submenu ul#region li a#commercial").addClass("plus");
	        }
	        if(change && regport == "subPort"){
	        	$("#portal-select-submenu  li a#subPort").removeClass("minus");
	        	$("#portal-select-submenu  li a#subPort").addClass("plus");
	        }	        
	    }
	
	    $("ul."+type).slideToggle(400,
	    
		    function () {
		        if(change){
		            
		            cl = $("li a."+type).attr("class");
		            cl = cl.split(" ");
		            
		            if(cl[1] == "plus"){
			        	$("li a."+type).removeClass("plus");
				    	$("li a."+type).addClass("minus");
				    }else{
				    
				        $("li a."+type).removeClass("minus");
				    	$("li a."+type).addClass("plus");
				    
				    }
				    
			    }
			});
	
	}
	
function generatePassword(len){

    var charactors = 'abcdefghijklmnopqrstuvwxyz123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ';
    var password = '';

    while(password.length < len){
  
        password += charactors.charAt(Math.floor(Math.random()*charactors.length));
    
    }
    
    $('p input[id=password]').val(password);
    
}

function page(page,content,url){

        var comodity    = $("input[name=comodity]:checked");
        var allComodity = "";
        var client      = $("select option:selected").val();
        var public      = $("input[name=type]:checked");
        var allPublic   = "";
        
        if(comodity.length > 0){
	        allComodity = "(";
	        
	        for(i = 1;i <= comodity.length; i++){
	            if(i == comodity.length){
	                allComodity += "'"+comodity.eq(i-1).val()+"'";
	            }else{
	            	allComodity += "'"+comodity.eq(i-1).val()+"',";
	            }
	        }
	        
	        allComodity += ")";
        	 
        }
        
        if(public.length > 0){
	        
	        for(i = 1;i <= public.length; i++){
	            if(i == public.length){
	                allPublic += public.eq(i-1).val();
	            }else{
	            	allPublic += public.eq(i-1).val()+",";
	            }
	        }
        	 
        }
 
	    $.ajax({
		type: "POST",
		url: "/helper/"+content,
		data: "page="+page+"&allcomodity="+allComodity+"&client="+client+"&allpublic="+allPublic+"&url="+url,
		success: function(html){    
	         
             $("div."+content).html(html); 
             window.scrollTo(0,0); 

        }

		});     
	
	}
	
	function getUrlStep(){
	    
	    var hash = window.location.hash;   
	    var divs = $("div#elearning-content div");
	    
	    for(i=0;i < divs.length;i++){
	    
	        if($("div#elearning-content a.title").eq(i).attr("href") == hash){
	        
	           $("div#elearning-content a.title h4").eq(i).removeClass("closed");
	           $("div#elearning-content a.title h4").eq(i).addClass("opened");
	           $("div#elearning-content div").eq(i).css("display","block");
	        
	        }
	        	        
	    }
	
	}
	 
	 
function contactFormToggle(){

    $("div.contactForm").slideToggle("slow",
	    
		    function () {

		            cl = $("h3.contactForm").attr("class");
                    
                                
		            if(cl == "nadpis contactForm plus"){
			        	$("h3.contactForm").removeClass("plus");
				    	$("h3.contactForm").addClass("minus");
				    }else{
				    
				        $("h3.contactForm").removeClass("minus");
				    	$("h3.contactForm").addClass("plus");
				    
				    }
				    
	});

}


function toggleUserPortal() {
    if ($('input[name=vse]').is(':checked')) {
        $('input[name=portal[]]').attr('disabled', true);
    } else {
        $('input[name=portal[]]').removeAttr('disabled');
    }   
}

function printBanner(width,height,type,file,link){

    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;height:'+newHeight+'px;margin-left:'+marginLeft+'px;margin-top:'+marginTop+'px;">';
    html += '    <script type="text/javascript" src="/Public/player/swfobject.js"></script> ';
    html += '    <div class="exit"><img onclick="closeWindow();" src="/Public/Images/exit.png" /><p></p></div>';
    if(type == '13'){
        html += ' <div id="banner" style="width:'+width+'px;height:'+height+'px;"><div>';
    }else{
    	html += ' <div><a href="'+link+'"><img src="/Public/Banner/'+file+'" /></a><div>';
    }
    
    html += '</div>';
    
	$("body").append(html);
	if(type == '13'){
		var so = new SWFObject('/Public/Banner/'+file+'','mpl1',width,height,'10');
		so.addParam('allowscriptaccess','always');
    	so.addParam('wmode','transparent');
		so.write('banner');
	}
	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.exit p").html("Okno se zavře za "+second+" sekund. ")
	if(second > 0)setTimeout(countDownBanner,1000);
	if(second == 0){
		closeWindow();
	}
}



