function unhighlightRow(eleId) {
    obj = document.getElementById(eleId);
    obj.style.backgroundColor="transparent";
    obj.style.cursor="auto";
}

function highlightRow2(eleId) {
    obj = document.getElementById(eleId);
    obj.style.backgroundColor="#FFD863";

    obj.style.cursor="pointer";
}

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 highlightRow(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_flat').getElementsByTagName('OBJECT');
    flashid = tmp[0];
    flashid.SetVariable('jsflatevent', 'over');
    subId = eleId.substr(4);
    flashid.SetVariable('jsflat', subId);
    */

}

function unhighlightRow(eleId) {
    obj = document.getElementById(eleId);
    obj.style.backgroundColor="transparent";
    obj.style.cursor="auto";

    if(!ff && flash) {
    	/*
    	flash.SetVariable('jsId', eleId.replace('row_', ''));
    	flash.SetVariable('jsEvent', 'out');
    	*/
    }
    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');
	*/
}

function highlightRow2(eleId) {
    obj = document.getElementById(eleId);
    obj.style.backgroundColor="#f1e5bb";
    obj.style.cursor="pointer";

    if(!ff && flash) {
    	flash.SetVariable('jsId', eleId.replace('row_', ''));
    	flash.SetVariable('jsEvent', 'over');
    }
    ff = false;
}

//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,filter) {
    document.location.href = 'http://www.doma-je-doma.cz/cs/vilky-bustehrad/katalog-projektu?faze='+phaseId+'&filter='+filter;
}

$(document).ready(function(){
	if($('a.savePage').length) {
		$('a.savePage').click(function(){
			$('html,body').animate({'scrollTop': 436}, 'normal');
		});
	}
});



    




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

$(window).load(function () {

    $('.showLidice').click(function(event) {
        $(this).blur();        
        $('#lidiceForm').slideDown(1000);
        /* $('#lidiceForm').toggle();  */
        
        event.preventDefault();
    });
    
    
    
   
    var inputpole = $('#lidiceForm .text');

    if (inputpole.length) {
        inputpole.each(function() { 
            $(this).data('label', $(this).val() );            
        });        
    }
    
    
    inputpole.focus(function(event) {
        if( $(this).val() == $(this).data('label')) $(this).val('');
    });    
    
    inputpole.blur(function(){
        if($(this).val() == '') $(this).val($(this).data('label'));
    });
 








	//osetreni delky stranky
	if($('div#leftContent').length && $('div#leftContent').hasClass('fixedheight')) {
		var h = 0;
		$('div#leftContent').children(':not(.bannerSmall)').each(function(){
			h += $(this).height();
		});

		if(h + 100 > 863) {
			$('div#leftContent').removeClass('fixedheight').append('<div class="leftContentFooter">&nbsp;</div>');
		}
	}

	flash = $('div#flash_big object').get(0);

	var pageGal = new Array();

	if($('a.galPic').length) {
		$('a.galPic').each(function(){
			pageGal.push($(this).get(0));
		});

		$('body').append(
		'<div id="galCover">&nbsp;</div>' +
		'<div id="galContent">&nbsp;</div>' +
		'<a href="#" id="galClose">X</a>'
		);

		$('div#galCover').css({
			'position': 'absolute',
			'width': '100%',
			'height': ($('body').height() - 82)+'px',
			'top': '82px',
			'left': '0px',
			'background-color': '#001722',
			'display': 'none',
			'opacity': '0'
		});

		$('div#galContent').css({
			'position': 'absolute',
			'width': '100%',
			'top': '82px',
			'left': '0px',
			'padding-top': '10px',
			'text-align': 'center',
			'display': 'none',
			'opacity': '0'
		});

		$('a#galClose').css({
			'position': 'absolute',
			'top': '92px',
			'right': '10px',
			'color': '#fff',
			'font-weight': 'bold',
			'text-decoration': 'none',
			'display': 'none',
			'opacity': '0'
		});

		$('div#galContent').append('<div id="galImgTitle">&nbsp;</div>');
		$('div#galContent').append('<a href="#" id="galLeft">&nbsp;</a>');
		$('div#galContent').append('<a href="#" id="galRight">&nbsp;</a>');
		$('div#galContent').append('<img class="galBigImg" src="'+$(pageGal[0]).attr('href').replace('sm/', 'big/')+'" alt="'+$(pageGal[0]).find('img').attr('alt')+'" />');
		$('div#galContent').append('<div class="clearer">&nbsp;</div>');

		$('a#galLeft').css('display', 'none');
		$('a#galRight').css('display', 'none');

		var x = 0;
		$.each(pageGal, function(){
			$('div#galContent').append('<img src="'+$(this).find('img').attr('src')+'" class="galSm" alt="'+$(this).find('img').attr('alt')+'" width="'+Math.floor($(this).find('img').width() / 1.5)+'" />');
			++x;
			if(x == 6) {
				$('div#galContent').append('<div class="clearer">&nbsp;</div>');
				x = 0;
			}
		});

		$('div#galContent img').css({
			'margin-right': '30px',
			'margin-bottom': '30px',
			'cursor': 'pointer'
		});

        /* ZMENA PRO PANORAMATA */
        try { if (SirkaObrazku) {} } catch(err) { SirkaObrazku = 646; }        
		$('img.galBigImg').css({
			'cursor': 'default',
			'width': SirkaObrazku + 'px'						
			/*  */
		});        
		
		

		if($('div#galCover').height() < $('div#galContent').height()) {
			$('div#galCover').height($('div#galContent').height() + 115);
		}

		$('div#galContent img').click(function(event){
			event.stopPropagation();
			event.preventDefault();

			$('div#galContent img.galBigImg').attr('src', $(this).attr('src').replace('/sm', '/big'));
			$('div#galContent img.galBigImg').attr('alt', $(this).attr('alt'));

			if($('div#galContent img.galBigImg').attr('alt')) {
				$('div#galImgTitle').html($('div#galContent img.galBigImg').attr('alt'));
			} else {
				$('div#galImgTitle').html('&nbsp;');
			}
		});

		$('a.galPic').click(function(event){
			event.stopPropagation();
			event.preventDefault();

			$('div#galCover').css('display', 'block').animate({'opacity': 0.95}, 'fast');
			$('div#galContent').css('display', 'block').animate({'opacity': 1});
			$('a#galClose').css('display', 'block').animate({'opacity': 1});

			$('html,body').animate({'scrollTop': 82}, 'normal');

			$('div#galContent img.galBigImg').attr('src', $(this).find('img').attr('src').replace('/sm', '/big'));
			$('div#galContent img.galBigImg').attr('alt', $(this).find('img').attr('alt'));

			$('div#galContent img.galBigImg').unbind('load');

			$('div#galContent img.galBigImg').load(function(){
				var pos = $('img.galBigImg').position();

				$('div#galImgTitle').css({
					'position': 'relative',
					'width': $('img.galBigImg').width()+'px',
					'left': pos.left+'px',
					//'background-color': '#fff',
					'color': '#fff',
					'margin-bottom': '4px'
				});

				if($('div#galContent img.galBigImg').attr('alt')) {
					$('div#galImgTitle').html($('div#galContent img.galBigImg').attr('alt'));
				} else {
					$('div#galImgTitle').html('&nbsp;');
				}

				//sipky
				var iWidth = $('img.galBigImg').width();
				var iHeight = $('img.galBigImg').height();

				$('a#galLeft').css({
					'position': 'absolute',
					'display': 'block',
					'text-decoration': 'none',
					'top': pos.top,
					'left': pos.left,
					'width': Math.round(iWidth / 2),
					'height': iHeight,
					'background-image': 'url("http://www.doma-je-doma.cz/grafika/arr_left.png")',
					'background-position': 'left center',
					'background-repeat': 'no-repeat'
					//'opacity': 0.8
				});

                $('a#galLeft:link').css({
                    'color': 'transparent'
                });


				$('a#galRight').css({
					'position': 'absolute',
					'display': 'block',
					'text-decoration': 'none',
					'top': pos.top,
					'left': (pos.left + Math.round(iWidth / 2)),
					'width': Math.round(iWidth / 2),
					'height': iHeight,
					'background-image': 'url("http://www.doma-je-doma.cz/grafika/arr_right.png")',
					'background-position': 'right center',
					'background-repeat': 'no-repeat'
					//'opacity': 0.8
				});

				$('a#galRight:link').css({
				    'color': 'transparent'
				});
                $('a#galRight:alink').css({
                    'color': 'transparent'
                });
                $('a#galRight:vlink').css({
                    'color': 'transparent'
                });

				$('a#galLeft').unbind('click');
				$('a#galLeft').click(function(event){
					event.stopPropagation();
					event.preventDefault();

					var pic = $('div#galContent img.galBigImg').attr('src').replace('/big', '/sm');
					var prev = '';
					var found = false;
					$('img.galSm').each(function(){
						if(basename($(this).attr('src')) == basename(pic)) {
							if(prev != '') {
								$('div#galContent img.galBigImg').attr('src', prev.attr('src').replace('/sm', '/big'));
								$('div#galContent img.galBigImg').attr('alt', prev.attr('alt'));
								if(prev.attr('alt') != '') {
									$('div#galImgTitle').html(prev.attr('alt'));
								} else {
									$('div#galImgTitle').html('&nbsp;');
								}
							}
							return false;
						}
						prev = $(this);
					});
				});

				$('a#galRight').unbind('click');
				$('a#galRight').click(function(event){
					event.stopPropagation();
					event.preventDefault();

					var pic = $('div#galContent img.galBigImg').attr('src').replace('/big', '/sm');
					var found = false;
					$('img.galSm').each(function(){
						if(found == true) {
							$('div#galContent img.galBigImg').attr('src', $(this).attr('src').replace('/sm', '/big'));
							$('div#galContent img.galBigImg').attr('alt', $(this).attr('alt'));
							$('div#galImgTitle').html($(this).attr('alt'));
							if($(this).attr('alt') != '') {
								$('div#galImgTitle').html($(this).attr('alt'));
							} else {
								$('div#galImgTitle').html('&nbsp;');
							}
							return false;
						}

						if(basename($(this).attr('src')) == basename(pic))found = true;
					});
				});
			});
		});

		function closeGal(event){
			event.stopPropagation();
			event.preventDefault();

			$('div#galCover').animate({'opacity': 0}, 'fast', 'linear', function(){$('div#galCover').css('display', 'none')});
			$('div#galContent').animate({'opacity': 0}, 'fast', 'linear', function(){$('div#galContent').css('display', 'none')});
			$('a#galClose').animate({'opacity': 0}, 'fast', 'linear', function(){$('a#galClose').css('display', 'none')});
		}

		$('a#galClose').click(closeGal);
		$('div#galContent').click(closeGal);
	}





	/* MOUSEOVER EFEKT PRO FOTOGALERII */
   $('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'><b>"+popisekFotky+"</b><br/>(klikněte pro zvětšení)</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).css({ 'padding-top': fotoPadding+'px' });

       $(this).prev('.picWrapper').css({
           'width': fotoWidth+'px',
           'height': (fotoHeight-textPadding)+'px',
           'padding-top': textPadding+'px'
       });

       $(this).mouseenter(function(){
           $(this).prev('.picWrapper').show();
       });

    });


    /* 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(); });












             $(function(){
                $('ul.jd_menu').jdMenu({   
                                            //onHideCheck: onHideCheckMenu,
                                            //onHide: onHideMenu, 
                                            //onClick: onClickMenu, 
                                            //onAnimate: onAnimate
                                            });
            });

            function onAnimate(show) {
                //$(this).fadeIn('slow').show();
                if (show) {
                    $(this)
                        .css('visibility', 'hidden').show()
                            .css('width', $(this).innerWidth())
                        .hide().css('visibility', 'visible')
                    .fadeIn('normal');
                } else {
                    $(this).fadeOut('fast');
                }
            }

            var MENU_COUNTER = 1;
            function loadMenu() {
                if (this.id == 'dynamicMenu') {
                    $('> ul > li', this).remove();
            
                    var ul = $('<ul></ul>');
                    var t = MENU_COUNTER + 10;
                    for (; MENU_COUNTER < t; MENU_COUNTER++) {
                        $('> ul', this).append('<li>Item ' + MENU_COUNTER + '</li>');
                    }
                }
            }

            function unloadMenu() {
                if (MENU_COUNTER >= 30) {
                    MENU_COUNTER = 1;
                }
            }

            // We're passed a UL
            function onHideCheckMenu() {
                return !$(this).parent().is('.LOCKED');
            }

            // We're passed a LI
            function onClickMenu() {
                $(this).toggleClass('LOCKED');
                return true;
            }


});








    
