var az = 0;
var aktHSMenu = 0;
var merken = new Array('fileadmin/system/image/hs_merken.gif', 'fileadmin/system/image/hs_merken_aktiv.gif');
var aktUrl = window.location.toString();
var bodywidth = 0;
var bodyheight = 0;
var isHs = false;
var topWert = 0;
var leftWert = 0;
var status = 0;
var uid = 0;
var tabelle = '';
var merkbild = '';
var baselink = 'http://www.warendorf.eu/';
var delaytime = 0;
var blaettern = '';

$(document).ajaxError(function(e, xhr, opts, err){
    var status = (xhr || {}).status;
    xhr = null;
    setTimeout(function() {
        throw (e.type + ' | ' + status + ' | ' + opts.url);
    },
    0);
});

function show_ajax_container(){
    $('.ajax-container')
    .animate({
        'width': '740px',
        'height': '450px',
        'top': '112px',
        'left': '30px'
    },
    800)
    .animate({
        'border': '0px none'
    },
    1,
    function(){
        $('.ajax-container .hotspot_edit').fadeIn(400);
        $('.ajax-container').css('background-image', 'url(fileadmin/system/image/ac_bg.gif)');
        $('img.mouse').hide(0);
        $('#rahmen_hotspots .showmerkinfo').css('display', 'block');
        $('#rahmen_hotspots .showmerkinfo').css('cursor', 'pointer');
        if ($('#rahmen_hotspots .showmerkinfo').size() > 0){
            $('#rahmen_hotspots .showmerkinfo').prepend($('.ajax-container .hotspot_edit .hs_merken').clone(false));
        }

        delaytime = setTimeout(merkinfo_schliessen, 15000);
    });
}

function showHSControls(){
    var wz_top = ($(window).height() / 2) - 49;
    $('.h_weiter_bild').css('top', wz_top);
    $('.h_zurueck_bild').css('top', wz_top);
    $(".h_weiter_bild").css('display', 'block');
    $(".h_zurueck_bild").css('display', 'block');
    $(".h_zurueck_bild").css('background-image', 'url("../../inhalte/aktuelles/trans_aktuell.png")');
    $(".h_weiter_bild").css('background-image', 'url("../../inhalte/aktuelles/trans_aktuell.png")');
    $(".h_zurueck_bild").bind('mouseenter',
    function(){
        $(".mouse").css('display', 'none');
        $(".h_zurueck").css('display', 'block');
        $(".h_zurueck_bild img").css('display', 'block');
    }).bind('mouseleave',
    function(){
        $(".h_zurueck").css('display', 'none');
        $(".h_zurueck_bild img").css('display', 'none');
    });

    $(".h_weiter_bild").bind('mouseenter',
    function(){
        $(".mouse").css('display', 'none');
        $(".h_weiter").css('display', 'block');
        $(".h_weiter_bild img").css('display', 'block');
    }).bind('mouseleave',
    function(){
        $(".h_weiter").css('display', 'none');
        $(".h_weiter_bild img").css('display', 'none');
    });
}

function hideHSControls(){
    $('#rahmen_hotspots .h_zurueck_bild').unbind('click');
    $('#rahmen_hotspots .h_weiter_bild').unbind('click');
    $(".h_weiter_bild").css('display', 'none');
    $(".h_zurueck_bild").css('display', 'none');
}

function showPRControls(){
    $(".p_weiter_bild").css('display', 'block');
    $(".p_zurueck_bild").css('display', 'block');
}

function hidePRControls(){
    $(".p_weiter_bild").css('display', 'none');
    $(".p_zurueck_bild").css('display', 'none');
}

function buttonActions(){
    $('.ajax-container .hotspot_edit .hs_merken').bind('mouseover',
    function(){

        if ($(this).children('img').attr('src') != 'fileadmin/system/image/hs_merken_aktiv.gif'){
            $(this).children('img').attr('src', 'fileadmin/system/image/hs_merken_over.gif');
            $('.ajax-container .hotspot_edit .merkenhover').css('display', 'block');
            $('.ajax-container .hotspot_edit h3 img').css('z-index', '-1');
        } else{
            $(this).children('img').fadeTo(0, 0.8);
            $('.ajax-container .hotspot_edit .merkenunaktiv').css('display', 'block');
            $('.ajax-container .hotspot_edit h3 img').css('z-index', '-1');
        }
    }).bind('mouseleave',
    function(){
        if ($(this).children('img').attr('src') != 'fileadmin/system/image/hs_merken_aktiv.gif'){
            $(this).children('img').attr('src', 'fileadmin/system/image/hs_merken.gif');
            $('.ajax-container .hotspot_edit .merkenhover').css('display', 'none');
        } else{
            $(this).children('img').fadeTo(0, 1);
        }
        $('.ajax-container .hotspot_edit .merkenunaktiv').css('display', 'none');
        $('.ajax-container .hotspot_edit .merkenaktiv').css('display', 'none');
        $('.ajax-container .hotspot_edit .merkenhover').css('display', 'none');
        $('.ajax-container .hotspot_edit h3 img').css('z-index', '0');
    });

    $('.ajax-container .hotspot_edit .hs_schliessen').bind('mouseover',
    function(){
        $(this).children('img').attr('src', 'fileadmin/system/image/hs_schliessen_over.gif');
        $('.ajax-container .hotspot_edit .schliessenhover').css('display', 'block');
        $('.ajax-container .hotspot_edit h3 img').css('z-index', '-1');
    }).bind('mouseleave',
    function(){
        $(this).children('img').attr('src', 'fileadmin/system/image/hs_schliessen.gif');
        $('.ajax-container .hotspot_edit .schliessenhover').css('display', 'none');
        $('.ajax-container .hotspot_edit h3 img').css('z-index', '0');

    });

}
function zoom_prev(ele){
      $('#rahmen_hotspots .h_zurueck_bild').one('click',
    function(){ 
        ele = $('.zoom_pic img.aktiv');
        //$('.zoom_pic img').stop().hide(0);
        //$(ele).fadeOut(500);
       $('.zoom_pic img').removeClass('aktiv');
        if (ele.prev().index('.ajax-container .zoom_out') >= 0){

            ele.prev().stop().fadeIn(500,
            function(){
                ele.prev().addClass('aktiv');
                $('.zoom_pic img').not('.aktiv').stop().fadeOut(500);
                zoom_prev(ele.prev());
            });
        } else{
         if (ele.index('.ajax-container .zoom_out') == 0){
             $('.ajax-container .zoom_out:last').stop().fadeIn(500,
            function(){
                $('.ajax-container .zoom_out:last').addClass('aktiv');
                $('.zoom_pic img').not('.aktiv').stop().hide();
                zoom_prev($('.ajax-container .zoom_out:last'));//.eq(anz_bilder - 1));
            });
        }}
   // return false;
   });
    };
    
function zoom_next(ele){  
         $('#rahmen_hotspots .h_weiter_bild').one('click',
    function(){
        ele = $('.zoom_pic img.aktiv');
        var anz_bilder = $('.ajax-container .zoom_out').size();  
        $('.zoom_pic img').removeClass('aktiv');
        if (ele.index('.ajax-container .zoom_out') < anz_bilder -1){
          
            ele.next().stop().fadeIn(500,

            function(){
                ele.next().addClass('aktiv');
                $('.zoom_pic img').not('.aktiv').stop().hide();
                zoom_next(ele.next());
            });
        } else{
      
         if (ele.index('.ajax-container .zoom_out') == (anz_bilder -1)){
            $('.ajax-container .zoom_out:first').stop().fadeIn(500,

            function(){
            $('.ajax-container .zoom_out:first').addClass('aktiv');    
            $('.zoom_pic img').not('.aktiv').stop().fadeOut(500);
                zoom_next($('.ajax-container .zoom_out:first'));//.eq(0));
            });
        }
        }
        return false;
        });
};  
/*  
function controlAction(ele){
    
        zoom_prev(ele);
        zoom_next(ele);

}
*/

function zoom_in(ele){

    var i = parseInt(ele.parent().attr('id').substr(ele.parent().attr('id').length - 1)) - 1;
    
    $('.hotspot_edit .zoom_in img.bighs_content').each(function(){
                
        var pic = new Image();
        pic.src = $(this).parent().attr('href');
        pic.alt = 'zoom_out';
        pic.className = 'zoom_out';
        pic.width = $(this).attr('width');
        pic.height = $(this).attr('height'); 
        pic.style.zIndex = 1;
        pic.style.position = 'absolute';
        pic.style.top = '-112px';
        pic.style.left = '-30px';
        pic.style.display = 'none';
        
        $('.zoom_pic').append(pic);
        
    });
    	 var anz_bild = ($('.ajax-container .zoom_out').size()) -1;
    
    	$('.zoom_pic .zoom_out').eq(anz_bild).remove();
    $('.zoom_pic .zoom_out').stop();
    $('.zoom_pic .zoom_out').bind('click',
    function(){
        $('.zoom_pic .zoom_out').stop();
        zoom_out($(this));
        return false;
    });
    
    $('.zoom_pic .zoom_out').stop();
    
//    $('.zoom_pic .zoom_out').load(function(){
        $('.zoom_pic .zoom_out').eq(i).addClass('aktiv');
        $('.zoom_pic .zoom_out').eq(i).fadeIn(800,
        function(){
        if ( $("#rahmen_hotspots .showmerkinfo").length > 0 ) {
        $("#rahmen_hotspots .showmerkinfo").css('z-index', '1');
        }
        $('.hs_merken').css('display','none');
            $('.ajax-container .zoom_in').unbind('click');
            $('.ajax-container .zoom_in').bind('click',
            function(){
                return false;
            });
            showHSControls();

            
            zoom_prev($('.zoom_pic .zoom_out').eq(i));
            zoom_next($('.zoom_pic .zoom_out').eq(i));

//            controlAction($('.zoom_pic .zoom_out').eq(i));
//        });
    });

    resizeBG();
}

function zoom_out(ele){

    $('.zoom_pic .zoom_out').stop();
    $('.zoom_in').stop();

    var id = '#hotspot' + (ele.index('.zoom_out') + 1);

    $('.ajax-container .zoom_in').click(function(){
         
        zoom_in($(this));
         
        return false;
    });
    ele.fadeOut(800,
    function(){
        hideHSControls();

        $('.zoom_out').remove();
    });
    
    load_hotspot($(id));
  
    //resizeBG();
}

function blaetternAni(){
    $('.blaettercontent img').mouseover(function(){
        $(this).fadeTo(1, 0.5);
    }).bind('mouseleave',
    function(){
        $(this).fadeTo(1, 1);
    });

    $('.blaettercontent .prevlink img').mouseover(function(){
        $('.ajax-container .blaettercontent span.zvhs').show(0);
    }).bind('mouseleave',
    function(){
        $('.blaettercontent span').hide(0);
    });

    $('.blaettercontent .nextlink img').mouseover(function(){
        $('.ajax-container .blaettercontent span.znhs').show(0);
    }).bind('mouseleave',
    function(){
        $('.blaettercontent span').hide(0);
    });
    //resizeBG();
}

function hs_info_zoom(ele){
    var link = ele.attr('href');
    var title = ele.attr('title');
    
    var pic = new Image();
    pic.src = link;
    pic.alt = title;
    pic.className = 'bigbild';
        
    $('.zoom_container').prepend(pic);
    $('.zoom_container').show('slow');
    $('.zoom_container').mousemove(function(event){
        $('.zoom_container img.mouse').css({
            'display': 'block',
            'top': (event.pageY - 130),
            'left': (event.pageX - 75)
        });
    });
    
    $('.zoom_container').bind('mouseleave',
    function(event){
        $('.zoom_container img.mouse').css({
            'display': 'none'
        });
    });
    $('.zoom_container img.bigbild').live('click',
    function(){
        $('.zoom_container img.bigbild').remove();
        $('.zoom_container img.mouse').css({
            'display': 'none'
        });
        $(this).parent().hide('slow');
        $('.zoom_container').css({
            'display': 'none'
        });
        return false;
    });
}

function mouse_zoom(){
    $('.zoom_in_inv .bighs_content').mousemove(function(event){
        $('.zoom_in_inv img.mouse').attr('src', 'fileadmin/system/image/zoom_in.gif');
        $('.zoom_in_inv img.mouse').css({
            'position': 'absolute',
            'display': 'block',
            'top': (event.pageY - 130),
            'left': (event.pageX - 75)
        });
    });

    $('.zoom_in_inv .bighs_content').bind('mouseleave',
    function(event){
        $('.zoom_in_inv img.mouse').css({
            'display': 'none'
        });
    });
    $('.zoom_in .bighs_content').mousemove(function(event){
        $('.zoom_in img.mouse').attr('src', 'fileadmin/system/image/zoom_in.gif');
        $('.zoom_in img.mouse').css({
            'position': 'absolute',
            'display': 'block',
            'top': (event.pageY - 130),
            'left': (event.pageX - 75)
        });
    });
    $('.zoom_in .bighs_content').bind('mouseleave',
    function(event){
        $('.zoom_in img.mouse').css({
            'display': 'none'
        });
    });

    $('.ajax-container .zoom_out').live('mousemove',
        function(event){
        $('.zoom_in img.mouse').attr('src', 'fileadmin/system/image/zoom_out.gif');
        $('.zoom_in img.mouse').css({
            'position': 'absolute',
            'display': 'block',
            'top': (event.pageY - 130),
            'left': (event.pageX - 75)
        });
    });
}

function hs_merken(ele){
    uid = parseInt($('.ajax-container .hotspot_edit .hs_merken').find('span.uid').text());
    status = parseInt($('.ajax-container .hotspot_edit .hs_merken').find('span.status').text());
    status = 1 - status;
    merkbild = merken[status];

    $.ajax({
        type: "POST",
        url: "index.php?id=96",
        data: "tabelle=" + tabelle + '&hsuid=' + uid + '&hsstatus=' + status,
        success: function(data){
            
            if (status == 1){
                $('.ajax-container .hotspot_edit h3 img').css('z-index', '-1');
                $('.ajax-container .hotspot_edit .merkenhover').hide(0);
                $('.ajax-container .hotspot_edit .merkenaktiv').fadeIn(100).delay(320).fadeOut(100,
                function(){
                    $('.ajax-container .hotspot_edit h3 img').css('z-index', '0');
                });
            } else{
                $('.ajax-container .hotspot_edit .merkenunaktiv').hide(0);
                $('.ajax-container .hotspot_edit h3 img').css('z-index', '0');
            }
            $('.ajax-container .hotspot_edit .hs_merken span.status').text(status);
            $('.ajax-container .hotspot_edit .hs_merken img').attr('src', merkbild);
            ele.find('.hs_merken span.status').text(status);
            ele.find('.hs_merken img').attr('src', merkbild);
        }
    });

    $.ajax({
        type: "POST",
        url: "fileadmin/system/php/add_to_merkliste.php",
        data: "link=" + $('.ajax-container .hotspot_edit .hs_merken').attr('href') + '&hsuid=' + uid + '&hsstatus=' + status,
        success: function(msg){
            //Erfolgreiches Merken.....
            }
    });

}

function load_info_hotspot_content(ele){
    $('.ajax-container .hs_content_left').replaceWith(ele.find('.hs_content_left').clone(false));

    $('.ajax-container .hotspot_edit .hs_merken').attr('href', ele.find('a.hs_merken').attr('href'));
    uid = parseInt(ele.find('.hs_merken span.uid').text());
    $('.ajax-container .hotspot_edit .hs_merken span.uid').text(uid);
    status = parseInt(ele.find('.hs_merken span.status').text());
    $('.ajax-container .hotspot_edit .hs_merken span.status').text(status);
    merkbild = merken[status];
    $('.ajax-container .hotspot_edit .hs_merken img').attr('src', merkbild);
    
    /*******/
    $('.ajax-container img.enlarge').unbind('mouseenter').bind('mouseenter',
    function(){
        var bild = $(this).attr('src');
        if (bild != 'none'){
            $(this).css({
                'background-image': 'url("' + bild + '")',
                'cursor': 'pointer'
            });
            $(this).attr('src', 'fileadmin/system/image/starckinfoimgover.png');
        }
    });
    $('.ajax-container img.enlarge').unbind('mouseleave').bind('mouseleave', function(){
        var bild = $(this).css('background-image');
        bild = bild.replace('url("', '');
        bild = bild.replace('")', '');
        bild = bild.replace('url(', '');
        bild = bild.replace(')', '');
        if (jQuery.browser.webkit) {
            //alert(bild);
        }
        if (bild != 'none' && bild.indexOf('url') == -1){
            $(this).attr('src', bild);
        }
    });

    $('.ajax-container .hs_content_left a.a_enlarge').unbind('click').bind('click',
    function(){
        hs_info_zoom($(this));

        return false;
    });
    /******/

}

function load_info_hotspot_menu(ele){

    $('.ajax-container .hotspot_edit ul img').hide(0);

    $('.ajax-container .hotspot_edit ul li').not(ele).find('img.hsNaviNO').show(0);

    $('.ajax-container .hotspot_edit li ul.submenu li').not(ele).find('img.hsNaviSUB').show(0);

    ele.children('a:first').find('img.hsNaviNO').hide(0);
    ele.children('a:first').find('img.hsNaviSUB').hide(0);
    ele.children('a:first').find('img.hsNaviACT').show(0);

    $('.ajax-container .hotspot_edit li ul.submenu').hide(0);
    ele.children('ul.submenu').show(0);
    ele.parent('ul.submenu').show(0);

    $('.ajax-container .hotspot_edit li').removeClass('aktiv');
    ele.addClass('aktiv');
}

function load_info_hotspot(ele){

    var aktID = ele.attr('id');
    var anz_hotspots = $('.normalhotspot').size();

    tabelle = 'tx_wplushotspots_info';

    $('.presenter-dimming').fadeTo(400, 0.5);

    $('.ajax-container .hotspot_edit').replaceWith(ele.find('.hotspot_edit').clone(true));

    $('.highslide-html-content').hide(0);

    $('.hotspot_link').hide(0);

    $('.ajax-container .hs_schliessen').click(function(){
        merkinfo_schliessen();
        $('.ajax-container').css('background-image', 'none');
        $('.ajax-container').hide(0);
        $('.hotspot_link').show(0);
        $('.hotspot').show(0);
        $('.presenter-dimming').fadeOut(400);
        showPRControls();
        return false;
    });

    $('.ajax-container .prevlink').click(function(){
        $('.blaettercontent span').hide(0);
        load_hotspot($('.normalhotspot:last'));
        return false;
    });

    $('.ajax-container .nextlink').click(function(){
        $('.blaettercontent span').hide(0);
        load_hotspot($('.normalhotspot:first'));
        return false;
    });

    blaetternAni();

    $('.info_hotspot li a').unbind('click').click(function(evt){
        var aktHS = $(this).attr('href').substr($(this).attr('href').lastIndexOf('#'));
        var aktHSClass = aktHS.substring(1);
        load_info_hotspot_content($('#hotspot0 ' + aktHS));
        load_info_hotspot_menu($('.ajax-container .hotspot_edit li.' + aktHSClass));
        return false;
    });

    $('.info_hotspot li a').unbind('mouseenter').mouseenter(function(evt){
        
        var aktHS = $(this).attr('href').substr($(this).attr('href').lastIndexOf('#'));
        var aktHSClass = aktHS.substring(1);

        $('.ajax-container .hotspot_edit li.' + aktHSClass).children('a:first').find('img.hsNaviSUB').css('display', 'none');
        $('.ajax-container .hotspot_edit li.' + aktHSClass).children('a:first').find('img.hsNaviNO').css('display', 'none');
        $('.ajax-container .hotspot_edit li.' + aktHSClass).children('a:first').find('img.hsNaviACT').css('display', 'inline');
    });

    $('.info_hotspot li a').unbind('mouseleave').mouseleave(function(evt){
        
        var aktHS = $(this).attr('href').substr($(this).attr('href').lastIndexOf('#'));
        var aktHSClass = aktHS.substring(1);
        if ($('.' + aktHSClass).is('.aktiv')){

        } else{
            $('.ajax-container .hotspot_edit li.' + aktHSClass).children('a:first').find('img.hsNaviSUB').css('display', 'inline');
            $('.ajax-container .hotspot_edit li.' + aktHSClass).children('a:first').find('img.hsNaviNO').css('display', 'inline');
            $('.ajax-container .hotspot_edit li.' + aktHSClass).children('a:first').find('img.hsNaviACT').css('display', 'none');
        }
    });


    hidePRControls();
    buttonActions();

    show_ajax_container();

    load_info_hotspot_content(ele);
    load_info_hotspot_menu($('.ajax-container .hotspot_edit li.' + aktID));

    $('.ajax-container .info_hotspot .hs_merken').click(function(){
        hs_merken(ele);
        return false;
    });
}

function load_hotspot(ele){
    $('.bighs_content').removeAttr("title");
    var aktID = ele.attr('id');
    var anz_hotspots = $('.normalhotspot').size();

    tabelle = 'tx_wplushotspots_single';

    $('img.mouse').hide(0);

    $('.ajax-container .hotspot_edit').replaceWith(ele.find('.hotspot_edit').clone(false));

    $('.highslide-html-content').hide(0);

    $('.hotspot_link').hide(0);

    $('.ajax-container .hs_schliessen').one('click',
    function(){
        merkinfo_schliessen();
        $('.ajax-container').css('background-image', 'none');
        $('.ajax-container').hide(0);
        $('.hotspot_link').show(0);
        $('.hotspot').show(0);
        $('.presenter-dimming').fadeOut(400);
        return false;
    });


    $('.ajax-container .prevlink').one('click',
    function(){
        $('.blaettercontent span').hide(0);
        if (ele.index('.normalhotspot') == 0){
            load_info_hotspot($('#hotspot0 div:first'));
        } else if (ele.prev().attr('id') != 'hotspot100'){
            load_hotspot(ele.prev());
        } else{
            load_hotspot(ele.prev().prev());
        }
        return false;
    });

    $('.ajax-container .nextlink').one('click',
    function(){
        $('.blaettercontent span').hide(0);
        if (ele.index('.normalhotspot') == anz_hotspots - 1){
            load_info_hotspot($('#hotspot0 div:first'));
        } else if (ele.next().attr('id') != 'hotspot100'){
            load_hotspot(ele.next());
        } else{
            load_hotspot(ele.next().next());
        }
        return false;
    });

    if ($('.ajax-container .hotspot_vorschau img').size() < 2){
        $('.ajax-container .hotspot_vorschau').html('');
    } else{
        $('.ajax-container .hotspot_vorschau img:first').fadeTo(10, 0.5);
        $('.ajax-container .hotspot_vorschau img').each(function(index){
            $('.ajax-container .hotspot_vorschau img').eq(index).fadeTo(10, 0.5);
            $('.ajax-container .hotspot_vorschau img').eq(1 - index).fadeTo(10, 1);
        });
    }

    $('.ajax-container .zoom_in').bind('click',
    function(){
        $('.ajax-container .zoom_in').unbind('click');
        zoom_in($(this));
        return false;
    });

    $('.ajax-container .hotspot_edit .hs_merken').click(function(){
        hs_merken(ele);
        return false;
    });

    status = parseInt(ele.find('.hs_merken span.status').text());
    merkbild = merken[status];
    $('.ajax-container .hotspot_edit .hs_merken img').attr('src', merkbild);
  $('.hs_merken').css('display','block');
    blaetternAni();

    mouse_zoom();

    buttonActions();

    hidePRControls();

    show_ajax_container();
}

function preload_animation(ele){
    var ausfuehren = true;
    $('#ue100').addClass('click_preload');
    $('.animate').css('zIndex', '0');
    laden_width = $('.mouseover-click').width();
    $('#ue100').append('<div class="loader_bg"></div>');
    $('.loader_bg').css({
        position: "absolute",
        background: "#ffffff",
        height: "23px",
        display: "block",
        bottom: "0px",
        right: "0",
        width: laden_width
    });

    $('.mouseover-click').hide(0);
    $(document.createElement("img")).attr({
        "src": "fileadmin/system/image/story_loading.png"
    }).appendTo('.loader_bg');
    $('.loader_bg img:first').addClass('pic_loading');
    $('.pic_loading').css({
        position: "absolute",
        top: "3px",
        left: "2px"
    });

    $(document.createElement("img")).attr({
        "src": "fileadmin/system/image/preloader_cancel_normal.png"
    }).appendTo('.loader_bg');
    $('.loader_bg img:last').addClass('pic_cancel');
    $('.pic_cancel').css({
        position: "absolute",
        top: "3px",
        right: "2px"
    });
    $(document.createElement("img")).attr({
        "src": "fileadmin/system/image/story_cancel.png"
    }).appendTo('.loader_bg').addClass('cancel_string');
    $('.cancel_string').css('display','none');
    $('.loader_bg').append('<div class="laden_bg"></div>');
    inner_laden_width = laden_width - 4;
    $('.laden_bg').css({
        position: "absolute",
        background: "#cfc9c3",
        height: "3px",
        bottom: "2px",
        left: "2px",
        width: inner_laden_width
    });

    $('.laden_bg').append('<div class="laden"></div>');

    $('.laden').css({
        position: "absolute",
        background: "#877968",
        height: "3px",
        bottom: "0px",
        width: "0%"
    });

    $("img.pic_cancel").bind({
        click: function(){
            $('#ue100').removeClass('click_preload');
            $('.loader_bg').remove();
            $('.mouseover-click').show(0);
            $('.laden').stop();
            hide_popup($('#ue100'));
            ausfuehren = false;
            z = 0;
            aktBild = 0;
            return false;

        },
        mouseenter: function(){
            $(this).attr({
                "src": "fileadmin/system/image/preloader_cancel_hover.png"
            });
            $('.cancel_string').show(0);
            $('.pic_loading').hide(0);
            $('.cancel_string').css({
                position: "absolute",
                top: "3px",
                right: "19px"
            });
        },
        mouseleave: function(){
            $(this).attr({
                "src": "fileadmin/system/image/preloader_cancel_normal.png"
            });
            $('.pic_loading').show(0);
            $('.cancel_string').hide(0);
        }
    });

    $('.laden').animate({
        width: inner_laden_width
    },
    5000, "linear",
    function(){
        if (ausfuehren == true){
            $('#ue100').removeClass('click_preload');
            load_animation(ele);
            return false
        }
    });

}
function load_animation(ele){

    arr_text_abbrechen = new Array();
    arr_text_abbrechen['de'] = new Object();
    arr_text_abbrechen['en'] = new Object();
    arr_text_abbrechen['es'] = new Object();
    arr_text_abbrechen['fr'] = new Object();
    arr_text_abbrechen['it'] = new Object();
    arr_text_abbrechen['pt'] = new Object();
    arr_text_abbrechen['ru'] = new Object();
    arr_text_abbrechen['nl'] = new Object();
    
    arr_text_abbrechen['de'][0] = 'Animation abbrechen';
    arr_text_abbrechen['de'][1] = 'Lade Animation...';
    arr_text_abbrechen['en'][0] = 'skip animation';
    arr_text_abbrechen['en'][1] = 'Loading...';
    arr_text_abbrechen['es'][0] = 'Cancelar animación';
    arr_text_abbrechen['es'][1] = 'Loading...';
    arr_text_abbrechen['fr'][0] = 'Interrompre l`animation';
    arr_text_abbrechen['fr'][1] = 'charge l`animation...';
    arr_text_abbrechen['it'][0] = 'Interrompi animazione';
    arr_text_abbrechen['it'][1] = 'Stop animazione...';
    arr_text_abbrechen['pt'][0] = 'Cancelar animação';
    arr_text_abbrechen['pt'][1] = 'Loading...';
    arr_text_abbrechen['ru'][0] = '&#1055;&#1088;&#1077;&#1088;&#1074;&#1072;&#1090;&#1100; &#1072;&#1085;&#1080;&#1084;&#1080;&#1088;&#1086;&#1074;&#1072;&#1085;&#1085;&#1099;&#1081; &#1089;&#1102;&#1078;&#1077;&#1090;';
    arr_text_abbrechen['ru'][1] = '&#1047;&#1072;&#1075;&#1088;&#1091;&#1079;&#1082;&#1072; &#1072;&#1085;&#1080;&#1084;&#1072;&#1094;&#1080;&#1080;...';
    arr_text_abbrechen['nl'][0] = 'Stop animatie';
    arr_text_abbrechen['nl'][1] = 'Animatie wordt geladen...';    
    
    die_sprache = ele.children('a.mouseover-click').attr('href');
    die_sprache = die_sprache.substr(0, 2);


    $('.ajax_animation').css('background-color', 'transparent');

    $('.ajax_animation').show(0);


    var link = ele.children('a.mouseover-click').attr('href') + '?random=' + Math.random() * 99999;
    $('.ajax_animation').load(link + " .normal_animation", function(){
        $('.ajax_animation').css('background-color', '#746B61');
        $('.loader_bg').remove();
        $('.mouseover-click').show(0);
        
        $('.ajax_animation').append('<div class="abbruchbutton"><img class="abbrechen_klein" src="fileadmin/system/image/abbrechen.png" alt="' + arr_text_abbrechen[die_sprache][0] + '" /><img class="abbrechen_gross" src="fileadmin/system/image/abbrechen_gross_' + die_sprache + '.jpg" alt="' + arr_text_abbrechen[die_sprache][0] + '" /></div>');

        $('.ajax_animation').append('<div class="presenter"><div class="fortschritt"></div></div>');
        $('.ajax_animation .abbruchbutton').show(0);
        $('.ajax_animation .abbruchbutton').unbind('click');

        $('.ajax_animation .abbruchbutton img.abbrechen_klein').bind('mouseenter',
        function(){
            $(this).hide(0);
            $('.ajax_animation .abbruchbutton img.abbrechen_gross').show(0);
        });
        $('.ajax_animation .abbruchbutton img.abbrechen_gross').bind('mouseleave',
        function(){
            $(this).hide(0);
            $('.ajax_animation .abbruchbutton img.abbrechen_klein').show(0);
        });
        $('.ajax_animation .abbruchbutton').click(function(){
            ele.parent().css('z-index', 3);
            ele.hide('slow');
            hide_popup(ele);
            $(this).remove();
            $('.ajax_animation').html('');
            $('.presenter-dimming').fadeOut(400);
            $('.ajax_animation').hide(0);

            z = 0;
            aktBild = 0;
            return false;
        });

        aktBild = 0;
        startanimation('.ajax_animation ');
        $('#abbruchbutton').hide(0);
    });
}

function hide_popup(ele){
    ele.stop().animate({
        'opacity': 0,
        'right': -10,
        'bottom': 0
    },
    1000,
    function(){
        ele.parents('.hotspot').css('z-index', 3);
        ele.css('z-index', 1);
    });

    ele.parents('.hs_frame').hide(0);
}

function hs_popup(ele){

    ele.css('z-index', 77);

    ele.children('.hs_frame').css('display', 'block');

    ele.find('.highslide-html-content, .animation').css({
        'z-index': 78
    });

    ele.find('.highslide-html-content, .animation').stop().animate({
        'opacity': 1,
        'right': '0',
        'bottom': 0
    },
    500);
    $('.presenter-dimming').stop().fadeTo(400, 0.5);

    ele.find('.highslide-html-content, .animation').bind('mouseleave',
    function(evt){
        if (!$('#ue100').hasClass('click_preload')){

            if (evt.relatedTarget.className != 'ajax_animation'){
                hide_popup($(this));
            }

            $('.presenter-dimming').fadeOut(200);

            $(this).unbind('click');
            $(this).unbind('mouseleave');
        }
    });


    if (ele.attr('id') == 'hotspot100'){
        ele.find('.animation').one('click',
        function(){
            preload_animation($(this));
            return false;
        });
    } else{
        ele.find('.highslide-html-content').click(function(){
            $(this).unbind('mouseleave');
            hide_popup($('.highslide-html-content, .animation'));

            topWert = ele.css('top');
            leftWert = ele.css('left');
            $('.ajax-container').css({
                'width': '1px',
                'height': '1px',
                'top': topWert,
                'left': leftWert,
                'z-index': '11',
                'border': '1px solid #fff'
            });

            load_hotspot(ele);
            return false;
        });
    }
}

function merkinfo_schliessen(){
    clearTimeout(delaytime);

    $('#rahmen_hotspots .showmerkinfo').remove();
    $.ajax({
        type: "POST",
        url: "index.php?id=96",
        data: "merkinfo=" + 1,
        success: function(msg){

            }
    });
    $.ajax({
        type: "POST",
        url: "fileadmin/system/php/add_to_merkliste.php",
        data: "merkinfo=" + 1,
        success: function(msg){

            }
    });
}

function hotspotsFunctions(){
    bodywidth = $('body').width() - 240;
    bodyheight = $('body').height();

    bodywidth = $('.rahmen_bild img').width();
    bodyheight = $('.rahmen_bild img').height();

    $('.hotspot').css('display', 'none');
    $('.highslide-html-content, .animation').css({
        'opacity': 0
    });

    if (aktUrl.search('#hs') != -1){

        var anker = parseInt(aktUrl.substr(aktUrl.length - 1));
        if (anker !== null && anker >= 0){
            var hotspotId = '#hotspot' + anker;
            load_hotspot($(hotspotId));

        }
    } else if (aktUrl.search('#bighotspot') != -1){
        var anker = aktUrl.substr(aktUrl.lastIndexOf('#'));
        load_info_hotspot($('#hotspot0 ' + anker));
    }

    $('.hotspot_link_touched').bind('mouseenter', function(){
        
        $('.highslide-html-content img').removeAttr("title");

        if (!$('#ue100').hasClass('click_preload')){
            $('.highslide-html-content, .animation').stop();
            hs_popup($(this).parents('.hotspot'));
            $('.highslide-html-content, .animation').not('div:animated').animate({
                'opacity': 0
            },
            500,
            function(){
                $(this).parents('.hotspot').css('z-index', 3);
            });
        }
    });

    $('.big_hotspot').click(function(){
        load_info_hotspot($('#hotspot0 div:first'));
        return false;
    });

    $('#rahmen_hotspots').click(function(event){
        if ($('.showmerkinfo').css('display') == 'block' && event.target.className != 'showmerkinfo'){
            merkinfo_schliessen();
            return false;
        }
    });

    $('#rahmen_hotspots .showmerkinfo .merkinfo_schliessen').click(function(){
        merkinfo_schliessen();
        return false;
    });

}