	var drag = false;
	var abortClose = false;
	var dragged = false;
	var globalLang = 'de';
	
	function makeDraggable(objStr,offset) {
	
			if (!offset)
				offset = 0;
				
   		new Draggable(objStr,{
				handle:objStr,
				
				onStart:function(){},
				
				onDrag:function(){drag=true;if (!dragged) {dragged=true;drag = false;}},
				
				onEnd:function(){setTimeout('dragEnd()',10);},
				
				snap: function(x,y,draggable) {
				
					function constrain(n, lower, upper) {
						if (n > upper) return upper;
						else if (n < lower) return lower;
						else return n;
					}

					element_dimensions = Element.getDimensions(draggable.element);
					parent_dimensions = Element.getDimensions(document.body);
					return[
						constrain(x, 0, parent_dimensions.width - element_dimensions.width+offset),
						constrain(y, 0, parent_dimensions.height - element_dimensions.height+offset)];
				},
				
				starteffect: function () {
					if ($('trailer_obj').innerHTML!=$('trailer_dummy').innerHTML)
						$('trailer_obj').innerHTML = $('trailer_dummy').innerHTML;					
					$('trailer_obj').style.cursor='hand';
					if (objStr=='trailerFull' && (document.trailerFullObj) && (typeof document.trailerFullObj.Stop=='function'))
						document.trailerFullObj.Stop();
					else if (document.trailerLoopObj && (typeof document.trailerLoopObj.Stop=='function'))
						document.trailerLoopObj.Stop();


				},
				
				endeffect: function () {setZIndex(objStr);if (objStr=='trailerFull' && document.trailerFullObj && (typeof document.trailerFullObj.Stop=='function')) document.trailerFullObj.Play(); else if (document.trailerLoopObj && (typeof document.trailerLoopObj.Stop=='function'))	document.trailerLoopObj.Stop();}
				
				
   		});		
	}

	function init() {

		$('bulletin').setStyle({zIndex:1});
		$('impressum').setStyle({zIndex:2});
		$('erika').setStyle({zIndex:4});
		$('shop').setStyle({zIndex:3});
		$('trailer').setStyle({zIndex:5});	
		//$('auktion').setStyle({zIndex:6});	



		makeDraggable('erika',-5);
		makeDraggable('bulletin',-5);
		makeDraggable('impressum',-5);
		makeDraggable('shop',-5);
		makeDraggable('trailer',-5);
		//makeDraggable('auktion',-5);
		
		getBulletin();


	}

	function setZIndex(objStr) {
		obj = $(objStr);
		elems_arr = ['erika','bulletin','shop','impressum','trailer'];

		currIndex = obj.style.zIndex;

		for (i=0;i<elems_arr.length;i++) {
			if ($(elems_arr[i]).style.zIndex>currIndex)
				$(elems_arr[i]).style.zIndex = $(elems_arr[i]).style.zIndex-1;
		}
		obj.style.zIndex = elems_arr.length;
		
	}

	function dragEnd() {
		drag = false;
		abortClose = false;
		
	}
	function openPage(objStr,deepOpen) {
	
		if (document.trailerLoopObj)
			if (typeof document.trailerLoopObj.Stop=='function') {
				document.trailerLoopObj.Stop();
			}	
		
		if ($('trailer_obj').innerHTML!=$('trailer_dummy').innerHTML)
				$('trailer_obj').innerHTML = $('trailer_dummy').innerHTML;		
		
		if (objStr=='erika')
			param ='erika_image='+erika_image+'&lang='+globalLang;
		else	
			param = 'lang='+globalLang;
		
		if (!deepOpen)
			deepOpen = '';
			
		
		new Ajax.Updater('fullPage', objStr+"/index.php", {parameters: param, method:"get",evalScripts:true,onComplete:function (req) {if ($(objStr+'Full')) makeDraggable(objStr+'Full',-26);if (deepOpen) openSubPage($(deepOpen).getElementsByTagName('a')[0],deepOpen); else setLang();}, onFailure:show_failure, onException:show_exception });

		$('fullPage').style.display='block';
	}


	function closePage() {
		if (!abortClose) {
			if ((document.trailerLoopObj) && (typeof document.trailerLoopObj.Stop=='function')) 
					document.trailerLoopObj.Stop();
		
			if ((document.trailerFullObj) && (typeof document.trailerFullObj.Stop=='function'))
				document.trailerFullObj.Stop();

			if ((document.erikaFilmObj) && (typeof document.erikaFilmObj.Stop=='function'))
				document.erikaFilmObj.Stop();			
				
			$('fullPage').style.display='none';
			$('fullPage').innerHTML='';
			//$('trailer').style.display='block';
			
			globalObj = null;
			globalObjSub = null;
			globalObjSubId = null;
			globalObjStr = null;
			globalParam = null;			
		
		}		

		abortClose = false;
	}
	
	
	function getBulletin() {
		param = 'lang='+globalLang;
		new Ajax.Updater('bulletin_content', "bulletin/bulletin_pre.php", {parameters: param, method:"get",evalScripts:true,onFailure:show_failure, onException:show_exception });
		
	}
	
	
	
	
	function setLang() {
		langArr = $$('div#lang a.lang');

		for (i=0;i<langArr.length;i++) {
			if (langArr[i].getAttribute('id').split('_')[1]==globalLang) 
				langArr[i].style.display='none';
			else
				langArr[i].style.display='block';
		}		
	}













function getObj(name)
{
  if (document.getElementById)
  {
  	this.obj = document.getElementById(name);
	this.style = document.getElementById(name).style;
  }
  else if (document.all)
  {
	this.obj = document.all[name];
	this.style = document.all[name].style;
  }
  else if (document.layers)
  {
   	this.obj = document.layers[name];
   	this.style = document.layers[name];
  }
}


var clipTop = 0;
var clipWidth = 330;
var clipBottom = 500;
var topper = 10;
var lyrheight = 0;
var time,amount,theTime,theHeight,DHTML;

function initScroll()
{
	DHTML = (document.getElementById || document.all || document.layers)
	if (!DHTML) return;
	var x = new getObj('fullContent');
	if (document.layers)
	{
		lyrheight = x.style.clip.bottom;
		lyrheight += 20;
		x.style.clip.top = clipTop;
		x.style.clip.left = 0;
		x.style.clip.right = clipWidth;
		x.style.clip.bottom = clipBottom;
	}
	else if (document.getElementById || document.all)
	{
		lyrheight = x.obj.offsetHeight;
		x.style.clip = 'rect('+clipTop+'px,'+clipWidth+'px,'+clipBottom+'px,0)';
	}
}

function scrollayer(layername,amt,tim)
{
	if (!DHTML) return;
	thelayer = new getObj(layername);
	if (!thelayer) return;
	amount = amt;
	theTime = tim;
	realscroll();
	
}

function realscroll()
{
	if (!DHTML) return;
	clipTop += amount;
	clipBottom += amount;
	topper -= amount;
	
	if (clipTop < 0 || clipBottom > lyrheight)
	{
		clipTop -= amount;
		clipBottom -= amount;
		topper += amount;
		return;
	}

	if (document.getElementById || document.all)
	{
		clipstring = 'rect('+clipTop+'px,'+clipWidth+'px,'+clipBottom+'px,0)';
		thelayer.style.clip = clipstring;
		thelayer.style.top = topper + 'px';
	}
	else if (document.layers)
	{
		thelayer.style.clip.top = clipTop;
		thelayer.style.clip.bottom = clipBottom;
		thelayer.style.top = topper;
	}
	time = setTimeout('realscroll()',theTime);
}

function stopscroll()
{
	if (time) clearTimeout(time);
}















	function show_exception( requestObject, ex) {
		alert("Keine AJAX-Anfrage an " + requestObject.url + " moeglich: " + ex);
	}

	function show_failure( requestObject ) {
		alert("Error from Server:" + requestObject.statusText);
	}
