function changedaten(span)
{
    new Ajax.Request('/login/'+span,
    {
        method: 'post',
        onSuccess: function(transport)
        {
            $(span).innerHTML = transport.responseText;
        }
    }
    );
}

function galerie(webcontainerID)
{
    new Ajax.Request('/galerie',
    {
        method: 'post',
        parameters: {galerieID: webcontainerID},        
        onSuccess: function(transport)
        {
            $('galerie').innerHTML = transport.responseText;
        }
    }
    );
    
}

function film(webcontainerID)
{
    new Ajax.Request('/filminfo',
    {
        method: 'post',
        parameters: {galerieID: webcontainerID},        
        onSuccess: function(transport)
        {
            $('extra_div').innerHTML = transport.responseText;
        }
    }
    );
    
}


function newwin(url, width, height, bgurl, top, left, scrollbars, resizable)
{
    if(width > 0 && height > 0)
    {
        var jetzt = new Date();
        var name = "win_" + jetzt.getTime();
        left = left != undefined ? left : 0;
        top = top != undefined ? top : 0;
        scrollbars = (scrollbars != undefined && scrollbars == 1) ? ",scrollbars=yes" : "";
        resizable = (resizable != undefined && resizable ==1) ? ",resizable=yes" : "";
        f = window.open(url, name, "width=" + width + ",height=" + height + ",left=" + left + ",top=" + top + scrollbars + resizable);
    }else{
        f = window.open(url);
    }
    if(bgurl != undefined && bgurl != "")
            location.href = bgurl;
    f.focus;
}

function deletimage(pos,text)
{
    confirm (text+'?');
    new Ajax.Request('/deleteimages',
    {
        method: 'post',
        parameters: {position: pos},
        onCreate:function(){
            Element.hide('images_'+pos);
            // $('images_'+pos).hide;   
        }
    }
    );
       
}
function urlclick(url)
{
    new Ajax.Request('/urlklick',
    {
        method: 'post',
        parameters: {urlclick: url}
    }
    );
}

function galeriewechsel(url,webcontainerID,start)
{
    new Ajax.Request('/galeriewechsel',
    {
        method: 'post',
        parameters: {url: url, webcontainerID: webcontainerID, start: start},        
        onSuccess: function(transport)
        {
            $('galerie_div').replace(transport.responseText);
        }        
    }
    );
}

// alert(navigator.appName);
function seitenwechsel(link)
{
    new Ajax.Request('/seitenwechsel',
    {
        method: 'post',
        parameters: {url: link},            
        onSuccess: function(transport)
        {
            $('content_inhalt').replace(transport.responseText);
            
            slider1 = new Control.Slider('handle1', 'track1',{
            axis: 'vertical',
            range: $R(0, ($('scrollable1').scrollHeight-$('scrollable1').offsetHeight)/10),
            onSlide: function(v) { scrollVertical(v, $('scrollable1'), slider1);  },
            onChange: function(v) { scrollVertical(v, $('scrollable1'), slider1); }
            });
            var bla = (($('scrollable1').scrollHeight-$('scrollable1').offsetHeight)/10);
            if(bla == 0)
            {
                $('handle1').remove();
                $('track1').remove();
            }
            // Event.stopObserving('scrollable1');
            $('scrollable1').stopObserving();
            // mozilla
            Event.observe('scrollable1', 'DOMMouseScroll', wheel);
            // IE/Opera
            Event.observe('scrollable1', 'mousewheel', wheel);

        }        
    }
    );
}

function obermenue(link)
{
    new Ajax.Request('/obermenu',
    {
        method: 'post',
        parameters: {url: link},            
        onSuccess: function(transport)
        {
            $('head_nav').replace(transport.responseText);
        }        
    }
    );
}
 
function divschliessen(div)
{
    // alert(div);
    // open = false;
    $(div).hide();
    $('overlay').remove();
}

function changeimage(webcontainerID,key)
{
    new Ajax.Request('/galerieansicht',
    {
        method: 'post',
        parameters: {webcontainerID: webcontainerID, key: key},       
        onSuccess: function(transport)
        {
            $('galerie_uebersicht').innerHTML = transport.responseText;
	}
    }
    );
}
 
function galerie_bilder(webcontainerID,key)
{
    /*
    var overlay = 0;
    if(open != undefined && open == true)
    {
	overlay = 1;
    }
    open = true;
    if(overlay == 0)
    {
        */
        var objBody = $$('body')[0];
        objBody.appendChild(Builder.node('div',{id:'overlay'}));        
    // }   
    new Ajax.Request('/galerieansicht',
    {
        method: 'post',
        parameters: {webcontainerID: webcontainerID, key: key},         
        onSuccess: function(transport)
        {
            $('galerie_uebersicht').innerHTML = transport.responseText;
            var arrayPageScroll = document.viewport.getScrollOffsets();
	    var Top = 95 + arrayPageScroll[1] + (document.viewport.getHeight() / 10);
	    var Left = arrayPageScroll[0] + 50;
	    $('galerie_uebersicht').setStyle({ top: Top + 'px', left: Left + 'px' }).show();
	    $('galerie_uebersicht').observe('click', (function(event) { if (event.element().id == 'galerie_uebersicht') divschliessen('galerie_uebersicht')}));
	 //   if(overlay == 0)
	 //   {
		// stretch overlay to fill page and fade in
		var arrayPageSize = getPageSize();
                $('overlay').setStyle({ width: arrayPageSize[0] + 'px', height: arrayPageSize[1] + 'px', opacity: 0.8});
		$('overlay').observe('click', (function() {  divschliessen('galerie_uebersicht') }));
	   // }
	}
    }
    );
}

function getPageSize() {
	 var xScroll, yScroll;
	
	if (window.innerHeight && window.scrollMaxY) {	
		xScroll = window.innerWidth + window.scrollMaxX;
		yScroll = window.innerHeight + window.scrollMaxY;
	} else if (document.body.scrollHeight > document.body.offsetHeight){ // all but Explorer Mac
		xScroll = document.body.scrollWidth;
		yScroll = document.body.scrollHeight;
	} else { // Explorer Mac...would also work in Explorer 6 Strict, Mozilla and Safari
		xScroll = document.body.offsetWidth;
		yScroll = document.body.offsetHeight;
	}
	
	var windowWidth, windowHeight;
	
	if (self.innerHeight) {	// all except Explorer
		if(document.documentElement.clientWidth){
			windowWidth = document.documentElement.clientWidth; 
		} else {
			windowWidth = self.innerWidth;
		}
		windowHeight = self.innerHeight;
	} else if (document.documentElement && document.documentElement.clientHeight) { // Explorer 6 Strict Mode
		windowWidth = document.documentElement.clientWidth;
		windowHeight = document.documentElement.clientHeight;
	} else if (document.body) { // other Explorers
		windowWidth = document.body.clientWidth;
		windowHeight = document.body.clientHeight;
	}	
	
	// for small pages with total height less then height of the viewport
	if(yScroll < windowHeight){
		pageHeight = windowHeight;
	} else { 
		pageHeight = yScroll;
	}

	// for small pages with total width less then width of the viewport
	if(xScroll < windowWidth){	
		pageWidth = xScroll;		
	} else {
		pageWidth = windowWidth;
	}

	return [pageWidth,pageHeight];
}


