var v;
$(document).ready(function(){
    $('.colorbox').colorbox();
    
 /*** odkazy obalujici block-level elemnty ***/
    $(".page-uvod .zeme .inner a").each(function(){
    	elm_url = $(this).attr("href");
    	$(this).parent().parent().wrap( $("<a href='"+elm_url+"' class='obalovaci'/>") );
    });
    $("#right-col .nabidky( li a").each(function(){
    	elm_url = $(this).attr("href");
    	$(this).parent().parent().wrap( $("<a href='"+elm_url+"' class='obalovaci'/>") );
    });
    $(".last_minute .cont h3 a").each(function(){
        elm_url = $(this).attr("href");
        $(this).parent().parent().parent().wrap( $("<a href='"+elm_url+"' class='obalovaci'/>") );
    });

    
  /*** vymenovac obrazku ***/

  $("#prvni_obrazek .preload").load(function(){ // napred musime natahnout obrazek, abychom meli jeho velikost
    preimg = $(this);
    mainimg = $("#prvni_obrazek .vetsi");  // vymenovat budem jiny obrazek, jinak by se load volal pri kazde zmene
  
    $("#prvni_obrazek").css({height: preimg.height(), width: preimg.width()}); // velikost <div>u obsahujiciho obrazek
    $("#prvni_obrazek .vetsi").attr('style', 'max-height:'+preimg.height()+'px; max-width:'+preimg.width()+'px; '+
       'width:  expression(this.width  > '+preimg.width()+'  ? "'+preimg.width()+'px"  : true); '+
       'height: expression(this.height > '+preimg.height()+' ? "'+preimg.height()+'px" : true); ' ); //mrdka IE

    $(".gallery.nahledy a").each(function(){
      var newsrc = $(this).find(".preload").attr("src");
      var newhref = $(this).attr("href");
      $(this).mouseenter(function(){
        mainimg.attr("src",newsrc);
        mainimg.parent().attr("href", newhref);
        $(this).find(".thumb").fadeTo("fast", 0.7);
      });//mouseenter
      $(this).mouseleave(function(){
        $(this).find(".thumb").stop();
        $(this).find(".thumb").fadeTo("slow", 1.0);
      });//mouseleave
    });//.gallery.nahledy a
  });//mainimg load
    



 /*** obarvovani zajezdu ***/
    $(".ceniky table.zajezd ").each(function(){
    	var zt = $(this);
    	zt.find("tbody tr>*").each(function(){
    		var cell = $(this);
    		cell.mouseenter(function(){
    			if (cell.attr('class')!=null) {
    				colnum = -1;
    				ub = -1;
		    		var spls = cell.attr('class').split(' ');//zparsuj tridy
					for (var i=0; i<spls.length; i++) { 
						m = spls[i].match('c([0-9]+)');
						if (m!=null) colnum = m[1];
						m = spls[i].match('ub([0-9]+)');
						if (m!=null) ub = m[1];
					}
					if (colnum!=-1)
						zt.find(".c"+colnum).each(function(){	$(this).addClass('highlight');	});
					if (ub!=-1) 
						$(".ubytovani .ub"+ub).addClass('highlight');
    			}
    			cell.parent().children().each(function(){  $(this).addClass('highlight');	});
    		});
    		cell.mouseleave(function(){
    			zt.find("*").each(function(){
    				$(this).removeClass('highlight');
    			});
    			$(".ubytovani .ub"+ub).each(function(){
    				$(".hovubyt.ub"+ub).removeClass('highlight');
    			});
    		});
    	});
    	
    	zt.find("thead tr>*").each(function(){
    		var cell = $(this);
    		cell.mouseenter(function(){
    			if (cell.attr('class')!=null) {
		    		var spls = cell.attr('class').split(' ');//zparsuj tridy
					for (var i=0; i<spls.length; i++) { 
						m = spls[i].match('c([0-9]+)');
						if (m!=null) colnum = m[1];
						m = spls[i].match('ub([0-9]+)');
						if (m!=null) ub = m[1];
					}
	    			zt.find(".c"+colnum).each(function(){
	    				$(this).addClass('highlight');
	    			});
    			}
    		});
    		cell.mouseleave(function(){
    			zt.find("*").each(function(){
    				$(this).removeClass('highlight');
    			})
    		});
    	});
    });
    
});

