
// JavaScript Document 

var debuggerWindow = false;

var global_domain = 'http://www.pearls.de/';
var active_host = 'http://' + location.hostname + '/';
var global_url_index = '';
var imagesAPIcontainerUrl = 'http://images.pageya.com/dynamicImage/';
var imagesAPIurl = 'http://images.pageya.com/dynamicImage.php'; 
var maxImageRetries = 3;
var imageRetries = 0;
var web20Navigation = false;
var web20startUrl;
var web20ActiveGalImg;
var web20ActiveContainer = new Array();
var web20ActiveGalImgSrc = new Array();
var web20ActiveGalDynImgSrc = new Array();
var web20ActiveGalSizeCheck = 0;
var web20GalTextLoaded = false;
var web20GalNavHeight;
var web20GalTable;
var web20GalId;
var web20Gal = false;
var web20GalNextImg;
var web20GalPrevImg;
var web20Popup = false;
var web20PopupTextLoaded = false;
var web20MaxImages = 0;
var web20NxtImageSrc = "";
var web20NxtTicksLeft = 5;
var web20NxtImageRunning = false;
var web20ImgFolder;
var prepareGalImgFinished = false;
var prepareGalerieDescrFinished = false;
var prepareGalerieRatingsFinished = false;
var galerieNavVisible = true;
var smsPremiumKey1 = 'PARTY';
var smsPremiumKey2 = 'PEARLS';
var ratingName = 'Perlen';

var galerieClickCmdShowNext = false;
var galerieGoNextEnabled = true;

var premiumSmsShortNum = '82323';

var web20Centered = true;

var showImgHeight = 420;

var jsPopupActivated = true;
var jsPopupVisible = false;
var ieAnchor = false;
var showCloseButton = false;

//this part is just for transfering the initialation data to the next ajax function
var replaceImageWithFlashActionId = 0;
var replaceImageWithFlashId = new Array();
var replaceImageWithFlashSrc = new Array();
var replaceImageWithFlashData = new Array();

//flash/img-hybrid objects are loaded by replaceImageWithFlash.
//but when opening a web2.0 popup a flash movie behind a web2.0 popup doesn't work in ff2
//so we make a list of the pathes here and replace the flash back to images if we open a web20 popup
var hybridIds = new Array();
var hybridData = new Array();
var hybridImgSize = new Array();
var hybridImgLink = new Array();
var hybridImgHeading = new Array();
var hybridImgText = new Array();
var hybridFlashSrc = new Array();
var hybridFlashSize = new Array();
var hybridStatus = 0;


var jsPopupBackgroundColor = "white";
var designs_backColor = 'cdcdcd';
var designs_contentBackColor = 'ffffff';
var designs_linkColor = 'd10780';
var designs_delimiterColor = 'e4e4e4';
var designs_textColor = '474747';

var quicktimePAN = 0;
var haveqt = false;

var popupWindow;
var quicktimeRotate;

var dall = false;
var dlay = false;
var deid = false;

var AjaxReceiveType = 0;
var http_request = false;

//image folder
var designs = '/eigenedateien/designs/2006-05-06/';
var sliderImagePrefix = 'sliderImage';
var sliderOnlyAutomatic = true;
var sliderStartOnInit = false;

var arrowLeft = designs + 'left.gif';
var arrowLeftHover = designs + 'leftHover.gif';
var arrowLeftActive = false;
var arrowLeftEnabled = true;

var arrowRight = designs + 'right.gif';
var arrowRightHover = designs + 'rightHover.gif';
var arrowRightActive = false;
var arrowRightEnabled = true;

var sliderWidth = 888;

//set if round-sliding is enabled or not
var infiniteSliding = true;

var adScrollerPaused = new Array();


var elementWidth = 144;
var elementSpacer = 4;
var elementCount = 10;
var elementColumns = Math.floor( sliderWidth / elementWidth );

//speed of sliding. higher is slower
//see also sliderTimerReq for speed adjustment

//possible values: 6,12,24,36,48,72,144
var slideStepVal = 144;
var slideStep = Math.floor(elementWidth/slideStepVal);

//smoothness of moving. smaller means higher CPU usage
var sliderTimerReq = 25;

var slideValue = 0;
var firstSlideImage = 0;
var lastSlideImage = 9;

var initFirstSlideImage;
var initLastSlideImage;

var slideCount = 0;
var activeSlideLeft = false;
var activeSlideRight = false;

var activeAddLeftImage = 0;
var activeAddRightImage = 9;

var infiniteSlideRight = false;
var infiniteSlideLeft = false;

var sliderDebug = false;

//adscrollers
var adScrollerPos = 0;
var adScrollerSpeed = 50;

var showImageLink;
var showImageTarget;

//gallery settings
var max_gallery_image_dimension = '1024';
var embed_gallery_logo = '1';
var navToolTipShown = false;
var goGalerieNavImage;
var showGalerieDescr = false;
var galerieCacheImages = 3; //amount of images to precache

var fbLoggedIn = -1;
var fbShareButtonType = 1; //0 = Automatic Share, Requires App Key. //1 = Popup

var twitter = 'pearlsnabburg';

function fbGetStatus(shareContainer,forceLogin){
    if( typeof(forceLogin) == "undefined" )
        forceLogin = true;
    if( fbLoggedIn != -1 )
        return fbLoggedIn;
    return function(){
        FB.getLoginStatus(function(response) {
            if (response.session) {
                fbLoggedIn = true;
              // logged in and connected user, someone you know
            } else {
                if( forceLogin )
                    fbLogIn(shareContainer);
              // no user session available, someone you dont know
            }
        });
        return fbLoggedIn;
    };
}

function fbLogIn(shareContainer){
    fbLoggedIn = false;
    FB.login(function(response) {
        if (response.session) {
          if (response.perms) {
            fbLoggedIn = true;
            fbShareContainer(shareContainer);
            // user is logged in and granted some permissions.
            // perms is a comma separated list of granted permissions
          } else {
            // user is logged in, but did not grant any permissions
          }
        } else {
          // user is not logged in
        }
    }, {perms:'publish_stream'});
    if( fbLoggedIn )
        return true;
}

function putShareButton(container,link,title){
    if( typeof(link) == "undefined" )
        link = document.location.href;
    if( typeof(title) == "undefined" )
        title = "title";
    
    if( container.substr(0,1) != "#" )
        container = "#" + container;
    var containerId = "_" + container.substr(1) ;
        
    link = getNonJsUrl(link);
    
    var shareCount = 0;
    $(container).attr("fb",link);

    var bttn = '<div id="' + containerId + '" class="fb_share_box"><span class="fb_share_size_small"><span class="fb_share_text" style="cursor:pointer;"><span class="">Teilen</span></span><span class="fb_share_nub"></span><span class="fb_share_c"><span class="fb_share_ct" id="' + container.substring(1) + '_ct">' + shareCount + '</span></span></span></a></div>';
    
    if( twitter.length > 0 && twitter != 0 ){
        var via = twitter;
        if( via == 1 )
            via = "";
        else via = "&via=" + via;
        
       //    bttn += '<a href="http://twitter.com/share?url=' + link + via + '&text=' + title + '"><img src=""></a>';
    }

    $(container).append(bttn);
    $(container + " .fb_share_size_small").click( function(){
        var container = $(this).parent().parent();
        if( fbShareButtonType == 1 || fbGetStatus(container.attr("id")) ){
            fbShareContainer(container.attr("id"));
        }
    });
    fbPutShareCountToButton(container);
}

function fbPutShareCountToButton(container,state){
    if( typeof(state) == "undefined" ){
        setTimeout("fbPutShareCountToButton('" + container + "','1')",100);
        return;
    }
    if( fbGetStatus(null,false) ){
        FB.api({
            method: 'links.getStats',
            urls: urlencode( $(container).attr("fb") )
            },function(response) {
                var shareCount = response[0].total_count;
                $(container + "_ct").html(shareCount);
                if( $(container + " .fb_share_c").is(":visible") == false ){
                    $(container + " .fb_share_c").animate({ "opacity": "show" }, "slow", function(){
                        $(container + " .fb_share_nub").css("visibility", "visible");
                    });
                }
        });
    }
}

function fbShareContainer(container){
    var link = $("#" + container).attr("fb");
    if( fbShareButtonType == 1 ){
        var url = "http://www.facebook.com/sharer.php?u=" + link;
        var w = 800;
        var h = 400;
        h = h - 20; var x=0, y=0, parameter="";
        if (w < screen.availWidth || h < screen.availHeight) {
            x = (screen.availWidth - w - 12) / 2;
            y = (screen.availHeight - h - 104) / 2;
            if (window.opera) y = 0; // Opera positioniert unter den Symbolleisten
            if (x<0 || y<0) { x=0; y=0; }
            else parameter = "width=" + w + ",height=" + h + ",";
        }
        parameter += "left=" + x + ",top=" + y;
        parameter += ",menubar=no,location=no,toolbar=no,status=no";
        parameter += ",resizable=yes,scrollbars=yes";
        var fbShare = window.open(url,"fbShare",parameter);
        if (fbShare) fbShare.focus();
        return;
    }
    if(!fbLoggedIn){
        return;
    }
    //message, picture, link, name, caption, description, source
    var message = "";
    /*message = $(".galerieFbShare textarea").val();
    if( message.length == 0 || message == commentBox )
        message = "";*/
    
    $("#" + container).html("Der Eintrag wurde geteilt.");
    setTimeout(function(){
        $("#" + container).hide(100);
    },800);
    
    var caption = 'Lounge und Discothek Pearls Nabburg';
    FB.api('/me/feed', 'post', { message: message, link:link, caption:caption }, function(response) {
        if (!response || response.error) {
        } else {
            fbPutShareCountToButton(container);
        }
    });
}

function getNonJsUrl(url){
    if( typeof(url) == "undefined" )
        url = document.location.href;
        
    var pos = url.indexOf("#");
    if( pos != -1 ){
        if( url.indexOf("#img:") > -1 ){
            var image = url.substr( url.indexOf("#img:") + 5 );
            url = url.substring(0, pos);
            var urlParts = url.split(",");
            urlParts[9] = image;
            url = "";
            for( i = 0; i<urlParts.length; i++ ){
                url += urlParts[i];
                if( i < ( urlParts.length-1 ) )
                    url += ',';
            }
        }                
    }
    return url;
}

function urlencode (str) {
    str = (str+'').toString();
    return encodeURIComponent(str).replace(/!/g, '%21').replace(/'/g, '%27').replace(/\(/g, '%28').replace(/\)/g, '%29').replace(/\*/g, '%2A').replace(/%20/g, '+');
}

function JSdebugger(msg){
    if( debuggerWindow ){
        $("#debugger").show();
        
        $("#debugger").html( $("#debugger").html() + '<div>' + msg + '</div>');
        
        document.getElementById("debugger").scrollTop = document.getElementById("debugger").scrollHeight;
    }
}

var href = document.location.href;
var ignoreHash = false;
function checkHrefChanged(){
    if( !ignoreHash ){
        if( document.location.href != href ){
            href = document.location.href;
            init();
            return;
        }
    }
    setTimeout("checkHrefChanged()","200");
}

function replaceHybridImgs(direction){ //0 == img with flash; 1 == flash with imgs
    if( hybridStatus != direction ){
        var i;
        for( i = 0; i< hybridIds.length; i++ ){
            var container = document.getElementById( hybridIds[i] );
            var width, height, tmp;
            if( direction == 0 ){
                tmp = hybridFlashSize[ i ].split("x");
                width = tmp[0];
                height = tmp[1];
                container.innerHTML = returnFlashObject( hybridFlashSrc[ i ],"","_url=" + hybridImgLink[ i ] + "&_headline=" + hybridImgHeading[ i ] + "&_text=" + hybridImgText[ i ],hybridFlashSrc+'swf',width + 'px',height + 'px');
            }else{
                tmp = hybridImgSize[ i ].split("x");
                width = tmp[0];
                height = tmp[1];
                container.innerHTML = hybridData[i];
            }
        }
    }
    hybridStatus = direction;
}


function keyPressHandler(e) {
        var kC;
        if(window.event) kC = event.keyCode;
        if(!e) e = window.event;
        if(e.keyCode) kC = e.keyCode;
        else if(e.which) code = e.which;
        
        var kC  = (window.event) ?    // MSIE or Firefox?
                event.keyCode : e.keyCode;
        
        var Esc = (window.event) ?   
                27 : e.DOM_VK_ESCAPE // MSIE : Firefox
        if(kC==Esc){
                if( jsPopupActivated && jsPopupVisible ){
                    hideJsPopup();
                }
        }
        if( kC == 37 ){ //pfeil zurŸck
            eval(web20GalPrevImg);
        }
        if( kC == 39 ){ //pfeil vorwŠrts
            eval(web20GalNextImg);
        }
}

function getSize() {  
        var myWidth = 0, myHeight = 0;  
        
        if( typeof( window.innerWidth ) == 'number' ) {  
                //Non-IE  
                myWidth = window.innerWidth;  
                myHeight = window.innerHeight;  
        } else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {  
                //IE 6+ in 'standards compliant mode'  
                myWidth = document.documentElement.clientWidth;  
                myHeight = document.documentElement.clientHeight;  
        } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {  
                //IE 4 compatible  
                myWidth = document.body.clientWidth;  
                myHeight = document.body.clientHeight;  
        }  
        return [ myWidth, myHeight ];  
}
 
function checkUriHash(){

        if( ieAnchor == false && ( document.location.href.substr( document.location.href.length -8 ) == '#jsPopup' || document.location.href.substr( document.location.href.length -8 ) == '&jsPopup' ) ){
            
        }else if( ieAnchor == true && ( document.location.href.substr( document.location.href.length -9 ) == '#hjsPopup' || document.location.href.substr( document.location.href.length -9 ) == '&hjsPopup' ) ){
        }else{
                if( jsPopupActivated && jsPopupVisible ){
                        hideJsPopup();
                }
        }
        
        if( web20Navigation && jsPopupActivated == false && jsPopupVisible == false ){

            var innerLoc = document.getElementById('hiddenURIdata').innerHTML;

            //get web20 start url
            node = document.getElementById('leftMenueNav0');
            node = node.firstChild;
            web20startUrl = node.href;
            if( document.location.href == ( global_domain + "/" + global_url_index ) || document.location.href == global_domain ){
                if( innerLoc.length == 0 )
                    openAJAXUrl(web20startUrl,true);    //first start
                else
                    openAJAXUrl(web20startUrl);         //not first start
            }else{
    
                var loc = document.location.href;
    
                var p = loc.indexOf('#')+1;
                var params = loc.substr(p);
                //params = params.replaceAll("","&");
                while( innerLoc.indexOf("&amp;") > 0 ){
                    innerLoc = innerLoc.replace("&amp;","&");
                }
               /* if( params.substr( params.length-1,1 ) == "#" || params.substr( params.length-1,1 ) == "&" ){
                    history.back();
                    alert("back");
                    //params = params.substr( 0, params.length-1 );
                }
    
                if( params.substr( params.length-8,8 ) == "#jsPopup" || params.substr( params.length-8,8 ) == "&jsPopup" ){
                    history.back();
                    //params = params.substr( 0, params.length-8 );
                }
    
                if( params.substr( params.length-9,9 ) == "#hjsPopup" || params.substr( params.length-9,9 ) == "&hjsPopup" ){
                    history.back();
                    //params = params.substr( 0, params.length-9 );
                }
               */
                if( params != innerLoc ) {
                    openAJAXUrl(params);
                    openNavigationPoint( findNavigationPoint ( params ) );
                }
            }
        }
        
        setTimeout("checkUriHash();",200);
}

var greyHtmlValue = 10;
function greyHTML(){
        replaceHybridImgs(1);
        greyHtmlValue+=20;
       // document.body.style.overflow = 'hidden';
        document.getElementById('cover').style.display = 'block';
        document.getElementById('cover').style.height = '5000px';
        document.getElementById('cover').style.filter = 'alpha(Opacity=' + greyHtmlValue + ')';
        document.getElementById('cover').style.opacity = greyHtmlValue/100;
        document.getElementById('cover').style.MozOpacity = greyHtmlValue/100;
        document.getElementById('cover').style.KhtmlOpacity = greyHtmlValue/100;
        document.getElementById('cover').style.zIndex="1";
        
        if( greyHtmlValue < 50) setTimeout("greyHTML();",1);
        else{
            greyHtmlValue = 10;
            setTimeout("document.getElementById('jsPopup').style.visibility = 'visible'",10);
            setTimeout("document.getElementById('jsPopup').style.display = 'block'",10);
            if( document.getElementById('directions') ) setTimeout("document.getElementById('directions').style.display = 'block'",10);
            if( document.getElementById('gth') ) setTimeout("document.getElementById('gth').style.display = 'block'",10);
            setTimeout("jsPopupVisible = true",10);
        }
}

var ungreyHTMLValue = 50;
function ungreyHTML(){
        ungreyHTMLValue-=20;
        document.getElementById('cover').style.filter = 'alpha(Opacity=' + ungreyHTMLValue + ')';
        document.getElementById('cover').style.opacity = ungreyHTMLValue/100;
        document.getElementById('cover').style.MozOpacity = ungreyHTMLValue/100;
        document.getElementById('cover').style.KhtmlOpacity = ungreyHTMLValue/100;
        if( ungreyHTMLValue > 10 ) setTimeout("ungreyHTML();",1);
        else{
            ungreyHTMLValue = 50;
            document.getElementById('cover').style.display = 'none';
            document.body.style.overflow = 'auto';
            replaceHybridImgs(0);
        }
}

function hideJsPopupN(){
    web20Gal = false;
history.back();history.back();history.back();history.back();history.back();    
}

function hideJsPopup(){
        web20Gal = false;
	ieAnchor = false;

	var decr = 0;	
	if( document.location.href.substr( document.location.href.length -8 ) == '#jsPopup' || document.location.href.substr( document.location.href.length -8 ) == '&jsPopup' ) 
		decr = 7;
	else if( document.location.href.substr( document.location.href.length -9 ) == '#hjsPopup' || document.location.href.substr( document.location.href.length -9 ) == '&hjsPopup' )
		decr = 8;
	else decr = 0;
	
	document.location.href = document.location.href.substr( 0, document.location.href.length -decr );
	
	
	jsPopupActivated = false;
	jsPopupVisible = false;
	quicktimeRotate = false;
	document.getElementById('jsPopup').innerHTML = '';
	document.getElementById('jsPopup').style.display = 'none';
	document.getElementById('jsPopupHistory').style.display = 'none';
	
	//document.getElementById('jsPopupHistory').src = 'about:blank';
	//setTimeout("document.getElementById('jsPopupHistory').innerHTML = ''",1000);
	
	if( showCloseButton ){
		document.getElementById('jsClose').style.display = 'none';
	}
	
	ungreyHTML();
}

function flushHistory(){
	AjaxReceiveType = 4;
	makeRequest('./history2.php?action=flushVisited');
}

function receiveFlushHistory(){

}

function showJsQuicktime(top,src,width,height){

        /*if( haveqt == false ){
                alert('Um unsere Panoramen betrachten zu koennen, muessen Sie das Quicktime Plugin installieren.');
                return false;
        }*/
        
        scroll(0,0);
        
        var agent=navigator.userAgent.toLowerCase();
        var is_iphone = agent.indexOf('iphone');
        if (is_iphone > -1) {
                src = src.substr(0,src.length-7) + "(2).m4v"
               return false;//cancel here as we don't host iphone movies yet 
        }

        setTimeout("doShowJsQuicktime(" + top + ",'" + src + "'," + width + "," + height + ")",10);
        return false;
}

function doShowJsQuicktimePostProcess(){
        setTimeout("quicktimeRotator()",100);
}

function doShowJsQuicktime(top,src,width,height){

        var size = getSize();
        var bHeight = size[1];
        
        var margin = 100;
        if( height > ( bHeight - margin ) ){
                var scale = ( bHeight - margin )/height;
                width = width*scale;
                height = bHeight - margin;
        }


        if( parseInt( window.pageYOffset ) > 0 )
                top = parseInt( window.pageYOffset );
        else    top = parseInt( document.body.scrollTop );
        
        if (/Firefox[\/\s](\d+\.\d+)/.test(navigator.userAgent)){
                var ffversion=new Number(RegExp.$1) // capture x.x portion and store as a number
                /*if (ffversion<3)
                        top = 0;*/
        }
        
        top = top + Math.floor( ( bHeight - height ) / 2 );
        
        //place it on top:
        top = 249;
        
        greyHTML();
        document.getElementById('jsPopup').style.zIndex="12";

        document.getElementById('jsPopup').style.position='absolute';
        if( web20Centered ){
            document.getElementById('jsPopup').style.marginLeft = (-1 * Math.round(width/2)) + "px";
            document.getElementById('jsPopup').style.left = "50%";
        }
        document.getElementById('jsPopup').style.top = top + "px";
        document.getElementById('jsPopup').style.width = width + "px";
        document.getElementById('jsPopup').style.height = ( height + 58 ) + "px";
        document.getElementById('jsPopup').style.backgroundColor = jsPopupBackgroundColor;
        document.getElementById('jsPopup').style.border="1px solid black";
        document.getElementById('jsPopup').style.paddingBottom="1px";
        document.getElementById('jsPopup').style.paddingRight="6px";
        document.getElementById('jsPopup').style.paddingLeft="6px";
        document.getElementById('jsPopup').style.visibility = 'hidden';
        document.getElementById('jsPopup').style.display = 'block';


        //there would be a lot of work rewriting the html code to give the panoramaText to this function (lots of pages)
        //so let's receive it with an ajax request:
        
        AjaxReceiveType = 5;
        makeRequest('.code/getTitleFromPath.php?path=' + src);
        
        var htmlContent = '<a id="#jsPopup"><' + '/a><a id="#hjsPopup"><' + '/a><div id="panoramaStart"><div id="panoramaText"><' + '/div><div id="panoramaClose"><a href="javascript:hideJsPopupN();">Schlie&szlig;en<' + '/a>&nbsp;<img src="' + designs + 'html/close.gif" alt="close" onclick="hideJsPopup();"><' + '/div><' + '/div>';
        
        document.getElementById('jsPopup').innerHTML = htmlContent + returnQuicktimeObject(src,width,height);

        if( document.location.href.substr(document.location.href.length-1,1) == '#' ){
                 s = 'jsPopup';
        }
        else{
                if( ( document.location.href.substr(document.location.href.length-8,8) == '#jsPopup' || document.location.href.substr(document.location.href.length-8,8) == '&jsPopup' ) || ( document.location.href.substr(document.location.href.length-9,9) == '#hjsPopup' || document.location.href.substr(document.location.href.length-9,9) == '&hjsPopup' ) ) s = '';
            else{
                if( document.location.href.indexOf('#') > -1 )
                    s = "&jsPopup";
                else
                    s = '#jsPopup';
            }
        }

        document.location.href = document.location.href + s;
        jsPopupActivated = true;
        
//some browsers don't work with the usual back-button way (for instance ie7), so make an iframe here:
if( dall ){
        document.getElementById('jsPopupHistory').style.display ='block';
        document.getElementById('jsPopupHistory').style.visibility = 'hidden';
        document.getElementById('jsPopupHistory').style.position ='absolute';
        document.getElementById('jsPopupHistory').style.top = "0px";
        document.getElementById('jsPopupHistory').style.left = "0px";
        document.getElementById('jsPopupHistory').style.border = "1px solid black";
        document.getElementById('jsPopupHistory').style.width = "100px";
        document.getElementById('jsPopupHistory').style.height = "100px";
        document.getElementById('jsPopupHistory').style.zIndex=16;
        document.getElementById('jsPopupHistory').innerHTML = '<' + 'iframe src="history2.php"><' + '/iframe>';
}

        if( showCloseButton ){
                document.getElementById('jsClose').style.position = 'absolute';
                document.getElementById('jsClose').style.left = "50%";
                document.getElementById('jsClose').style.top = (top) + "px";
                document.getElementById('jsClose').style.width = "21px";
                document.getElementById('jsClose').style.height = "21px";
                document.getElementById('jsClose').style.zIndex="13";
                document.getElementById('jsClose').style.marginLeft = (-1 * Math.round(width/2)-21) + "px";
                document.getElementById('jsClose').innerHTML = '<a href="#" onclick="return hideJsPopup();"><img src="' + designs + 'close.gif" title="schlie&szlig;en" alt="schlie&szlig;en"><' + '/a>';
                document.getElementById('jsClose').style.display = 'block';
        }
        
        scrollYPos = window.pageYOffset;
        if( scrollYPos == 0 )
                scrollYPos = document.documentElement.scrollTop;
        if( scrollYPos == 0 )
                scrollYPos = document.body.scrollTop;
        
        jsPopupOpened = true;
        quicktimeRotate = true;

        setTimeout("doShowJsQuicktimePostProcess()",200);
}

function receivePanoramaText(res){
        document.getElementById('panoramaText').innerHTML = res;
}

function quicktimeClicked(){
        //quicktimeRotate = false;
}

function quicktimeRotator(){
                      
        if( quicktimeRotate ){
                setTimeout("quicktimeRotator()",12);
                if( document.myQtMovie ){
                        try
                        {
                                quicktimePAN = document.myQtMovie.GetPanAngle();
                                quicktimePAN = quicktimePAN - 0.0625;
                                document.myQtMovie.SetPanAngle(quicktimePAN);
                        }
                        catch(err)
                        {
                                //do nothing
                        }
                }
        }
}

function returnQuicktimeObject(src,width,height){
        var str = '<' + 'object' + ' CLASSID="clsid:02BF25D5-8C17-4B23-BC80-D3488ABDDC6B" id="myQtMovie" ';
        str = str + 'onclick="quicktimeClicked();" width="' + width;
        str = str + '" height="' + height + '" CODEBASE="http://www.apple.com/qtactivex/qtplugin.cab"' + '>';
        str = str + '<' + 'param name="src" value="' + src + '"' + '>' + '<' + 'param name="autoplay" value="true"' + '>';
        str = str + '<' + 'param name="enablejavascript" value = "true"' + '>';
        str = str + '<' + 'param name="loop" value="false"' + '>' + '<' + 'param name="controller" value="true"' + '>';
        str = str + '<' + 'param name="showlogo" value="false"' + '>';
        str = str + '<' + 'embed src="' + src + '" width="' + width + '" height="' + height + '" autoplay="true" ';
        str = str + 'loop="false" controller="true" enablejavascript="true" pluginspage="http://www.apple.com/quicktime/" ';
        str = str + ' name="myQtMovie" showlogo="false" type="video/x-m4v"';
        str = str + ' >';
        str = str + '<' + '/embed' + '>' + '<' + '/object' + '>';
        return str;
}




function init(){
    var node;
    
    if( document.getElementById('sliderImageContent') )
        initSlider();
    checkUriHash();
    checkHrefChanged();
    
    if( document.sI ){
        var container = ( document.sI.container.value );
        var height = ( document.sI.height.value );
        var table = ( document.sI.table.value );
        var datum = ( document.sI.datum.value );
        var id = ( document.sI.id.value );
        var vara = ( document.sI.vara.value );
        var image = ( document.sI.image.value );
        var art = ( document.sI.art.value );
        var opti = ( document.sI.obti.value );//opened by top images
        
        if( art == "galerie" ){
            var address = document.location.href;
            if( address.indexOf("#img:") > -1 ){
                image = address.substr( address.indexOf("#img:") + 5 );
            }
            
            if( opti == 0 ) //normal galerie
                showGalerie(container,height,table,datum,id,image,vara,true);
            else //opened by top images - no navigation bar
                showGalerie(container,height,table,datum,id,image,vara,false);
        }
        else
            showImage(container,height,table,datum,id,art);
        
    }
    
    if( document.youTubeVideo ){
        var agent=navigator.userAgent.toLowerCase();
        var is_iphone = agent.indexOf('iphone');
        var is_ipod = agent.indexOf('ipod');
        if (is_iphone > -1 || is_ipod > -1 ) {
            //can't display embed content.
            //open new window with url
            var url = document.youTubeVideo.url.value;
            var p = url.indexOf("/v/") + 3;
            url = url.substring(p);
            p = url.indexOf("&");
            url = url.substring(0,p);
            url = "http://m.youtube.com/watch?v=" + url;
            document.getElementById("youTubeContainer").innerHTML = "<h2><a target=\"_blank\" href=\"" + url + "\">Als Apple iPhone / iPod Nutzer klicken Sie Hier um zum Video zu gelangen.</a></h2>";
        }

    }
    
    node = document.getElementById('jsEnabledData');
    if( node != null ) node.style.display='block';
    node = document.getElementById('ResultAnmOk');
    if( node != null ) node.style.display = 'none';
    node = document.getElementById('ResultAbmOk');
    if( node != null ) node.style.display = 'none';
    node = document.getElementById('Error');
    if( node != null ) node.style.display = 'none';
    
    try{
        if(document.all) dall = true;
    }catch(e){
        
    }
    try{
    if(document.layers) dlay = true;
    }catch(e){
        
    }
    try{
        if(document.getElementById) deid = true;
    }catch(e){
        
    }
    //check for quicktime
    var minVersion = '6'
    //haveqt = PluginDetect.isMinVersion('QuickTime', minVersion);
    
    if( sliderStartOnInit )
        automaticSlide();
        
    initFbShareBttns();
}

function initFbShareBttns(){
    if( $(".fb_share").length > 0 ){
        $(".fb_share").each(function(index) {
            putShareButton( "#" + $(this).attr("id"), $(this).attr("fb") );
        });
    }
    initTweetBttns();
}

function initTweetBttns(){
    if( $(".twitter_share").length > 0 ){
        $(".twitter_share").each( function(index) {
            twPutTweetButton( $(this).attr("tweet"), $(this).attr("title") );
        });
    }
}

function hover(name,adresse){
    try{
        if( document.getElementById(name) != "undefined" ){
            if(dall){
                if(document.all[name])
                    document.all[name].src = adresse;
            }else if(dlay){
                if(document.name)
                    document.name.src = adresse;
            }else if(deid){
                if(document.getElementById(name))
                    document.getElementById(name).src = adresse;
            }
        }
    }catch(e){
        
    }
}
    

function newsletterAnm(email){
        hide('ResultAnmOk');
        hide('Error');
        hide('ResultAbmOk');
        var r = Math.random();
        var currentTime = new Date();
        password = email + (currentTime.getTime()*r);
	/*
  	-- action=register --
		nickname=? 	[ "maxi" aber auch "Max Mustermann" ]
		email=?         [ info@almardo.com ]
		password=?  	[ passwort ]
		password2=?  	[ passwort Wiederholung ]
		encrypted=?     [ Passwort verschlüsselt speichern? 0=nein 1=ja ]
	*/
        AjaxReceiveType = 1;
        var url = './code/logonInfo.php?action=register&nickname='+email+'&email='+email+'&password='+password+'&password2='+password+'&encrypted=0';
	makeRequest(url);
        return false;
}

function newsletterAbm(email){
        hide('ResultAnmOk');
        hide('Error');
        hide('ResultAbmOk');
	AjaxReceiveType = 2;
   	/*
        -action=deleteProfile
	login=? 	[ username z.B. "maxi" ODER email z.B. "info@almardo.com" ]
	*/
	makeRequest('.code/logonInfo.php?action=deleteProfile&login='+email+'&no-html=1');
        return false;
}

function newsletterAnmReceive(response){
        if( response == '&result=OK&' ){
                hide('registerInput');
                hide('registerBttn');
                result = 'Sie haben sich erfolgreich angemeldet.';
                document.getElementById('ResultAnmOk').innerHTML = result;
                show('ResultAnmOk'); 
        }else{
                hide('registerInput');
                hide('registerBttn');
                var result = '';
                switch (response){
                        case "&why=email-exists&result=Error&":
                        case "&why=user-exists&result=Error&":
                                result = 'Sie haben sich erfolgreich angemeldet.';
                                break;
                        case "&why=no-contact-data-set&result=Error&":
                        case "&result=Error&why=no-email-address&":
                                result = 'Bitte geben Sie eine korrekte Emailadresse ein.';
                                break;
                        default:
                                result = 'Fehlgeschlagen.';
                }
                document.getElementById('ResultAnmError').innerHTML = result;
                show('ResultAnmError');
        }
}

function newsletterAbmReceive(response){
        if( response != '&result=Error&why=Key+does+not+match&' ){
                show('ResultAbmOk');
        }else{
                show('Error');
                document.getElementById('ErrorStr').innerHTML = 'Der von Ihnen Ÿbergebene Code war falsch';
        }
}

function sendContactForm(from,email,subject,text){
        if( from.length > 0 && email.length > 0 && subject.length > 0 && text.length > 0 ){
                AjaxReceiveType = 3;
                while( text.indexOf("\n") > 0 ){
                    text = text.replace("\n","<br>");
                }
                text = escape(text);
                var url = 'code/send.php?from=' + email + '&fromname=' + from + '&subject=' + subject + '&text=' + text + '&nospam=enabled';
                $.ajax({
                    type: "POST",
                    url: '/code/send.php',
                    data: { from: email, fromname: from, subject: subject, text: text, nospam: 'enabled' },
                    success: function(data) {
                        document.getElementById('formResult').style.display = 'block';
                        document.getElementById('formData').style.display = 'none';
                    }
                });
        }
        return false;
}
  
function makeRequest(url) {

        JSdebugger('ajax request start (' + AjaxReceiveType + '): ' + url);
        
        var httpRequest;
        
        if (window.XMLHttpRequest) { // Mozilla, Safari, ...
                httpRequest = new XMLHttpRequest();
                if (httpRequest.overrideMimeType) {
                        httpRequest.overrideMimeType('text/xml');
                        // See note below about this line
                }
        } 
        else if (window.ActiveXObject) { // IE
                try {
                        httpRequest = new ActiveXObject("Msxml2.XMLHTTP");
                } 
                catch (e) {
                        try {
                                httpRequest = new ActiveXObject("Microsoft.XMLHTTP");
                        } 
                        catch (e) {}
                }
        }
        
        if (!httpRequest) {
                alert('Giving up :( Cannot create an XMLHTTP instance');
                return false;
        }
        
        httpRequest.onreadystatechange = function() { alertContents(httpRequest); };
        httpRequest.open('GET', url, true);
        httpRequest.send('');
        
        return true;

}

    function alertContents(httpRequest) {

        if (httpRequest.readyState == 4) {
            if (httpRequest.status == 200) {
                
                JSdebugger('ajax result (' + AjaxReceiveType + '): ' + httpRequest.responseText);
                
                switch( AjaxReceiveType ){
                case 1:
                        newsletterAnmReceive(httpRequest.responseText);
                break;
                case 2:
                        newsletterAbmReceive(httpRequest.responseText);
                break;
                case 4:
                        receiveFlushHistory(httpRequest.responseText);
                break;
                case 5:
                        receivePanoramaText(httpRequest.responseText);
                break;  
                case 6:
                        receiveAJAXUrl(httpRequest.responseText);
                break;
                case 7:
                        replaceImageWithFlash(httpRequest.responseText);
                break;
                case 8:
                        getGalerieDescr(httpRequest.responseText);
                break;
                case 9:
                        prepareGalImg(httpRequest.responseText,"",1);
                break;
                case 10:
                        prepareGalImg(httpRequest.responseText,"",2);
                break;
                case 11:
                       showGalerieMMSInfo(httpRequest.responseText);
                break;
                case 12:
                        showGalerieRatings(httpRequest.responseText);
                break;
                case 13:
                        galerieRatingValueSet(httpRequest.responseText);
                break;
                case 14:
                        preCacheNextGalerieImage(httpRequest.responseText);
                break;
                case 15:
                        preCacheNextGalerieImageDimensions(httpRequest.responseText);
                break;
                default:
                }
                //alert(httpRequest.responseText);
            } else {
                    //alert('There was a problem with the request.');
            }
        }

    }
    
function preparePrintView(){
        var url = document.location.href;
        
        if( url.indexOf('&') > -1 )
                url = url + "&print=true";
        else
                url = url + "?print=true";
                
        document.location.href = url;
}

function bodyScroll(){

}

function bodyUnload(){

}

function sliderNavHover(arrow){
	if( arrow == 'left_arrow' && arrowLeftEnabled ){
		if( arrowLeftActive ){
			arrowLeftActive = false;
			document.getElementById(arrow).src = arrowLeft;
		}else{
			arrowLeftActive = true;
			document.getElementById(arrow).src = arrowLeftHover;
		}
	}else if( arrow == 'right_arrow' && arrowRightEnabled ){
		if( arrowRightActive ){
			arrowRightActive = false;
			document.getElementById(arrow).src = arrowRight;
		}else{
			arrowRightActive = true;
			document.getElementById(arrow).src = arrowRightHover;
		}
	}
	
}

function getSliderImage(originalID,newID){
        data = document.getElementById(sliderImagePrefix + originalID.toString()).innerHTML;
        if( sliderDebug ) document.getElementById('debugTxt').innerHTML = data + '<' + 'div>' + '(' + originalID + ' / ' +  newID + ')<' + '/div>';
        return '<div id="' + sliderImagePrefix + newID + '" class="sliderImage">' + data + '</div>';
}

function addSliderImageRight(){
        originalID = getActiveRightImage();
        newID = lastSlideImage+1;
        lastSlideImage++;

        elementCount++;        
        data = getSliderImage(originalID,newID) + document.getElementById('sliderImageContent').innerHTML;
        document.getElementById('sliderImageContent').innerHTML = data;        
        document.getElementById('sliderImageContent').style.width = parseInt( document.getElementById('sliderImageContent').style.width ) + ( elementWidth + 4 ) + 'px';
}

function addSliderImageLeft(){
        originalID = getActiveLeftImage();
        newID = firstSlideImage-1;

        lastSlideImage++;
        elementCount++;
        data = document.getElementById('sliderImageContent').innerHTML + getSliderImage(originalID,newID);
        document.getElementById('sliderImageContent').innerHTML = data;        
        document.getElementById('sliderImageContent').style.width = parseInt( document.getElementById('sliderImageContent').style.width ) + ( elementWidth + 4 ) + 'px';

        slideCount++;  
	slideValue = ( parseInt( slideValue ) - ( elementWidth ) );
        document.getElementById('sliderImageContent').style.marginLeft = ( slideValue - slideCount*elementSpacer ).toString() + "px";
}

function getActiveLeftImage(){
        res = activeAddLeftImage;
        activeAddLeftImage++;
        if( activeAddLeftImage > initLastSlideImage )
                activeAddLeftImage = initFirstSlideImage;
        return res;
}

function getActiveRightImage(){
        res = activeAddRightImage;
        activeAddRightImage--;
        if( activeAddRightImage < initFirstSlideImage )
                activeAddRightImage = initLastSlideImage;
        return res;
}

function enableRightArrow(){
        if(!sliderOnlyAutomatic){
            arrowRightEnabled = true;
            arrowRightActive = true;
            sliderNavHover('right_arrow');
        }
}

function enableLeftArrow(){
        if(!sliderOnlyAutomatic){
            arrowLeftEnabled = true;
            arrowLeftActive = true;
            sliderNavHover('left_arrow');
        }
}

function disableRightArrow(){
        if( infiniteSliding == false ){
                arrowRightActive = true;
                sliderNavHover('right_arrow');
                arrowRightEnabled = false;
        }else{
                addSliderImageRight();
        }
}

function disableLeftArrow(){
        if( infiniteSliding == false ){
                arrowLeftActive = true;
                sliderNavHover('left_arrow');
                arrowLeftEnabled = false;
        }else{
                addSliderImageLeft();
        }
}

function initSlider(){
        if( sliderDebug ){
                document.body.innerHTML = document.body.innerHTML + '<' + 'div id="debugTxt">' + '<' + '/div>';
        }
        initFirstSlideImage = firstSlideImage;
        initLastSlideImage = lastSlideImage;
        document.getElementById('sliderImageContent').style.width = (elementCount * ( elementWidth + 4 ) ) + 'px';
        if( ( parseInt( slideCount ) > parseInt( firstSlideImage ) && activeSlideRight == false ) == false )
                disableLeftArrow();
        if( ( parseInt( slideCount ) <= parseInt( lastSlideImage - elementColumns ) && activeSlideLeft == false ) == false )
                disableRightArrow();
}


function setSlideRight(){
        if( parseInt( slideCount ) > parseInt( firstSlideImage ) && activeSlideRight == false ){
                activeSlideRight = true;
                infiniteSlideRight = true;
                slideCount--;
                enableRightArrow();
                doSlideRight();
        }else if( activeSlideRight == false ) disableLeftArrow();
}

function setSlideLeft(){
        if( parseInt( slideCount ) <= parseInt( lastSlideImage - elementColumns ) && activeSlideLeft == false ){
                activeSlideLeft = true;
                infiniteSlideLeft = true;
                slideCount++;
                enableLeftArrow();
                doSlideLeft();
        }else if( activeSlideLeft == false ) disableRightArrow();        
}

function automaticSlide(){
    setTimeout("slideLeft()",100);
}

function slideRight(){
        if( parseInt( slideCount ) > parseInt( firstSlideImage ) && activeSlideRight == false && infiniteSlideRight == false ){
                activeSlideRight = true;
                slideCount--;
                enableRightArrow();
                doSlideRight();
        }else if( activeSlideRight == false && infiniteSlideRight == false ) disableLeftArrow();
        infiniteSlideRight = false;
}

function slideLeft(){
        if( parseInt( slideCount ) <= parseInt( lastSlideImage - elementColumns ) && activeSlideLeft == false && infiniteSlideLeft == false ){
                activeSlideLeft = true;
                slideCount++;
                enableLeftArrow();
                doSlideLeft();
        }else if( activeSlideLeft == false && infiniteSlideLeft == false ) disableRightArrow();
        infiniteSlideLeft = false;
}

function doSlideRight(){
        if( activeSlideLeft ){
                activeSlideRight = false;
                return;
        }
	slideValue = ( parseInt( slideValue ) + slideStep );
        
        if( sliderOnlyAutomatic )
            document.getElementById('sliderImageContent').style.marginLeft = ( slideValue ).toString() + "px";
        else
            document.getElementById('sliderImageContent').style.marginLeft = ( slideValue - slideCount*elementSpacer ).toString() + "px";
        
	if(  Math.abs(slideValue/slideCount) != ( elementWidth ) && slideValue != 0 )
		setTimeout("doSlideRight()",sliderTimerReq);
        else{
                activeSlideRight = false;
                if( ( parseInt( slideCount ) > parseInt( firstSlideImage ) && activeSlideRight == false ) == false ){
                        disableLeftArrow();
                        if( infiniteSliding == false ) return;
                }
                if(sliderOnlyAutomatic)
                    setTimeout("slideRight()",sliderTimerReq);
                if( infiniteSlideRight ){
                        slideCount--;
                        setTimeout("doSlideRight()",sliderTimerReq);
                }
        }
}

function doSlideLeft(){
        if( activeSlideRight ) {
                activeSlideLeft = false;
                return;
        }
        var marginLeft = document.getElementById('sliderImageContent').style.marginLeft.substr(0,document.getElementById('sliderImageContent').style.marginLeft.length-2);
        slideValue = marginLeft;
	slideValue = ( parseInt( slideValue ) - slideStep );
        
        if( sliderOnlyAutomatic )
            document.getElementById('sliderImageContent').style.marginLeft = ( slideValue ).toString() + "px";
        else
            document.getElementById('sliderImageContent').style.marginLeft = ( slideValue - slideCount*elementSpacer ).toString() + "px";
        
	if(  Math.abs(slideValue/slideCount) != ( elementWidth  ) && slideValue != 0  ){
		setTimeout("doSlideLeft()",sliderTimerReq);
        }else{
                activeSlideLeft = false;
                if( ( parseInt( slideCount ) <= parseInt( lastSlideImage - elementColumns ) && activeSlideLeft == false ) == false ){
                        disableRightArrow();
                        if( infiniteSliding == false ) return;
                }
                if(sliderOnlyAutomatic){
                    setTimeout("slideLeft()",sliderTimerReq);
                }
                if( infiniteSlideLeft ){
                        slideCount++;
                        setTimeout("doSlideLeft()",sliderTimerReq);
                }
        }
}

function openPopup(address){
        if( !popupWindow ){
		var popupAddress = ''

		if(address.length>0) popupAddress = address;

		popupWindow = window.open(popupAddress, 'http000www0pearls0de0', 'width='+screen.availWidth+',height='+screen.availHeight+',top=0,left=0,statusbar=no,resizable=no,scrollbars=yes');
        }else popupWindow.focus();
}


var startFrom;
    function initialize(to) {
        
        if (GBrowserIsCompatible()) {      
            map = new GMap2(document.getElementById("map_canvas"));
            var mapTypeControl = new GMapTypeControl();
            var topRight = new GControlPosition(G_ANCHOR_TOP_RIGHT, new GSize(10,10));
            var bottomRight = new GControlPosition(G_ANCHOR_BOTTOM_RIGHT, new GSize(10,10));
            map.addControl(mapTypeControl, topRight);
            GEvent.addListener(map, "dblclick", function() {
                    map.removeControl(mapTypeControl);
                    map.addControl(new GMapTypeControl(), bottomRight);
                });
            map.addControl(new GSmallMapControl());
            map.setCenter(new GLatLng(37.4419, -122.1419), 13);
            
            gdir = new GDirections(map, document.getElementById("directions"));
            GEvent.addListener(gdir, "load", onGDirectionsLoad);
            GEvent.addListener(gdir, "error", handleErrors);
            
            setDirections(startFrom, to, "de_DE");
        }
    }

    function setDirections(fromAddress, toAddress, locale) {
      gdir.load("from: " + fromAddress + " to: " + toAddress,
                { "locale": locale });
    }

    function handleErrors(){
	   if (gdir.getStatus().code == G_GEO_UNKNOWN_ADDRESS)
	     alert("Die von Ihnen eingegebene Adresse konnte nicht gefunden werden.");
	   else if (gdir.getStatus().code == G_GEO_SERVER_ERROR)
	     alert("A geocoding or directions request could not be successfully processed, yet the exact reason for the failure is not known.\n Error code: " + gdir.getStatus().code);
	   
	   else if (gdir.getStatus().code == G_GEO_MISSING_QUERY)
	     alert("The HTTP q parameter was either missing or had no value. For geocoder requests, this means that an empty address was specified as input. For directions requests, this means that no query was specified in the input.\n Error code: " + gdir.getStatus().code);

	//   else if (gdir.getStatus().code == G_UNAVAILABLE_ADDRESS)  <--- Doc bug... this is either not defined, or Doc is wrong
	//     alert("The geocode for the given address or the route for the given directions query cannot be returned due to legal or contractual reasons.\n Error code: " + gdir.getStatus().code);
	     
	   else if (gdir.getStatus().code == G_GEO_BAD_KEY)
	     alert("The given key is either invalid or does not match the domain for which it was given. \n Error code: " + gdir.getStatus().code);

	   else if (gdir.getStatus().code == G_GEO_BAD_REQUEST)
	     alert("A directions request could not be successfully parsed.\n Error code: " + gdir.getStatus().code);
	    
	   else alert("An unknown error occurred.");
	   
	}

	function onGDirectionsLoad(){ 
      // Use this function to access information about the latest load()
      // results.

      // e.g.
      // document.getElementById("getStatus").innerHTML = gdir.getStatus().code;
	  // and yada yada yada...
	}
        
    function showMap(top,width,height,from,to,table,id){
        var mapsKey = 'ABQIAAAAxSKqVivnRTfXrp0EffKx2hSINJhGHqvpb2eIdWyt35R0Znt5BxT9U4m5U1Qr0WaU92H-9R0alNt4Sw';
        if( mapsKey.length == 0 )
            return false;
        
        scroll(0,0);
        if( from.length == 0 ) from = 'Regensburg';
        greyHTML();
        startFrom = from;
    var map;
    var gdir;
    var geocoder = null;
    var addressMarker;
    
    var data = '<a id="#jsPopup"><' + '/a><a id="#hjsPopup"><' + '/a><' + 'form action="#" onsubmit="setDirections(this.from.value, this.to.value, this.locale.value); return false"' + '><div id="gmapsStart"><div id="gmapsStartAddr">Startadresse:&nbsp;<' + 'input type="text" size="25" id="fromAddress" name="from" value="' + from + '"/' + '><input type="hidden" id="toAddress" name="to" value="' + to + '" /><input style="margin-left:10px;" name="submit" type="submit" value="Route berechnen" /><' + '/div><div id="gmapsLanguage">Sprache:&nbsp;<select onchange="setDirections(this.form.from.value, this.form.to.value, this.form.locale.value);" id="locale" name="locale"><option value="en">English<' + '/option><option value="fr">Franais<' + '/option><option value="de" selected>Deutsch<' + '/option><option value="ja">Japanese<' + '/option><option value="es">Espa–ol<' + '/option><' + '/select>&nbsp;&nbsp;&nbsp;<' + '/div><div id="gmapsClose"><a href="#" onclick="return hideJsPopup();">Schlie&szlig;en<' + '/a><' + '/div><' + '/div><' + '/form><table style="clear:both;"><tr id="gth"><th>Wegbeschreibung<' + '/th><th>Karte<' + '/th><' + '/tr><tr><td valign="top"><div id="directions" style="width: 335px"><' + '/div><' + '/td><td valign="top"><div id="map_canvas" style="width: 570px; height: 595px;"><' + '/div><' + '/td><' + '/tr><' + '/table> ';

        document.getElementById('jsPopup').style.zIndex="12";
      //  document.getElementById('jsPopup').style.border="1px solid white";
        document.getElementById('jsPopup').style.backgroundColor = jsPopupBackgroundColor;
        document.getElementById('jsPopup').style.border="1px solid black";


        document.getElementById('jsPopup').style.position='absolute';
        if( web20Centered ){
            document.getElementById('jsPopup').style.marginLeft = (-1 * Math.round(width/2)-6) + "px";
            document.getElementById('jsPopup').style.left = "50%";
        }
        document.getElementById('jsPopup').style.top = top + "px";
        document.getElementById('jsPopup').style.width = width + "px";
        document.getElementById('jsPopup').style.display = 'block';
        document.getElementById('jsPopup').style.visibility = 'hidden';
        document.getElementById('jsPopup').style.border = '1px solid transparent';
        document.getElementById('jsPopup').innerHTML = data;
        document.getElementById('directions').style.display = 'none';
        document.getElementById('gth').style.display = 'none';

        prepareGalerieDescr(table,id);

//some browsers don't work with the usual back-button way (for instance ie7), so make an iframe here:
if( dall ){
        document.getElementById('jsPopupHistory').style.display ='block';
        document.getElementById('jsPopupHistory').style.visibility = 'hidden';
        document.getElementById('jsPopupHistory').style.position ='absolute';
        document.getElementById('jsPopupHistory').style.top = "0px";
        document.getElementById('jsPopupHistory').style.left = "0px";
        document.getElementById('jsPopupHistory').style.width = "100px";
        document.getElementById('jsPopupHistory').style.height = "100px";
        document.getElementById('jsPopupHistory').style.zIndex=16;
        document.getElementById('jsPopupHistory').innerHTML = '<' + 'iframe src="history2.php"><' + '/iframe>';
}

    initialize(to);
    
        if( document.location.href.substr(document.location.href.length-1,1) == '#' ){
                 s = 'jsPopup';
        }
        else{
                if( ( document.location.href.substr(document.location.href.length-8,8) == '#jsPopup' || document.location.href.substr(document.location.href.length-8,8) == '&jsPopup' ) || ( document.location.href.substr(document.location.href.length-9,9) == '#hjsPopup' || document.location.href.substr(document.location.href.length-9,9) == '&hjsPopup' ) ) s = '';
            else{
                if( document.location.href.indexOf('#') > -1 )
                    s = "&jsPopup";
                else
                    s = '#jsPopup';
            }
        }
        document.location.href = document.location.href + s;
jsPopupActivated = true;

    return false;
    }
    
    function openNavigationPoint(navID){
        
        if( web20Navigation ){
            //close other nodes
            
            var i = 0;
            node = document.getElementById(('leftMenueNav' + i).toString());
            
            while(node != null){
                while( node != null && node.nodeName != 'UL'){
                        if( node.nodeName == 'LI' ) node = node.firstChild;
                        node = node.nextSibling;
                }
                if( node != null ){
                    node.style.display = 'none';
                }
                i++;
    
                node = document.getElementById(('leftMenueNav' + i).toString());
            }
            
            node = document.getElementById(navID);//.style.display = 'block';
            
            while( node != null && node.nodeName != 'UL'){
                    if( node.nodeName == 'LI' ) node = node.firstChild;
                    node = node.nextSibling;
            }
            if( node != null ){
                node.style.display = 'block';
            }
                
            return false;
            
        }
            
    }
    
    function findNavigationPoint(searchStr){
        
        
        var i = 0;
        node = document.getElementById(('leftMenueNav' + i).toString());
        
        while(node != null){
            
            var link = node.firstChild;
            
            if( link.href.indexOf(searchStr) > -1 ) return 'leftMenueNav' + i;

            while( node != null && node.nodeName != 'UL'){
                    if( node.nodeName == 'LI' ) node = node.firstChild;
                    node = node.nextSibling;
            }
            
            if( node != null ){
                node = node.firstChild.nextSibling;
                while( node != null ){
                    link = node.firstChild;
                    
                    if( link.href.indexOf(searchStr) > -1 ) return 'leftMenueNav' + i;

                    node = node.nextSibling;
                    
                    if( node != null ) node = node.nextSibling;
                }
            }
            
            
            i++;

            node = document.getElementById(('leftMenueNav' + i).toString());
        }
        
        return -1;
        
    }
    
    function openAJAXUrl(params,justOpen){
   
        params = params.replace(active_host + "/" + global_url_index + "?","");
        params = params.replace(active_host + global_url_index + ")", "");
        if( web20Navigation ){
            var loc = document.location.href;
            var pos = loc.indexOf('#');
            if( pos > -1 ){
                loc = loc.substr(0,pos);                
            }
            loc = loc + "#" + params;
            document.location.href = loc;
            document.getElementById('hiddenURIdata').innerHTML = params;//loc;
            if( justOpen == false || typeof justOpen == "undefined" ){
                AjaxReceiveType = 6;
                url = 'http://www.pearls.de/code/readHtmlFile.php?' + params;
                makeRequest(url);
            }
            return false;
        }
        return false;
    }
    
    function receiveAJAXUrl(result){
        result = (result);
        document.getElementById('overview-content').innerHTML = result;
        var node;
        node = document.getElementById('jsEnabledData');
        if( node != null ) node.style.display='block';
        node = document.getElementById('ResultAnmOk');
        if( node != null ) node.style.display = 'none';
        node = document.getElementById('ResultAbmOk');
        if( node != null ) node.style.display = 'none';
        node = document.getElementById('Error');
        if( node != null ) node.style.display = 'none';
    }
    
    function replaceAll( str, replacements ) {
        for ( i = 0; i < replacements.length; i++ ) {
            var idx = str.indexOf( replacements[i][0] );
    
            while ( idx > -1 ) {
                str = str.replace( replacements[i][0], replacements[i][1] ); 
                idx = str.indexOf( replacements[i][0] );
            }
    
        }

    return str;
    }
    
    function checkFlashImg(id,path){
        if( hybridStatus != 1 ){
            
            //first we wanna know if the user has flash. If not we can end here.
            
            if( hasRequestedVersion == true ){
                //user has flash. find out path to flash file
        
                var container = document.getElementById(id);

                var parts = path.split('/');
                var folder = '';
                var i;


                for( i = 0; i < (parts.length-1); i++ ){
                    folder += parts[i] + '/';
                }

                var tmp = parts[ parts.length-1 ];
                var fileName = '';
                parts = tmp.split('.');
                
                for( i = 0; i < (parts.length-1); i++ ){
                    fileName += parts[i]+'.';
                }
                fileName += "swf";
                
                var flashSrc = folder + fileName;
                
                replaceImageWithFlashActionId++;
                
                replaceImageWithFlashSrc[replaceImageWithFlashActionId] = flashSrc;
                replaceImageWithFlashData[replaceImageWithFlashActionId] = container.innerHTML;
                replaceImageWithFlashId[replaceImageWithFlashActionId] = id;

                //find out how big the image is and open the function replaceImageWithFlash
                AjaxReceiveType = 7;
                
                url = active_host + 'code/abmessungenErmitteln.php?pfad=' + flashSrc + '&absolute&getImgSize&id=' + replaceImageWithFlashActionId;
               // if( flashSrc.indexOf('2006-04-26') > -1 ) alert(url);
                makeRequest(url);
            }
        }
        
    }
    
    function replaceImageWithFlash(data){
        var parts = data.split('&');
        
        var innerParts = parts[1].split('=');
        var width = innerParts[1];
        var transactionID;
        innerParts = parts[2].split('=');
        height = innerParts[1];
        innerParts = parts[3].split('=');
        transactionID = innerParts[1];
        
       // alert(data);
        
        //if file exists
        if( height > -1 && width > -1 ){
//alert(height);
//alert(width);
            var imgSize = document.getElementById(replaceImageWithFlashId[transactionID]).firstChild.firstChild.width + "x" + document.getElementById(replaceImageWithFlashId[transactionID]).firstChild.firstChild.height;
            imgSize = imgSize.replace(/px/g,"");
            
            var headline;
            var text;
            
            if( document.getElementById(replaceImageWithFlashId[transactionID]).firstChild.nextSibling != null && document.getElementById(replaceImageWithFlashId[transactionID]).firstChild.nextSibling.nextSibling != null && document.getElementById(replaceImageWithFlashId[transactionID]).firstChild.nextSibling.nextSibling.nextSibling != null ){
                headline = escape(document.getElementById(replaceImageWithFlashId[transactionID]).firstChild.nextSibling.nextSibling.innerHTML);
                text = escape(document.getElementById(replaceImageWithFlashId[transactionID]).firstChild.nextSibling.nextSibling.nextSibling.innerHTML);
            }
            
            var widthHeight = Array();
            widthHeight = imgSize.split("x");
            width = widthHeight[0];
            height = widthHeight[1];
            
            var flashSize = width + "x" + height;
            
            hybridData[ hybridIds.length  ] = replaceImageWithFlashData[transactionID];
            hybridImgSize[ hybridIds.length  ] = imgSize;
            hybridFlashSrc[ hybridIds.length  ] = replaceImageWithFlashSrc[transactionID];
            hybridImgLink[ hybridIds.length ] = document.getElementById(replaceImageWithFlashId[transactionID]).firstChild.href;
            hybridFlashSize[ hybridIds.length  ] = flashSize;
            hybridImgHeading[ hybridIds.length  ] = headline;
            hybridImgText[ hybridIds.length  ] = text;
            hybridIds[ hybridIds.length  ] = replaceImageWithFlashId[transactionID];
            
            var container = document.getElementById(replaceImageWithFlashId[transactionID]);
            container.innerHTML = returnFlashObject(replaceImageWithFlashSrc[transactionID],"","modulUrl=" + escape(hybridImgLink[ hybridIds.length -1 ]) + "&modulHeadline=" + headline + "&modulText=" + text,replaceImageWithFlashSrc[transactionID]+'swf',width + 'px',height + 'px');

        
        }
    }

    function returnFlashObject(flashUrl,flashParams,flashVars,name,width,height){
        text = '<' + 'object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000"'+
        'codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,0,0" '+
        'width="' + width + '" height="' + height + '" menu="false" id="' + name + '" align="middle"'+
        '>' + '<' + 'param name="allowScriptAccess" value="sameDomain" /' + '>'+
        '<' + 'param name="movie" value="' + flashUrl + '" /' + '>'+
        '<' + 'param name="quality" value="high" /' + '>'+
        '<' + 'param name="bgcolor" value="#000000" /' + '>'+
        '<' + 'param name="menu" value="false" /' + '>';
        var i;
        var flP = flashParams.split("&");
        if( flP.length > 0 ){
                for( i = 0; i< flP.length; i++ ){
                        var f = flP[i].split("=");
                        text = text + '<' + 'param name="' + f[0] + '" value="' + f[1] + '" /' + '>';
                }
        }
        
        //calculate containing folder
        
        var parts = flashUrl.split('/');
        var folder = '';
        var i;


        for( i = 0; i < (parts.length-1); i++ ){
            folder += parts[i] + '/';
        }
        
        folder = folder.replace("./",global_domain);

        //set standard flash vars here:
        if( flashVars.length > 0 )
            flashVars += "&";

        flashVars += "modulGlobal_backColor=" + designs_backColor + "&modulGlobal_contentBackColor=" + designs_contentBackColor + "&modulGlobal_linkColor=" + designs_linkColor;
        flashVars += "&modulGlobal_delimiterColor=" + designs_delimiterColor + "&modulGlobal_textColor=" + designs_textColor + "&modulFolder=" + folder;
        
        text = text + '<' + 'param NAME="FlashVars" VALUE="' + flashVars + '" /' + '>'+
        '<' + 'embed id="plasmaEmbed" src="' + flashUrl + '" quality="high" menu="false" '+
        'bgcolor="#ffffff" width="' + width + '" height="' + height + '" name="' + name + '" align="middle" allowScriptAccess="sameDomain" ';
         if( flP.length > 0 ){
                for( i = 0; i< flP.length; i++ ){
                        var f = flP[i].split("=");
                        text = text + ' ' + f[0] + '="' + f[1] + '" ';
                }
        }
        text = text + 'type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" FlashVars="'+
        flashVars+'"'+ '>' + '<' + '/embed' + '>'+
        '<' + '/object' + '>';
        return text;
    }
                
    function show(DivID) {
        node = document.getElementById(DivID);
        if( node != null ){
            node.style.display = 'block';
        }
    }
    
    function hide(DivID) {
        node = document.getElementById(DivID);
        if( node != null ){
            node.style.display = 'none';
        }
    }
    
    function goGalerieNext(){
        eval(web20GalNextImg);
        return false;
    }
    
    function goGaleriePrev(){
        eval(web20GalPrevImg);
        return false;
    }
    
    function getDynamicImageDimension(dynImgPath){
        JSdebugger("getDynamicImageDimension(" + dynImgPath + "){");
        var url = $.ajax({
            url: active_host + 'code/abmessungenErmitteln.php?pfad=' + dynImgPath + '&absolute',
            async: false
        }).responseText;
        JSdebugger("getDynamicImageDimension:" + url);
        return url;
    }
    
    function getDynamicImage(imgUrl,width,height,isGallery,isGalleryMaximized){
        if (typeof isGalleryMaximized == 'undefined' ) isGalleryMaximized = false;

        if( isGalleryMaximized ){
            if( embed_gallery_logo.length > 0 || ( max_gallery_image_dimension.length > 0 && max_gallery_image_dimension > 0 ) ){
                if( max_gallery_image_dimension.length > 0 && max_gallery_image_dimension > 0 ){
                    width = max_gallery_image_dimension;
                }else width = 0;
                height = width;
            }
        }
        JSdebugger("getDynamicImage(" + imgUrl + "," + width + "," + height + "," + isGallery + "){");
        
        var dynImgUrl = "";
        
        var quality = "95";
        var embedLogo = "0";
        if( isGallery && embed_gallery_logo.length > 0 )
            embedLogo = "1";
        
        if( !isGalleryMaximized ){
            var imgUrlNew = imgUrl.replace("http://","");
            imgUrlNew = imgUrlNew.replace(/\./g,"_");
            
            dynImgUrl = imagesAPIcontainerUrl + imgUrlNew + "-" + width + "-" + height + "-" + quality + "-" + "0" + "-" + "0" + "-" + embedLogo + ".jpg";
        }else{
            dynImgUrl = imagesAPIurl + "?q=" + imgUrl + "," + width + "," + height + "," + quality + "," + "saveNgetFile" + "," + "" + "," + "" + "," + "0" + "," + "" + "," + "" + "," + embedLogo;
        }
        
        JSdebugger("getDynamicImage:" + dynImgUrl);
        return dynImgUrl;
    }
    
    function goGalerieNav(image,count,folder,table,id,waited,lastImage,reload){
        if( !galerieGoNextEnabled )
            return;
        if( typeof(reload) == "undefined" ) reload = false;
        
        if(!reload)
            goGalerieNavImage = image;
        
        if( !reload ){
            setTimeout("goGalerieNav('" + image + "','" + count + "','" + folder + "','" + table + "','" + id + "','" + waited+ "','" + image + "',1)",300);
            return;
        }else{
            if( lastImage != goGalerieNavImage && goGalerieNavImage.length > 0 ){
                JSdebugger("goGalerieNav: skip");
                return;
            }
        }
        
        //$("#web20GalImg").css("background-image","url(/eigenedateien/designs/html/loading.gif)");
        
        web20GalImgHoverNavHide();
        //$("#GalerieNavContainer20").hide();
        //$("#web20GalImgSrc").attr("src","/eigenedateien/designs/html/transparent.gif");
        //$("#web20GalImgLnk").css("background-color","transparent");
        
        if( web20GalTextLoaded == true || !showGalerieDescr ){
            
            web20NxtTicksLeft = 10;
            
            var virtualUrl = document.location.href;
            var p = virtualUrl.indexOf("&sI=") + 4;
            var tmp = virtualUrl.substring(p);
            var p2 = tmp.indexOf("&");
            virtualUrl = virtualUrl.substring(0,p) + image + virtualUrl.substring(p + p2);
            
            //google analytics
            pageTracker._trackPageview( virtualUrl );
            
            web20ActiveGalSizeCheck++;            
    
            document.getElementById('GalerieNavContainer20').innerHTML = getGalerieNav(image,count,folder,table,id);
            
            var nextImg = image*1 + 1;
            if( nextImg > count ) nextImg = 1;
            
            if( galerieClickCmdShowNext )
                document.getElementById("web20GalImgLnk").href = 'javascript:goGalerieNav(\'' + nextImg + '\',\'' + count + '\',\'' + folder + '\',\'' + table + '\',\'' + id + '\');';
            else if( embed_gallery_logo.length > 0 || ( max_gallery_image_dimension.length > 0 && max_gallery_image_dimension > 0 ) )
                document.getElementById("web20GalImgLnk").href = getDynamicImage(folder + '(' + image + ').jpg',0,0,true,true);
            else
                document.getElementById("web20GalImgLnk").href = folder + '(' + image + ').jpg';
            
            web20NxtImageSrc = folder + '(' + image + ').jpg';
            
            var address = document.location.href;
            if( address.indexOf("#") > -1 ){
                address = address.substring(0, address.indexOf("#") );
            }
            ignoreHash = true;  //open a semaphore here
                document.location.href = address + "#img:"+ image;
                href = address + "#img:"+ image;
            ignoreHash = false;
            
            if( web20NxtImageRunning == false )
                callPrepareGalImg();
    
            web20ActiveGalImg = image;
        }
    }
    
    //this functions is need to let the user change his decision in a very short period of time.
    //avoids flickering when going through gallery very fast
    //var web20NxtImageSrc = "";
    //var web20NxtTicksLeft = 5;

    
    function callPrepareGalImg(){
        
        web20NxtImageRunning = true;

        if( web20NxtTicksLeft < 1 ){
            prepareGalImg("web20GalImg",web20NxtImageSrc,true);
            web20NxtImageRunning = false;
        }else{
            web20NxtTicksLeft--;
            setTimeout("callPrepareGalImg();",5);
        }
        
    }
    
    function getGalerieMMSInfo(table,id,image){
        //receive image Ident Number for premium sms service
        AjaxReceiveType = 11;
        url = active_host + 'code/lese_global.php?start=getMmsIdent&tableID=' + table + '&modulID=' + id + '&imgID=' + image;
        makeRequest(url);
        return false;
    }
    
    function showGalerieMMSInfo(data){
        var pos = data.indexOf("<value>");
        data = data.substr(pos + ("<value>").length);
        pos = data.indexOf("<" + "/value>");
        data = data.substr(0,pos);

        document.getElementById('GalerieNavContainer20NavBText').innerHTML = "<h2>Achtung dieser Service ist nicht kostenlos!</h2><h5>(99 Cent pro Bild zzgl. Transponderleistung)</h5><h2>Schicke einfach eine SMS mit dem Inhalt:</h2><h2> " + smsPremiumKey1 + " " + smsPremiumKey2 + " " + data + "</h2><h2> an die Servicenummer: " + premiumSmsShortNum + "</h2><div></div>"
    }
    
    function getGalerieRatings(table,id,image){
        //receive image Ident Number for premium sms service
        if( prepareGalImgFinished && prepareGalerieDescrFinished ){ //give the other requests time to finish
            prepareGalerieRatingsFinished = false;
            AjaxReceiveType = 12;
            url = active_host + 'code/lese_global.php?start=getGalerieRatingsPosition&tableID=' + table + '&modulID=' + id + '&imgID=' + image;
            makeRequest(url);
        }else{
            prepareGalerieRatingsFinished = false;
            setTimeout("getGalerieRatings('" + table + "','" + id + "','" + image + "');",500);
        }
    }
    
    function setGalerieRatingSelectionVisible(tableID,modulID,imgID){

        data = '<h2>Bewertung nach dem Schulnotensystem.</h2><h2>Note 1 f&uuml;r sehr gut - Note 6 f&uuml;r gef&auml;llt mir gar nicht</h2><div id="GalerieNavContainerRatingSelection">';
        for( var i=1; i<=6; i++){
            data+= '<span><h3><a href=\"\" onclick=\"return setGalerieRatingValue(\'' + tableID + '\',\'' + modulID + '\',\'' + imgID + '\',\'' + (7-i) + '\');"\">' + i + '</a>&nbsp;&nbsp;</h3></span>'
        }
        data+= '</div>';
        
        document.getElementById('GalerieNavContainerRatingText').innerHTML = data;
        return false;
    }
    
    function setGalerieRatingValue(tableID,modulID,imgID,rating){
        AjaxReceiveType = 13;
        url = active_host + 'code/schreibe_global.php?start=setGalerieRatings&tableID=' + tableID + '&modulID=' + modulID + '&imgID=' + imgID + "&rating=" + rating;
        makeRequest(url);
        return false;
    }
    
    function galerieRatingValueSet(data){
        var value = getXMLvalue(data,"value");
        document.getElementById('GalerieNavContainerRating').innerHTML = "<div><h2>Vielen Dank f&uuml;r die Bewertung</h2></div>"
    }
    
    function getXMLvalue(data,name){
        var pos = data.indexOf("<" + name + ">");
        data = data.substr(pos + ("<" + name + ">").length);
        pos = data.indexOf("<" + "/" + name + ">");
        data = data.substr(0,pos);
        return data;
    }
    
    function showGalerieRatings(data){
        
        var value =     getXMLvalue(data,"value");
        value *= 1;
        var hasRated =  getXMLvalue(data,"hasRated");
        hasRated *= 1;
        var tableID =   getXMLvalue(data,"tableID");
        var modulID =   getXMLvalue(data,"modulID");
        var imgID =     getXMLvalue(data,"imgID");
        
        var text;
        
        if( hasRated )
            return;

        if( value > 0 ){
            if( value <= 100 )
                text = "Bild bewerten";//"Dieses Bild ist auf Platz " + value + " unserer Top 100 Bilder.";
            else
                text = "Bild bewerten";//"Dieses Bild ist auf Platz " + value + " unserer Top Bilder.";
        }else if(value == 0 ){
            text = "Bild bewerten";
        }else text = "Bild bewerten"; //"Dieses Bild benoetigt noch mehr Bewertungen, um in unsere Top 100 Bilder aufgenommen zu werden.";

        if( hasRated == 0 ){
            data = "<div><h3><a href=\"#\" onclick=\"return setGalerieRatingSelectionVisible('" + tableID + "','" + modulID + "','" + imgID + "');\">" + text + "</a></h3><div id=\"GalerieNavContainerRatingText\"></div></div>";
        }else{
            data = "<div><h3>" + text + "</h2></div>";
        }
        document.getElementById('GalerieNavContainerRating').innerHTML = data;
        prepareGalerieRatingsFinished = true;
    }

    function showNavToolTip(){
        if( navToolTipShown )
            return;
        if( !$(".pageSwitcherToolTip").is(":visible") ){
            $(".pageSwitcherToolTip").animate({
                height: 'toggle'
            }, 300, function() {
                navToolTipShown = true;
            });
        }
    }
    
    function getGalerieNav(image,count,folder,table,id){
        var visible = galerieNavVisible;
        
        var lessimg = image*1 - 1;
        var moreimg = image*1 + 1;
        if( lessimg < 1 ) lessimg = count;
        if( moreimg > count ) moreimg = 1;
        web20GalPrevImg = 'goGalerieNav(\'' + lessimg + '\',\'' + count + '\',\'' + folder + '\',\'' + table + '\',\'' + id + '\');'
        var less = web20GalPrevImg + 'return false;';
        web20GalNextImg = 'goGalerieNav(\'' + moreimg + '\',\'' + count + '\',\'' + folder + '\',\'' + table + '\',\'' + id + '\');';
        var more = web20GalNextImg + 'return false;';
        
        prepareGalerieDescrFinished = false;
        if( !showGalerieDescr )
            prepareGalerieDescrFinished = true;
            
        prepareGalImgFinished = false;
        getGalerieRatings(table,id,image);
        
        var data = "";
        data +="<div id=\"GalerieNavContainer20NavA\">"; //level0
            if( visible ){
                
                if( pageSwitchType == 0 || pageSwitchType == 1 ){
                
                    var bttnLeft;
                    var bttnRight;
                    
                    if( pageSwitchType == 0 ){
                            bttnLeft = '<img src="./eigenedateien/designs/html/navLeft.gif\" alt="Back">';
                            bttnRight = '<img src="./eigenedateien/designs/html/navRight.gif\" alt="Forward">';
                    }else{
                            bttnLeft = '<h3>&lt;&lt;&lt;</h3>';
                            bttnRight = '<h3>&gt;&gt;&gt;</h3>';
                    }
                
                    data += "<div class=\"pageSwitcher20\" onmouseover=\"showNavToolTip();\">";//level1
                        data += "<div class=\"sitesGal20\"><h2>Bild " + image + " von " + count + "</h2></div>";
                        data+= "<div class=\"pageSwitchGal20_" + pageSwitchType + "\">";//level2
                                data+= "<div class=\"pageSwitchLeftGal\">";//level3
                                        data+= "<a href=\"#\" onclick=\"" + less + "\">" + bttnLeft + "</a>";
                                data+= "</div><div class=\"pageSwitchRightGal\">";//level3 close /level3
                                        data+= "<a href=\"#\" onclick=\"" + more + "\">" + bttnRight + "</a>";
                                data+= "</div>";//close level3
                        data+= "</div>";//close level2
                        data+= '<div class=\"pageSwitcherToolTip\">Schon gewusst? Du kannst auch mit den Pfeiltasten navigieren!</div>';
                    data+= "</div>";//close level1
                
                }
            }
            if( galerieClickCmdShowNext )
                data+= "<div class=\"galDownload20\"><h2><a target=\"_blank\" href=\"" + folder + "(" + image + ").jpg" + "\">Herunterladen</a></h2></div>";

            data += '<div id="GalerieNavDownload"><h3><a href="' + folder + '(' + image + ').jpg' + '" target="_blank">Bild downloaden</a></h3></div>';
            data +='<div id="GalerieNavContainerRating"></div>';
            //data+='<div id="GalerieNavContainer20NavB"><h3><a href="#" onclick="return getGalerieMMSInfo(\'' + table + '\',\'' + id + '\',\'' + image + '\');">Bild per MMS auf ein Handy schicken</a></h3><div id=\"GalerieNavContainer20NavBText\"></div></div>';
            data+='</div>';//level0
        return data;
    }

    function drawGalImg(path){
        var imgsrc = path;
        
        var galerie = false;
        if( imgsrc.indexOf('/gross/') > -1 )
            galerie = true;

        if( !galerie ){
            /*document.getElementById("imageBorderGal20").style.width = width + 'px';
            document.getElementById("imageBorderGal20").style.height = height + 'px';
            document.getElementById("imageBorderGal20").style.marginLeft = (-1*Math.round(width/2)) + 'px';
            document.getElementById("imageBorderGal20").style.top = '0px';*/
            $("#PopupDescr").css("float","right");
        }else{
            $("#PopupDescr").css("float","left");
        }

        if( galerie )
            galerieGoNextEnabled = false;
        
        $("#web20GalImgSrc").attr("src",imgsrc);
        //$("#web20GalImgLnk").fadeTo(20,0.1);

        $("#imageBorderGal20").css("padding","0px");
        
        if( galerie ){
            galerieGoNextEnabled = true;
            $("#GalerieNavContainer20").show();
        }
    }
    
    function prepareGalImg(container,imgsrc,isGalleryImage){
        var width = document.getElementById('imgBorderGalContainer20').style.width;
        width = width.replace(/px/g,"") - 6;
        var height;
        if( jsPopupActivated )
            height = document.getElementById('imgBorderGalContainer20').style.height;
        height = height.replace(/px/g,"");
        if( height <= 0 )
            height = showImgHeight;
        height = height.replace(/px/g,"");
        displayGalImg( getDynamicImage(imgsrc,width,height,isGalleryImage) );
    }
    
    function displayGalImg(path){
        setTimeout('drawGalImg("' + path + '")',0);
        if( ( ( web20Gal && web20GalTextLoaded == false ) || !showGalerieDescr ) || ( web20Popup && web20PopupTextLoaded == false ) ){
            prepareGalerieDescrFinished = false;
            if( !showGalerieDescr && !web20Popup )
                prepareGalerieDescrFinished = true;
            prepareGalImgFinished = true;
            if( showGalerieDescr || web20Popup )
                prepareGalerieDescr(web20GalTable,web20GalId);
        }
        else{
            prepareGalerieDescrFinished = true;
            prepareGalImgFinished = true;
        }
    }
    
    function prepareGalerieDescr(table,id){
        setTimeout(function(){
            $.ajax({
            url: active_host + 'code/lese_global.php?name=' + table + '&start=getRecordValue&record=zeilea,vard&htmlOutput=true&indexID=' + id,
            success: function(data) {
              getGalerieDescr(data);
            }
          });
        },10);
    }
    
    function getGalerieDescr(data){
        prepareGalerieDescrFinished = true;
        if( web20Gal ) web20GalTextLoaded = true;
        if( web20Popup ) web20PopupTextLoaded = true;
        
        var zeilea = getXMLvalue(data,"valuezeilea");
        var vard = getXMLvalue(data,"valuevard");

        if( document.getElementById('GalerieDescr20Heading') )
            document.getElementById('GalerieDescr20Heading').innerHTML = '<h2>' + zeilea + '<' + '/h2>';
        else if( document.getElementById('GalerieDescrHeading') )
            document.getElementById('GalerieDescrHeading').innerHTML = '<h2>' + zeilea + '<' + '/h2>';

        if( document.getElementById('PopupDescrHeading') )
            document.getElementById('PopupDescrHeading').innerHTML = '<h2><a target="' + showImageTarget + '" href="' + showImageLink + '">' + zeilea + '<' + '/a><' + '/h2>';
        
        if( document.getElementById('GalerieDescr20Text') )
            document.getElementById('GalerieDescr20Text').innerHTML = '<div class="text">' + vard + '<div id="descrFb" class="fb_share_standalone"></div><' + '/div>';
        else if( document.getElementById('GalerieDescrText') )
            document.getElementById('GalerieDescrText').innerHTML = '<div class="text">' + vard + '<div id="descrFb" class="fb_share_standalone"></div><' + '/div>';
            
        if( document.getElementById('PopupDescrText') )
            document.getElementById('PopupDescrText').innerHTML = '<div class="text">' + vard + '<div id="descrFb" class="fb_share_standalone"></div><' + '/div>';
        
        if( document.getElementById('GalerieDescr20') ){
            document.getElementById('GalerieDescr20').style.backgroundImage = 'none';//'url("")';
        }else{
            if( document.getElementById('GalerieDescr') ){
                document.getElementById('GalerieDescr').style.backgroundImage = 'none';//'url("")';
                if( web20Popup )
                    document.getElementById('GalerieDescr').style.display = 'block';
            }
            if( document.getElementById('PopupDescr') ){
                document.getElementById('PopupDescr').style.backgroundImage = 'none';//'url("")';
                document.getElementById('PopupDescr').style.height = 'auto';
                if( web20Popup )
                    document.getElementById('PopupDescr').style.display = 'block';
            }
        }
        if( $("#descrFb").length > 0 ){
            putShareButton( "descrFb" );
        }
    }

    function web20GalImgHoverNavShow(){
        if( $("web20GalImgClose").length > 0 ){
            document.getElementById('web20GalImgClose').style.display = 'block';
            document.getElementById('web20GalImgLeft').style.display = 'block';
            document.getElementById('web20GalImgRight').style.display = 'block';
        }
    }
    
    function web20GalImgHoverNavHide(){
        if( $("web20GalImgClose").length > 0 ){
            document.getElementById('web20GalImgClose').style.display = 'none';
            document.getElementById('web20GalImgLeft').style.display = 'none';
            document.getElementById('web20GalImgRight').style.display = 'none';
        }
    }

    function showGalerie20(height,table,datum,id,image,max){
        web20Gal = true;
        jsPopupActivated = true;
        var top = 170;
        var width = 790;
        web20GalNavHeight = 74;
        web20ActiveGalImg = image;
        web20GalTable =  table;
        web20GalId = id;
        web20GalTextLoaded = false;
        web20MaxImages = max;
        scroll(0,0);
        greyHTML();
    
        var imgFolder = global_domain + 'eigenedateien/' + table + '/' + datum + '/gross/';
        
        web20ImgFolder = imgFolder;

        nextImg = image*1 + 1;

        if( nextImg > max ) nextImg = 1;
        lastImg = image*1 -1;
        if( lastImg < 1 ) lastImg = max;
        
        if( galerieClickCmdShowNext ){
            nextImgLnk = 'javascript:goGalerieNav(\'' + nextImg + '\',\'' + max + '\',\'' + imgFolder + '\',\'' + table + '\',\'' + id + '\');';
            lastImgLnk = 'javascript:goGalerieNav(\'' + lastImg + '\',\'' + max + '\',\'' + imgFolder + '\',\'' + table + '\',\'' + id + '\');';
            nextImgTarget = "_self";
        }else{
            if( embed_gallery_logo.length > 0 )
                document.getElementById("web20GalImgLnk").href = getDynamicImage(folder + '(' + image + ').jpg',0,0,true,true);
            else
                nextImgLnk = imgFolder + "(" + image + ").jpg";
            nextImgTarget = "_blank;";
        }

        var data = '<div id="imgBorderGalContainer20" style="width:' + width + 'px;height:' + (700) + 'px;">';
        data+= '<div id="imageBorderGal20" style="position:absolute;left:50%;top:200px;margin-left:' + (-1*Math.round(100/2-1)) + 'px;width:' + (100) + 'px;height:' + (100) + 'px;" onmouseover="web20GalImgHoverNavShow()" onmouseout="web20GalImgHoverNavHide()">';
        data+= '<div id="web20GalImg" style="padding:0px;margin:0px;';
        data+= 'background-repeat: no-repeat;  background-position: center;">';
        data+='<a id="web20GalImgLnk" target="' + nextImgTarget + '" href="' + nextImgLnk + '"><img id="web20GalImgSrc" src="./eigenedateien/designs/html/transparent.gif"></a>';
            data+='<div id="web20GalImgClose"><span><a href="#" onclick="return hideJsPopup();">X</a></span></div>';
            data+='<div id="web20GalImgLeft"><span><a href="" onclick="return goGaleriePrev();">&lt;</a></span></div><div id="web20GalImgRight"><span><a href="" onclick="return goGalerieNext();">&gt;</a></span></div>';
        data+='</div></div>';
        data+= '<div id="GalerieNavContainer20">' + getGalerieNav(image,max,imgFolder,table,id) + '</div></div>';
        //data+= '<div id="GalerieNavContainer20">' + getGalerieNav(image,max,imgFolder,table,id,showNavigation) + '</div>';
      //  data+= '<div id="GalerieDescr20" style="background-image:url(\'./eigenedateien/designs/html/loading.gif\');"><div id="GalerieDescr20Heading"></div><div id="GalerieDescr20Text"></div></div>';
        
        document.getElementById('jsPopup').style.zIndex="12";

	document.getElementById('jsPopup').style.backgroundColor = 'transparent';
        
        document.getElementById('jsPopup').style.position='absolute';
        
        if( web20Centered ){
            document.getElementById('jsPopup').style.marginLeft = (-1 * Math.round(width/2)-1) + "px";
            document.getElementById('jsPopup').style.left = "50%";
        }
        document.getElementById('jsPopup').style.top = top + "px";
        document.getElementById('jsPopup').style.width = width + "px";
        document.getElementById('jsPopup').style.height = height + "px";
        document.getElementById('jsPopup').style.display = 'block';
        document.getElementById('jsPopup').style.visibility = 'hidden';
        document.getElementById('jsPopup').innerHTML = data;

	prepareGalImg("web20GalImg",imgFolder + '(' + image + ').jpg',true);

        //some browsers don't work with the usual back-button way (for instance ie7), so make an iframe here:
        if( dall ){
                document.getElementById('jsPopupHistory').style.display ='block';
                document.getElementById('jsPopupHistory').style.visibility = 'hidden';
                document.getElementById('jsPopupHistory').style.position ='absolute';
                document.getElementById('jsPopupHistory').style.top = "0px";
                document.getElementById('jsPopupHistory').style.left = "0px";
                document.getElementById('jsPopupHistory').style.border = "1px solid black";
                document.getElementById('jsPopupHistory').style.width = "100px";
                document.getElementById('jsPopupHistory').style.height = "100px";
                document.getElementById('jsPopupHistory').style.zIndex=16;
                document.getElementById('jsPopupHistory').innerHTML = '<' + 'iframe src="history2.php"><' + '/iframe>';
        }
    
        if( document.location.href.substr(document.location.href.length-1,1) == '#' ){
                 s = 'jsPopup';
        }
        else{
                if( ( document.location.href.substr(document.location.href.length-8,8) == '#jsPopup' || document.location.href.substr(document.location.href.length-8,8) == '&jsPopup' ) || ( document.location.href.substr(document.location.href.length-9,9) == '#hjsPopup' || document.location.href.substr(document.location.href.length-9,9) == '&hjsPopup' ) ) s = '';
            else{
                if( document.location.href.indexOf('#') > -1 )
                    s = "&jsPopup";
                else
                    s = '#jsPopup';
            }
        }
        document.location.href = document.location.href + s;
        return false;
    }

    function showFlash20(flashUrl,flashParams,flashVars,name,width,height){
        var top = 219;
        scroll(0,0);
        greyHTML();
    
        document.getElementById('jsPopup').style.zIndex="12";
	document.getElementById('jsPopup').style.backgroundColor = jsPopupBackgroundColor;
        document.getElementById('jsPopup').style.position='absolute';
        if( web20Centered ){
            document.getElementById('jsPopup').style.marginLeft = (-1 * (Math.round(width/2)+5)) + "px";
            document.getElementById('jsPopup').style.left = "50%";
        }else{
            document.getElementById('jsPopup').style.left = Math.round((990 - width)/2) + "px";
        }
        document.getElementById('jsPopup').style.top = top + "px";
        document.getElementById('jsPopup').style.width = width + "px";
        document.getElementById('jsPopup').style.height = (height+35) + "px";
        document.getElementById('jsPopup').innerHTML = '<div id="panoramaClose"><a href="#" onclick="return hideJsPopup();">Schlie&szlig;en<' + '/a><' + '/div>' + returnFlashObject(flashUrl,flashParams,flashVars,name,width,height);

        //some browsers don't work with the usual back-button way (for instance ie7), so make an iframe here:
        if( dall ){
                document.getElementById('jsPopupHistory').style.display ='block';
                document.getElementById('jsPopupHistory').style.visibility = 'hidden';
                document.getElementById('jsPopupHistory').style.position ='absolute';
                document.getElementById('jsPopupHistory').style.top = "0px";
                document.getElementById('jsPopupHistory').style.left = "0px";
                document.getElementById('jsPopupHistory').style.border = "1px solid black";
                document.getElementById('jsPopupHistory').style.width = "100px";
                document.getElementById('jsPopupHistory').style.height = "100px";
                document.getElementById('jsPopupHistory').style.zIndex=16;
                document.getElementById('jsPopupHistory').innerHTML = '<' + 'iframe src="history2.php"><' + '/iframe>';
        }
    
        if( document.location.href.substr(document.location.href.length-1,1) == '#' ){
                 s = 'jsPopup';
        }
        else{
                if( ( document.location.href.substr(document.location.href.length-8,8) == '#jsPopup' || document.location.href.substr(document.location.href.length-8,8) == '&jsPopup' ) || ( document.location.href.substr(document.location.href.length-9,9) == '#hjsPopup' || document.location.href.substr(document.location.href.length-9,9) == '&hjsPopup' ) ) s = '';
            else{
                if( document.location.href.indexOf('#') > -1 )
                    s = "&jsPopup";
                else
                    s = '#jsPopup';
            }
        }
        document.location.href = document.location.href + s;
        jsPopupActivated = true;
        return false;
    }

    function showImage(container,height,table,datum,id,art){
        var top = 170;
        var image = 1;
        if( art == "popup" )
            image = "poster.jpg";
        JSdebugger('showImage(' + container + ',' + height + ',' + table + ',' + datum + ',' + id + ',' + art + ')');

        showImgHeight = height;
        var width = document.getElementById("overview-content").style.width;
        width = width.replace(/px/g,"");
        width = 555;
        //alert(width);
        web20Popup = true;
        web20PopupTextLoaded = false;
        web20GalTable =  table;
        web20GalId = id;

        var imgFolder
        
        if( art == "popup" )
            imgFolder = global_domain + "eigenedateien/" + table + "/" + datum + "/";
        else
            imgFolder = global_domain + 'eigenedateien/' + table + '/' + datum + '/gross/';

        var nextImgLnk;
        var nextImgTarget;

        if( galerieClickCmdShowNext ){
            nextImgLnk = '#';
            nextImgTarget = "_self";
        }else{
            if( art == "popup" )
                nextImgLnk = imgFolder + "poster.jpg";
            else{
                if( embed_gallery_logo.length > 0 )
                    nextImgLnk = getDynamicImage(imgFolder + '(' + image + ').jpg',0,0,true,true);
                else
                    nextImgLnk = imgFolder + "(" + image + ").jpg";
            }
            nextImgTarget = "_blank;";
        }
        
        showImageLink = nextImgLnk;
        showImageTarget = nextImgTarget;

        //document.getElementById("web20GalImgLnk").href = folder + '(' + image + ').jpg';
        var data = '<div id="imgBorderGalContainer20" style="position:relative; width:' + Math.round(width/2) + 'px;';
            if( art == "popup" )
                data+= 'float:left;';
            data+= '">';
	    data+= '<div id="imageBorderGal20" style="padding:20px">';// style="position:absolute;left:50%;top:' + Math.round(height/2-32-10) + 'px;margin-left:' + (-1*Math.round(100/2-1)) + 'px;width:' + (100) + 'px;height:' + (100) + 'px;">';
	    data+= '<div id="web20GalImg" style="padding:0px;margin:0px;';
	    data+= 'background-repeat: no-repeat;  background-position: center;">';
	    data+='<a id="web20GalImgLnk" href="' + nextImgLnk + '" target="' + nextImgTarget + '"><img id="web20GalImgSrc" src="./eigenedateien/designs/html/transparent.gif"></a></div></div></div>';
	    //data+= '<div id="GalerieNavContainer20"><div id="GalerieNavContainer20NavA"><a target="_blank" href="' + imgFolder + '(1).jpg' + '"><h2>Bild in Originalgr&ouml;&szlig;e herunterladen</h2></a></div>';
        if( art == "popup" )
            data+= '</div>';
        else
            data+= '<div id="GalerieNavContainer20navB"></div></div>';
            
            
        if( art == "popup" )
            data+= '<div id="PopupDescr" style="background-image:url(\'./eigenedateien/designs/html/loading.gif\');"><div id="PopupDescrHeading"></div><div id="PopupDescrText"></div></div>';
        else
            data+= '<div id="GalerieDescr" style="background-image:url(\'./eigenedateien/designs/html/loading.gif\');"><div id="GalerieDescrHeading"></div><div id="GalerieDescrText"></div></div>';

        document.getElementById(container).innerHTML = data;

	if( art == "popup" )
            prepareGalImg("web20GalImg",imgFolder + "poster.jpg",false);
        else
            prepareGalImg("web20GalImg",imgFolder + '(' + image + ').jpg',false);

    }

    function showGalerie(container,height,table,datum,id,image,max,showNavigation){
        galerieNavVisible = showNavigation;
        
        web20Gal = true;
        var top = 170;
        showImgHeight = height;
        var width = document.getElementById("overview-content").style.width;
        width = width.replace(/px/g,"");
        width = 562;
        width-=2;
        //alert(width);
        web20ActiveGalImg = image;
        web20Popup = true;
        web20PopupTextLoaded = false;
        web20GalTable =  table;
        web20GalId = id;
        web20MaxImages = max;

        var nextImg = image*1 + 1;
        var count = max;

        var imgFolder = global_domain + 'eigenedateien/' + table + '/' + datum + '/gross/';
        web20ImgFolder = imgFolder;

        var data = '<div id="imgBorderGalContainer20" style="position:relative; width:' + width + 'px;">';
	    //data+= '<div id="imageBorderGal20" style="position:absolute;left:50%;top:' + Math.round(height/2-32-10) + 'px;margin-left:' + (-1*Math.round(100/2-1)) + 'px;width:' + (100) + 'px;height:' + (100) + 'px;">';
        data+= '<div id="imageBorderGal20" style="padding:20px">';
	    data+= '<div id="web20GalImg" style="padding:0px;margin:0px;';
	    data+= 'background-repeat: no-repeat;  background-position: center;">';
            
            var nextImgLnk;
            var nextImgTarget;
            
            if( galerieClickCmdShowNext ){
                nextImgLnk = 'javascript:goGalerieNav(\'' + nextImg + '\',\'' + count + '\',\'' + imgFolder + '\',\'' + table + '\',\'' + id + '\');';
                nextImgTarget = "_self";
            }else{
                if( embed_gallery_logo.length > 0 )
                    nextImgLnk = getDynamicImage(imgFolder + '(' + image + ').jpg',0,0,true,true);
                else
                    nextImgLnk = imgFolder + "(" + image + ").jpg";
                nextImgTarget = "_blank;";
            }

            
	   if( showNavigation )
                data+='<a id="web20GalImgLnk" target="' + nextImgTarget + '" href="' + nextImgLnk + '"><img id="web20GalImgSrc"  src="./eigenedateien/designs/html/transparent.gif"></a></div></div></div>';
            else
                data+='<img id="web20GalImgSrc"  src="./eigenedateien/designs/html/transparent.gif"></div></div></div>';
                
             data+= '<div id="GalerieNavContainer20">' + getGalerieNav(image,max,imgFolder,table,id,showNavigation) + '</div>';
            
            data+= '<div id="GalerieDescr" style="background-image:url(\'./eigenedateien/designs/html/loading.gif\');"><div id="GalerieDescrHeading"></div><div id="GalerieDescrText"></div></div>';

        //document.getElementById(container).innerHTML = data;
        
        $("#" + container).html(data);
        
        setTimeout( function(){
            if( galerieCacheImages > 0 ){
                var data = '';
                for( i = 0; i<= galerieCacheImages; i++ ){
                    data +='<img id="imgCache' + i + '">';
                }
                $("#showImageCacheContainer").html(data);
            }
            $("#web20GalImgSrc").load(function(){
                if( $(this).attr("src").indexOf("transparent.gif") == -1 ){
                    if( galerieCacheImages > 0 ){
                        for( i = 0; i<= galerieCacheImages; i++ ){
                            $("#imgCache" + i).attr("src", getNextImgSrc( $(this).attr("src"), (i+1)) );
                        }
                    }
                }
            });
        }, 100);
        
	prepareGalImg("web20GalImg",imgFolder + '(' + image + ').jpg',true);
    }
    
    function getNextImgSrc(src,nextCount){
        if( typeof(nextCount) == "undefined" )
            nextCount = 1;
        var nextImg = src;
        var start = nextImg.indexOf("/gross/(");
        var end = nextImg.indexOf(")_");
        nextImg = parseFloat( nextImg.substring(start+8,end) ) + nextCount;
        var nextImgSrc = src.substring(0,start+8) + nextImg + src.substring(end);
        return nextImgSrc;
    }

    function showPopup(height,table,datum,id){
        var top = 170;
        var width = 900;
        var image = 1;
        web20Popup = true;
        web20PopupTextLoaded = false;
        scroll(0,0);
        greyHTML();
        web20GalTable =  table;
        web20GalId = id;

    
        var imgFolder = global_domain + 'eigenedateien/' + table + '/' + datum + '/gross/';

        //var data = '<div id="imgBorderGalContainer20" style="width:' + width + 'px;height:' + (height) + 'px;">';
        var data = '<div id="imgBorderGalContainer20" style="width:' + width + 'px;">';
	    data+= '<div id="imageBorderGal20" style="position:absolute;left:50%;top:40%;margin-left:' + (-1*Math.round(100/2-1)) + 'px;width:' + (100) + 'px;height:' + (100) + 'px;">';
	    data+= '<div id="web20GalImg" style="padding:0px;margin:0px;';
	    data+= 'background-repeat: no-repeat;  background-position: center;">';
	    data+='<a id="web20GalImgLnk" href="#"><img id="web20GalImgSrc" src="./eigenedateien/designs/html/transparent.gif"></a></div></div></div>';
	    data+= '<div id="GalerieNavContainer20" style="text-align:center;"><a target="_blank" href="' + imgFolder + '(1).jpg' + '">Bild in Originalgr&ouml;&szlig;e herunterladen</a></div>';
           // data+= '<div id="GalerieDescr20" style="background-image:url(\'./eigenedateien/designs/html/loading.gif\');"><div id="GalerieDescr20Heading"></div><div id="GalerieDescr20Text"></div></div>';

        
	
        document.getElementById('jsPopup').style.zIndex="12";
	document.getElementById('jsPopup').style.backgroundColor = jsPopupBackgroundColor;
        document.getElementById('jsPopup').style.position='absolute';
        if( web20Centered ){
            document.getElementById('jsPopup').style.marginLeft = (-1 * Math.round(width/2)-1) + "px";
            document.getElementById('jsPopup').style.left = "50%";
        }
        document.getElementById('jsPopup').style.top = top + "px";
        document.getElementById('jsPopup').style.width = width + "px";
        document.getElementById('jsPopup').style.height = height + "px";
        document.getElementById('jsPopup').style.display = 'block';
        document.getElementById('jsPopup').style.visibility = 'hidden';
        document.getElementById('jsPopup').innerHTML = data;

	prepareGalImg("web20GalImg",imgFolder + '(' + image + ').jpg',false);

        //some browsers don't work with the usual back-button way (for instance ie7), so make an iframe here:
        if( dall ){
                document.getElementById('jsPopupHistory').style.display ='block';
                document.getElementById('jsPopupHistory').style.visibility = 'hidden';
                document.getElementById('jsPopupHistory').style.position ='absolute';
                document.getElementById('jsPopupHistory').style.top = "0px";
                document.getElementById('jsPopupHistory').style.left = "0px";
                document.getElementById('jsPopupHistory').style.border = "1px solid black";
                document.getElementById('jsPopupHistory').style.width = "100px";
                document.getElementById('jsPopupHistory').style.height = "100px";
                document.getElementById('jsPopupHistory').style.zIndex=16;
                document.getElementById('jsPopupHistory').innerHTML = '<' + 'iframe src="history2.php"><' + '/iframe>';
        }
    
        if( document.location.href.substr(document.location.href.length-1,1) == '#' ){
                 s = 'jsPopup';
        }
        else{
                if( ( document.location.href.substr(document.location.href.length-8,8) == '#jsPopup' || document.location.href.substr(document.location.href.length-8,8) == '&jsPopup' ) || ( document.location.href.substr(document.location.href.length-9,9) == '#hjsPopup' || document.location.href.substr(document.location.href.length-9,9) == '&hjsPopup' ) ) s = '';
            else{
                if( document.location.href.indexOf('#') > -1 )
                    s = "&jsPopup";
                else
                    s = '#jsPopup';
            }
        }
        document.location.href = document.location.href + s;
        jsPopupActivated = true;
        return false;
    }

    function initAdScroller(id){
        var ad = document.getElementById('adScroller' + id);
        
        var adBox = document.getElementById('adScrollerBox' + id);
        
        var adImgs = document.getElementById('adScrollerImageContent' + id);
        
        var items = adImgs.getElementsByTagName("div");
        var itemsCount = items.length;

        adScrollerPaused[id] = false

        if( itemsCount > 0 ){
            
            var widthLeft = 536;//parseInt(adBox.style.width);
            var adBoxHtml = '<div class="adScollerImageContent" id="adScrollerImageContent' + id + '1">' + adImgs.innerHTML + '</div><div class="adScollerImageContent" id="adScrollerImageContent' + id + '2">' + adImgs.innerHTML + '</div>';
            var i = 2;
            
            var widthVal = 135;
            
            while( widthLeft > 0 ){
                i++;
                adBoxHtml += '<div class="adScollerImageContent" id="adScrollerImageContent' + id + i + '">' + adImgs.innerHTML + '</div>';
                widthLeft -= itemsCount*widthVal;
            }
            
            adBox.innerHTML = adBoxHtml;
            //$(".adScollerImageContent").css("float","left");
            //$(".adScollerImageContent").css("margin-left","-" + (i-1) + "px");
            
            widthLeft = 536;
            var maxI = i;
            i = 0;
            
            while( widthLeft > 0 ){
                i++;
                var adScrEl = document.getElementById('adScrollerImageContent' + id + i);
                adScrEl.style.width = itemsCount*widthVal + 'px';
                $('#adScrollerImageContent' + id + i).css("float","left");
                widthLeft -= itemsCount*widthVal;
            }
            
            $("#adScrollerBox" + id).width(itemsCount*widthVal*i*2);
            
            startAdScroller(id);
      
        }
        
    }
    
    function pauseAdScroller(id){
        adScrollerPaused[id] = true;
    }
    
    function playAdScroller(id){
        adScrollerPaused[id] = false;
    }
    
    function startAdScroller(id){
        if( !adScrollerPaused[id] ){
            var adBox = document.getElementById('adScrollerBox' + id);
            var adScr1 = document.getElementById('adScrollerImageContent' + id + '1');
            
            if( isNaN(parseInt(adScr1.style.marginLeft)) == false && parseInt(adScr1.style.width) <= (-1*parseInt(adScr1.style.marginLeft)) ){
    var widthLeft = parseInt(adBox.style.width);
                var widthLeft = 536;//parseInt(adBox.style.width);
                var adBoxHtml = '<div class="adScollerImageContent" id="adScrollerImageContent' + id + '1">' + adScr1.innerHTML + '</div><div class="adScollerImageContent" id="adScrollerImageContent' + id + '2">' + adScr1.innerHTML + '</div>';
                var i = 2;
                var items = adScr1.getElementsByTagName("div");
                var itemsCount = items.length;
                
                var widthVal = 135;
                
                while( widthLeft > 0 ){
                    i++;   
                    adBoxHtml += '<div class="adScollerImageContent" id="adScrollerImageContent' + id + i + '">' + adScr1.innerHTML + '</div>';
                    widthLeft -= itemsCount*widthVal; 
                }
                
                adBox.innerHTML = adBoxHtml;
                //$(".adScollerImageContent").css("margin-left","-" + (i-1) + "px");
                //$(".adScollerImageContent").css("float","left");
                
                widthLeft = 536;
                var maxI = i;
                i = 0;
                
                while( widthLeft > 0 ){
                    i++;
                    var adScrEl = document.getElementById('adScrollerImageContent' + id + i);
                    adScrEl.style.width = itemsCount*widthVal + 'px';
                    $('#adScrollerImageContent' + id + i).css("float","left");
                    
                    widthLeft -= itemsCount*widthVal; 
                }
                
                $("#adScrollerBox" + id).width(itemsCount*widthVal*i*2);
                
                adScrollerPos = 0;
            }
            
            adScrollerPos--;
            adScr1.style.marginLeft=adScrollerPos+'px';
        }
        setTimeout('startAdScroller(' + id + ')',adScrollerSpeed);
    }
    
    function coverClicked(){
        if( jsPopupVisible )
            hideJsPopup();
        return false;
    }
    
    function jsPopupClicked(){
        return false;
    }

