function clearField(obj){
	obj.value = '';
	obj.className = obj.className.replace('inactive','');
	obj.onfocus = null;
	return true;
}

function validate(form){
	var email = form.newsletter.value;
	var filter=/^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i
	if (filter.test(email))
		return true;
	else{
		var url = window.location.href;
		if(url.match('/en/')) alert("Please enter a valid email address!");
		else alert("Bitte gib eine g\xfcltige E-mail-Adresse ein!");
		return false;
	}
}

function getEvent(e){return (e ? e : window.event);}
function getEventElement(e){var v=(e ? e : window.event);return(v.srcElement ? v.srcElement :(v.target ? v.target : v.currentTarget)); }
function attachEvent(obj,ev,fn){
	if(obj && obj[ev]){ var fo=obj[ev]; obj[ev]=function(e){ var o=fo(e); var n=fn(e); return o && n; } }
	else if(obj){ obj[ev]=function(e){ return fn(e); }; }
}
function activateExternalLinks(){
	var as = document.getElementsByTagName('A');
	for(var i=0,a;a=as[i];i++){
		if(a.className.match(/\b(iext|ext)\b/i)){
			attachEvent( a,'onclick',openWin );
			if(a.className.match(/\bext\b/)){
				var im = new Image();
				im.src = 'http://teenkom.de/graphics/external-link.gif';
				a.appendChild(im);
			}
		}
	}
}
function openWin(e){
	var el = getEventElement(e);
	while(el && el.tagName!='A') el = el.parentNode;
	if(el && el.href) return !window.open(el.href);
}

function writeAddress(){
	var args = [];
	for(var i=0;i<arguments.length;i++) args.push(arguments[i]);
	document.write(unescape(args.join('0')));
}

document.write('<style type="text/css"> .noscript { display:none } </style>');
attachEvent(window,'onload',activateExternalLinks);

function navToggle(obj){
	var $this = $(obj),
		SPEED = 400;
	if($this.hasClass('right-nav-open')){
		$(obj).next().slideUp(SPEED,function(){ $this.removeClass('right-nav-open'); } );
	}
	else{
		$(obj).addClass('right-nav-open').next().slideDown(SPEED);
	}	
}
