function highlightRowPure(eleId) {
    obj = document.getElementById("row-"+eleId);
    obj.style.backgroundColor="#2B383E";
    obj.style.cursor="pointer";
}

function unhighlightRowPure(eleId) {
    obj = document.getElementById("row-"+eleId);
    obj.style.backgroundColor="transparent";
    obj.style.cursor="auto";
}


function unhighlightRow(eleId) {
    /* /hideAllRows(); */
    unhighlightRowPure(eleId);

    tmp = document.getElementById('flashschema').getElementsByTagName('OBJECT');
    flashid = tmp[0];
    flashid.SetVariable('jsFloor', eleId);
    flashid.SetVariable('jsEvent', 'out');    
}


function highlightRow2(eleId) {
    highlightRowPure(eleId);
    
    tmp = document.getElementById('flashschema').getElementsByTagName('OBJECT');
    flashid = tmp[0];
    flashid.SetVariable('jsFloor', eleId);
    flashid.SetVariable('jsEvent', 'over');
}


function floorOver(eleId) {
    hideAllRows();
    highlightRowPure(eleId);
}

function floorOut(eleId) {
    unhighlightRowPure(eleId);
    /* /hideAllRows(); */
}

function floorClick(eleId) {    
    /* alert(floorPlanPath+"?id="+eleId); */
    window.top.location.href = floorPlanPath+"?id="+eleId;    
}

function hideAllRows() {
    $('#total-table tr').css({
        'background-color': 'transparent',
        'cursor': 'auto'
    })
}


function showElementById(eleId) {
    $('div#'+eleId).show();
    $('div#'+eleId+'Transparent').show();
    $('div#'+eleId+'Transparent').css({
            'background-color': '#ffffff',
            'opacity': 0.9
        });


}
function hideElementById(eleId) {
    $('div#'+eleId).hide();
    $('div#'+eleId+'Transparent').hide();
    /*  document.getElementById(eleId).style.display = 'none'; */
}




function chbgcolor(eleId){
    document.getElementById(eleId).style.backgroundColor = '#880049';
}

function chbgcolorb(eleId){
    document.getElementById(eleId).style.backgroundColor = 'transparent';
}


/* funkce, ktera jednak vypise mail pres JS, cimz blokne boty a jednak pouzije entity, cimz je to jeste lepsi :) */
function js_protect_email(var1,var2)
{
	var zavinac = "&#64";
	var mailto = "mai&#108;&#116;&#111;&#58;";
	var e_mail = var1+zavinac+var2;
	var title = "title='"+e_mail+"'";

	document.write("<a href='"+mailto+e_mail+"'"+title+">"+e_mail+"</a>");
}


function pic_window(picfile, title, popis, picwidth, picheight){
	/*picheight += 100;*/
	window.open('pic_window.php?pic='+picfile+'&title='+title+'&popis='+popis+'', 'picwindow', 'width='+picwidth+',height='+picheight+'');
}

function insertFlash(eleId, swfFile, width, height, alt, wmode, flashVars)
{
	directFlashVars = '';
	if(flashVars != '')directFlashVars = '?'+flashVars;

	flashHtml =
	'<!--[if !IE]> -->'+"\n"+
	'<object type="application/x-shockwave-flash" data="'+swfFile+directFlashVars+'" width="'+width+'" height="'+height+'">'+"\n"+
	'<!-- <![endif]-->'+"\n"+
	'<!--[if IE]>'+"\n"+
	'<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0" width="'+width+'" height="'+height+'">'+"\n"+
	'<param name="movie" value="'+swfFile+directFlashVars+'" />'+"\n"+
	'<!--><!---->'+"\n"+
	'<param name="loop" value="true" />'+"\n"+
	'<param name="menu" value="false" />'+"\n"

	if(wmode)flashHtml += '<param name="wmode" value="transparent" />'+"\n";
	if(flashVars != '')flashHtml += '<param name="flashvars" value="'+flashVars+'" />'+"\n";

	flashHtml += alt+"\n";
	flashHtml += '</object>'+"\n";
	flashHtml += '<!-- <![endif]-->'+"\n";

	obj = document.getElementById(eleId);
	obj.innerHTML = flashHtml;
}

/* 
function hideAllRows() {
    y = document.getElementById('table-list');

    objs = y.getElementsByTagName('TR');

    for (x = 1; x < objs.length; x++) {
        var varid = objs[x].id;
        document.getElementById(varid).style.backgroundColor="transparent";
        document.getElementById(varid).style.cursor="auto";
    }
}
 */

var flash = null;
var ff = false;




function showFlashImage(eleId) {
    /*
    hideAllRows();
    obj = document.getElementById(eleId);
    obj.style.backgroundColor="#f1e5bb";
    obj.style.cursor="pointer";
    obj = document.getElementById(eleId);
    obj.style.backgroundColor="#f1e5bb";
    obj.style.cursor="pointer";
    */

    /*
    tmp = document.getElementById('flash_big').getElementsByTagName('OBJECT');
    flashid = tmp[0];
    flashid.SetVariable('jsImgNum', eleId);
    flashid.SetVariable('jsEvent', 'over');
    */
}

function hideFlashImage() {
	/*
    tmp = document.getElementById('flash_big').getElementsByTagName('OBJECT');
    flashid = tmp[0];
    flashid.SetVariable('jsEvent', 'out');
    */
}






function showFlash(eleId) {
	/*
	flashid = document.getElementById('flash_flat').firstChild;
	flashid.SetVariable('jsflat', eleId);
	flashid.SetVariable('jsflatevent', 'over');
	*/
}



//fotogalerie
function houseOver(id){
	ff = true;

    $('table#list tr').css({
    	'background-color': 'transparent',
    	'cursor': 'auto'
    })

	$('tr#row_'+id+'').trigger('mouseover');
}

function houseOut(id) {
	ff = true;
	$('tr#row_'+id+'').trigger('mouseout');
}

function houseClick(id) {
	document.location.href = $('tr#row_'+id+' td a').attr('href');
}

function phaseClick(phaseId) {
}

function basename(path) {
    return path.replace(/\\/g,'/').replace( /.*\//, '' );
}

$(document).ready(function(){
	if($('#fader').length) {
		$.faderController.createFader('fader', 5500);
		$.faderController.beginFader('fader');
	}
	
	$('a.lightbox').lightBox({
	   /* imageLoading: 'img/lightbox/lightbox-ico-loading.gif', */
       imageBtnClose: 'img/lightbox/lightbox-btn-close.gif',
       imageBtnPrev: 'img/lightbox/lightbox-btn-prev.gif',
       imageBtnNext: 'img/lightbox/lightbox-btn-next.gif',
       containerBorderSize: 0,
       txtImage: txtOfImage,
       txtOf: txtOfOf
	});
	
	
	
	

	
	
	
	
	
	
	
	
});

$(window).load(function() {
    $('a.overlayBox img').each(function() {
    
       popisekFotky = $(this).attr("alt");
       fotoWidth = $(this).parent().width();
       fotoHeight = $(this).parent().height();
       fotoRealHeight = $(this).height();
              
       fotoPadding = Math.ceil((fotoHeight - fotoRealHeight) / 2);  
       textPadding = Math.ceil((fotoHeight-20)*0.45);
      
      
       $(this).before("<span class='picWrapper'><span class='picTextWrapper'>"+popisekFotky+"</span></span>");
       
       /*
        var vyskaPopisku = $(this).prev('.picTextWrapper').innerHeight();
        var textPadding = Math.ceil((fotoHeight-vyskaPopisku)/2);

       
       alert("HEIGHT: "+fotoHeight);      
       alert("REAL HEIGHT: "+fotoRealHeight);
       alert("VYSKA POPISKU: "+fotoRealHeight);
       alert("TEXT PADDING: "+textPadding);
        */
        
       $(this).prev('.picWrapper').css({
           'width': fotoWidth+'px',
           'height': (fotoHeight-textPadding)+'px',
           'padding-top': textPadding+'px'
       });
       
       
       
       
       $(this).css({ 'padding-top': fotoPadding+'px' }); 
       
       $(this).mouseenter(function(){
           $(this).prev('.picWrapper').show();        
       });
       
    });
        /* 
            $size = getimagesize($path);
            $pomer_zmenseni = 214 / $size[0];
            $nova_vyska = ceil($size[1] * $pomer_zmenseni);
            $padding = ceil((160 - $nova_vyska) / 2);
        */   
    
    /* CSSKOVE DEFINICE */    
    $('.picWrapper').css({
       'position': 'absolute',
       'z-index': 3,
       'background-color': '#111111',
       'color': '#ffffff',
       'display': 'block', 
       'text-align': 'center',
      
       'opacity': 0.8            
    });
    
    $('.picTextWrapper').css({    
        /* 'display': 'block', */
        'line-height': '20px',
        'margin': '0px',
        'padding': '0px'
        /* 'padding-top': '30%' */    
    });
    
    /* schova pri prvnim nacteni a pri mouseoutu */
    $('.picWrapper').hide().mouseleave(function() { $(this).hide(); });
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    /* FUNKCE PRO DVA OBRAZKY V SPACEPLANNINGU */
   $(' a.space img').each(function() {
    
       var popisekFotky = $(this).attr("alt");
       var fotoWidth = $(this).parent().width();
       var fotoHeight = $(this).parent().height();
       var fotoRealHeight = $(this).height();
              
       var fotoPadding = Math.ceil((fotoHeight - fotoRealHeight) / 2);  
       var textPadding = Math.ceil((fotoHeight-20)*0.45);
      
      
       $(this).before("<span class='picWrapperSpace'><span class='picTextWrapperSpace'>"+popisekFotky+"</span></span>");
               
       $(this).prev('.picWrapperSpace').css({
           'width': fotoWidth+'px',
           'height': (fotoHeight-textPadding)+'px',
           'padding-top': textPadding+'px'
       });
       
       
       
       
       $(this).css({ 'padding-top': fotoPadding+'px' }); 
       
       /* 
       $(this).mouseenter(function(){
           $(this).prev('.picWrapperSpace').hide();        
       });
        */
        
        $(this).prev('.picWrapperSpace').mouseenter(function() { $(this).hide() });
        $(this).mouseleave(function() { $(this).prev('.picWrapperSpace').show() }); 
       
    });

    
    /* CSSKOVE DEFINICE */    
    $('.picWrapperSpace').css({
       'position': 'absolute',
       'z-index': 3,
       'background-color': '#111111',
       'color': '#ffffff',
       'display': 'block', 
       'text-align': 'center',
      
       'opacity': 0.8            
    });
    
    $('.picTextWrapperSpace').css({    
        'line-height': '20px',
        'margin': '0px',
        'padding': '0px',
        'text-transform': 'uppercase', 
        'font-weight': 'bold',
    });
    
    /* schova pri prvnim nacteni a pri mouseoutu */
    $('.picWrapperSpace').show();
    /* 
    $('.picWrapperSpace').mouseleave(function() { $(this).show(); });
        */ 
    
    
    
    
    
    
    
    
    
    


});
