/*function menuexPoser()
{
    var menuOut = $("ul.sf-menu");
    var menu = $("ul.sf-menu li");
    menu.bind("mouseleave", function() {
        $.mask.close();
    //      $("#navDropBg").stop().slideUp();
    });
    
    menu.bind("click keydown mouseenter", function() {
        //$("#navDropBg").stop().slideDown();
        menuOut.expose({
         
            closeOnClick: true,
            maskId: 'exposeMask',
            color: '#3b3a3a',
            opacity: '0.3',
            loadSpeed: 0,
            closeSpeed: 0,
            width: '100%',
            height: '100%'
            ,
            onLoad: function() {

              
            },

            onClose: function() {
                
            }



        });
    });
}

*/
/*
function navDrop()
{
    var navBg = $("ul.sf-menu, #navDropBg");
    navBg.hoverIntent(function() {
        $("#navDropBg").stop().animate({
            opacity: 1,
            height: '380'
        }, 300, 'easeOutExpo', function() {
            });
    },
    function(){
        $("#navDropBg").stop().animate({
            opacity: 0,
            height: 0
        }, 300, 'easeOutExpo', function() {
            });
    });
}

*/


function showSliderContent()
{

    var sliderTxt = $(".showMore");

    sliderTxt.bind("click", function() {
        textHolder = sliderTxt.parents('.headerGal');
        textHolder.find('.sliderElement.active .elementText').css('display','block');
        switch (textHolder.attr('id')) {
            case 'headerGalHolder':
                height = 38;
                break;
            default:
                height = 360;
                break;
        }
        textHolder.find('.sliderElement.active .elementText').stop().animate({
            opacity: 1,
            height: height
        }, 500, 'easeOutExpo', function() {
            });

    });




}


function hideSliderContent()
{

    var sliderTxt = $(".closeMore");
    sliderTxt.bind("click", function() {


        $(this).parent().stop().animate({
            opacity: 0,
            height: '0'
        }, 300, 'linear', function() {
            $(this).css('display','none');
        });

    });


}


jQuery.fn.fadeDelay = function() {
    delay = 0;
    return this.each(function() {
        //   $(this).delay(delay).slideUp();
        $(this).stop().delay(delay).fadeTo( 150, 1,'easeOutCirc');
        delay += 25;
    });
};


jQuery.fn.fadeOutDelay = function() {
    delay = 0;
    return this.each(function() {
        //    $(this).delay(delay).slideDown();
        // if (!$(this).hasClass('active')) {
        $(this).stop().delay(delay).fadeTo(100, 0.03,'easeOutCirc');
        delay += 25;      
    //  }

    });
};



function showThumbs()
{
    var menuThumbs = $("#galHolder");
    menuThumbs.hoverIntent(function() {
        //        $(".sliderElement .elementSlogan").fadeDelay();
        //        $(".sliderElement .elementText").fadeDelay();

        $("#headerGalThumbs .bigUrl").fadeDelay();
        $("#headerGalThumbs .browse").fadeDelay();
    //    $("#indexVisual .active .elementText").fadeIn();

    },
    function(){
        $("#headerGalThumbs .bigUrl").fadeOutDelay();
        $("#headerGalThumbs .browse").fadeOutDelay();
    //  $("#indexVisual .active .elementText").fadeOut();

    });
}





/*
function fadePix(){
var img = $(".sliderElement img");
$('.sliderElement').hover(function() {
$('img', this).pixastic("desaturate");
}, function() {
$('.sliderElement').html(img);
});
}
*/
function transformSlider() {
    if ($('#galHolder').length>0) {
        
        // defaults
        holderSize = 11;
        
        // move galery
        $('#galHolder').detach().insertAfter('#nav');
        
        // build nav
        thumbs = new Array();
        $('#galHolder #headerGalHolder .sliderElement .bigUrl').each(function(index,item) {
            thumbs.push($(item).detach());           
        });
        
        $('#headerGalThumbs').append('<div class="nonscrollable noncircular"><div class="items"></div></div>');
        
        holderLength = parseInt(thumbs.length / holderSize);
        if (thumbs.length % holderSize > 0) {
            holderLength++;
        }
        for (c=0; c<holderLength; c++) {
            $('#headerGalThumbs .items').append('<div class="holder"></div>');
        }
        
        for (c=0; c<thumbs.length; c++) {
            hIndex = parseInt(c / holderSize);
            $('#headerGalThumbs .items .holder').eq(hIndex).append(thumbs[c]);
        }
        /*
        $('#headerGalThumbs .scrollable').before('<a class="prev browse left"></a>');
        $('#headerGalThumbs .scrollable').after('<a class="next browse right"></a>');
        */


        /*
        // multiply panes for circular scrollable
        panesLength = $('#galHolder #headerGalHolder .sliderElement').length;
        //if (panesLength > holderSize) {
        firstPanes = $('#galHolder #headerGalHolder .sliderElement').slice(0,10);
        //secondPanes = $('#galHolder #headerGalHolder .sliderElement').slice(10);
            
        $(firstPanes).each(function(index,item) {
            if (index) {
                $('#galHolder #headerGalHolder #indexVisual .sliderElement').eq(index).before('<div id="'+$(item).attr('id')+'" class="sliderElement">'+$(item).html()+'</div>');
            }
            else {
                $('#galHolder #headerGalHolder #indexVisual').prepend('<div id="'+$(item).attr('id')+'" class="sliderElement">'+$(item).html()+'</div>');
            }
        });
            

        $(firstPanes).each(function(index,item) {
            $('#galHolder #headerGalHolder #indexVisual').append('<div id="'+$(item).attr('id')+'" class="sliderElement">'+$(item).html()+'</div>');
        });
            
        //}
        
        // clone images / pixastic
        origImages = new Array();
        bwImages = new Array();
        iIndex = 0;
        $('#galHolder #headerGalHolder .sliderElement .bigImageUrl').each(function(index,item) {
            if (index==6) {

                
                
            
                imageSrc = $(item).text();
                origImages[iIndex] = $('<img src="'+imageSrc+'" alt="" />');
                $(item).after(origImages[iIndex]);
                origImages[iIndex].bind('load', {
                    item:item, 
                    index:index, 
                    imageSrc:imageSrc
                }, function(origEvent) {       
                    
                    bwImages[iIndex] = $('<img src="'+origEvent.data.imageSrc+'" class="bwImage" alt="" />');
                    $('#galHolder #headerGalHolder .sliderElement').eq(origEvent.data.index).find('img').after(bwImages[iIndex]);
                    //$(origEvent.data.item).next().after(bwImage);

                    bwImages[iIndex].bind('load', {
                        bwImage:bwImages[iIndex]
                        }, function(bwEvent) {

                        $(bwEvent.data.bwImage).pixastic("desaturate");

                    });                    
                });
               
                
                
                
                                
                
                
   
                $(item).detach();
                iIndex++;
            }
            
        });
        */
    //$(".bwImage").pixastic("desaturate");        
        
        
    }
}


function transformTimeline() {
    if ($('#timelineHolder').length>0) {
        // defaults
        smallHolderSize = 3;
        bigHolderSize = 8;
        
        // move galery
        $('#timelineHolder').detach().insertAfter('#nav');        
        
        // fetch years
        years = new Array();
        $('#timelineHolder .sliderElement .timelineYear').each(function(index,item) {
            years.push('<a href="#">'+$(item).text()+'</a>');           
        });        
        
        
        //build big nav  
        $('#timelineYearsBig').append('<div class="scrollable noncircular"><div class="items"></div></div>');
        
        holderLength = parseInt(years.length / bigHolderSize);
        if (years.length % bigHolderSize > 0) {
            holderLength++;
        }
        for (c=0; c<holderLength; c++) {
            $('#timelineYearsBig .items').append('<div class="holder"></div>');
        }
        
        for (c=0; c<years.length; c++) {
            hIndex = parseInt(c / bigHolderSize);
            $('#timelineYearsBig .items .holder').eq(hIndex).append(years[c]);
        }
        
        $('#timelineYearsBig .scrollable').before('<a class="prev browse left"></a>');
        $('#timelineYearsBig .scrollable').after('<a class="next browse right"></a>');
 
 
        //build small nav  
        $('#timelineYearsSmall').append('<div class="scrollable"><div class="items"></div></div>');
        
        holderLength = parseInt(years.length / smallHolderSize);
        if (years.length % smallHolderSize > 0) {
            holderLength++;
        }
        for (c=0; c<holderLength; c++) {
            $('#timelineYearsSmall .items').append('<div class="holder"></div>');
        }
        
        for (c=0; c<years.length; c++) {
            hIndex = parseInt(c / smallHolderSize);
            $('#timelineYearsSmall .items .holder').eq(hIndex).append(years[c]);
        }
        
        $('#timelineYearsSmall .scrollable').before('<a class="prev browse left"></a>');
        $('#timelineYearsSmall .scrollable').after('<a class="next browse right"></a>'); 
    /*
        // multiply panes for circular scrollable
        panesLength = $('#timelineHolder .sliderElement').length;
        if (panesLength > bigHolderSize) {
            firstPanes = $('#timelineHolder .sliderElement').slice(0,10);
            secondPanes = $('#timelineHolder .sliderElement').slice(20);
            
            $(secondPanes).each(function(index,item) {
                if (index) {
                    $('#timelineHolder #indexVisualTime .sliderElement').eq(index).before('<div id="'+$(item).attr('id')+'" class="sliderElement">'+$(item).html()+'</div>');
                }
                else {
                    $('#timelineHolder #indexVisualTime').prepend('<div id="'+$(item).attr('id')+'" class="sliderElement">'+$(item).html()+'</div>');
                }
            });
            

            $(firstPanes).each(function(index,item) {
                $('#timelineHolder #indexVisualTime').append('<div id="'+$(item).attr('id')+'" class="sliderElement">'+$(item).html()+'</div>');
            });
            
        }
*/        
        
    }
}
function transformContact() {
    if ($('#contactHolder').length>0) {

        
        // move 
        $('#contactHolder').detach().insertAfter('#nav');        
        infoText = $('#contactInfotext').detach();
        $('#indexVisualContact .subcl').eq(0).append(infoText);
        
    }
}

function transformVillenSlider() {
    if ($('#villenHolder').length>0) {
        
        if ($('#villenLoggedInLageplan').length > 0) {
            $('#villenHolder').addClass('loggedIn');
        }
        
        // defaults
        holderSize = 5;
        
        // move galery
        $('#villenHolder').detach().insertAfter('#nav');
        
        if ($('#villenLoggedInLageplan').length > 0) {
            $('#villenLoggedInLageplan .c33r .villenTextContainer').empty().attr('id','lageplanNav');
            $('#villenLoggedInLageplan .c33r .helpText').detach();
            $('#lageplanNav').append('<div class="holder"></div>');
            
            $('.sliderElement').slice(1).each(function(sIndex, sElement) {
                $(sElement).find('.villenTextContainer').after('<a href="#" class="buttonBackOverview">zur&uuml;ck zur &Uuml;bersicht</a>');
            });
            $('.buttonBackOverview').button({
                text: true,
                icons: {
                    secondary: "ui-icon-arrow-1-w"
                }
            });
            $('.buttonBackOverview').click(function(event) {
                event.preventDefault();
                $('#villenNav .items a').first().click();
            });
        }        
        
        // build nav
        // fetch years
        headlines = new Array();
        $('#villenHolder .sliderElement .villenHeadline').each(function(index,item) {
            headlines.push('<a href="#">'+$(item).text()+'</a>');           
        }); 
        
        $('#villenNav').append('<div class="scrollable noncircular"><div class="items"></div></div>');
        
        holderLength = parseInt(headlines.length / holderSize);
        if (headlines.length % holderSize > 0) {
            holderLength++;
        }
        for (c=0; c<holderLength; c++) {
            $('#villenNav .items').append('<div class="holder"></div>');
        }
        
        for (c=0; c<headlines.length; c++) {
            hIndex = parseInt(c / holderSize);
            $('#villenNav .items .holder').eq(hIndex).append(headlines[c]);
            if ($('#villenLoggedInLageplan').length > 0 && c > 0) {
                $('#lageplanNav .holder').append('<p class="navLink">'+headlines[c]+'</p>');
            }
        }
        
        $('#villenNav .scrollable').before('<a class="prev browse left"></a>');
        $('#villenNav .scrollable').after('<a class="next browse right"></a>');
        

        // render coords
        circles = new Array();
        thisCircles = new Array();
        activeCircle = new Array();
        $('#villenHolder').append('<div id="villenTooltips" class="tooltipsHolder"></div>');
        

        
        $('#villenHolder .sliderElement .dataHolder').each(function (hIndex, holder) {
            
            sliderElement = $(holder).parents('.sliderElement').first();
            elementId = $(sliderElement).attr('id');
            

            
            
            if ($(holder).find('.dataElement').length > 0) {
                

                holderId = 'dataHolder'+String(hIndex);
                $(holder).attr('id',holderId);
                switch (elementId) {
                    case 'villenLoggedInLageplan':
                        $('#villenNav').hide();
                        break;
                    default:
                        break;
                }
                rWidth = 630;
                dataView = Raphael(holderId, rWidth, 380);

                thisCircles[hIndex] = new Array();
                activeCircle[hIndex] = false;

                if (jQuery.browser!='msie') {
                    $(holder).add('#'+holderId+' svg').css({
                        'position':'absolute',
                        'left':0,
                        'top':0
                    });                    
                }
                else {
                    $(holder).add('#'+holderId+' rvml:group').css({
                        'position':'absolute',
                        'left':0,
                        'top':0
                    });                     
                }


                $(holder).find('.dataElement').each(function (eIndex, element) {
                    
                    dialogId = 'toolTip-'+String(hIndex)+'-'+String(eIndex);
                    $('#'+dialogId).addClass('villenTooltip');
                    coord = $(element).find('.coords');
                    cObj = {
                        x: parseInt($(coord).find('.coord-x').text()),
                        y: parseInt($(coord).find('.coord-y').text())
                    };
                    
                    elementText = $(sliderElement).find('.villenTextContainer').html();
                    

                    thisCircles[hIndex][eIndex] = dataView.circle(cObj.x, cObj.y, 4).attr({
                        'stroke': '#ffffff',
                        'fill': '#AA0000',
                        'stroke-width': 4,
                        'cursor':'pointer',
                        'fill-opacity': 1,
                        'title':$(element).find('h2.dataHeadline').text()

                    });  
                    
                    switch (elementId) {
                        case 'villenLoggedInLageplan':
                            $(thisCircles[hIndex][eIndex].node).bind('click', {
                                index:eIndex,
                                element: sliderElement
                            }, function(event) {
                                $("#villenHolder .scrollable").data('toolTabs').click(event.data.index+1);
                            });
                            break;
                        default:
                            $(thisCircles[hIndex][eIndex].node).bind('click', {
                                index:eIndex,
                                dialogId: dialogId
                            }, function(event) {
                                if ($('#'+event.data.dialogId).find('a.dataLink').length>0) {
                                    if ($('#'+event.data.dialogId).find('a.dataLink').first().attr('href')) {
                                        $('#'+event.data.dialogId).find('a.dataLink').first().click();
                                    }
                                }
                            });                            
                            break;
                    }

                    $(thisCircles[hIndex][eIndex].node).bind('mouseover', {
                        hIndex: hIndex,
                        index:eIndex,
                        elementId: elementId,
                        element: element,
                        sliderElement: sliderElement
                    }, function(event) {

                        circles = thisCircles[event.data.hIndex];
                        activateCircle(event.data.index);   
                        helpText = $(event.data.sliderElement).find('.helpText');

                        if (helpText.length > 0) {
                            if (!$(helpText).hasClass('hiddenHelp')) {
                                $(helpText).stop().animate({'opacity':0},1000, function() {
                                    $(helpText).addClass('hiddenHelp');
                                });
                            }
                        }
                        if (activeCircle[event.data.hIndex] && event.data.index != activeCircle[event.data.hIndex]) {
                            $('.tooltip').dialog('close');
                        }

                        dialogId = 'toolTip-'+String(event.data.hIndex)+'-'+String(event.data.index);
                        
                        if (event.data.elementId == 'villenLoggedInLageplan') {
                            $('#'+dialogId).dialog('open');
                        }
                        else {
                            if ($('#villenLoggedInLageplan').length > 0) {
                                $(event.data.sliderElement).find('.villenTextContainer').html($('#'+dialogId).html());
                            }
                            else {
                                hPosition = $('#nav .page').offset();
                                $('#'+dialogId).dialog('option', {
                                    position: [hPosition.left+605, 400-$(document).scrollTop()]
                                });  
                                $('#'+dialogId).dialog('open');
                            }
                        }

                        
                        

                    });

                    $(thisCircles[hIndex][eIndex].node).bind('mouseout', {
                        hIndex: hIndex,
                        index:eIndex,
                        elementId: elementId,
                        element: element,
                        sliderElement: sliderElement,
                        elementText: elementText
                    }, function(event) {
                        circles = thisCircles[event.data.hIndex];
                        deactivateCircle(event.data.index);
                        dialogId = 'toolTip-'+String(event.data.hIndex)+'-'+String(event.data.index);
                        if (event.data.elementId == 'villenLoggedInLageplan') {
                            $('#'+dialogId).dialog('close');                                                        
                        }
                        else {
                            if ($('#villenLoggedInLageplan').length > 0) {
                                $(event.data.sliderElement).find('.villenTextContainer').html(event.data.elementText);
                            }
                            else {
                                if (isNaN(activeCircle[event.data.hIndex]) || event.data.index != activeCircle[event.data.hIndex]) {
                                    $('#'+dialogId).dialog('close');                            
                                } 
                            }                            
                           
                        }

                        
                    });

                    $(thisCircles[hIndex][eIndex].node).bind('click', {
                        hIndex: hIndex,
                        index:eIndex
                    }, function(event) {
                        activeCircle[event.data.hIndex] = event.data.index;

                    });


                    tooltipId = 'toolTip-'+String(hIndex)+'-'+String(eIndex);
                    $(element).attr('id',tooltipId);
                    $(element).addClass('tooltip');
                    moveElement = $(element).detach();
                    $('#villenTooltips').append(moveElement);
                    offsetLeft = 941 - cObj.x;
                    offsetTop = -103 - cObj.y;

/*
                    $(thisCircles[hIndex][eIndex].node).tooltip({
                        'tip': '#'+tooltipId,
                        'position': 'bottom left',
                        'offset': [offsetTop,offsetLeft]
                    });  
*/
                    
                    
                    hPosition = $('#nav').offset();
                    
                    switch (elementId) {
                        case 'villenLoggedInLageplan':
                            
                            $('#'+dialogId).dialog({ 
                                autoOpen: false,
                                title: $('#'+dialogId).find('h2.dataHeadline').text(),
                                position: [hPosition.left+cObj.x+10, hPosition.top+cObj.y-60-$(document).scrollTop()],
                                height: 90,
                                resizable: false,
                                draggable: false,
                                width: 150

                            });
                            $('#'+dialogId).parents('.ui-dialog').addClass('lageplanDialog');
                            $('#'+dialogId).addClass('lageplanTooltip');
                            headline = $('#'+dialogId+' .dataHeadline').detach();
                            $('#'+dialogId+' .dataText').after(headline);
                            
                            $('#villenLoggedInLageplan #lageplanNav .navLink a').each(function(lIndex, navLink) {
                                $(navLink).bind('mouseover', {
                                    index: lIndex
                                }, function(event) {
                                    $(thisCircles[hIndex][event.data.index].node).mouseover();
                                });
                                $(navLink).bind('mouseout', {
                                    index: lIndex
                                }, function(event) {
                                    $(thisCircles[hIndex][event.data.index].node).mouseout();
                                });
                                $(navLink).bind('click', {
                                    index: lIndex
                                }, function(event) {
                                    event.preventDefault();
                                    $(thisCircles[hIndex][event.data.index].node).click();
                                }); 
                            });
                            
                            break;
                        default:
                            $('#'+dialogId).dialog({ 
                                autoOpen: false,
                                title: $('#'+dialogId).find('h2.dataHeadline').text(),
                                position: [hPosition.left+605, 400-$(document).scrollTop()],
                                height: 180,
                                resizable: false,
                                draggable: false

                            });
                            break;
                    }


           
                    $('#'+dialogId).find('a.dataLink').click(function() {
                        ajaxUrl = $(this).attr('href');

                        if (ajaxUrl) {
                            $.ajax({url: ajaxUrl, type: 'GET',dataType: 'html',  error: function(jqXHR, textStatus, errorThrown) {
                                alert(errorThrown);
                            }, success: function(data, textStatus, XMLHttpRequest){
                                data = data.replace(/\<script [^>]+>/gi,'');
                                data = data.replace(/\<\/script>/gi,'');

                                ajaxContent = $('<div></div>');
                                ajaxContent.html(data);
                                


                                $('#ajaxInsert').empty();
                                $('#ajaxInsert').append(ajaxContent);
                                //$('#ajaxInsert').html($(data).find('.ajaxContent').html());
                                //$(window).animate({scrollTop:600}, 500);
                                $('html, body').animate({scrollTop: $("#ajaxInsert").offset().top}, 1000, 'swing');

                                $("a.startImageGallery").
                                add("a.imgPop").
                                fancybox({
                                    'padding' : '10',
                                    'margin' : '10',
                                    'opacity' : true,
                                    'transitionIn' : 'elastic',
                                    'transitionOut' : 'elastic',
                                    'speedIn' : 600,
                                    'speedOut' : 300,
                                    'overlayShow' : true,
                                    'overlayColor': '#000',
                                    'hideOnContentClick': false,
                                    'autoScale' : false
                                    /*'title' : this.title */
                                });

                                if ($('.wohnUebersicht').length > 0) {
                                    $('.wohnUebersicht').each(function (wIndex, wItem) {

                                        wohnUebersichtView = Raphael($(wItem).attr('id'), 300, 186);


                                        switch(ajaxUrl) {
                                            case 'residenzen/die-villa-perle/eg-west.html':
                                                activeWE = 'EG West';
                                                break;
                                            case 'residenzen/die-villa-perle/eg-mitte.html':
                                                activeWE = 'EG Mitte';
                                                break;
                                            case 'residenzen/die-villa-perle/eg-ost.html':
                                                activeWE = 'EG Ost';
                                                break;
                                            case 'residenzen/die-villa-perle/1-og-west.html':
                                                activeWE = '1. OG West';
                                                break;
                                            case 'residenzen/die-villa-perle/1-og-mitte.html':
                                                activeWE = '1. OG Mitte';
                                                break;
                                            case 'residenzen/die-villa-perle/1-og-ost.html':
                                                activeWE = '1. OG Ost';
                                                break;
                                            case 'residenzen/die-villa-perle/2-og-west.html':
                                                activeWE = '2. OG West - Turm und Dachterrasse';
                                                break;
                                            case 'residenzen/die-villa-perle/2-og-ost.html':
                                                activeWE = '2. OG Ost - Turm';
                                                break;
                                        }
                                        wohnRects = new Array();
                                        // EG West
                                        wohnRects.push(wohnUebersichtView.rect(180, 128, 113, 41).attr({
                                            'stroke': '#ffffff',
                                            'fill': '#AA0000',
                                            'stroke-width': 0,
                                            'cursor':'pointer',
                                            'fill-opacity': (activeWE=='EG West'?0.75:0),
                                            'title':'EG West'
                                        }));    

                                        // EG Mitte
                                        wohnRects.push(wohnUebersichtView.rect(100, 128, 80, 41).attr({
                                            'stroke': '#ffffff',
                                            'fill': '#AA0000',
                                            'stroke-width': 0,
                                            'cursor':'pointer',
                                            'fill-opacity': (activeWE=='EG Mitte'?0.75:0),
                                            'title':'EG Mitte'
                                        }));   

                                        // EG Ost
                                        wohnRects.push(wohnUebersichtView.rect(4, 128, 96, 41).attr({
                                            'stroke': '#ffffff',
                                            'fill': '#AA0000',
                                            'stroke-width': 0,
                                            'cursor':'pointer',
                                            'fill-opacity': (activeWE=='EG Ost'?0.75:0),
                                            'title':'EG Ost'
                                        }));

                                        // 1. OG West
                                        wohnRects.push(wohnUebersichtView.rect(180, 93, 113, 34).attr({
                                            'stroke': '#ffffff',
                                            'fill': '#AA0000',
                                            'stroke-width': 0,
                                            'cursor':'pointer',
                                            'fill-opacity': (activeWE=='1. OG West'?0.75:0),
                                            'title':'1. OG West'
                                        }));    

                                        // 1. OG Mitte
                                        wohnRects.push(wohnUebersichtView.rect(100, 93, 80, 34).attr({
                                            'stroke': '#ffffff',
                                            'fill': '#AA0000',
                                            'stroke-width': 0,
                                            'cursor':'pointer',
                                            'fill-opacity': (activeWE=='1. OG Mitte'?0.75:0),
                                            'title':'1. OG Mitte'
                                        }));   

                                        // 1. OG Ost
                                        wohnRects.push(wohnUebersichtView.rect(4, 93, 96, 34).attr({
                                            'stroke': '#ffffff',
                                            'fill': '#AA0000',
                                            'stroke-width': 0,
                                            'cursor':'pointer',
                                            'fill-opacity': (activeWE=='1. OG Ost'?0.75:0),
                                            'title':'1. OG Ost'
                                        }));     

                                        // 2. OG West - Turm und Dachterrasse
                                        og2West = wohnUebersichtView.set();
                                        /*
                                        wohnRects.push(wohnUebersichtView.rect(180, 64, 106, 29).attr({
                                            'stroke': '#ffffff',
                                            'fill': '#AA0000',
                                            'stroke-width': 0,
                                            'cursor':'pointer',
                                            'fill-opacity': 0,
                                            'title':'2. OG West - Turm und Dachterrasse'
                                        }));   
                                        */
                                        wohnRects.push(wohnUebersichtView.path("M 150 73 L 180 73 L 194 65 L 227 65 L 227 37 L 250 32 L 271 37 L 271 65 L 297 69 L 297 73 L 293 74 L 293 93 L 150 93 L 150 73 z").attr({
                                            'stroke': '#ffffff',
                                            'fill': '#AA0000',
                                            'stroke-width': 0,
                                            'cursor':'pointer',
                                            'fill-opacity': (activeWE=='2. OG West - Turm und Dachterrasse'?0.75:0),
                                            'title':'2. OG West - Turm und Dachterrasse'
                                        }));

                                        // 2. OG Ost - Turm
                                        og2Ost = wohnUebersichtView.set();
                                        /*
                                        wohnRects.push(wohnUebersichtView.rect(4, 72, 176, 21).attr({
                                            'stroke': '#ffffff',
                                            'fill': '#AA0000',
                                            'stroke-width': 0,
                                            'cursor':'pointer',
                                            'fill-opacity': 0,
                                            'title':'2. OG Ost - Turm'
                                        }));       
                                        */
                                        wohnRects.push(wohnUebersichtView.path("M 4 88 L 48 73 L 48 57 L 65 50 L 84 50 L 102 57 L 102 73 L 150 73 L 150 93 L 4 93 L 4 88 z").attr({
                                            'stroke': '#ffffff',
                                            'fill': '#AA0000',
                                            'stroke-width': 0,
                                            'cursor':'pointer',
                                            'fill-opacity': (activeWE=='2. OG Ost - Turm'?0.75:0),
                                            'title':'2. OG Ost - Turm'
                                        }));

                                        for (c=0; c < wohnRects.length; c++) {
                                            $(wohnRects[c].node).bind('mouseover', {
                                                index: c
                                            },function(event) {
                                                activateRect(wohnRects[event.data.index]);
                                            });
                                            $(wohnRects[c].node).bind('mouseout', {
                                                index: c
                                            },function(event) {
                                                deactivateRect(wohnRects[event.data.index]);
                                            });
                                            $(wohnRects[c].node).bind('click', {
                                                index: c
                                            },function(event) {
                                                $(thisCircles[hIndex][event.data.index].node).click();
                                            });                                                

                                        }
                                        $(wItem).css({
                                            'position':'relative',
                                            'display':'block',
                                            'width':300,
                                            'height':230,
                                            'padding':0
                                        });
                                        $(wItem).children().css({                                            
                                            'position':'absolute',
                                            'left':0,
                                            'top':41,
                                            'z-index':10,
                                            'margin':0
                                        });
                                        $(wItem).find('h3').css({
                                            'top':12,
                                            'left':15,
                                            'margin':0
                                            
                                        });
                                        $(wItem).find('.singleImage').css({
                                            'z-index': 5,
                                            'margin':0
                                            
                                        });                                        
                                        /*
                                        $('.wohnUebersicht svg, .wohnUebersicht rvml:group').css({
                                            'position':'absolute',
                                            'left':0,
                                            'bottom':0
                                        });                                          
                                        */
                                       
                                    });

                                }                                    
                                if (jQuery.browser=='msie') {
                                    alert('debug2');
                                }

                                


                            }});
                            
                        }
                    });
                

                    $(element).hide();

                });                
            } 
            else {
                $(sliderElement).find('.helpText').hide();
            }

            
            
        });      



    /*
        // multiply panes for circular scrollable
        panesLength = $('#villenNav .sliderElement').length;
        if (panesLength > holderSize) {
            firstPanes = $('#villenNav .sliderElement').slice(0,10);
            secondPanes = $('#villenNav .sliderElement').slice(10);
            
            $(secondPanes).each(function(index,item) {
                if (index) {
                    $('#villenNav #indexVisualVillen .sliderElement').eq(index).before('<div id="'+$(item).attr('id')+'" class="sliderElement">'+$(item).html()+'</div>');
                }
                else {
                    $('#villenNav #indexVisualVillen').prepend('<div id="'+$(item).attr('id')+'" class="sliderElement">'+$(item).html()+'</div>');
                }
            });
            

            $(firstPanes).each(function(index,item) {
                $('#villenNav #indexVisualVillen').append('<div id="'+$(item).attr('id')+'" class="sliderElement">'+$(item).html()+'</div>');
            });
            
        }
        */
        
    }
}

circles = new Array();

function transformLageplan() {
    if ($('#lageplanHolder').length>0) {

        // defaults
        holderSize = 12;
        
        // move galery
        $('#lageplanHolder').detach().insertAfter('#nav');
        
        // build nav
        // fetch years
        headlines = new Array();
        $('#lageplanHolder .sliderElement .lageplanHeadline').each(function(index,item) {
            headlines.push('<p class="navLink"><a href="#">'+$(item).text()+'</a></p>');           
        }); 
        
        $('#lageplanNav').append('<div class=""><div class="items"></div></div>');
        
        
        holderLength = parseInt(headlines.length / holderSize);
        if (headlines.length % holderSize > 0) {
            holderLength++;
        }
        for (c=0; c<holderLength; c++) {
            $('#lageplanNav .items').append('<div class="holder"></div>');
        }
        
        for (c=0; c<headlines.length; c++) {
            hIndex = parseInt(c / holderSize);
            $('#lageplanNav .items .holder').eq(hIndex).append(headlines[c]);
        }
        
        
        $('#lageplanNav .items a').each(function(aIndex, aItem) {
            $(aItem).bind('mouseover', {
                index:aIndex
            }, function(event) {
                /*
                tooltipApi = $(circles[event.data.index].node).data('tooltip');
                tooltipApi.show();
                */
                $(circles[event.data.index].node).mouseover();
            });
            $(aItem).bind('mouseout', {
                index:aIndex
            }, function(event) {
                /*
                tooltipApi = $(circles[event.data.index].node).data('tooltip');
                tooltipApi.hide();
                */
                $(circles[event.data.index].node).mouseout();
            });   
            $(aItem).bind('click', {
                index:aIndex
            }, function(event) {
                event.preventDefault();
            });            
        });
        /*
        $('#lageplanNav .scrollable').before('<a class="prev browse left"></a>');
        $('#lageplanNav .scrollable').after('<a class="next browse right"></a>');      
        */
        // render coords
        
        var lageplan = Raphael('indexVisualLageplan', 630, 380);
        
        circles = new Array();
        
        $('#indexVisualLageplan svg').css({
            'position':'absolute',
            'left':0
        });
        
        // move tooltips
        $('#lageplanHolder').append('<div id="lageplanTooltips" class="tooltipsHolder"></div>');
        $('#lageplanHolder .sliderElement.staticDesign').each(function(tIndex, tItem) {
            headline = $(tItem).find('.lageplanHeadline').detach();
            text = $(tItem).find('.lageplanText').detach();
            tooltipId = 'toolTip'+String(tIndex);
            $('#lageplanTooltips').append('<div id="'+tooltipId+'" class="tooltip lageplanTooltip"><div class="tooltipArrow toolTipArrowBottom"></div></div>');
            
            $('#'+tooltipId).append(text);
            $('#'+tooltipId).append(headline);
        });
        
        
        
        
        
        $('#lageplanHolder .sliderElement .coords').each(function(cIndex, coord) {
            tooltipId = 'toolTip'+String(cIndex);
            cObj = {
                x: parseInt($(coord).find('.coord-x').text()),
                y: parseInt($(coord).find('.coord-y').text())
            };
            
            circles[cIndex] = lageplan.circle(cObj.x, cObj.y, 4).attr({
                'stroke': '#ffffff',
                'fill': '#AA0000',
                'stroke-width': 4,
                'cursor':'pointer',
                'r': 5,
                'title':$(coord).parents('.sliderElement').find('h2.lageplanHeadline').text()
                
            });
            
            hPosition = $('#nav .page').offset();
            
            offsetLeft = 0;
            if (cObj.x <= 100) {
                offsetLeft = 100;
            }
            else if (cObj.x >= 530) {
                offsetLeft = -100;
            }
            /*
            $(circles[cIndex].node).tooltip({
                'tip': '#'+tooltipId,
                'position': 'top center',
                'offset': [-230,offsetLeft]
            });
            */

            $('#'+tooltipId).dialog({ 
                autoOpen: false,
                title: '',
                position: [hPosition.left+cObj.x-10, hPosition.top+cObj.y-60-$(document).scrollTop()],
                height: (cIndex==22?110:90),
                resizable: false,
                draggable: false,
                width: 150
            }); 
            $('#'+tooltipId).parents('.ui-dialog').addClass('lageplanDialog');
            
            
            $(circles[cIndex].node).bind('mouseover', {
                index:cIndex,
                tooltipId:tooltipId,
                cObj:cObj
            }, function(event) {
                activateCircle(event.data.index);  
                hPosition = $('#nav .page').offset();
                $('#'+event.data.tooltipId).dialog('option', {
                    position: [hPosition.left+event.data.cObj.x-10, hPosition.top+event.data.cObj.y-60-$(document).scrollTop()]
                });
                $('#'+event.data.tooltipId).dialog('open');
        //        var api  = $("#lageplanHolder .scrollable").data('toolTabs');
      //          api.click(event.data.index+1);
            });
            
            $(circles[cIndex].node).bind('mouseout', {
                index:cIndex,
                tooltipId:tooltipId
            }, function(event) {
                deactivateCircle(event.data.index);
                $('#'+event.data.tooltipId).dialog('close');
         //       var api  = $("#lageplanHolder .scrollable").data('toolTabs');
             //   api.click(0);
            });            
            
        });
        
        
    }
}
function deactivateCircle(index) {
    circles[index].animate({
        'stroke': '#ffffff',
         'stroke-width': 4,
        'fill': '#AA0000',
         'fill-opacity': 1,
        'r': 5
    },
    250,
    'backIn'
    ); 
}
function activateCircle(index) {
    circles[index].animate({
        'stroke': '#ffffff',
         'stroke-width': 4,
        'fill': '#ffffff',
        'fill-opacity': 0.5,
        'r': 20
    },
    250,
    'backOut'
    ); 
}


function deactivateRect(rect) {
    if (activeWE!=rect.attr('title')) {
        rect.animate({
             'fill-opacity': 0
        },
        250,
        'backIn'
        );        
    }
 
}
function activateRect(rect) {
    if (activeWE!=rect.attr('title')) {
        rect.animate({
            'fill-opacity': 0.5
        },
        250,
        'backOut'
        ); 
    }
}


/* ######################### bw func ##################### */
/*
function fadePix(){
    //var img = $(".sliderElement img");

    $('#galHolder .active').find('.bwImage').stop().fadeOut(200);


    $('#galHolder .active').find('.elementSlogan').stop().animate({
        top: "1",
        "opacity": 1
    }, 200, function () {
        });
    $('#galHolder .active').find('.elementText').stop().animate({
        top: "-1",
        "opacity": 1
    }, 300 , function () {
        $('#galHolder .active').find('.headerButton').stop().animate({
            top: "-1",
            "opacity": 1
        }, 200);
    });


}

*/
/* ######################### bw func ende ##################### */


jQuery(document).ready(function(){


    $(".yform .type-text label").inFieldLabels({
        fadeOpacity:0.2, 
        fadeDuration: 400
    });
    /* hier buttons */


 $( ".showMoreButton").button({
        text: true,
        icons: {
            secondary: "ui-icon-arrow-1-n"
        }
    });
    $( ".closeMoreButton").button({
        text: true,
        icons: {
            secondary: "ui-icon-arrow-1-s"
        }
    });
    $( "a.more").not(".boxHome a.more").button({
        text: false,
        icons: {
            secondary: "ui-icon-arrow-1-e"
        }
    });
    $( ".sf-menu li ul.block a").button({
        text: true,
        icons: {
            primary: "ui-icon-arrow-1-e"
        }
    });
    
 $( ".backLink").button({
        text: true,
        icons: {
            primary: "ui-icon-arrow-1-w"
        }
    }); 
    
 $( "#linkMyAccount").button({
        text: true,
        icons: {
            primary: "ui-icon-key"
        }
    });     

    /* buttons ende */
    //   menuexPoser();
    //navDrop();
    //fadePix();






    /* image clicker */




/*

    $("#villen2 a").mouseover(function() {

        var url = $(this).parent().find('img').attr("src");
        var wrap = $("#picContainer2").fadeTo(1, 0.5);
        var img = new Image();
        img.onload = function() {
            wrap.fadeTo(100, 1);
            wrap.find("img").attr("src", url);

        };
        img.src = url;
        $("#villen2 a").removeClass("active");
        $(this).addClass("active");
    });


*/



/*
    $("#villen1 a").mouseover(function() {

        var url = $(this).parent().find('img').attr("src");
        var wrap = $("#picContainer1").fadeTo(100, 0.5);
        var img = new Image();
        img.onload = function() {
            wrap.fadeTo(100, 1);
            wrap.find("img").attr("src", url);

        };
        img.src = url;
        $("#villen1 a").removeClass("active");
        $(this).addClass("active");
    //}).filter(":first").mouseover();





    });
*/
    /* image clicker ende */

    
    
    $("a.startImageGallery").
    add("a.imgPop").
    fancybox({
        'padding' : '10',
        'margin' : '10',
        'opacity' : true,
        'transitionIn' : 'elastic',
        'transitionOut' : 'elastic',
        'speedIn' : 600,
        'speedOut' : 300,
        'overlayShow' : true,
        'overlayColor': '#000',
        'hideOnContentClick': false,
        'autoScale' : false
        /*'title' : this.title */
    });



    // #### video link ####
    $("a.fancyvideo").click(function() {
        $.fancybox({
            'padding' : '10',
            'margin' : '10',
            'opacity' : true,
            'transitionIn' : 'elastic',
            'transitionOut' : 'elastic',
            'speedIn' : 600,
            'speedOut' : 300,
            'overlayShow' : true,
            'overlayColor': '#000',
            'hideOnContentClick': false,
            'autoScale' : false,
            'title' : this.title,
            'width' : 680,
            // 'height' : 495,
            'height' : 410,
            // 'href' : this.href.replace(new RegExp("watch\\?v=", "i"), 'v/'),
            'href' :this.href = this.href.replace(new RegExp("watch\\?v=", "i"), 'v/') + '&autoplay=1',
            'type' : 'swf',
            'swf' : {
                'allowfullscreen':'true', 
                'wmode':'transparent'
            }
        });
        return false;
    });


    transformSlider();
    transformTimeline();  
    transformVillenSlider();
    //transformContact();
    transformLageplan();

    if (!$('#main .page').children().length) {
        $('#main').detach();
    }

    $(".scrollable.circular").scrollable({
        easing: 'easeOutCirc', 
        speed: 500,
        circular: true, 
        mousewheel: true
    });
    $(".scrollable.noncircular").scrollable({
        easing: 'easeOutCirc', 
        speed: 500,
        circular: false, 
        mousewheel: true
    });
    /*
    $("#headerGalThumbs .scrollable a").each(function(index,item) {
       $("#headerGalHolder .sliderElement").eq(index).css('background-image','url('+$(item).attr('href')+')');
    });
*/
    /*
function showHeadTxt()
{
  var menuThumbs = $("#galHolder");
    menuThumbs.bind("mouseleave", function() {

 $(".sliderElement .elementSlogan").fadeOutDelay();
        $(".sliderElement .elementText").fadeOutDelay();
    });

    menuThumbs.bind("click keydown mouseenter", function() {
        $(".sliderElement .elementSlogan").fadeDelay();
        $(".sliderElement .elementText").fadeDelay();


    });
}

*/
/*
    $.tools.toolTabs.addEffect("fadeExt", function(tabIndex, done) {

        currentIndex = 0;
        tabPanes = this.getPanes();
        tabPanes.each(function (tIndex, pane) {
            if ($(pane).hasClass('active')) {
                currentIndex = tIndex;
            }
        });
       
        // einblenden bw dann raus 
        tabPanes.eq(currentIndex).find('.elementSlogan').stop().animate({
            top: "-1",
            "opacity": 0
        }, 800 , function () {


            });
        tabPanes.eq(currentIndex).find('.headerButton').stop().animate({
            top: "1",
            "opacity": 0
        }, 200 ,function () {

            tabPanes.eq(currentIndex).find('.elementText').stop().animate({
                top: "1",
                "opacity": 0
            }, 200);
        });



        tabPanes.eq(currentIndex).find('.bwImage').stop().fadeIn(400,  function () {
            //  tabPanes.eq(currentIndex).find('.elementSlogan').fadeOut(500);

            tabPanes.eq(currentIndex).stop().fadeOut(600, function () {


                });
        });




        //tabPanes.eq(tabIndex).find('.bwImage').css('opacity', '1');

        // einblenden bw dann col 
        tabPanes.eq(tabIndex).stop().fadeIn(2600, function () {
          
            tabPanes.eq(tabIndex).find('.bwImage').stop().fadeOut(200,  function () {
                //   tabPanes.eq(tabIndex).find('.elementSlogan').fadeIn(600);

                tabPanes.eq(tabIndex).find('.elementSlogan').stop().animate({
                    top: "1",
                    "opacity": 1
                }, 300, function () {

                   

                    });




                tabPanes.eq(tabIndex).find('.elementText').stop().animate({
                    top: "-1",
                    "opacity": 1
                }, 500 , function () {
                    tabPanes.eq(tabIndex).find('.headerButton').stop().animate({
                        top: "-1",
                        "opacity": 1
                    }, 300);

                });

            });
        });








        $('#galHolder').hoverIntent(function()  {
            $('.active').find('.elementSlogan').stop().animate({
                top: "1",
                "opacity": 1
            }, 200, function () {
                });
            $('.active').find('.elementText').stop().animate({
                top: "-1",
                "opacity": 1
            }, 300 , function () {
                $('.active').find('.headerButton').stop().animate({
                    top: "-1",
                    "opacity": 1
                }, 200);
            });
        },
        function(){
            $('.active').find('.elementSlogan').stop().animate({
                top: "-1",
                "opacity": 0
            }, 300 , function () {
                });
            $('.active').find('.headerButton').stop().animate({
                top: "1",
                "opacity": 0
            }, 100 , function () {

                $('.active').find('.elementText').stop().animate({
                    top: "1",
                    "opacity": 0
                }, 100 );
            });
        });

        done.call();
    });
*/


    $("#headerGalThumbs .nonscrollable").toolTabs("#headerGalHolder .sliderElement", {
           
        // enable "cross-fading" effect
        current: 'activeX',
        effect: 'fade',
        //    fadeOutSpeed: "fast",
        fadeInSpeed: 2000,
        fadeOutSpeed: 1000,
        // start from the beginning after the last tab
        rotate: true,
        initialIndex: 11
        /* ,onBeforeClick: function(event, tabIndex) {
             //   $("#headerGalThumbs .scrollable .bigUrl img").eq(this.getIndex()).mouseleave();
             
                // load image/canvas
                
                bigImageUrl = $('#galHolder #headerGalHolder .sliderElement').eq(tabIndex).find('.bigImageUrl');
               if (bigImageUrl.length>0) {
                    imageSrc = bigImageUrl.text();
                    origImage = $('<img src="'+imageSrc+'" alt="" />');
                    bigImageUrl.after(origImage);
                    origImage.bind('load', {item:bigImageUrl, imageSrc:imageSrc, tabIndex:tabIndex}, function(origEvent) {       

                        bwImage = $('<img src="'+origEvent.data.imageSrc+'" class="bwImage" style="opacity:1" alt="" />');
                        
                        $('#galHolder #headerGalHolder .sliderElement').eq(tabIndex).find('img').after(bwImage);

                        bwImage.bind('load', {bwImage:bwImage}, function(bwEvent) {

                   //      $(bwEvent.data.bwImage).pixastic( "glow", {amount:1.0,radius:1.0});
                        //     $(bwEvent.data.bwImage).pixastic("laplace", {edgeStrength:0.1,invert:true,greyLevel:0});
                           //  $(bwEvent.data.bwImage).pixastic("desaturate");
                         //    tabPanes.eq(tabIndex).find('.bwImage').stop().fadeOut(200);
//$(bwEvent.data.bwImage).pixastic("sharpen", {amount:0.5});
                        });                    
                    });

                    bigImageUrl.detach();                    
                    
                }
              
             
            }*/
        ,
        onClick: function(event, tabIndex) {
/*
            event.preventDefault();
            var tabPanes = this.getPanes();
            */
            /*
                if ($(this.getCurrentTab()).attr('href')) {
                    //alert($(this.getCurrentPane()).attr('class'));
                    
                    $(tabPanes[tabIndex]).css('background-image','url('+$(this.getCurrentTab()).attr('href')+')');
                    $(tabPanes[tabIndex]).pixastic("invert");
                }
                */
               /*
            tabPanes.removeClass('active');
            $(tabPanes[tabIndex]).addClass('active');
            */
        //   $("#headerGalThumbs .scrollable .bigUrl img").eq(tabIndex).mouseenter();

        }
    });
    /*.slideshow({

         autoplay: false,
            interval: 8000
    });
    */
    $("#headerGalHolder .sliderElement").hide().eq(0).show();
    //    $("#headerGalHolder .sliderElement").eq(11).find('.bwImage').css('opacity', '0');


    // fadePix();



    scrollablePrevButton = function(holderId, prevNextId) {
        if (!$('#'+prevNextId+' a.prev').hasClass('disabled')) {
            api = $("#"+holderId+" .scrollable").data('toolTabs')
            api.prev();
            if (api.getIndex() < api.getPanes().length-1) {
                $('#'+prevNextId+' a.next').removeClass('disabled');
            }
            if (api.getIndex()==0) {
                $('#'+prevNextId+' a.prev').addClass('disabled');
            }
        }        
    };

    scrollableNextButton = function(holderId, prevNextId) {
        if (!$('#'+prevNextId+' a.next').hasClass('disabled')) {
            api = $("#"+holderId+" .scrollable").data('toolTabs')
            api.next();
            if (api.getIndex()>0) {
                $('#'+prevNextId+' a.prev').removeClass('disabled');
            }
            if (api.getIndex() >= api.getPanes().length-1) {
                $('#'+prevNextId+' a.next').addClass('disabled');
            }
        }        
    };
    

    $("#timelineHolder .scrollable").toolTabs("#timelineHolder .sliderElement", {
           

        current: 'active',
        effect: 'fade',
        rotate: false,
        initialIndex: 0,
        onBeforeClick: function(event, tabIndex) {

                                   
        },
        onClick: function(event, tabIndex) {

            //event.preventDefault();
            var tabPanes = this.getPanes();
            tabPanes.removeClass('active');
            $(tabPanes[tabIndex]).addClass('active');


        }
    });
    
    $('#timelinePrevNext a.prev').addClass('disabled');
    $('#timelinePrevNext a.prev').click(function() {
        scrollablePrevButton('timelineHolder', 'timelinePrevNext');
    });
    $('#timelinePrevNext a.next').click(function() {
        scrollableNextButton('timelineHolder', 'timelinePrevNext');
    });
    
    $('#timelinePrevNext').hide();


    $("#villenHolder .scrollable").toolTabs("#villenHolder .sliderElement", {
           

        current: 'active',
        effect: 'fade',
        rotate: false,
        initialIndex: 0,
        onBeforeClick: function(event, tabIndex) {
            $('.tooltip').dialog('close');
                                   
        },
        onClick: function(event, tabIndex) {

            //event.preventDefault();
            var tabPanes = this.getPanes();
            tabPanes.removeClass('active');
            $(tabPanes[tabIndex]).addClass('active');
            
            /*
            for (c=0; c<thisCircles.length; c++) {
                
                for (d=0; d<thisCircles[c].length; d++) {
                    
                    api = $(thisCircles[c][d].node).data('tooltip');
                    
                    
                    if (api.isShown(true)) {
                        activeCircle[c] = false;
                        api.hide();
                    }
                    
                }
            }
            */

        }
    });

    
    $('#villenPrevNext a.prev').addClass('disabled');
    $('#villenPrevNext a.prev').click(function() {
        scrollablePrevButton('villenHolder', 'villenPrevNext');
    });
    $('#villenPrevNext a.next').click(function() {
        scrollableNextButton('villenHolder', 'villenPrevNext');
    });
    
    $('#villenPrevNext').hide();

    /*
    $("#lageplanHolder .scrollable").toolTabs("#lageplanHolder .sliderElement", {
           

            current: 'active',
            effect: 'fade',
            rotate: false,
            initialIndex: 0,
            onBeforeClick: function(event, tabIndex) {

                                   
            },
            onClick: function(event, tabIndex) {
                event.preventDefault();
                var tabPanes = this.getPanes();
                currentIndex = 0;
                tabPanes.each(function(index,pane) {
                    if ($(pane).hasClass('active')) {
                        currentIndex = index;
                    }
                });                
                if (currentIndex) {
                    deactivateCircle(currentIndex-1);
                }
                if (tabIndex) {
                    activateCircle(tabIndex-1);
                }
                tabPanes.removeClass('active');
                $(tabPanes[tabIndex]).addClass('active');


            }
    });

    
    $('#lageplanPrevNext a.prev').addClass('disabled');
    $('#lageplanPrevNext a.prev').click(function() {
        scrollablePrevButton('lageplanHolder', 'lageplanPrevNext');
    });
    $('#lageplanPrevNext a.next').click(function() {
        scrollableNextButton('lageplanHolder', 'lageplanPrevNext');
    });
        */


    $(".boxHome img, img.thumb").insetBorder({
        speed          : 250,           
        borderColor    : "#ffffff",  
        inset          : 5,             
        borderType     : "solid",       
        outerClass     : "thumbBorder",    
        innerClass     : "thumbInner"    
    });
    //  $(".scrollable img.thumb").pixastic("desaturate");
    //showThumbs();
    showSliderContent();
    hideSliderContent();
    /* navigation */
/*
    $('ul.sf-menu').superfish({
        delay:       0,
        animation:   {
            opacity:'show'
        },
        speed:       320,
        autoArrows:  false,
        dropShadows: false,
        onBeforeShow: function(){

        },
        onHide    : function(){
        }
    });
    */
    /* navigation ende */
    // $("#headerGalHolder .sliderElement .active").eq(11).find('.bwImage').stop().fadeOut(200);
    //  $("#headerGalHolder .sliderElement .active").eq(11).find('.bwImage').stop().css('opacity', '0');



    $('#dialogLogin').dialog({ 
        autoOpen: false,
        title: 'Login',
        buttons: [
        {
            text: "Ok",
            click: function() {
                $(this).find('form').submit();
                $(this).dialog("close"); 
            }
        }
        ]
    });
    
    $('#loginButton').click(function (event) {
        event.preventDefault();
        $('#dialogLogin').dialog('open');
    })
    
    $('#loginButtonMainNav').click(function (event) {
        event.preventDefault();
        $('#dialogLogin').dialog('open');
    })
    
    
    
    $('#indexVisual .showMore').hide();

    $('#contactFormSubmit').click(function(event) {
        event.preventDefault();
        $('#contactForm').submit();
    });
    
    $('#nav ul.sf-menu li').eq(5).detach();

});
