$(document).ready(StartUp);
function StartUp()
{
    if (document.getElementById('PropertyImageMainBorder'))
    {
        Elements = document.getElementById('PropertyImageMainBorder').getElementsByTagName('input');
        ImageSlideShow = new Array();
        for (i = 0; i < Elements.length; i++)
        {
            ImageSlideShow[i] = { src: Elements[i].value, dir: ((i % 2) ? ('down') : ('up')) };
        }
        ImageSlideShow[Elements.length] = { src: Elements[0].value, dir: ((Elements.length) ? ('down') : ('up')) }  ;
        $('#PropertyImageMainBorder').crossSlide({
            speed: 25,
            fade: 1
        },
     ImageSlideShow
    );
    }
    $('#RealsLogin').html('<iframe name="reals-login" src="http://www.reals.cz/united-real-login.php" scrolling="no" frameborder="0" allowTransparency="true" style="border:none; overflow:hidden; width:250px; height:250px"></iframe>');
    $('a[rel="NewWindow"]').click(function ()
    {
        window.open($(this).attr('href'), "_blank");
        return false;
    });
    $('.ScrollLeft').click(function ()
    {
        $('.NewsBoxContentInner').scrollTo({ top: ' = 0 px', left: '-=645px' }, 500);
        return false;
    });
    $('.ScrollRight').click(function ()
    {
        $('.NewsBoxContentInner').scrollTo({ top: ' = 0 px', left: '+=645px' }, 500);
        return false;
    });
    $('#PropertyGalleryScrollLeft').click(function ()
    {
        $('.PhotoGalleryScroll').scrollTo({ top: ' = 0 px', left: '-=652px' }, 1000);
        return false;
    });
    $('#PropertyGalleryScrollRight').click(function ()
    {
        $('.PhotoGalleryScroll').scrollTo({ top: ' = 0 px', left: '+=652px' }, 1000);
        return false;
    });
    $('#PropertyGallery .PhotoGalleryScroll a').colorbox({rel: "colorbox", slideshowAuto: false, slideshow: true, transition: "none", photo: true, width: "75%", height: "75%" });
    $('#FacebookLikeIt').html( '<iframe name="facebook" src="http://www.facebook.com/plugins/like.php?href=' + encodeURIComponent(document.URL) + '&layout=standard&show_faces=false&width=190&colorscheme=light" scrolling="no" frameborder="0" allowTransparency="true" style="border:none; overflow:hidden; width:190px; height:70px"></iframe>');
   
    $('[id^="PropertyContact"]').focus(function ()
    {
        if ($(this).val() == $(this).attr('title'))
        {
            $(this).val('');
        }
    });
    $('[id^="PropertyContact"]').blur(function ()
    {
        if ($(this).val() == '')
        {
            $(this).val($(this).attr('title') );
        }
    });
   /* $('#PropertyImageMainLink').click(function ()
    {
        $.colorbox({ href: $(this).attr('href'), rel: "colorbox", slideshowAuto: false, slideshow: true, transition: "none", photo: true, width: "75%", height: "75%" });
        return false;
    });*/
    $('#PropertyMenuSlideshow a').click(function ()
    {
        $.colorbox({ href: $('#PropertyGallery .PhotoGalleryScroll a').attr('href'), rel: "colorbox", slideshowAuto: true, slideshow: true, transition: "none", photo: true, width: "75%", height: "75%" });
        return false;
    });
    $('#PropertyMenuMap a').click(function ()
    {
        $.colorbox({ href: $('#PropertyMenuMap a').attr('href'), scrolling: false, transition: "none", iframe: true, width: "920", height: "540" });
        return false;
    });
    $('.BranchMap').html('<iframe frameborder="0"  scrolling="no" style="width:100%; height:100%; border:0; display:block" src="http://www.unitedreal.cz/mapa/' + $('.BranchMap').html() + '/1/550/250/" />');
    $('.PropertyMap').html('<iframe frameborder="0"  scrolling="no" style="width:100%; height:100%; border:0; display:block" src="http://www.unitedreal.cz/mapa/' + $('.PropertyMap').html() + '/1/415/300/" />');
    $('select.SubmitForm').change(function ()
    {
        $('input[type="hidden"][name="' + $(this).attr('name') + '"]').val($(this).val());
        $('input[type="hidden"][name="' + $(this).attr('name') + '"]').parents('form').submit();
    });
    //$("a[rel='colorbox']").colorbox({ transition: "none", slideshowAuto: false, photo: true, width: "75%", height: "75%" });
    $($('[href^="#SearchBoxTab"][class!="Active"]').attr('href')).attr('show', 'false');
    $($('[href^="#SearchBoxTab"][class="Active"]').attr('href')).attr('show', 'true');
    $('div[id^="SearchBoxTab"][show!="true"]').hide();
    $('[href^="#SearchBoxTab"]').click(function ()
    {
        if ($(this).attr('class') != 'Active')
        {
            $('[href^="#SearchBoxTab"][class="Active"]').attr('class', '');
            $(this).attr('class', 'Active');
            $('div[id^="SearchBoxTab"]').hide();
            $($(this).attr('href')).fadeIn('slow');
        }
        return false;
    });
    Ajax();
};
function Ajax()
{
    $('#SearchBoxTabIndexProperties select.Ajax').bind('change',
    function ()
    {
        var FormData = $("#SearchBoxTabIndexPropertiesForm").serializeArray();
        $("#SearchBoxTabIndexProperties").load('/ajax.php', { 'template': '#SearchBoxTabIndexProperties', 'property_search': { 'data': FormData} }, function (Response, Status)
        {
            if (Status == "success") { Ajax(); };
        });
    });
    $('#SearchBoxTabProperties select.Ajax').bind('change',
    function ()
    {
        var FormData = $("#SearchBoxTabPropertiesForm").serializeArray();
        $("#SearchBoxTabProperties").load('/ajax.php', { 'template': '#SearchBoxTabProperties', 'property_search': { 'data': FormData} }, function (Response, Status)
        {
            if (Status == "success") { Ajax(); };
        });
    });
    $('#SearchBoxQuick select.Ajax').bind('change',
    function ()
    {
        var FormData = $("#SearchBoxQuickForm").serializeArray();
        $("#SearchBoxQuick").load('/ajax.php', { 'template': ( ( $( "#SearchBoxQuickForm" ).attr( 'action' ) ) ? ('#SearchBoxQuick') : ( '#SearchBoxQuickBranch' ) ), 'property_search': { 'data': FormData} }, function (Response, Status)
        {
            if (Status == "success") { Ajax(); };
        });
    });
}

        function replaceT(obj)
        {
            var newO = document.createElement('input');
            newO.setAttribute('type', 'password');
            newO.setAttribute('name', obj.getAttribute('name'));
            obj.parentNode.replaceChild(newO, obj);
            newO.focus();
            newO.focus();
        }

