/************************************************************
Schuelerhilfe
Global functions
Author: Planetactive GmbH

/************************************************************
GENERAL
ACCORDION
CENTER FINDER
GOOGLE MAPS
TYPO3 DEFAULT
*/

/************************************************************
* GENERAL
************************************************************/
window.addEvent('domready',function(){
	// fix ie stacking order
	if(Browser.Engine.trident){
		var blocks = $$('#nav ul li');
		var zi = 1000;
		if(blocks){
			blocks.each(function(block, i){
				block.style.zIndex = zi--;
			});
		}
	}
	//when mainnav is displayed, hide first select (ie6)
	if(Browser.Engine.trident && Browser.Engine.version == '4'){
		var navMainPoints = $$('#nav ul:nth-child(only)');
		if(navMainPoints){
			navMainPoints.each(function(el){
				el.addEvent('mouseover',function(event){
					refElement = $(document.body).getElement('select')
					if(refElement) refElement.setStyle('opacity','0');
				});
				el.addEvent('mouseout',function(event){
					refElement = $(document.body).getElement('select')
					if(refElement) refElement.setStyle('opacity','1');
				});
			});
		}
	}
	//smoothscroll
	new SmoothScroll({ 
		duration:1000
	}, window);
	// init accordions
	$$('ul.accordion').each(function(el){
		accordion(el);
	});
	// setup stage navigation
	if ($$('div.cntStage').length>0 && $$('div.cntStageMapAT').length==0 ){
		buildStageNav();
		$('navTab').getElements('a').each(function(el){
			el.addEvent('click',function(event){
				event.preventDefault();
				stageTimer = false;
				window.clearTimeout(stageTimeout);
				switchTabs(el.rel);
			});
		});
	}
	
	// setup map at
	if($('cntMapPoints')) {
		$('cntMapPoints').getElements('a').each(function(el){
			el.addEvent('mouseover',function(event){
				showMapPoint(el,el.rel);
			});
			el.addEvent('mouseout',function(event){
				hideMapPoint(el,el.rel);
			});
		});
	}
	if($('areaWien')){
		// wien special
		$('areaWien').addEvent('mouseover',function(event){
			var container = $('cntMapPoints');
			new Element('div',{
				'html':'<h6>Sch&uuml;lerhilfe Wien</h6>',
				'id':'cntMapInfoWien',
				'class':'cntMapInfo',
				'style':'top:85px; left:402px;'
			}).inject(container,'top');
		});
		$('areaWien').addEvent('mouseout',function(event){
			$('cntMapInfoWien').dispose();
		});
	}
	
	// Slidetabmenue
	if($('slidetabsmenu')){
		activeTab = $('slidetabslink1');
		$('slidetabsmenu').getElements('li a').each(function(el){
			el.addEvent('click',function(event){
				event.preventDefault();
				activeTab.getParent().removeClass('ac');
				$('slidetabsmenu'+activeTab.get('id').substr((activeTab.get('id').length)-1,1)).setStyle('display','none');
				el.getParent().addClass('ac');
				$('slidetabsmenu'+el.get('id').substr((el.get('id').length)-1,1)).setStyle('display','block');
				activeTab = el;
			});
		});
	
	};
	
	// Vertical Slide for the Search Field
	if ( $('vertical_slide') ) {
	var myVerticalSlide = new Fx.Slide('vertical_slide');

		myVerticalSlide.hide();

		$('v_toggle').addEvent('click', function(e){
		e.stop();
		myVerticalSlide.toggle();
		});
	}
	// Datenschutz Links
	if ($$('.datenschutz').length>0){
		$(document.body).getElements('a.datenschutz').addEvents({
    		'click': function(event){
    			event.preventDefault();
        	openPopup('/'+this.getProperty('href'),740,500,'-customParams[scrollbars=1]');
			}
		});
	}

	
});

/************************************************************
* STAGE
************************************************************/
var currentTab = 'tab_0';
var tabLength = 0;
var stageTimer = true;
var stageTimeout = null;
var stageTimeoutDefault = 30;
	 
function buildStageNav(){
	new Element('ul',{
		'id':'navTab',
		'class':'clearfix'
	}).inject($('cntAcc'),'bottom');
	var navTabLiStr = '<li><a href="#" class="navTab back" rel="back" title="zur&uuml;ck"></a></li>';
	$('cntAcc').getElements('.accContent').each(function(el){	
		if(tabLength>0)el.set('styles',{
			'opacity':0
		});
		tabLength++;
		navTabLiStr += (currentTab == el.id)? '<li class="active"><a href="#" rel="'+el.id+'" title="'+el.title+'">'+el.title+'</a></li>':'<li><a href="#" rel="'+el.id+'" title="'+el.title+'">'+el.title+'</a></li>';
	});
	navTabLiStr += '<li><a href="#" class="navTab forward" rel="forward" title="vor"></a></li>';
	$('navTab').set('html', navTabLiStr);
	stageTimeout = window.setTimeout('setStageInterval()',getStageTimer(currentTab));
}

function getStageTimer(tab) {
	return ($(tab).get('lang')!=null? $(tab).get('lang')*1000:30*1000);
}

function setStageInterval(){
	var currIndex = parseInt(currentTab.substr(4,1));
	var newTab = (currIndex < tabLength-1)? 'tab_'+(currIndex+1):'tab_0';
	switchTabs(newTab);
}

function switchNavTab(nextIndex){
	$('navTab').getElements('a[rel='+currentTab+']').getParent().removeClass('active');
	$('navTab').getElements('a[rel='+nextIndex+']').getParent().addClass('active');
	currentTab = nextIndex;
}

function switchTabs(newTab){
	curItem = $(currentTab);
	if (newTab == 'back' || newTab == 'forward') {
		window.clearTimeout(stageTimeout);
		currIndex = parseInt(currentTab.substr(4,1));
	}
	if (newTab == 'back') nextIndex = (currIndex > 0)? 'tab_'+(currIndex-1):'tab_'+(tabLength-1);
	else if (newTab == 'forward') nextIndex = (currIndex < tabLength-1)? 'tab_'+(currIndex+1):'tab_0';
	else if (newTab != 'back' && newTab != 'forward' && newTab != '') nextIndex = newTab;
	else return;
	
	nextItem = $(nextIndex);
	if (nextItem!=curItem){
		new Fx.Morph(curItem, { 
			duration:1000,
			transition:Fx.Transitions.Quad.easeInOut,
			wait:false
		}).start({
			'opacity':[0]
		});
		new Fx.Morph(nextItem, { 
			duration:1000,
			transition:Fx.Transitions.Quad.easeInOut,
			wait:false
		}).start({
			'opacity':[0,1]
		}).addEvent('onComplete', function(){
			if (stageTimer) stageTimeout = window.setTimeout('setStageInterval();',getStageTimer(nextIndex));
		});
		switchNavTab(nextIndex);
	}
}

/************************************************************
* STAGE AT (Map)
************************************************************/
function buildMapPoints() {
	var container = $('cntMapPoints');
	for (i=0; i<sh.map.length; i++) {
		new Element('a',{
			'html':'',
			'href':(sh.map[i].href!=''? sh.map[i].href:"/index.php?id=720&L=1&center_number="+sh.map[i].centerid ),
			'rel':i,
			'class':'dot',
			'style':'top:'+sh.map[i].top+'px; left:'+sh.map[i].left+'px;'
			}).inject(container,'bottom');
	}
}

function showMapPoint(el,i) {
	var container = $('cntMapPoints');
	el.set('class','dot dotHilight');
	new Element('div',{
		'html':'<h6>'+sh.map[i].name+'</h6><p>'+sh.map[i].street+'</p>',
		'id':'cntMapInfo'+i,
		'class':'cntMapInfo',
		'style':'top:'+(parseInt(sh.map[i].top)-25)+'px; left:'+(parseInt(sh.map[i].left)+10)+'px;'
		}).inject(container,'top');
}

function hideMapPoint(el,i) {
	el.set('class','dot');
	$('cntMapInfo'+i).dispose();
}

/************************************************************
* VIDEO PLAYBACK
************************************************************/
function video( containerName, playerName, flvPath, imgPath, sound, autostart ){
	window.addEvent('domready',function(){
		if(Browser.Plugins.Flash.version>=8){
			var swiff = new Swiff(playerName,{
				container: containerName,
				width: 320,
				height: 200,
				params: {
					wMode: 'opaque',
					bgcolor: '#ffffff',
					allowScriptAccess: 'sameDomain',
					allowFullScreen: 'false',
					menu: 'false',
					salign: 'tr'
				},
				vars: {
					extVideoPath: flvPath,
					extImgPath: imgPath,
					extSound: sound,
					extAutoStart: autostart
				}
			});
		}
	});
}

/************************************************************
* ACCORDION
************************************************************/
function accordion(parent){
	window.addEvent('domready',function(){
		// add class to first li
		parent.getElements('li')[0].set('class','first');
 		
		// remove links from titles
		parent.getElements('dt a').each(function(el){
			var temp = el.get('html');
			var parent = el.getParent();
			el.dispose();
			parent.set('html',temp);
		});
 		
		// initialize accordion
		var speed = 300;
 		
		if (parent.hasClass('accordionFullWidth')) {
			new Accordion(parent.getElements('dt'),parent.getElements('dd'),{
				start:'all-close',
				alwaysHide:true,
				duration:speed,
				onActive:function(e){
					e.addClass('open')
					},
				onBackground:function(e){
					e.erase('class')
					}
			});
		}
		else {
			new Accordion(parent.getElements('dt'),parent.getElements('dd'),{
				show:0,
				duration:speed,
				onActive:function(e){
					e.addClass('open')
					},
				onBackground:function(e){
					e.erase('class')
					}
			});
		}
	});
}

/************************************************************
* CENTER FINDER
************************************************************/

function zipRequest(ajaxurl, pclength){
	if(!pclength)
	{
		pclength = 5;
	}
	s = 'type=2';
	if(ajaxurl.indexOf(s)<0) {
		ajaxurl.indexOf( '?' ) < 0 ? ajaxurl += '?' : ajaxurl += '&';
		ajaxurl += s;
	}

	window.addEvent('domready',function(){
		var input = $('zipsearch');
		var output = $('sh_collection');
		
		// search function
		var search = function(){
			var zip = input.value;
			if(zip.length == pclength && isNaN(zip)==false){
				$('loader').set('class','active');
				new Request.HTML({
					url:'/'+ajaxurl,
					method:'get',
					update:output,
					onComplete:function(responseHTML){
						if(responseHTML.length==0){
							if(input.getParent().getElements('h6')==0) var headline = new Element('h6',{
								'html':'Es konnte keine Sch&uuml;lerhilfe in Ihrer N&auml;he gefunden werden.',
								'class':'clearfix'
							}).inject(output,'before');
							else {
								input.getParent().getElements('h6').empty();
								input.getParent().getElements('h6').set('text','Es konnte keine Schülerhilfe in Ihrer Nähe gefunden werden.');
							}
						}
						else{
							if(input.getParent().getElements('h6')==0) var headline = new Element('h6',{
								'html':'Bitte w&auml;hlen Sie jetzt Ihre bevorzugte Sch&uuml;lerhilfe aus.',
								'class':'clearfix'
							}).inject(output,'before');
							else {
								input.getParent().getElements('h6').empty();
								input.getParent().getElements('h6').set('text','Bitte wählen Sie jetzt Ihre bevorzugte Schülerhilfe aus.');
							}
						}
						pager(output);
						$('loader').erase('class');
					}
				}).send('tx_pacenterfinder_piResPlz[postalcode]='+zip);
			}
		};
		
		//add events to input
		input.setAttribute('autocomplete','off');
		input.addEvents({
			'keyup':search,
			'keydown':function(event){
				if(event.key=='enter'){
					new Event(event).stop();
					search();
				}
			}
		});
	});
}

function pager(parent){
	window.addEvent('domready',function(){
		var items = parent.getElements('li');
		var show = 5;
		var current = 0;
		var pager,previous;

		// hide items on start
		items.each(function(el,i){
			if(i>show-1) el.setStyle('display','none');
		});
		if(parent.getElements('.pager').length>0) parent.getElements('.pager')[0].dispose();

		// create pager navigation
		var pages = Math.ceil(items.length/show);
		if(items.length > show){
			// create dom elements
			var pager = new Element('div',{
				'class':'pager'
			}).inject(parent,'bottom');
			var rw = new Element('em',{
				'html':'zur&uuml;ck'
			}).inject(pager);
			for(var i=1;i<=pages;i++){
				var link = new Element('span',{
					'html':i
				}).inject(pager);
			}
			var fw = new Element('em',{
				'html':'vor'
			}).inject(pager);
			pager.getElements('span')[0].set('class','active');
			
			// page switch function
			var navigator = function(which){
				pager.getElements('span').each(function(el){
					el.set('class','');
				});
				pager.getElements('span')[which].set('class','active');
				items.each(function(el,j){
					(j>=which*show && j<which*show+show) ? el.setStyle('display','block') : el.setStyle('display','none');
				});
			};
			
			// show selected page
			pager.getElements('span').each(function(el,i){
				el.addEvent('click',function(){
					navigator(i);
					current = i;
				});
			});
			
			// show previous
			pager.getElements('em')[0].addEvent('click',function(){
				current == 0 ? previous = show-1 : previous = current-1;
				navigator(previous);
				current = previous;
			});
			
			// show next
			pager.getElements('em')[1].addEvent('click',function(){
				current == show-1 ? next = 0 : next = current+1;
				navigator(next);
				current = next;
			});
		}
	});
}

/************************************************************
* GOOGLE MAPS
************************************************************/
function mapCenterfinder(marker){
	window.addEvent('domready',function(){
		if (GBrowserIsCompatible()) {
			var map = new GMap2(document.getElementById("map_canvas"));
			var bounds = new GLatLngBounds();
			var character = String.fromCharCode("A".charCodeAt(0) - 1);
			
			// create bounds
			marker.each( function(item){
				bounds.extend(item);
			});
			
			// create icon
			var createIcon = function(){
				character = String.fromCharCode(character.charCodeAt(0) + 1);
				var icon = new GIcon(G_DEFAULT_ICON, "http://www.google.com/mapfiles/marker" + character + ".png");
				icon.printImage    = "http://maps.google.com/mapfiles/marker"+character+"ie.gif";
				icon.mozPrintImage = "http://maps.google.com/mapfiles/marker"+character+"ff.gif";
				return icon;
			};
			
			// set map attributes and add markers
			map.addControl(new GSmallMapControl());
			map.addControl(new GHierarchicalMapTypeControl());
			map.setCenter( bounds.getCenter(), map.getBoundsZoomLevel(bounds));
			marker.each( function(item) {
				var icon = createIcon();
				map.addOverlay(new GMarker(item,{
					icon:icon
				}));
			});
		}
	});
}

function mapCorparate(marker){
	window.addEvent('domready',function(){
		if (GBrowserIsCompatible()) {
			var map = new GMap2(document.getElementById("map_canvas"));
			var bounds = new GLatLngBounds();
			var character = String.fromCharCode("A".charCodeAt(0) - 1);
			
			// create bounds
			marker.each( function(item){
				bounds.extend(item);
			});
			
			// create icon
			var createIcon = function(){
				character = String.fromCharCode(character.charCodeAt(0) + 1);
				var icon = new GIcon(G_DEFAULT_ICON, "http://www.google.com/mapfiles/marker" + character + ".png");
				icon.printImage    = "http://maps.google.com/mapfiles/marker"+character+"ie.gif";
				icon.mozPrintImage = "http://maps.google.com/mapfiles/marker"+character+"ff.gif";
				return icon;
			};
			
			// set map attributes and add markers
			map.addControl(new GSmallMapControl());
			map.addControl(new GHierarchicalMapTypeControl());
			map.setCenter( bounds.getCenter(), map.getBoundsZoomLevel(bounds)-2);
			marker.each( function(item) {
				var icon = createIcon();
				map.addOverlay(new GMarker(item,{
					icon:icon
				}));
			});
		}
	});
}

function mapCenterRoute(marker){
	window.addEvent('domready',function(){
		if (GBrowserIsCompatible()) {
			mapDir = new GMap2(document.getElementById("map_canvas"));
			var bounds = new GLatLngBounds();
			var character = String.fromCharCode("A".charCodeAt(0) - 1);
			
			// create bounds
			marker.each( function(item){
				bounds.extend(item);
			});
			
			// create icon
			var createIcon = function(){
				character = String.fromCharCode(character.charCodeAt(0) + 1);
				var icon = new GIcon(G_DEFAULT_ICON, "http://www.google.com/mapfiles/marker" + character + ".png");
				icon.printImage    = "http://maps.google.com/mapfiles/marker"+character+"ie.gif";
				icon.mozPrintImage = "http://maps.google.com/mapfiles/marker"+character+"ff.gif";
				return icon;
			};
			
			// set mapDir attributes and add markers
            
			mapDir.addControl(new GSmallMapControl());
			mapDir.addControl(new GHierarchicalMapTypeControl());
			mapDir.setCenter( bounds.getCenter(), mapDir.getBoundsZoomLevel(bounds)-2);
			marker.each( function(item) {
				var icon = createIcon();
				mapDir.addOverlay(new GMarker(item,{
					icon:icon
				}));
			});
			
			//directions
			if (marker.length == 2) {
				dirn = new GDirections(mapDir);
				dirn.loadFromWaypoints(marker,{
					locale:'de_DE',
					getSteps:true
				});
				//dirn.preserveViewport();
				mapDir.setCenter( bounds.getCenter(), mapDir.getBoundsZoomLevel(bounds));
				GEvent.addListener(dirn,"load", function() {
					setTimeout('customPanel(mapDir,"map_canvas",dirn,document.getElementById("route_desc"))', 1);
				});
			}

		}
	});
}

function customPanel(map,mapname,dirn,div) {
	var html = "";
	
	function dirHead(point,dist) {
		var target = '"' + mapname+".showMapBlowup(new GLatLng("+point.toUrlValue(6)+"))"  +'"';
		html += '<div class="mapDirHead">';
		html += '	<p>';
		html += '		<strong>Route nach/zu Sch&uuml;lerhilfe '+centerName+'</strong>';
		html += '		'+dist;
		html += '	</p>';
		html += '</div>';
	}
	
	function listStart() {
		html += '<ol>';
	}
	
	function detail(point, num, description, dist) {
		var target = '"' + mapname+".showMapBlowup(new GLatLng("+point.toUrlValue(6)+"))"  +'"';
		html += '	<li><span class="description">'+description+'</span><span class="distance">'+dist+'</span></li>';
	}
	
	function listEnd() {
		html += '</ol>';
	}
	
	function dirFoot(point, type, address) {
		var target = '"' + mapname+".showMapBlowup(new GLatLng("+point.toUrlValue(6)+"))"  +'"';
		html += '<div class="mapDirFooter">';
		html += '	<address>';
		html += '		<p>Sch&uuml;lerhilfe '+centerName+'</p>';
		html += '		<p>'+centerStreet+'<br />';
		if (centerStreetAdd!='') html += '		'+centerStreetAdd+'<br />';
		html += '		'+centerCity+'</p>';
		html += '	</address>';
		html += '</div>';
	}
	
	function copyright(text) {
		html += '<div style="font-size: 0.86em;">' + text + "<\/div>";
	}

	// === read through the GRoutes and GSteps ===

	for (var i=0; i<dirn.getNumRoutes(); i++) {
		if (i==0) {
			var type="play";
		} else {
			var type="pause";
		}
		var route = dirn.getRoute(i);
		var geocode = route.getStartGeocode();
		var point = route.getStep(0).getLatLng();
		dirHead(point,route.getDistance().html+" (ca. "+route.getDuration().html+")")
		listStart();
		for (var j=0; j<route.getNumSteps(); j++) {
			var step = route.getStep(j);
			detail(step.getLatLng(), j+1, step.getDescriptionHtml(), step.getDistance().html);
		}
		listEnd();
	}
		
	// === the final destination waypoint ===
	var geocode = route.getEndGeocode();
	var point = route.getEndLatLng();
	dirFoot(point, "stop", geocode.address);
			 
	// === the copyright text ===
	//copyright(dirn.getCopyrightsHtml());
		
	// === drop the whole thing into the target div
	div.innerHTML = html;

}

/************************************************************
* POPUP
************************************************************/
var afpl = false;function gpd(dv,wh){absV=0;calV=parseInt(dv);calV=(calV<1)?1:(calV>100)?100:calV;absV=Math.round((calV * (eval('screen.'+wh)/100)));return absV;}function gsc(wh){cp = Math.round(eval('screen.'+wh+'-openPopup_'+wh)/2);return cp;}function pps(){aa=arguments[0].split(',');rs=',left='+aa[0]+',top='+aa[1];return rs;}function wps(){aa=arguments[0].split(',');sb=false;tb=false;st=false;lb=false;di=false;mb=false;rz=false;for (i=0;i<aa.length;i++){sb = (aa[i].indexOf('scrollbars') != -1)? aa[i]:(!sb)? 'scrollbars=no':sb;tb = (aa[i].indexOf('toolbar') != -1)? aa[i]:(!tb)? 'toolbar=no':tb;st = (aa[i].indexOf('status') != -1)? aa[i]:(!st)? 'status=no':st;lb = (aa[i].indexOf('location') != -1)? aa[i]:(!lb)? 'location=no':lb;di = (aa[i].indexOf('directories') != -1)? aa[i]:(!di)? 'directories=no':di;mb = (aa[i].indexOf('menubar') != -1)? aa[i]:(!mb)? 'menubar=no':mb;rz = (aa[i].indexOf('resizable') != -1)? aa[i]:(!rz)? 'resizable=no':rz;}rs=','+sb+','+tb+','+st+','+lb;return rs;}function pds(){aa = arguments[0].split(',');bName=navigator.appName;bApp=navigator.appVersion;bVer=parseInt(navigator.appVersion);ns4=(document.layers||(bName.indexOf('Netscape')>=0&&bVer<5))?true:false;ie4=(document.all&&document.styleSheets)?true:false;ns5=(document.getElementById&&!document.all)?true:false;op5=(document.all&&!document.styleSheets)?true:false;win=(bApp.indexOf('Win')>=0)?true:false;mac=(bApp.indexOf('Mac')>=0)?true:false;diw =(ie4&&win)?aa[0]:(ns4&&win)?aa[2]:(ns5&&win)?aa[4]:(op5&&win)?aa[6]:(ie4&&mac)?aa[8]:(ns4&&mac)?aa[10]:(ns5&&mac)?aa[12]:(op5&&mac)?aa[14]:0;dih=(ie4&&win)?aa[1]:(ns4&&win)?aa[3]:(ns5&&win)?aa[5]:(op5&&win)?aa[7]:(ie4&&mac)?aa[9]:(ns4&&mac)?aa[11]:(ns5&&mac)?aa[13]:(op5&&mac)?aa[15]:0;pw=parseInt(openPopup_width)+parseInt(diw);ph=parseInt(openPopup_height)+parseInt(dih);rs='width='+pw+',height='+ph;return rs;}function openPopup(){pa=new Array('customPosition','customParams','browserDiff');for (i=0;i<pa.length;i++) eval('openPopup_'+pa[i]+'=false');openPopup_popupUrl = arguments[0];openPopup_width=(typeof(arguments[1])=='string'&&arguments[1].indexOf('%')>-1)?gpd(arguments[1],'width'):arguments[1];openPopup_height=(typeof(arguments[2])=='string'&&arguments[2].indexOf('%')>-1)?gpd(arguments[2],'height'):arguments[2];opo=(arguments.length>3)?arguments[3]:'';if(opo!=''){opo=opo.slice(1,opo.length);opoArray = opo.split('-');for (i=0;i<opoArray.length;i++){for (j=0;j<pa.length;j++){eval('openPopup_'+pa[j]+' = (opoArray[i].indexOf("'+pa[j]+'") != -1 && typeof(opoArray[i]) == "string")? opoArray[i].substring(opoArray[i].indexOf("[")+1,opoArray[i].indexOf("]")):(!openPopup_'+pa[j]+')? false:openPopup_'+pa[j]);}}}ps=(!openPopup_browserDiff)?'width='+openPopup_width+',height='+openPopup_height:pds(openPopup_browserDiff);ps+=(!openPopup_customPosition)?',left='+gsc('width')+',top='+gsc('height'):pps(openPopup_customPosition);ps+=(!openPopup_customParams)?',scrollbars=no,toolbar=no,status=no,location=no,directories=no,menubar=no,resizable=no':wps(openPopup_customParams);var poa=new Array();var time=new Date();var rnd=time.getTime();var pna='POPUP'+rnd;poa[poa.length]=open(openPopup_popupUrl,pna,ps);if (typeof(poa[poa.length-2]) == 'object') poa[poa.length-2].close();poa[poa.length-1].focus();}var afpl = true;
/************************************************************
* DISPLAY DEFAULT VALUE IN INPUT FIELD
************************************************************/
function dV(obj,val){obj.value=(obj.value==val)?'':(obj.value=='')?val:obj.value;}
/************************************************************
* TYPO3 DEFAULT
************************************************************/
var browserName=navigator.appName;var browserVer=parseInt(navigator.appVersion);var version="";var msie4=(browserName=="Microsoft Internet Explorer"&&browserVer>=4);if((browserName=="Netscape"&&browserVer>=3)||msie4||browserName=="Konqueror"||browserName=="Opera"){version="n3";}else{version="n2";}
function blurLink(theObject){if(msie4){theObject.blur();}}
function decryptCharcode(n,start,end,offset){n=n+offset;if(offset>0&&n>end){n=start+(n-end-1);}else if(offset<0&&n<start){n=end-(start-n-1);}return String.fromCharCode(n);}
function decryptString(enc,offset){var dec="";var len=enc.length;for(var i=0;i<len;i++){var n=enc.charCodeAt(i);if(n>=0x2B&&n<=0x3A){dec+=decryptCharcode(n,0x2B,0x3A,offset);}else if(n>=0x40&&n<=0x5A){dec+=decryptCharcode(n,0x40,0x5A,offset);}else if(n>=0x61&&n<=0x7A){dec+=decryptCharcode(n,0x61,0x7A,offset);}else{dec+=enc.charAt(i);}}return dec;}
function linkTo_UnCryptMailto(s){location.href=decryptString(s,-1);}