
//alert("huhu");


/*****************************************************
*/ function __P___Language() {}
/******************************************************/
 
lang = 'en';
lang_show_failed_keys = '';

if(typeof INT != 'object') INT = new Object();
/*INT['firstname'] = new Object();
INT['firstname']['de'] = 'Vorname';
INT['firstname']['en'] = 'First Name';*/

function $L(key) {
	
	this.lang = lang;
	this.def_lang = 'en';
	
	if(!INT[key]) {
		return key+lang_show_failed_keys;
	} else if(INT[key]) {
		if(INT[key][this.lang]) return INT[key][this.lang];
		else if(INT[key][this.def_lang]) return INT[key][this.def_lang];
		else return key+lang_show_failed_keys;
	} else return key+lang_show_failed_keys;
}


/* Menu Functions */

//---------------------------------------------------------------------------------------
//-- Menu Functions ---------------------------------------------------------------------
//---------------------------------------------------------------------------------------

function Interface () {
	
	this.window = false;
	this.title = '';
	
	this.init = function() {
		this.clearOnFocus();
		if(!Ext.isIE) this.dockMenu();
		
		if(typeof this.submenuimages == 'object') this.preloadImages.defer(500,this,[this.submenuimages]);
		/*var topnavflashid = Ext.get('topnavflashid');
		if(topnavflashid) {
			topnavflashid.on('mouseover',function(e,i){
				var playbutlq = Ext.get('playbutlq');
				playbutlq.fadeOut({endOpacity:.1,duration:1}).fadeIn({endOpacity:1,duration:.5});
			},topnavflashid);			
		}*/
		
		Ext.getBody().addListener('mousemove',function(ev,t,o) { 
			if(!$('leftsubmenuimg')) return false;
			var tEl = Ext.get(ev);
			var tEl = ev.getTarget();
			while(tEl) {
				if(tEl && tEl.id && tEl.id == 'leftmenu') tEl = false;
				else if(tEl && tEl.parentNode) tEl = tEl.parentNode;
				else tEl = null;
			}
			
			if(tEl === null) {
				//DebugDump(tEl,'tEl')
				if(this.selectedSubmenuImg != this.submenuimages['startimage']['sid'])
					this.showSubmenuImg('startimage');			
			}
		},this,{
			buffer:3000
			//delegate:'left',
			//,stopPropagation:true
		});		
	}
	
	
	this.dockMenu = function() {
		
		var ahrefs = Ext.DomQuery.select('.topnavstatic p a');
		
		Ext.each(ahrefs,function(ni){
			
			var item = Ext.get(ni);
			item.on('mouseover',function(e,i){
				
				this.animate({
						fontSize: { to: 25, unit:'px' }
						//,color: this.hasClass('selected') ? { to: '#eb0000' } : { to: '#eb0000' }
						,lineHeight:{ to: 42, unit:'px' }
						//,marginRight:{to:17,unit:'px'}
						//,opacity:{to:.75,from:1}
					},
					0.15,      // animation duration
					function() {
						//this.frame("eb0000", 1, { duration: 0.25 });
						//this.fadeOut({endOpacity:.5,duration:.25}).fadeIn({endOpacity:1,duration:.25});
					},      // callback
					'easeOut', // easing method
					'motion'    // animation type ('run','color','motion','scroll')
				);

				this.animate({
						//fontSize: { to: 25, unit:'px' }
						color: this.hasClass('selected') ? { to: '#eb0000' } : { to: '#eb0000' }
						//,lineHeight:{ to: 42, unit:'px' }
						//,marginRight:{to:17,unit:'px'}
						//,opacity:{to:.75,from:1}
					},
					0.35,      // animation duration
					function() {
						//this.frame("eb0000", 1, { duration: 0.25 });
						//this.fadeOut({endOpacity:.5,duration:.25}).fadeIn({endOpacity:1,duration:.25});
					},      // callback
					'easeOut', // easing method
					'color'    // animation type ('run','color','motion','scroll')
				);

			},item);


			item.on('mouseout',function(e,i){

				this.animate({
						fontSize: { to: 17, unit:'px' }
						//,color: this.hasClass('selected') ? { to: '#eb0000' } : { to: '#ffffff' }
						,lineHeight:{ to: 50, unit:'px' }
						//,marginRight:{to:25,unit:'px'}
						//,opacity:{to:1,from:.75}
					},
					0.35,      // animation duration
					function() {
						//this.fadeOut({endOpacity:.5,duration:.25}).fadeIn({endOpacity:1,duration:.25});
					},      // callback
					'easeIn', // easing method
					'motion'    // animation type ('run','color','motion','scroll')
				);

				this.animate({
						//fontSize: { to: 17, unit:'px' }
						color: this.hasClass('selected') ? { to: '#eb0000' } : { to: '#ffffff' }
						//,lineHeight:{ to: 50, unit:'px' }
						//,marginRight:{to:25,unit:'px'}
						//,opacity:{to:1,from:.75}
					},
					0.7,      // animation duration
					function() {
						//this.fadeOut({endOpacity:.5,duration:.25}).fadeIn({endOpacity:1,duration:.25});
					},      // callback
					'easeIn', // easing method
					'color'    // animation type ('run','color','motion','scroll')
				);
				
			},item);			
						
		});
		
	}
	
	this.clearOnFocus = function() { // ext version
		/**
		* Clears all input/textareas with classname "clearonfocus"
		* on focus-Mouseevent. -- works bad on textareas with much text...
		*/
		
		//var cofs = Ext.DomQuery.jsSelect('.cof');
		var cofs = Ext.DomQuery.select('.cof');
		
		Ext.each(cofs,function(input) {
			var input = Ext.get(input);
			input._defaultValue = input.getAttribute('title');
			if((!input.id) || (input.id.length == 0)) input.id = 'id'+new Date().format('YmdHis')+'_'+(1+Math.floor((Math.random()*32767)));
			input.addListener('focus', function(ev,input) {
				var input = Ext.get(input);
				if(input.getValue() == input._defaultValue) {
					$(input.id).value = '';
					//input.set({value:''});
					
				}
				input.addClass('on-focus');
			});
			input.addListener('blur', function(ev,input) {
				var input = Ext.get(input);
				if(input.getValue() == '') {
					//input.set({value:input._defaultValue});
					$(input.id).value=input._defaultValue;
				}
				input.removeClass('on-focus');				
			});
			
		});	
	}

	this.clearOnFocusOrg = function() {
		/**
		* Clears all input/textareas with classname "clearonfocus"
		* on focus-Mouseevent.
		*/
		
		return; // prototype fxme
		
		$$('.cof').each(function(input) {
			input._defaultValue = input.readAttribute('title');
			input.observe('focus', function(ev) {
				if(input.value == input._defaultValue) {
					input.value = '';
				}
				//input.addClassName('on-focus');
			});
			input.observe('blur', function(ev) {
				if(input.value == '') {
					input.value = input._defaultValue;
				}
				//input.removeClassName('on-focus');				
			});
			
		});	
	}
	
	this.quicksearch = function(event) {
		if(event.keyCode != 13) return;
		this.do_search();
	}
	
	this.do_search = function() {
		document.location.href = '/suche/'+this.quicksearchEL.value;
	}
	
	this.donotinterruptsubmits = function() {
		this.coverbackground('visible',0.8);
		// get sid
		PA = new ProgressAnimation();
		PA.viewProgress(this.cover,false,'Bild wird geladen',false,0.5);
	}
	
	this.jumpTo = function(path) {
		window.open(path);
	}
	
	//---------------------------------------------------------------------------------------
	this.showSubmenuImg = function(sid) {
		this.leftsubmenuimg = Ext.get('leftsubmenuimg');
		if(typeof this.submenuimages != 'undefined') var selimg = this.submenuimages[sid];
		if(this.leftsubmenuimg && selimg) this.leftsubmenuimg.set({src:selimg.src,width:selimg.width,height:selimg.height,alt:selimg.description});
		
		/*this.leftsubmenuimg.fadeOut('t',{
			easing: 'easeIn',
			duration: .25,
			endOpacity:0.25,
			scope:this,
			concurrent:true,
			callback:function() {
				if(typeof this.submenuimages != 'undefined') var selimg = this.submenuimages[sid];
				if(typeof console == 'object') console.log('x '+ img.id+': %o',selimg);
				if(this.leftsubmenuimg && selimg) this.leftsubmenuimg.set({src:selimg.src,width:selimg.width,height:selimg.height,alt:selimg.description});
				this.leftsubmenuimg.fadeIn({endOpacity:1,duration:.25,concurrent:true,easing:'easeOut'});
			}
		});*/
		
		
		this.selectedSubmenuImg = sid;
	}

	this.preloadImages = function(images){
        var preload = Ext.get(document.body).createChild({tag:"div", style:"display:none"});
 		//if(typeof console == 'object') console.log('x preload: '+images.length+': %o',images);
        
        if(images && images.length > 0) {
			Ext.each(images, function(image){
				if (typeof(image)=='string'){
				 image={src:image}
				}
								
				if (image.src){
					preload.createChild({tag:"img", src:image.src});
					if(typeof console == 'object') console.log('x preload: image.src: %o',image.src);
				}
				
				if (image.fullSrc){
					preload.createChild({tag:"img", src:image.fullSrc});
				}
			}, this);
        } else if(typeof images == 'object') {
        	for(img_sid in images) {
  				if (images[img_sid].src){
					preload.createChild({tag:"img", src:images[img_sid].src});
					//if(typeof console == 'object') console.log('x preload: images[img_sid].src: %o',images[img_sid].src);
				}      		
        	} 
        }
    }

	
	//---------------------------------------------------------------------------------------
	
	this.loadVideoPlayer=function(p) {
		
		// start with iphone, dann mp4, dann flash
		
		if(!p) p = {id:'playme'};
		var tpl = '';
		var defaults = {
			'mp4_video':{
				src:'/local/video/testfilmchen-iphone.m4v', 
				width:620,
				height:365,
				type: 'video/mp4; codecs="avc1.42E01E, mp4a.40.2"',
				id:'movie',
				flowplay_context:'class="contentplayer"',
				poster_img:{src:'/local/media/media/apogee_trailer_big_thumb1.jpg'}
			}
		};
		
		var p = Ext.apply(defaults,p);
		
		var playableVideo = false;
		var html5Playback = false;
		
		//if(typeof console == 'object') console.log('x b4 '+ navigator.userAgent+': %o',(navigator.userAgent.match(/iPad/i)));
		
		for(vformats in p) {
			var playable = this.SupportsHTML5VideoFormat(p[vformats]['type']);
			//if(typeof console == 'object') console.log('x AHHHH '+ vformats+': %o',playable);

			if(
				((!navigator.userAgent.match(/iPhone/i)) || (!navigator.userAgent.match(/iPod/i)))
				&& (vformats == 'iphone_video')
			) continue;

			if(
				(!navigator.userAgent.match(/iPad/i))
				&& (vformats == 'ipad_video')
			) continue;	
			
			if(playable == 'probably') {
				//if(playableVideo == 'probably') continue;
				var playableVideo = p[vformats];
				var html5Playback = true;
			} else if(playable == 'maybe') {
				//if(html5Playback == 'probably') continue;
				var playableVideo = p[vformats];
				var html5Playback = true;			
			}
			
			//if(typeof console == 'object') console.log('x b4 '+ vformats+': %o',playable);
			
		}
		
		// flash fallback
		if(html5Playback == false) {
			/*if((navigator.userAgent.match(/iPad/i)) && (p.mp4_video)) {
				var playableVideo = p.mp4_video;
				var html5Playback = true;
				//if(typeof console == 'object') console.log('x iPad? '+ playable+': %o',playableVideo);
			}
			else*/ if(p.flash_video) var playableVideo = p.flash_video;
			else if(p.mp4_video) var playableVideo = p.mp4_video;
		}
		
		//if(typeof console == 'object') console.log('x afterall '+ playable+': %o',playableVideo);
		
		// detect iphone
		if(
			((navigator.userAgent.match(/iPhone/i)) || (navigator.userAgent.match(/iPod/i))) 
			&& (html5Playback)
		) { 
			
			if(p.iphone_video) var playableVideo = p.iphone_video;
			
			if (document.cookie.indexOf("iphone_redirect=false") == -1) {

				var video_style = '';
				if(playableVideo.poster_img) {
					tpl += '<img style="cursor:pointer;" src="'+playableVideo.poster_img.src+'" ';
					tpl += 'id="'+playableVideo.id+'_splash" ';
					tpl += 'onclick="IF.playHTML5Video(\''+playableVideo.id+'\');" />';
					var video_style = 'style="display:none;" '
				}
				
				
				//if((!navigator.userAgent.match(/iPhone/i)) && (!navigator.userAgent.match(/iPod/i)) && (!navigator.userAgent.match(/iPad/i))) {
					tpl += '<div class="close-video-wr" style="width:'+playableVideo.width+'px;"><img src="/local/javascripts/fancybox/fancy_closebox.png" id="'+playableVideo.id+'_closeimg" onclick="IF.controlHTML5Video(\''+playableVideo.id+'\',\'stop\');" class="close-video" /></div>';
				//}				
								
				var v_width = playableVideo.width;
				if(playableVideo.img_width && playableVideo.img_width >0) var v_width = playableVideo.img_width;
				var v_height = playableVideo.height;
				if(playableVideo.img_height && playableVideo.img_height > 0) var v_height = playableVideo.img_height;				
				
				tpl += '<video '+video_style;
				if(playableVideo.poster_img) tpl += 'poster="'+playableVideo.poster_img.src+'" ';
				tpl += 'id="'+playableVideo.id+'" ';
				tpl += 'width="'+v_width+'" height="'+v_height+'"';
				tpl += 'preload controls>';
				tpl += '<source src="'+playableVideo.src+'" type=\''+playableVideo.type+'\' />';
				tpl += '</video>';

				
			}
		} else if(html5Playback) {
			// || Ext.isGecko3 --> needs different format
			
			if(playableVideo) {
				
				if((navigator.userAgent.match(/iPad/i)) && (p.ipad_video)) var playableVideo = p.ipad_video;
				
				var video_style = '';
				if(playableVideo.poster_img) {
					tpl += '<img style="cursor:pointer;" src="'+playableVideo.poster_img.src+'" ';
					tpl += 'id="'+playableVideo.id+'_splash" ';
					tpl += 'onclick="IF.playHTML5Video(\''+playableVideo.id+'\');" />';
					var video_style = 'style="display:none;" '
				}
				
				//if((!navigator.userAgent.match(/iPhone/i)) && (!navigator.userAgent.match(/iPod/i)) && (!navigator.userAgent.match(/iPad/i))) {
					tpl += '<div class="close-video-wr" style="width:'+playableVideo.width+'px;"><img src="/local/javascripts/fancybox/fancy_closebox.png" id="'+playableVideo.id+'_closeimg" onclick="IF.controlHTML5Video(\''+playableVideo.id+'\',\'stop\');" class="close-video" /></div>';
				//}
				tpl += '<video '+video_style;
				if(playableVideo.poster_img) tpl += 'poster="'+playableVideo.poster_img.src+'" ';
				tpl += 'id="'+playableVideo.id+'" ';
				tpl += 'width="'+playableVideo.width+'" height="'+playableVideo.height+'"';
				tpl += 'preload controls>';
				tpl += '<source ';
				tpl += 'src="'+playableVideo.src+'" type=\''+playableVideo.type+'\' />';
				tpl += '</video>';
			}
		} else { // flash
			tpl += '<a '+playableVideo.flowplay_context+' href="'+playableVideo.src+'" style="display:block;width:'+playableVideo.width+'px;height:'+playableVideo.height+'px;">';
			if(playableVideo.poster_img) tpl += '<span  style="display:block;overflow:hidden;width:'+playableVideo.width+'px;height:'+playableVideo.height+'px;"><img src="'+playableVideo.poster_img.src+'" /></span>';
			tpl += '</a>';			
			if(playableVideo.loadPlayer) {
				//this.setFlowPlayerConf({id:playableVideo.id});
				OnLoadFunctions[OnLoadFunctions.length] = "IF.setFlowPlayerConf({id:'"+playableVideo.id+"'});";
			}
		}
		
				
		return tpl;
	}
	

	this.controlHTML5Video = function(id,c) {
				
		switch(c) {
			case'close':
			case'stop':
				if(typeof $(id).pause == 'function') $(id).pause();
				$(id+'_splash').style.display='block';
				if((id == 'player' || id == 'playerhq') && ($('topnavflashid'))) $('topnavflashid').style.display='none';
				if($(id+'_closeimg')) {
					$(id+'_closeimg').style.display='none';
				}
				$(id).style.display='none';
				break;
			case'pause':
				if(typeof $(id).pause == 'function') $(id).pause();
		}
		
	}
	

	this.playHTML5Video = function(id) {
		$(id+'_splash').style.display='none';
		if($(id+'_closeimg')) {
			$(id+'_closeimg').style.display='block';
		}
		$(id).style.display='block';
		//if(typeof console == 'object') console.log('x $(id): %o',$(id));
		$(id).play();
	}
	
	//this.headplayer_playing = false;
	this.loadHeadVideo=function(quality) {
		
		 
		var load_overlay = true;
		
		var p = {
			'mp4_video':{
				src:'/local/video/testfilmchen-iphone.m4v', //<source src="http://clips.vorwaerts-gmbh.de/big_buck_bunny.ogv" type="video/ogg">
				// src:'/local/flash/topvideos/'+currentpage+'_'.quality.'.m4v',
				width:620,
				height:365,
				type: 'video/mp4; codecs="avc1.42E01E, mp4a.40.2"',
				flowplay_context:'class="myPlayer" id="player'+quality+'"',
				id:'mp4_player'+quality
				//'poster_img':{src:'/local/media/media/apogee_trailer_big_thumb1.jpg'}
			}
		};		
		
		//document.getElementById('player'+quality).style.display = 'block';
		
		if((navigator.userAgent.match(/iPhone/i)) || (navigator.userAgent.match(/iPod/i))) { 
			$('headplayer'+quality).style.position='absolute';
			$('headplayer'+quality).style.top='-5000px';
			$('headplayer'+quality).style.left='-5000px';
			$('headplayer'+quality).style.display='block';
			if(typeof $('player'+quality).play == 'function') $('player'+quality).play();
			$('topnavflashid').style.display='block';
			$('topnavflashid').style.top='-5000px';
			$('topnavflashid').style.left='-5000px';			
			var load_overlay = false;
		} else if(Ext.isWebKit) {
			
			if($('player').paused == true && $('playerhq').paused == true) {
				// ok, no player playing
			} else return false;
			
			$('topnavflashid').style.display='block';
			
			if(quality == 'hq') {
				$('headplayer').style.display='none';
			} else $('headplayerhq').style.display='none';
			$('headplayer'+quality).style.display='block';
			$('player'+quality+'_closeimg').style.display='block';
			if(typeof $('player'+quality).play == 'function') $('player'+quality).play();
			$('player'+quality).addEventListener('pause',IF.pauseHTML5HeadPlayer,true); // not working anymore... donno...
			$('player'+quality).addEventListener('ended',IF.pauseHTML5HeadPlayer,true);
			
			/*Ext.get('player'+quality).on({
				'pause' : IF.pauseHTML5HeadPlayer,
				'ended' : IF.pauseHTML5HeadPlayer,
				scope: this
			});*/			
			
			var load_overlay = false;
		} else if(typeof $f('player'+quality).play == 'function'){
			$('topnavflashid').style.display='block';
			$('headplayer'+quality).style.display='block';
			$('player'+quality).style.display='block';	
			var load_overlay = false;
		}

		if(load_overlay==true) {
			document.getElementById('playbuthq').style.display = 'none';
			document.getElementById('playbutlq').style.display = 'none';
			document.getElementById('topnavflashid').style.top = '50%';
			document.getElementById('topnavflashid').style.marginTop = '-222px';
			document.getElementById('topnavflashid').style.marginLeft = '-415px';
			document.getElementById('topnavflashid').style.padding = '15px';
			document.getElementById('topnavflashid').style.backgroundColor = '#1a1a1a';
			document.getElementById('topnavflashid').style.height = '425px';
			document.getElementById('overlay').style.display = 'block';
		}
		
	}
	
	this.pauseHTML5HeadPlayer = function(e) {
		
		var load_overlay = false;
		//if(typeof console == 'object') console.log('x '+ $('player').id+': %o',typeof $('player').pause);
		
		//document.getElementById('player').style.display = 'none';
		document.getElementById('headplayerhq').style.display = 'none';
		document.getElementById('headplayer').style.display = 'none';
		
		$('player_closeimg').style.display='none';
		$('playerhq_closeimg').style.display='none';
		$('topnavflashid').style.display='none';
		
		if(typeof $('player').pause == 'function') $('player').pause();
		if(typeof $('playerhq').pause == 'function') $('playerhq').pause();
		
		//this.headplayer_playing = false;
		
		if(load_overlay==true) {
			//document.getElementById('playbuthq').style.display = 'block';
			//document.getElementById('playbutlq').style.display = 'block';
			//document.getElementById('stierkopf').style.visibility = 'visible';
			//document.getElementById('topnavflashid').style.top = '88px';
			//document.getElementById('topnavflashid').style.marginTop = '0px';
			//document.getElementById('topnavflashid').style.marginLeft = '-513px';
			//document.getElementById('topnavflashid').style.padding = '0px 112px';
			//document.getElementById('topnavflashid').style.backgroundColor = 'transparent';
			//document.getElementById('topnavflashid').style.height = '300px';
			document.getElementById('overlay').style.display = 'none';
		}
	}


	this.SupportsHTML5Video=function() {
	  return !!document.createElement('video').canPlayType;
	}

	this.SupportsHTML5VideoFormat=function(format) {
		if (!this.SupportsHTML5Video()) { return false; }
		var v = document.createElement("video");
		if(v) return v.canPlayType(format);
		else return false
	}

	this.setFlowPlayerConf = function(params) {
		
		if(document.domain.indexOf('yellowspace')) {
			var f_key = false;
			var f_player =  "/local/flash/flowplayer/flowplayer-3.1.5.swf";
		} else {
			var f_player =  "/local/flash/flowplayer/flowplayer.commercial-3.1.5.swf";
			var f_key = '$a33cad4d3a007ed0fb8';
		}	
		
		if(typeof console == 'object') console.log('x '+ params.id+': %o',$(params.id));
		
		var player = flowplayer(params.id, f_player, {
		key: f_key,
		  clip:  { 
			  scaling: 'fit',
			  autoPlay: false, 
			  autoBuffering: true,
			  play: null
			},
			log:{level:'debug'},
		  canvas: {
			  backgroundColor: "#1a1a1a",
			  backgroundGradient: 'none'
			  },
			onLoad: function(){
				//alert("player loaded");
			},	
			onStart: function(){
				//alert("player loaded");
			},			
			logo: { 
				url: 'http://www.thomaskramer.com/images/logo.png', 
				top: 30, 
				right: 30, 
				opacity: 1, 
				fullscreenOnly: true, 
				displayTime: 0, 
				linkUrl: '#'
			},
		  plugins: {
			controls: {
			  tooltipColor: '#5F747C',
			  backgroundGradient: 'none',
			  bufferGradient: 'none',
			  timeBgColor: '#555555',
			  sliderGradient: 'none',
			  borderRadius: '0px',
			  buttonColor: '#d8030a',
			  backgroundColor: '#222222',
			  buttonOverColor: '#050505',
			  progressColor: '#eb0003',
			  progressGradient: 'medium',
			  volumeSliderColor: '#000000',
			  timeColor: '#0b0a0a',
			  tooltipTextColor: '#ffffff',
			  volumeSliderGradient: 'none',
			  bufferColor: '#000000',
			  durationColor: '#de020a',
			  sliderColor: '#000000',
			  height: 24,
			  opacity: 1.0,
			  stop:true
			}
		  }
		});
		
		if(typeof console == 'object') console.log('x player: %o',player);
				
	}
	
	//---------------------------------------------------------------------------------------
	this.adjustSize = function(r) {
		sizeUnit = "%";
		defaultSize = 100;
		maxSize = 160;
		minSize = 98;	
	}


	//---------------------------------------------------------------------------------------
	this.toggleView = function(elId,force) {
		if(!$(elId)) return false;
		if($(elId).style.display == 'none') $(elId).style.display = '';
		else $(elId).style.display = 'none';
	}

	//---------------------------------------------------------------------------------------
	this.setFooter = function() {
		el_id = 'navteaserarea';
		// wie kann ich das anders machen?
		// ohne javascript, wird man den footer nicht sehen, keine gute sache
		// damit kommt man nicht zum impressum
		if(!document.getElementById('footer')) return;
		ft = document.getElementById('footer');
		if(!document.getElementById('navteaserarea')) {
			ft.style.visibility = 'visible';
			return;
		}
		if(!PAGEdom) return;
		nt = document.getElementById('navteaserarea'); // contains left subnav and navboxes
		if(document.getElementById(el_id)) {			
			nt = document.getElementById(el_id); // contains left subnav and navboxes
			var nt_dp = PAGEdom.toDocumentPosition(nt); // get document position of navteaserarea
		} else if(document.getElementById('content')) {
			nt = document.getElementById('content'); // contains left subnav and navboxes
			var nt_dp = PAGEdom.toDocumentPosition(nt); // get document position of navteaserarea		
		}
		/*var nt_dp = PAGEdom.toDocumentPosition(nt); // get document position of navteaserarea
		//DebugDump(nt_dp,'nt_dp.y '+nt_dp.y);
		//DebugDump(scrollTop,'scrollTop '+scrollTop);
		var wHeight = PAGEdom.getWindowHeight();
		var pHeight = document.body.offsetHeight; // Safari needs body.offsetHeight //PAGEdom.getPageHeight();
		//DebugDump(pHeight,'pHeight '+pHeight);
		//DebugDump(wHeight,'wHeight '+wHeight);
		if(pHeight
		&& wHeight
		&& pHeight<wHeight) {
			nt.style.height = (wHeight-ft.offsetHeight-nt_dp.y-1)+'px'; // window.height - footer - navteaser position
		}*/


		var nt_dp_bottom = nt_dp.y + nt.offsetHeight;
		//DebugDump(nt_dp,'nt_dp.y '+nt_dp.y+ ' / ' +nt_dp_bottom);
		// DebugDump(scrollTop,'scrollTop '+scrollTop);
		var wHeight = PAGEdom.getWindowHeight();
		var pHeight = document.body.offsetHeight; // Safari needs body.offsetHeight //PAGEdom.getPageHeight();
		//DebugDump(wHeight,'wHeight '+wHeight);
		//DebugDump(pHeight,'pHeight '+pHeight);
		if(pHeight
		&& wHeight
		&& pHeight < wHeight) {
			nt.style.height = (wHeight-ft.offsetHeight-nt_dp.y)+'px'; // window.height - footer - navteaser position
			//DebugDump(nt.style.height,'1 nt.style.height '+nt.style.height);
		} else if(nt_dp_bottom
		&& wHeight
		&& nt_dp_bottom > wHeight) {
			// do nothing
			//DebugDump(nt.style.height,'2 nt.style.height '+nt.style.height);	
		} else { // tja wenn pHeight > wHeight ist muss man doch auch nichts mehr machen
			//nt.style.height = (wHeight-ft.offsetHeight-nt_dp.y)+'px'; // window.height - footer - navteaser position
			//DebugDump(nt.style.height,'3 nt.style.height '+nt.style.height);		
		}


		op = 1;
		ft.style.opacity = op; // set opacity for effect : filter:alpha(opacity=50); -moz-opacity:0.5; opacity:0.5; 
		ft.style.filter = "alpha(opacity:"+Math.round(op*100)+")";

	}

	//---------------------------------------------------------------------------------------
	this.loginOperation = function(operation,formname) {
		//alert();
		document.forms[0].operation.value = operation;
		document.forms[0].onsubmit(); // workaround browser bugs.
		document.forms[0].submit();
	}
	
	//---------------------------------------------------------------------------------------
	this.logout = function() {
		document.forms['login'].operation.value = '[logout]';
		document.forms['login'].onsubmit(); // workaround browser bugs.
		document.forms['login'].submit();
	}	
	//---------------------------------------------------------------------------------------
	this.toggleMode = function() {
		if(mode) mode_value = mode;
		else if (document.getElementById('list_rdbms')) mode_value = "admin";
		else mode_value = "browse";
		//mode_el = document.getElementById("mymode");
		switch (mode_value) {
			case"admin":
				document.getElementById("mymode").value = 'browse';
				//mode_value = document.getElementById("mymode").value;
				break;
			case"browse":
				document.getElementById("mymode").value = 'admin';
				//mode_value = document.getElementById("mymode").value;
				break;			
		}
		//alert(document.getElementById("mymode").value);
		document.forms['login'].onsubmit(); // workaround browser bugs.
		document.forms['login'].submit();
	}
	
	//---------------------------------------------------------------------------------------

	this.linkExternalLinks = function() {
		if(is_phpos_environment) return;
		//return;
		 var links = document.getElementsByTagName('A');
		 for (var i=0; i<links.length; i++) { 
		  // var anchor = anchors[i]; 
		  var v = links[i].getAttribute("href");
		  var c = links[i].getAttribute("onclick");
		  
		   if (!c
		   && v
		   && v.indexOf('http') != -1) {
			 //DebugDump(c,'external link found');
			 //DebugDump(v,'external link found');
			 //this.addEvent(document,'click',function() {return false;}.bind(this));
			 links[i].setAttribute('target',"_blank");
			}
			
			 
		 } 

		/*links = document.getElementsByTagName('A');
		for(i=0;i<links.length;i++) {
			var atts = links[i].attributes;//getAttribute('href');
			DebugDump(atts,'external link found');
			for(p=0;p<atts.length;p++) {
				DebugDump(atts[p],''+p);
			}		
		}*/
	}

	this.jumpToExternalLink = function(myUrl,myName,hitId,hitName) {
	
		var jumpPage = "/link/external";
		var path = myUrl;
		jumpPage = jumpPage+"?path="+path;
		if ((hitName && hitName.length > 0) && (hitName && hitName.length >0)) jumpPage = jumpPage+"&object_id="+hitId+"&object_name="+hitName;
		mywin = window.open(jumpPage,myName);
		mywin.focus();
		
	}

	// browser
	//---------------------------------------------------------------------------------------
	this.browserSubmit = function(v,i,eidb,formname) {
		//alert('huhu'); return;
		if(!formname) formname = 'contentform';
		document.getElementById(i).value = v;
		document.forms[formname].onsubmit(); // workaround browser bugs.
		document.forms[formname].submit();
	}

	this.setDirPath = function(id,order_dir,eidb) {
		document.getElementById(eidb+'order').value = id;
		this.browserSubmit(order_dir,eidb+'order_dir');
	} 
		
	this.changeDirPath = function(id,order_dir,eidb) {
		img_path = '/images_admin/embedded_browser/';
		document.getElementById(eidb+'order').value = id;
		switch(order_dir) {
			case"desc":
				document.getElementById(id+'_order_dir_dot').src = img_path+"asc_blue_dot.gif";
				order_change = 'asc';
			break;
			case"asc":
				document.getElementById(id+'_order_dir_dot').src = img_path+"desc_blue_dot.gif";
				order_change = 'desc';
			break;	
		}	
		this.browserSubmit(order_change,eidb+'order_dir');
	} 
	
	// submit
	this.justSubmit = function(formname) {
		if(!formname) formname = 'contentform';
		document.forms[formname].onsubmit(); // workaround browser bugs.
		document.forms[formname].submit();	
	}

	// submit
	this.setHiddenAndSubmit = function(hidden_value,hidden_id,formname) {
		if(!formname) formname = 'contentform';
		document.getElementById(hidden_id).value = hidden_value;
		//alert(document.forms[formname]['triggers'].value)
		document.forms[formname].onsubmit(); // workaround browser bugs.
		//DebugDump(document.forms[formname],'form '+formname);
		document.forms[formname].submit();
	}

	// submit
	this.setHidden = function(hidden_value,hidden_id,formname) {
		if(!formname) formname = 'contentform';
		document.getElementById(hidden_id).value = hidden_value;
	}	
	//---------------------------------------------------------------------------------------
	//---------------------------------------------------------------------------------------
	this.magnifier_is_visible = false;
	this.magnify = function(m) {
		var mtop, st, ww;
		
		if(this.magnifier_is_visible == true) {
			setTimeout(function(){ this.magnify(m); }.bind(this), 300);
			return;
		}
		
		
/*
.menuitemGNW {
	position: absolute;
	visibility: hidden;
}

.fllGN {
	background-image: url(/images_admin/icons/kr_hl.png);
	background-repeat: no-repeat;
	background-position: left top;
	width: 36px; 
	height:72px; 
	float:left;
}

.fllGNib {
	background-image: url(/images_admin/icons/kr_hr.png);
	background-repeat: no-repeat;
	background-position: right top;	
	height:72px; 
	width: 36px;
	float:left;
}

.fllGNCT {
	float:left;
	background-color: #000;
	margin: 1px 0 0 0;
	he

*/		
		st = PAGEdom.docScrollTop();
		mtop = (st+160)+'px';
		ww = GetWindowWidth();
		this.mag = document.createElement('div');
		this.mag.style.position = 'absolute';
		this.mag.style.zIndex = 10020;
		this.mag.style.left = 60+'px';
		this.mag.style.top = mtop;		
		this.mag.style.width = (ww-120)+'px';	
		this.mag.style.textAlign = 'center';
		//this.mag.style.height = '180px';
		this.mag.style.padding = '3px';
		this.mag.style.fontWeight = 'bold';
		//this.mag.style.fontSize = '400%';
		this.mag.style.fontSize = '60px';
		this.mag.style.lineHeight = '60px';
		this.mag.style.color = '#fff';
		//this.mag.style.border = '1px solid red';
		
		this.mag.innerHTML = m;
		document.getElementsByTagName('body')[0].appendChild(this.mag);
		
		this.mag_bg = document.createElement('div');
		this.mag_bg.style.position = 'absolute';
		this.mag_bg.style.zIndex = 10019;
		this.mag_bg.style.left = 60+'px';
		this.mag_bg.style.top = mtop;		
		this.mag_bg.style.width = (this.mag.offsetWidth)+'px';//(ww-60)+'px';
		this.mag_bg.style.height = this.mag.offsetHeight+'px';//'200px';
		
		op = 0.1;
		this.mag_bg.style.opacity = op; // set opacity for effect : filter:alpha(opacity=50); -moz-opacity:0.5; opacity:0.5; 
		this.mag_bg.style.filter = "alpha(opacity:"+Math.round(op*100)+")";
		
		
		rk = document.createElement('div');
		rk.className = 'fllGN';
		this.mag_bg.appendChild(rk);
		
		ct = document.createElement('div');
		ct.style.width = (this.mag.offsetWidth - 72)+'px';
		ct.className = 'fllGNCT';
		this.mag_bg.appendChild(ct);	
		
		lk = document.createElement('div');
		lk.className = 'fllGNib';
		this.mag_bg.appendChild(lk);		
		
		document.getElementsByTagName('body')[0].appendChild(this.mag_bg);
		
		new Effect.Opacity(this.mag_bg, {duration:0.3, from:0.1, to:0.7,afterFinish: function() {IF.magnifier_is_visible = true;}});
		
		//new Effect.Appear(this.mag_bg,{duration:0.5});
		//new Effect.Appear(this.mag,{duration:0.5});
		//new Effect.SlideDown(menuitems[i],{duration:0.8});
		//new Effect.BlindDown(menuitems[i],{duration:0.8});
		//new Effect.Grow(menuitems[i],{duration:0.8});		

		//this.mag.style.backgroundColor = '#ffffff';
		this.addEvent(document,'mousedown',this.hideme = function(event) {this.hideMagnifier(event);}.bind(this));
	}
	//---------------------------------------------------------------------------------------
	this.hideMagnifier = function(event) {
	
		var el;
		el = this.gettarget(event);
		
		// If the active button was clicked on, exit.
		if (el == this.mag) return;
		if (el == this.mag_bg) return;
	
		// If the element is not part of a menu, reset and clear the active
		// button.
		
		PAGEdom.removeNode(this.mag);
		mag_bg = this.mag_bg;
		new Effect.Opacity(this.mag_bg, {duration:0.3, from:0.7, to:0,afterFinish: this.sau_Effect_rmNode});
		//new Effect.Puff(this.mag_bg, {duration:0.5,afterFinish: rmNode});
		//PAGEdom.removeNode(this.mag_bg);
	}	
	
	this.sau_Effect_rmNode = function(obj) {
		PAGEdom.removeNode(obj.element);
		IF.magnifier_is_visible = false;
	}
	//---------------------------------------------------------------------------------------
	
	//---------------------------------------------------------------------------------------
	this.coverbackground = function(vs,op) {
		
		if(!op) op = 0;
		
		if(!this.cover) {
			this.cover = document.createElement('div');
			this.cover.style.position = 'absolute';
			this.cover.style.zIndex = 5;
			this.cover.style.left = 0+'px';
			this.cover.style.top = 0+'px';
			this.cover.style.opacity = op; // set opacity for effect : filter:alpha(opacity=50); -moz-opacity:0.5; opacity:0.5; 
			this.cover.style.filter = "alpha(opacity:"+Math.round(op*100)+")";
			this.cover.style.backgroundColor = "#fff";
			document.getElementsByTagName('body')[0].appendChild(this.cover);
		}
		
		if(!vs) {
			this.cover.style.visibility = 'hidden';
		} else {
			ww = GetWindowWidth();
			wh = GetWindowHeight();
			st = PAGEdom.docScrollTop();
			bodyheight = st+wh;
			bodyheight = document.body.offsetHeight;
			this.cover.style.width = (ww-15)+'px';
			this.cover.style.height = ((bodyheight-15))+'px';
			this.cover.style.visibility =  'visible';			
		}
	}
	
	//---------------------------------------------------------------------------------------
	this.setField = function(sourcefield_id,targetfield_id,value,disable) {

		sourcefield = $(sourcefield_id);
		targetfield = $(targetfield_id);
		//DebugDump(sourcefield.value,'sourcefield.value');
		if(targetfield.value != value) {
			targetfield.value = value;
		}
	
	}
	
	//---------------------------------------------------------------------------------------
	this.getPHPOSContent = function(event,sid,conf) { //,{width:200,height:400,autosize:false}
		
		if(typeof conf != 'object') conf = {};

		default_conf = {
			width:400,
			height:600,
			autosize: true,
			topclose: true,
			overflow: 'auto',
			fullscreen: false
		};		
		
		var conf = Ext.apply(default_conf,conf);
		//DebugDump(conf,'conf');
		if(event) Event.stop(event);
		
		Lightview.show({
			href: '/ajax/getphposcontent/'+sid,
			rel: 'ajax',
			options: {
				autosize: conf.autosize,
				width: conf.width,
				height: conf.height,
				topclose: conf.topclose,
				myOverflow: conf.overflow,
				sid:sid,
				ajax: {
					onSuccess: function(transport) {
						//DebugDump(transport.responseText,'transport.responseText');
					},
					onComplete: function(a){
						//DebugDump(this,'onComplete this');
						//DebugDump(a,'onComplete a');
						//DebugDump(Lightview,'Lightview');
						if(Lightview.view.options.myOverflow == 'auto') { // dunno, why lightview is not doing it by it self :(
							var ic = $('phposcontent_'+Lightview.view.options.sid);
							ic.style.width = ((Lightview.view.options.width)-5)+'px';
							ic.style.height = ((Lightview.view.options.height)-15)+'px';
							ic.style.overflow = 'auto';
						}
					},
					parameters: {sid:sid,noxml:true}
				}
			}
		});		
	}
	
	//---------------------------------------------------------------------------------------
	this.getContent = function(event,context,classname,sid) { // die hier is nich so dolle....
		
		switch(context) {
			case'contact':
				this.contactWindow(event,context,classname,sid);
				break;
			case'rqp':
				this.requestPasswordWindow(event,context,classname,sid);
				break;
			case'sendarticle':
			case'send':
				this.getAdviseWindow(event,context,classname,sid);
				break;
			default:
				// get ajax content
		}
	}

	this.contactWindow = function(event,t,c,sid) {
		Event.stop(event);
		Lightview.show({
			href: '/php-os/app_local/scripts/ajax_contact.php',
			rel: 'ajax',
			options: {
				autosize: true,
				topclose: true,
				ajax: {
					onSuccess: function(transport) {
						//DebugDump(transport.responseText,'transport.responseText');
					},
					onComplete: function(){
						// once the request is complete we observe the form for a submit
						$('adviseform').observe('submit', IF.submitContactWindow);
						if($('aam_email') && $('aam_email').value.length == 0) $('aam_email').focus();
						BB.clearOnFocus();
					},
					parameters: {t:t,c:c,sid:sid}
				}
			}
		});	
	}
	
	// lightview submit callback
	this.submitContactWindow = function(event) {
	  // block default form submit
	  Event.stop(event);
		  
	  Lightview.show({
		href: '/php-os/app_local/scripts/ajax_contact.php',
		rel: 'ajax',
		options: {
		  title: 'results',
		  menubar: false,
		  topclose: true,
		  autosize: true,
		  ajax: {
			parameters: Form.serialize('adviseform'), // the parameters from the form
			onComplete: function(){
				// once the request is complete we observe the form for a submit
				if($('adviseform')) $('adviseform').observe('submit', IF.submitContactWindow);
				BB.clearOnFocus();
			}	
		  }
		}
	  });
	}	
	
	this.requestPasswordWindow = function(event,t,c,sid) {
		Event.stop(event);
		Lightview.show({
			href: '/php-os/app_local/scripts/ajax_request_password.php',
			rel: 'ajax',
			options: {
				autosize: true,
				topclose: true,
				ajax: {
					onSuccess: function(transport) {
						//DebugDump(transport.responseText,'transport.responseText');
					},
					onComplete: function(){
						// once the request is complete we observe the form for a submit
						$('adviseform').observe('submit', IF.submitAjaxRequestPassword);
						if($('aam_email') && $('aam_email').value.length == 0) $('aam_email').focus();
					},
					parameters: {t:t,c:c,sid:sid}
				}
			}
		});		
	}
	
	// lightview submit callback
	this.submitAjaxRequestPassword = function(event) {
	  // block default form submit
	  Event.stop(event);
		  
	  Lightview.show({
		href: '/php-os/app_local/scripts/ajax_request_password.php',
		rel: 'ajax',
		options: {
		  title: 'results',
		  menubar: false,
		  topclose: true,
		  autosize: true,
		  ajax: {
			parameters: Form.serialize('adviseform'), // the parameters from the form
			onComplete: function(){
				// once the request is complete we observe the form for a submit
				if($('adviseform')) $('adviseform').observe('submit', IF.submitAjaxRequestPassword);
			}	
		  }
		}
	  });
	}	
	
	// lightview submit form
	this.getAdviseWindow = function(event,t,c,sid) {

		Event.stop(event);
		Lightview.show({
			href: '/php-os/app_local/scripts/ajax_advise_mail.php',
			rel: 'ajax',
			options: {
				autosize: true,
				topclose: true,
				ajax: {
					onSuccess: function(transport) {
						//DebugDump(transport.responseText,'transport.responseText');
					},
					onComplete: function(){
						// once the request is complete we observe the form for a submit
						$('adviseform').observe('submit', IF.submitAjaxFormDemonstration);
						if($('aam_recipientmail') && $('aam_recipientmail').value.length == 0) $('aam_recipientmail').focus();
					},
					parameters: {t:t,c:c,sid:sid}
				}
			}
		});
	}

	// lightview submit callback
	this.submitAjaxFormDemonstration = function(event) {
	  // block default form submit
	  Event.stop(event);
		  
	  Lightview.show({
		href: '/php-os/app_local/scripts/ajax_advise_mail.php',
		rel: 'ajax',
		options: {
		  title: 'results',
		  menubar: false,
		  topclose: true,
		  autosize: true,
		  ajax: {
			parameters: Form.serialize('adviseform'), // the parameters from the form
			onComplete: function(){
				// once the request is complete we observe the form for a submit
				if($('adviseform')) $('adviseform').observe('submit', IF.submitAjaxFormDemonstration);
			}	
		  }
		}
	  });
	}
	
	
	
	//---------------------------------------------------------------------------------------
	
	this.windowPrint = function() {
		window.print();
	}
	
	this.printDonation = function(printform) {
		
		
		var firstformEL = false;
	//if (!def_printversion_available) return alert('Es ist keine Druckansicht f\u00FCr diese Seite verf\u00FCgbar...');
		var contentEL = document.getElementById('content');
		var contentforms = contentEL.getElementsByTagName('FORM');
		for (var i=0; i<contentforms.length; i++) { 
			if(contentforms[i]) { firstformEL = contentforms[i]; break; }
		}	
		
		if(firstformEL) {
			//var o_target = firstformEL.target;
			var o_action = firstformEL.action;
			//firstformEL.target = printform;
			firstformEL.action = printform;
		}
		this.printVersion();
		//window.print();
		if(firstformEL) {
			//firstformEL.target = o_target;
			firstformEL.action = o_action;	
		}
	}

	this.printVersion = function() {
		var firstformEL = false;
	//if (!def_printversion_available) return alert('Es ist keine Druckansicht f\u00FCr diese Seite verf\u00FCgbar...');
		var contentEL = document.getElementById('content');
		var contentforms = contentEL.getElementsByTagName('FORM');
		for (var i=0; i<contentforms.length; i++) { 
			if(contentforms[i]) { firstformEL = contentforms[i]; break; }
		}
		//firstformEL.submit();
		//alert(firstformEL.name);
		if(firstformEL) var Ppath = firstformEL.action;//parent.content.myPlainPagePath;
		else var Ppath = parent.content.myPlainPagePath;
		
		var Pname = "PrintVersion";
		var no_w = '/none';
		var no_w = checkUrl(no_w);
		var WHeight = GetWindowHeight()-100;
		mywin = window.open(no_w,Pname,"top=20,left=30,width=540,height="+WHeight+",scroll=yes,scrollbars=yes,titlebar=no,status=no,toolbar=no,location=no,directories=no,menubar=yes,resizable=yes");
		
		Ppath = Ppath+"?print=true";
		var Ppath = checkUrl(Ppath);		
		//spendenformulardrucken
		if(firstformEL) {
			
			var o_target = firstformEL.target;
			var o_action = firstformEL.action;
			//alert(o_target);
			firstformEL.target = Pname;
			firstformEL.action = Ppath;
			firstformEL.onsubmit(); // workaround browser bugs.
			firstformEL.submit();
			firstformEL.target = o_target;
			firstformEL.action = o_action;			
		} else {
			mywin.location.href =createUrl(Ppath);
		}
		
		
		
		/*if (document.forms[formname]) { // this part will be true from now on
			var createdTempHidden = false;
			if (document.createElement) {
				switch (SmartAgent){
					case "Netscape6":
					case "MSIE5.5":
					case "Opera5":
					case "Khtml":
						try {
							var tempFormObj;
							var tempHiddenObj;
							tempFormObj = parent.content.document.forms[0];
							var tempHidden = 	parent.content.document.createElement('input');
							tempHidden.setAttribute('type','hidden');
							tempHidden.setAttribute('name','print');
							tempHidden.setAttribute('value','true');
							tempHiddenObj = tempFormObj.appendChild(tempHidden);
							var createdTempHidden = true;
						} catch(e) {
							Ppath = Ppath+"?print=true";
						}
						break;
				case "Netscape4":
				case "MSIE5":
				default:
					var Ppath = Ppath+"?print=true";
					var Ppath = createUrl(Ppath);
					break;
				}
			} else {
				var Ppath = Ppath+"?print=true";
				var Ppath = createUrl(Ppath);
			}
			setActionAndSubmit(Pname,Ppath,'parent.content.document.forms[0]');
			if (createdTempHidden) tempFormObj.removeChild(tempHidden);
		} else {
			var Ppath = Ppath+"?print=true"; 
			mywin.location.href =createUrl(Ppath);
		}
		*/
		
		if(mywin) mywin.focus();
	}

	//---------------------------------------------------------------------------------------
	this.buildWindow = function() {
		
		// window
		//bodyroot = document.getElementsByTagName('form')[0];
		if(!document.getElementById('content')) return;
		bodyroot = document.getElementById('content');
		this.w_wrapper = document.createElement("div");	
		

		this.w_wrapper.id = 'window';
		this.w_wrapper.className = 'window';
		this.w_wrapper.style.position = 'absolute';
		//this.w_wrapper.style.display = 'none';
		this.w_wrapper.style.visibility = 'hidden';
		this.w_wrapper.width = 300;
		this.w_wrapper.height = 300;
		this.w_wrapper.style.width = this.w_wrapper.width+'px';
		this.w_wrapper.style.height = this.w_wrapper.height+'px';
		this.w_wrapper.style.overflow = 'auto';
		//this.w_wrapper.style.border = '1px solid black';
		//this.w_wrapper.style.backgroundColor = 'white';
		//this.w_wrapper.style.zIndex = 100000;
		WWidth = GetWindowWidth();
		WHeight = GetWindowHeight();
		dst = PAGEdom.docScrollTop();
		var topheight = (((WHeight+dst)/2)-(this.w_wrapper.height/2));
		if(topheight<133) topheight = 133;
		this.w_wrapper.style.top = topheight+'px';
		var leftwidth = ((WWidth/2)-(this.w_wrapper.width/2));
		if(leftwidth<250) leftwidth = 250;
		this.w_wrapper.style.left = leftwidth+'px';
		bodyroot.appendChild(this.w_wrapper);

		this.makeNewWndow();
				
	}
	
	this.makeNewWndow = function() {
		this.window = new ContentWindow(this.title,this.w_wrapper.id);
		this.window.client_area_id = 'windowclientarea';
		this.window.title_id = 'windowtitlearea';
		this.window.init(this.window);	
	}
	

	
	//---------------------------------------------------------------------------------------
	this.gettarget = function(event) {

		if(window
		&& (window.event)
		&& (window.event.srcElement)) {
			t = window.event.srcElement;
		} else {
			t = (event.target.tagName ? event.target : event.target.parentNode);
		}
		return t;
	}	
	

	//---------------------------------------------------------------------------------------
	this.addEvent = function(el,evname,func) {
	
		if (el.attachEvent) { // IE
			el.attachEvent("on" + evname, func);
		} else if (el.addEventListener) { // Gecko / W3C
			el.addEventListener(evname, func, true);
		} else {
			el["on" + evname] = func;
		}
	
	}
	
	//---------------------------------------------------------------------------------------
	this.removeEvent = function(el,evname,func) {
	
		if (el.detachEvent) { // IE
			el.detachEvent("on" + evname, func);
		} else if (el.removeEventListener) { // Gecko / W3C
			el.removeEventListener(evname, func, true);
		} else {
			el["on" + evname] = null;
		}
	
	}
}

IF = new Interface(); 
OnLoadFunctions[OnLoadFunctions.length] = "IF.init();";

var reg = 'phpos'; 
var is_phpos_environment = document.location.href.match(reg);
if(!is_phpos_environment) {
	browserSubmit = IF.browserSubmit;
	setDirPath = IF.setDirPath;
	changeDirPath = IF.changeDirPath;
}
//OnLoadFunctions[OnLoadFunctions.length] = "browserSubmit();";
//---------------------------------------------------------------------------------------
function checkSubmit() { // weiss nich, ob ich das brauche... ist der onsubmit gerade
	return true;
}

//---------------------------------------------------------------------------------------
//-- TinyMCE Settings -------------------------------------------------------------------
//---------------------------------------------------------------------------------------

IF.tinymceSettings = {
	theme : "advanced",
	height: "200", //config.height,
	plugins: "safari,pagebreak,style,advhr,advimage,advlink,emotions,insertdatetime,preview,media,searchreplace,print,contextmenu,paste,directionality,noneditable,visualchars,nonbreaking",
	theme_advanced_buttons1 : //"bold,italic,underline,strikethrough,|,justifyleft,justifycenter,justifyright,justifyfull,|,styleselect,formatselect",
"cut,copy,paste,pastetext,|,undo,redo,|,preview,|,removeformat,|,cleanup,code",

	theme_advanced_buttons2 : //"cut,copy,paste,pastetext,pasteword,|,bullist,numlist,|,outdent,indent,blockquote,|,undo,redo,|,link,unlink,anchor,image,cleanup,code",
"bold,italic,blockquote,|,sub,sup,|,link,unlink,anchor,|,styleselect,formatselect",

	theme_advanced_buttons3 : //"hr,removeformat,|,sub,sup,|,charmap,media,advhr,|,ltr,rtl,|,insertdate,inserttime,preview,|,forecolor",
"bullist,numlist,outdent,indent,|,hr,nonbreaking,media,image,|,charmap",

	//theme_advanced_buttons4 : "styleprops,|,cite,abbr,acronym,del,ins,attribs,|,visualchars,nonbreaking",
	theme_advanced_toolbar_location : "top",
	theme_advanced_toolbar_align : "left",
	theme_advanced_statusbar_location : "bottom",
	theme_advanced_resizing : false,
	extended_valid_elements : //"a[name|href|target|title|onclick],img[class|src|border=0|alt|title|hspace|vspace|width|height|align|onmouseover|onmouseout|name],hr[class|width|size|noshade],font[face|size|color|style],span[class|align|style]",
"a[name|href|target|title|onclick|class|style],img[class|src|border=0|alt|title|hspace|vspace|width|height|align|onmouseover|onmouseout|name],hr[class|width|size|noshade],span[class|align|style],div[class|align|style]",
	//theme_advanced_blockformats : "span,p,div,h1,h2,h3,h4,h5,h6,blockquote",
	
	
	/* linebreak tests, hier scheint etwas schlimmeres nicht zu stimmen...
	forced_root_block:false,
	remove_linebreaks:false,
	//force_p_newlines:false,
	//force_br_newlines:true,
	apply_source_formatting:true,
	entity_encoding:"",
	cleanup:false,
	cleanup_on_startup:true,
	//convert_newlines_to_brs:true,
	
	force_p_newlines:false,
	force_br_newlines:true,
	convert_newlines_to_brs:false,
	remove_linebreaks:true,					
	cleanup:false,
	
	*/
	cleanup_on_startup:false,
	
	//template_external_list_url : "example_template_list.js"
	//file_browser_callback : "FileBrowser"
	 file_browser_callback:"ezfilemanager",
	 relative_urls:false,
	 theme_advanced_enable:"styleselect",
	 content_css: "/local/stylesheets/wysiwyg.css",
	 language:"en",
	 onchange_callback:"myCustomOnChangeHandler"
	 //add_form_submit_trigger:true
	 //body_id:"content"
};


function TKF () {
	
	this.init = function() {
		if($('livecommentwr')) {
			this.event_sid = event_sid;
			this.E_livecommentwr = Ext.get('livecommentwr');
			this.E_livecommentsrepeatwr = Ext.get('livecommentsrepeatwr');			
			this.loadLivecomments(event_sid);
		}
		this.reg_timer = setTimeout(function(){this.checkRegisterTime();}.bind(this), 10000);
	}
	
	
	this.lasttimestamp = 0;
	this.loadLivecomments = function() {
		
		var post = '';
		post += 'ajax=1';
		post += '&last_time='+this.lasttimestamp;
		var url = '/partystream-livecomments';		
		Ext.Ajax.request({
			scope:this,
			method:'post',
			url: url+'/'+this.event_sid,
			success: function(response,options){
				var rData = Ext.util.JSON.decode(response.responseText);//passed back from server
				if(rData) {
					if(rData.last_time && rData.last_time != null && rData.last_time >0) {
						this.lasttimestamp = rData.last_time;
					}
					setTimeout(function(){this.showLivecomments(rData['comments']);}.bind(this), 750);
				} else {
					this.comments_timer = setTimeout(function(){this.loadLivecomments();}.bind(this), 20000);
				}
				
			},
			failure: function(response,options){ 
				// no comments? there are no failures	
				this.comments_timer = setTimeout(function(){this.loadLivecomments();}.bind(this), 20000);
			},
			params: post
		});				
		
	}
	
	this.commentappends = 1;
	this.rownumber = 0;
	this.showLivecomments = function(comments) {
		
		this.comments_timer = setTimeout(function(){this.loadLivecomments();}.bind(this), 20000);

		var tpl ='';
		tpl += '<div class="lcb">';
		tpl += '<div class="lcbnr">{0}</div>';
		tpl += '<img src="{1}" width="100" height="100" border="0" alt="{2}" />';
		tpl += '<p class="lcbm">{5}</p>';
		tpl += '<p class="lcbf">{2} {3}<span> | </span>{4}<span> | </span>{6}</p>';
		tpl += '</div>';
		tpl += '';
		tpl += '';
		tpl += '';
		var t = '';
		
		if(comments.length >= 8) dur = 2;
		else dur = 1;
		this.rownumber = this.rownumber + comments.length;
		var rownumber = this.rownumber;
		
		
		for(i=0;i<comments.length;i++) {
			// 0 number
			// 1 foto_path
			// 2 firstname
			// 3 lastname
			// 4 country
			// 5 message
			// 6 zeit
			for(ck in comments[i]) {
				if(comments[i][ck] == null) comments[i][ck] = '';
			}
			t += String.format(tpl,rownumber,comments[i]['foto_path'],comments[i]['firstname'],comments[i]['lastname'],comments[i]['country'],comments[i]['message'],comments[i]['mtime']); 
			rownumber--;
		}
		
		if(t.length>0) {
			var newwr = '<div id="commentappends'+this.commentappends+'" style="display:none;"></div>';
			var wr = Ext.get('livecommentsrepeatwr');
			wr.insertHtml('afterBegin',newwr);
			var com_wr = Ext.get('commentappends'+this.commentappends);
			com_wr.insertHtml('afterBegin',t);
			com_wr.slideIn('t',{
				useDisplay:true,
				endOpacity: 1,
				easing: 'easeOut',
				concurrend:true,
				duration: dur
			});			
			this.commentappends++;
		}
	}
	
	
	this.sendCommentForm = function(hidden_value,hidden_id,formname) {
		// no ext available 
		if(!formname) formname = 'contentform';
		document.getElementById(hidden_id).value = hidden_value;
		document.forms[formname].onsubmit(); // workaround browser bugs.
		document.forms[formname].submit();	
	}
	
	this.checkregstatus = false;
	this.checkRegisterTime = function() {
	
		return false;
		
		this.reg_timer = setTimeout(function(){this.checkRegisterTime();}.bind(this), 25000);
		
		var post = '';
		post += 'ajax=1';
		post += '&triggers=getpartylivestreaminfo';
		post += '&event_sid='+this.event_sid;
		var url = '/ajax/dotrigger';
		Ext.Ajax.request({
			scope:this,
			method:'post',
			url: url,
			success: function(response,options){
				var rData = Ext.util.JSON.decode(response.responseText);//passed back from server
				
				if(rData) {
					this.lastData = rData;
					
					if(!this.checkregstatus) {
						this.checkregstatus = rData['qt_status'];
						//this.changeStream(rData);
					} else if(this.checkregstatus != rData['qt_status']) {
						this.checkregstatus = rData['qt_status'];
						this.changeStream(rData);
					}
					if($('qt_msg')) $('qt_msg').innerHTML = rData['qt_msg'];
				}
				
			},
			failure: function(response,options){ 
				// no comments? there are no failures	
			},
			params: post
		});
	}
	
	this.changeStream = function(data) {
		
		//DebugDump(rData,'rData');
		var e = '<object classid="clsid:02BF25D5-8C17-4B23-BC80-D3488ABDDC6B" codebase="http://www.apple.com/qtactivex/qtplugin.cab#version=6,0,2,0" width="'+data['qt_width']+'" height="'+data['qt_height']+'" align="middle">'
			  +'<param name="src" value="'+data['qt_src']+'" />'
			  +'<param name="href" value="'+data['qt_href']+'" />'
			  +'<param name="autoplay" value="true" />'
			  +'<param name="controller" value="false" />'
			  +'<param name="target" value="quicktimeplayer" />'
			  +'<embed src="'+data['qt_href']+'" target="quicktimeplayer" autoplay="true" controller="false" width="'+data['qt_width']+'" height="'+data['qt_height']+'" align="middle" bgcolor="black" pluginspage="http://www.apple.com/quicktime/download/">'
			  +'</embed>'
			+'</object>'	
		;

		var qts = $$('object');
		if(qts[0]) qts[0].remove();
		//alert(qts[0]);
		var com_wr = Ext.get('livestreamwr');
		com_wr.insertHtml('afterBegin',e);
		
		$('qt_msg').style.display = '';
		$('qt_msg').innerHTML = data['qt_msg'];
		
	}
	
	this.lastData = false;
	
	this.reconnectStream = function() {
		return; // this doesn't seem to work
		if(this.lastData == false) {
			return false;
		} else {
			this.changeStream(this.lastData);
		}
	}
	
}

TK = new TKF();

if(typeof Ext == 'object') {

	// application main entry point
	Ext.onReady(function() {
		TK.init();
	}); // eo function onReady
	
}

//---------------------------------------------------------------------------------------
//-- Size Functions -------------------------------------------------------------------
//---------------------------------------------------------------------------------------

function AdjustFontSize() {

	this.sizeUnit = "%";
	this.defaultSize = 100;
	this.maxSize = 125; // Windows 125! / Mac 145
	this.minSize = 90;

	this.init = function() {
		CFS = new CookieManager('fontSize');
		if ( !document.body || !document.getElementById ) return;
		var size = window.location.search? window.location.search.slice(1): CFS.getValue("fontSize");
		size = !isNaN( parseFloat(size) )? parseFloat(size): this.defaultSize;
		// in case default unit changed or size passed in url out of range
		if ( size > this.maxSize || size < this.minSize ) size = this.defaultSize;
		document.body.style.fontSize = size + this.sizeUnit;
	}
  
	this.adjust = function(inc) {
		var size = parseFloat( document.body.style.fontSize );
		/* !!!!! Änderung  Anfang !!!! */
		size = !isNaN( parseFloat(size) )? parseFloat(size): this.defaultSize;
		/* !!!!! Änderung Ende  !!!! */
		size += inc;
		// Test against max and min sizes 
		if (inc > 0) size = Math.min(size, this.maxSize);
		else size = Math.max(size, this.minSize);
		CFS.save( "fontSize", size, 180, "/" );
		document.body.style.fontSize = size + this.sizeUnit;
	}

	this.reset = function() {
		document.body.style.fontSize = this.defaultSize + this.sizeUnit;
		CFS.del("fontSize", "/");
	}
}




function SmartBrowser() {

  var ua, s, i;

  this.isIE    = false;  // Internet Explorer
  this.isOP    = false;  // Opera
  this.isNS    = false;  // Netscape
  this.version = null;

  ua = navigator.userAgent;

  s = "Opera";
  if ((i = ua.indexOf(s)) >= 0) {
    this.isOP = true;
    this.version = parseFloat(ua.substr(i + s.length));
    return;
  }

  s = "Netscape6/";
  if ((i = ua.indexOf(s)) >= 0) {
    this.isNS = true;
    this.version = parseFloat(ua.substr(i + s.length));
    return;
  }

  // Treat any other "Gecko" browser as Netscape 6.1.

  s = "Gecko";
  if ((i = ua.indexOf(s)) >= 0) {
    this.isNS = true;
    this.version = 6.1;
    return;
  }

  s = "MSIE";
  if ((i = ua.indexOf(s))) {
    this.isIE = true;
    this.version = parseFloat(ua.substr(i + s.length));
    return;
  }
}

var SMbrowser = new SmartBrowser();



