function profilbild(string){
	if(chkFile(string,'jpg,jpeg,gif')){
		document.getElementById('fileupload').className='ok2';
	}else{
		document.getElementById('fileupload').className='ok0';
	}
}
function loader(){
	document.getElementById('loader').style.display='inline';
}
function okswitch(status,postfix){
	document.getElementById('ok'+postfix).className='ok'+status;	
}
function okswitch2(status,postfix){
	document.getElementById('ok'+postfix).className='check'+status;	
}
function checkURL(string){
	if(string.length<6 || string.indexOf(' ')!=-1 ||  string.indexOf('\\')!=-1 ||  string.indexOf('.')==-1 ||  string.indexOf('@')!=-1 ||  string.indexOf(' ')!=-1){
		return false
	}
	return true;
}
//#######################################################

function chkField(feld,optinal_bool,minlang){
	if(!optinal_bool || optinal_bool=='undefined')optinal_bool=false;
	if(!minlang)minlang=4;
	
	if(feld.value.length<minlang){
		if(optinal_bool==true){
			okswitch(1,'_'+feld.name);
		}else{		
			okswitch(0,'_'+feld.name);
		}
		return false;
	}else{
		okswitch(2,'_'+feld.name);
		return true
	}	
}
function isExt(string,extensions){
	ext=string.split('.');
	ext=ext[ext.length-1];
	yes_ext=extensions.split(',');
	for(x=0;x<yes_ext.length;x++){
		if(ext==yes_ext[x]){
			return true	
		}	
	}
	return false	
}
function chkRadio(elem,optinal_bool){
	if(!optinal_bool || optinal_bool=='undefined')optinal_bool=false;
	namei=elem.name;
	formi=elem.form;
	//alert(elem.form.elements[namei].length);
	ok=false;
	with(elem.form){
		for(x=0;x<elements[namei].length;x++){
			if(elements[namei][x].checked == true){
				ok=true;
			}
		}
	}
	if(ok==false){
		if(optinal_bool==true){
			okswitch2(1,'_'+elem.name);
		}else{		
			okswitch2(0,'_'+elem.name);
		}
		return false;
	}else{
		okswitch2(2,'_'+elem.name);
		return true
	}
	
}

function chkURLField(feld,optinal_bool){
	if(feld.value==''){
		okswitch(1,'_'+feld.name);
	}else if(checkURL(feld.value)){
		okswitch(2,'_'+feld.name);
	}else{
		okswitch(0,'_'+feld.name);
	}	
}
function chkMailField(feld,optinal_bool){
	if(feld.value==''){
		okswitch(1,'_'+feld.name);
	}else if(chkMail(feld.value)){
		okswitch(2,'_'+feld.name);
	}else{
		okswitch(0,'_'+feld.name);
	}	
}
function chkMail(string){
	if(string.indexOf('@')!=-1 && string.indexOf('.')!=-1 && string.indexOf('http:')==-1 && string.indexOf('www.')==-1 && string.indexOf(' ')==-1){
		temp=string.split('.');
		if(string.length>4 && temp[temp.length-1].length>1 && temp[temp.length-1].length<5){
			return true;	
		}
	}
	return false
}
function chkDigitField(feld,optinal_bool){
	if(feld.value==''){
		okswitch(1,'_'+feld.name);
	}else if(chkDigit(feld.value)){
		okswitch(2,'_'+feld.name);
	}else{
		okswitch(0,'_'+feld.name);
	}	
}
function chkDatetimeField(feld,optinal_bool){
	alert(feld.value)
	if(feld.value==''){
		okswitch(1,'_'+feld.name);
	}else if(chkDatetime(feld.value)){
		okswitch(2,'_'+feld.name);
	}else{
		okswitch(0,'_'+feld.name);
	}	
}

function chkDateField(feld,optinal_bool){
	if(feld.value==''){
		okswitch(1,'_'+feld.name);
	}else if(chkDate(feld.value)){
		okswitch(2,'_'+feld.name);
	}else{
		okswitch(0,'_'+feld.name);
	}	
}

function chkTimeField(feld,optinal_bool){
	if(feld.value==''){
		okswitch(1,'_'+feld.name);
	}else if(chkTime(feld.value)){
		okswitch(2,'_'+feld.name);
	}else{
		okswitch(0,'_'+feld.name);
	}	
}

function chkDigit(string){
	if(!isNaN(string) && parseFloat(string) && parseFloat(string)==string){
		return true;
	}	
	return false;
}
function chkDatetime(string){
	var zeit=0;
	var today = new Date();
	var thisYear = today.getFullYear();
	var jahr=(parseInt(thisYear));
	
	temp=string.split('-');
	temp2=temp[2].split(' ');
	zeit=temp2[1];
	temp[2]=temp2[0];
	if(string.length==19 && temp[0]>1970 && temp[0]<=jahr && temp[1]>0 && temp[1]<13 && temp[2]>0 && temp[2]<32 && chkTime(zeit.toString())){
		return true;	
	}

	return false;
}

function chkDate(string){
	var zeit=0;
	var today = new Date();
	var thisYear = today.getFullYear();
	var jahr=(parseInt(thisYear));
	
	temp=string.split('-');
	if(string.length==10 && temp[0]>1970 && temp[0]<=jahr && temp[1]>0 && temp[1]<13 && temp[2]>0 && temp[2]<32){
		return true;	
	}

	return false;
}
function chkTime(string){
	temp=string.split(':');
	if(temp.length==3 && (temp[0]>=0 && temp[0]<25 && temp[0].length==2)  && (temp[1]>=0 && temp[1]<60 && temp[1].length==2) && (temp[2]>=0 && temp[2]<60 && temp[2].length==2)){
		return true;
	}
	return false;
}
function chkFileField(feld,optinal_bool,formate){
	if(feld.value==''){
		okswitch(1,'_'+feld.name);
	}else if(chkFile(feld.value,formate)){
		okswitch(2,'_'+feld.name);
	}else{
		okswitch(0,'_'+feld.name);
	}	
}
function chkFile(string,formate){
	ok=true;
	if(formate){
		ok=false;
		endung=string.split('.');
		endung=endung[endung.length-1];
		formate=formate.split(',');
		for(x=0;x<formate.length;x++){
			if(endung.toLowerCase()==formate[x].toLowerCase()){
				ok=true;
				break;
			}		
		}
	}
	return ok;
}
function chkCheck(feld,optinal_bool){
	if(!optinal_bool)optinal_bool=false;
	if(feld.checked && feld.checked==true){
		okswitch2(2,'_'+feld.name);
	}else{
		if(optinal_bool){
			okswitch2(1,'_'+feld.name);
		}else{
			okswitch2(0,'_'+feld.name);
		}
	}
}
function chkSelect(feld,optinal_bool){
	if(feld.selectedIndex>0){
		okswitch(2,'_'+feld.name);
	}else{
		if(optinal_bool){
			okswitch(1,'_'+feld.name);
		}else{
			okswitch(0,'_'+feld.name);
		}
	}
	return true;
}
function chkPw(formular){
	with(formular){
		if(elements['pw_new1'].value!='' && elements['pw_new1'].value==elements['pw_new2'].value){
			if(elements['pw_new1'].value.length<5){
				document.getElementById('pass1').className='ok1';
				document.getElementById('pass2').className='ok1';				
			}else{
				document.getElementById('pass1').className='ok2';
				document.getElementById('pass2').className='ok2';
			}
		}else{
			document.getElementById('pass1').className='ok0';
			document.getElementById('pass2').className='ok0';
		}
		
	}
}

var win_handle=new Array();
function centerPop(page,breite,hoehe){//30 mai 07 seebacher
		var name,name_r,h,b,top_pos,left_pos,attributes;
		
		if(!breite)breite=730;
		if(!hoehe)hoehe=400;
		name_r=page.split('/');
		name_r=name_r[name_r.length-1];
		name_r=name_r.split('.');
		name=name_r[0];
		
		
		if(win_handle[name] && win_handle[name].closed && win_handle[name].closed==false){
		 	win_handle[name].close();
		}
		
		if(screen.width && screen.height){
			b=screen.width;
			h=screen.height-40;
		}else{
			b=1024;
			h=768;
		}

		top_pos=Math.round((h-hoehe)/2);
		left_pos=Math.round((b-breite)/2);
		
		//attribute setzen
		attributes="width=" +breite + ", height=" +hoehe + ",top=" +top_pos+ ",left="+left_pos+", scrollbars=yes, resizable=yes";
		//genster öffnen und in glob var zurück schreiben.
		win_handle[name]=window.open(page,'window',attributes);		
}

var agent = navigator.appName;
var agent_ver = parseInt(navigator.appVersion);
if(agent.indexOf('Microsoft')!=-1 && agent.indexOf('Opera')==-1){
	var ie=true;	
}else{
	var ie=false;
}

function bookmark(titel){
	if(!titel){
		titel=document.title;
	}
	var url = this.location.href;
	if (window.sidebar) { // Mozilla Firefox Bookmark
		window.sidebar.addPanel(titel, url,"");
	} else if( window.external ) { // IE Favorite
		window.external.AddFavorite( url, titel); }
	else if(window.opera && window.print) { // Opera Hotlist
		return true; 
	}
 	
	/*
	
	
	
	if(window.external && ie && agent_ver>=4){
		var url = this.location.href;
		var who = titel;
		window.external.AddFavorite(url,who);
	}else{
		alert('Bitte mit STRG+D zu den Lesezeichen hinzufügen \noder diesen Link in die Lesezeichen-Leiste Ihres Browsers ziehen');
	}
	*/
	
}
function repl(wo_ersetzen,ersetzen_von,ersetzen_in){
	with(document.getElementById(wo_ersetzen)){
		value=value.split(ersetzen_von).join(ersetzen_in);	
	}
}
function switchInline(layer,showDisplay){//2005 by seebacher
	if(!showDisplay){
		showDisplay='block';
	}
	if(!document.getElementById ){
		return false;//fehler vermeiden
	}
	layer=layer.split(',');
	for(x=0;x<layer.length;x++){
		with( document.getElementById(layer[x]) ){
			/*onClick=function(){
					switchInline(this.ElementId)
			}*/		
			if(style.display!=showDisplay){
				style.display=showDisplay;				
			}else{
				style.display='none';				
			}
		}
		
	}
}
function addPic(url,ziel_id){
	html='';
	if(window.opener.document && window.opener.document.getElementById(ziel_id)){
		thumb_url='/image.php?img='+escape(url)+'&wt=100&ht=140';
		html='<img src="'+thumb_url+'" /><input type="hidden" name="'+ziel_id+'" value="'+url+'" />';
		html+='<a href="javasc'+'ript:dellPic(\''+ziel_id+'\')">löschen</a>';
		window.opener.document.getElementById(ziel_id).innerHTML=html;	
		window.close();
	}
}
function dellPic(ziel_id){
	document.getElementById(ziel_id).innerHTML='<a href="javascript:centerPop(\'user_picdb.php?ziel_id='+ziel_id+'\');">Bild hinzufügen</a>';
}

//###################
function switchInline(layer,showDisplay){//2005 by seebacher
	if(!showDisplay){
		showDisplay='block';
	}
	if(!document.getElementById ){
		return false;//fehler vermeiden
	}
	layer=layer.split(',');
	for(x=0;x<layer.length;x++){
		with( document.getElementById(layer[x]) ){
			/*onClick=function(){
					switchInline(this.ElementId)
			}*/		
			if(style.display!=showDisplay){
				style.display=showDisplay;				
			}else{
				style.display='none';				
			}
		}
		
	}
}

function help(layer){
	//bei nuegestaltung ist in sitchInine() default dann inline.. 
	//zum aufruf der hilfe wird dann diese funktion verwendet
	switchInline(layer,'block');
}
function text2html($string){
	//$string='bläser ülköü'
	$plain=new Array(
	'ä',
	'ü',
	'ö',
	'Ä',
	'Ü',
	'Ö'	
	);
	$html=new Array(
	'&auml;',
	'&uuml;',
	'&ouml;',
	'&Auml;',
	'&Uuml;',
	'&Ouml;'
	)
	for($x=0;$x<$plain.length;$x++){
		var $string=$string.split($plain[$x]).join($html[$x]);	
	}
	return $string;
}




function showAd(welche){
	//return '';
	//alert(welche)
	var myLoc=document.location.pathname.toLowerCase();
	switch(welche){
		case 'bottom':
			google_ad_client = "pub-7107165744514144";
			/* 468x60, Erstellt 15.04.10 */
			google_ad_slot = "9400538747";
			google_ad_width = 468;
			google_ad_height = 60;
			preIt='<div class="googleAdV">';
			postIt='</div>';
			break;
		case 'right':
			google_ad_client = "pub-7107165744514144";
			/* 120x600, Erstellt 15.04.10 */
			google_ad_slot = "9337228975";
			google_ad_width = 120;
			google_ad_height = 600;
			preIt='<div id="googleSkyscraper">';
			postIt='</div>';
			break;
		case 'top':
			google_ad_client = "pub-7107165744514144";
			/* Banner Bottom 468x60, Erstellt 15.04.10 */
			google_ad_slot = "2761058823";
			google_ad_width = 468;
			google_ad_height = 60;
			preIt='<div class="googleAdTop">';
			postIt='</div>';
		break;
	}
	//alert(myLoc);
	var showAdsense=((myLoc.indexOf('cardshark')==-1 && myLoc.indexOf('card-shark')== -1 )?true:false);
	showAdsense=(document.location.href.toString().indexOf("id=")!=-1 || document.location.href.toString().indexOf('local') != -1)?false:true;// für testzwecke auf false schalten
	
	if(showAdsense){/*showAdsense==true*/
                document.write(preIt+'<scr'+'ipt type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></sc'+'ript>'+postIt);
	}
}


function facebook_like(){
	//return true;
	var url=document.location.pathname;
	/*text=''; for(b in document.location){text+=b+':'+document.location[b]+'\n';};alert(text)*/	
	url_r=url.split('/');
	if(url_r.length>2)url='/'+url_r[1]+'.html';	
	/* alert(url_r); alert(url);*/
	url=escape('http://www.egomanie.com'+url);
	like_code='<iframe src="http://www.facebook.com/plugins/like.php?href='+url+'&amp;layout=button_count&amp;show_faces=true&amp;width=150&amp;action=like&amp;font=verdana&amp;colorscheme=light&amp;height=21" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:150px; height:21px;" allowTransparency="true"></iframe>';
	document.write(like_code);
}
//################################
