var protectedValue="";
var originalValue="";
function selectValueFromDB( plzValue){
	originalValue=plzValue;
	protectedValue=parseInt( plzValue);
	protectedValue=protectedValue.toString();
	if( originalValue.length>3){
		
		setTimeout( "checkValue()", 1000);
		return;
	}
	wrongPLZ( plzValue);
}
function checkValue(){
	advAJAX.get({
		  url: defaultHost+"/plz/"+originalValue,
		  unique: false,
		  onLoading : function(obj) { if(document.getElementById('loader'))document.getElementById('loader').className='on';},
		  onSuccess : function(obj) { if(document.getElementById('loader'))document.getElementById('loader').className='off';if( obj.responseText.length>20){  insertedValue("value", 2); document.getElementById('city').innerHTML=obj.responseText; document.getElementById('showThisDiv').style.display='block'; } else { if(protectedValue.length>4) {wrongPLZ( protectedValue);}} }
	});
	document.getElementById('city').style.display='block';
}
var showMonit=true;
function wrongPLZ( plzValue){
	if( showMonit && plzValue.length>3){
		showMonit=false;
		alert('Deine PLZ existiert leider nicht in unserer Datenbank. Bitte wähle die PLZ deiner nächstgreren Stadt.');
		clearValue('plz');
		setFocus('plz');
		showMonit=true;
		return;
	}
}

function performGruscheln( id, objectLink ) {
	objectLink.disabled = true;
	advAJAX.post({
		url: defaultHost+"/index.php/knuffeln/"+id,
		unique: false,
		onSuccess : function(obj) { if( obj.responseText.length > 20 ) { document.getElementById('bt_knuffeln').style.display="none"; } }
	});
}


function validateWilkommen(){
	if( !isNotEmptyField('pass' )){
		alert('Bitte gebe ein Passwort an.');
		setFocus('pass');
		clearValue('pass2');
		return;
	}
	if( !higherThan('pass', 4 )){
		alert('Dein Passwort muss min. 5 Zeichen haben.');
		clearValue('pass');
		clearValue('pass2');
		setFocus('pass');
		return;
	}
	if( higherThan('pass', 12 )){
		alert('Dein Passwort darf max. 12 Zeichen haben.');
		clearValue('pass');
		clearValue('pass2');
		setFocus('pass');
		return;
	}
	if( !passIsEqual('pass', 'pass2' )){
		alert('Passwrter stimmen nicht berein');
		clearValue('pass');
		clearValue('pass2');
		setFocus('pass');
		return;
	}
	if( !isNotEmptyField('plz' )){
		alert('Bitte gebe eine PLZ an.');
		setFocus('plz');
		clearValue('plz');
		return;
	}
	if( !higherThan('plz', 3 )){
		alert('PLZ muss min 4 Zeichen haben.');
		clearValue('plz');
		setFocus('plz');
		return;
	}
	if( higherThan('plz', 5 )){
		alert('PLZ darf max. 5 Zeichen haben.');
		clearValue('plz');
		setFocus('plz');
		return;
	}
	if( !document.getElementById('citySel')){
		alert('Bitte w?hle deine Stadt.');
		clearValue('plz');
		setFocus('plz');
		return;
	}
	document.forms[0].submit();
}
function validateRegistration(){
	if( !document.getElementById('citySel')){
		selectValueFromDB(document.getElementById('plz').value);
	}
	if( !isNotEmptyField('nick' )){
		alert('Bitte gebe deinen Nick an.');
		setFocus('nick');
		return;
	}
	if( !higherThan('nick', 2 )){
		alert('Dein Nick muss min. 3 Zeichen haben.');
		clearValue('nick');
		setFocus('nick');
		return;
	}
	if( higherThan('nick', 10 )){
		alert('Dein Nick darf max. 10 Zeichen haben.');
		clearValue('nick');
		setFocus('nick');
		return;
	}
	if( !isNotEmptyField('pass' )){
		alert('Bitte gebe ein Passwort an.');
		setFocus('pass');
		clearValue('pass2');
		return;
	}
	if( !higherThan('pass', 4 )){
		alert('Dein Passwort muss min. 5 Zeichen haben.');
		clearValue('pass');
		clearValue('pass2');
		setFocus('pass');
		return;
	}
	if( higherThan('pass', 12 )){
		alert('Dein Passwort darf max. 12 Zeichen haben.');
		clearValue('pass');
		clearValue('pass2');
		setFocus('pass');
		return;
	}
	if( !passIsEqual('pass', 'pass2' )){
		alert('Passwrter stimmen nicht berein');
		clearValue('pass');
		clearValue('pass2');
		setFocus('pass');
		return;
	}
	if( !isNotEmptyField('email' )){
		alert('Bitte gebe eine E-Mail an.');
		setFocus('email');
		return;
	}
	if( higherThan('email', 100 )){
		alert('Bitte gebe eine krzere E-Mail an - max. 100 Zeichen.');
		clearValue('email');
		setFocus('email');
		return;
	}
	if( !( isChecked('geschlecht1' ) || isChecked('geschlecht2' ) )){
		alert('Bitte whle dein Geschlecht.');
		return;
	}
	if( !isNotEmptyField('plz' )){
		alert('Bitte gebe eine PLZ an.');
		setFocus('plz');
		clearValue('plz');
		return;
	}
	if( !higherThan('plz', 3 )){
		alert('PLZ muss min 4 Zeichen haben.');
		clearValue('plz');
		setFocus('plz');
		return;
	}
	if( higherThan('plz', 5 )){
		alert('PLZ darf max. 5 Zeichen haben.');
		clearValue('plz');
		setFocus('plz');
		return;
	}
	if( !isNotEmptyField('foto' )){
		alert('Bitte whle ein Foto zum hochladen.');
		return;
	}
	if( !isChecked('agb' )){
		alert('Die AGB sind nicht akzeptiert worden.');
		return;
	}
	document.forms[2].submit();
}
function validateLogin( doSubmit){
	if( !isNotEmptyField('nick' )){
		alert('Bitte Nick angeben.');
		setFocus('nick');
		return false;
	}
	if( !higherThan('nick', 1 )){
		alert('Dein Nick muss min. 3 Zeichen haben.');
		clearValue('nick');
		setFocus('nick');
		return false;
	}
	if( !isNotEmptyField('pass' )){
		alert('Bitte gebe dein Passwort an.');
		setFocus('pass');
		clearValue('pass2');
		return false;
	}
	if( !higherThan('pass', 1 )){
		alert('Passwort muss min. 2 Zeichen haben.');
		clearValue('pass');
		clearValue('pass2');
		setFocus('pass');
		return false;
	}
	if( higherThan('pass', 12 )){
		alert('Passwort darf max. 12 Zeichen haben');
		clearValue('pass');
		clearValue('pass2');
		setFocus('pass');
		return false;
	}
	if( doSubmit){
		document.forms[2].submit();
	}
	return true;
}
function validateFP( doSubmit){
	if( !isNotEmptyField('nick' )){
		alert('Bitte gebe deinen Nick an.');
		setFocus('nick');
		return false;
	}
	if( !higherThan('nick', 1 )){
		alert('Dein Nick muss min. 3 Zeichen haben.');
		clearValue('nick');
		setFocus('nick');
		return false;
	}
	if( !isNotEmptyField('mail' )){
		alert('Bitte gebe eine E-Mail an.');
		setFocus('mail');
		return false;
	}
	if( !higherThan('mail', 6 )){
		alert('E-Mail muss min. 7 Zeichen haben.');
		clearValue('mail');
		setFocus('mail');
		return false;
	}
	if( higherThan('mail', 100 )){
		alert('E-Mail darf max. 100 Zeichen haben.');
		clearValue('mail');
		setFocus('mail');
		return false;
	}

	if (doSubmit)
	 document.getElementById('loginForm').submit();

	return true;
}
function validateNewPost()
{
	if( higherThan('title', 30 )){
		alert('berschrift darf max. 30 Zeichen');
		clearValue('title');
		setFocus('title');
		return;
	}
	if( !isNotEmptyField('content' )){
		alert('Bitte Inhalt schreiben.');
		setFocus('content');
		return;
	}
	if( higherThan('content', 2100 )){
		alert('Inhalt darf max. 2100 Zeichen haben.');
		setFocus('content');
		return;
	}
	document.forms[0].submit();
}
function validateNewPm()
{
	if( !isNotEmptyField('title' )){
		alert('Bitte gebe eine berschrift an.');
		setFocus('title');
		return;
	}
	if( higherThan('title', 45 )){
		alert('berschrift darf max. 45 Zeichen');
		clearValue('title');
		setFocus('title');
		return;
	}
	if( !isNotEmptyField('content' )){
		alert('Bitte Inhalt schreiben.');
		setFocus('content');
		return;
	}
	if( higherThan('content', 2000 )){
		alert('Inhalt darf max. 2000 Zeichen haben.');
		setFocus('content');
		return;
	}
	document.forms[2].submit();
}
function validateNewThread()
{
	if( !isNotEmptyField('title' )){
		alert('Bitte gebe eine berschrift an.');
		setFocus('title');
		return;
	}
	if( higherThan('title', 30 )){
		alert('berschrift darf max. 30 Zeichen');
		clearValue('title');
		setFocus('title');
		return;
	}
	if( !isNotEmptyField('content' )){
		alert('Bitte Inhalt schreiben.');
		setFocus('content');
		return;
	}
	if( higherThan('content', 2100 )){
		alert('Inhalt darf max. 2100 Zeichen haben.');
		setFocus('content');
		return;
	}
	document.forms[2].submit();
}
function validateNewThreadA()
{
	if( !isNotEmptyField('title' )){
		alert('Bitte gebe eine berschrift an.');
		setFocus('title');
		return;
	}
	if( higherThan('title', 30 )){
		alert('berschrift darf max. 30 Zeichen');
		clearValue('title');
		setFocus('title');
		return;
	}
	if( !isNotEmptyField('content' )){
		alert('Bitte Inhalt schreiben.');
		setFocus('content');
		return;
	}
	if( higherThan('content', 2100 )){
		alert('Inhalt darf max. 2100 Zeichen haben.');
		setFocus('content');
		return;
	}
	document.forms[4].submit();
}
function validateNewComment()
{
	if( !isNotEmptyField('content' )){
		alert('Bitte Kommentar schreiben.');
		setFocus('content');
		return;
	}
	if( higherThan('content', 1600 )){
		alert('Kommentar darf max. 1600 Zeichen haben.');
		setFocus('content');
		return;
	}
	document.getElementById('newComment').submit();
}
function validateNewCommentGallery( galID )
{
	if( !isNotEmptyField('content__'+galID )){
		alert('Bitte Kommentar schreiben.');
		setFocus('content__'+galID);
		return;
	}
	if( higherThan('content__'+galID, 1600 )){
		alert('Kommentar darf max. 1600 Zeichen haben.');
		setFocus('content__'+galID);
		return;
	}
	document.getElementById('newComment' ).submit();
}
function validateNewComment2()
{
	if( !isNotEmptyField('content2' )){
		alert('Bitte Kommentar schreiben.');
		setFocus('content2');
		return;
	}
	if( higherThan('content2', 250 )){
		alert('Kommentar darf max. 250 Zeichen haben.');
		setFocus('content2');
		return;
	}
	document.getElementById('newInlineComment').submit();
}
function validateNewComment3()
{
	if( !isNotEmptyField('content' )){
		alert('Bitte Kommentar schreiben.');
		setFocus('content');
		return;
	}
	if( higherThan('content', 250 )){
		alert('Kommentar darf max. 250 Zeichen haben.');
		setFocus('content');
		return;
	}
	document.getElementById('newCommentForm').submit();
}
function validateNewGallery(galID)
{
	if( !isNotEmptyField('content_'+galID )){
		alert('Bitte Kommentar schreiben.');
		setFocus('content_'+galID);
		return;
	}
	if( higherThan('content_'+galID, 250 )){
		alert('Kommentar darf max. 250 Zeichen haben.');
		setFocus('content_'+galID);
		return;
	}
	document.getElementById('newInlineComment'+galID ).submit();
}
function loadFormPages(){
	advAJAX.get({
		url: defaultHost+"/index.php/register_empty",
		unique: false,
		onSuccess : function(obj) { if( obj.responseText.length>20){ document.getElementById('smalRegistration').innerHTML=obj.responseText; } }
	});
}
function loadFriendsPages(){
	advAJAX.get({
		url: defaultHost+"/index.php/friends_show_box/"+loadFriendsPage,
		unique: false,
		onSuccess : function(obj) { if( obj.responseText.length>20){ document.getElementById('freindsContents').innerHTML=obj.responseText; } TB_init(); }
	});
}
function loadGalleryPages()
{
	return true;
  regex = /\?debug$/;
  debug = '';
  if (regex.test(document.URL))
    debug = '?debug';

	advAJAX.get({
		url: defaultHost+"/index.php/gallery_show_box/"+loadGalleryPage + debug,
		unique: false,
		onSuccess : function(obj) { if( obj.responseText.length>20){ document.getElementById('galleryContents').innerHTML=obj.responseText; } }
	});
}
function loadFriendsPages4(){
	advAJAX.get({
		url: defaultHost+"/index.php/friends_show_box_4/"+loadFriendsPage4,
		unique: false,
		onSuccess : function(obj) { if( obj.responseText.length>20){ document.getElementById('freindsContents4').innerHTML=obj.responseText; } }
	});
}
function loadFriendsPagesSmall()
{
	advAJAX.get({
		url: defaultHost+"/index.php/friends_show_box_small/"+loadFriendsPageSmall,
		unique: false,
		onSuccess : function(obj) { if( obj.responseText.length>20){ document.getElementById('freindsContents').innerHTML=obj.responseText; } }
	});
}
function loadKeywordUserPages(){
	advAJAX.get({
		url: defaultHost+"/index.php/keyword_users_show_box/"+loadKeywordUserPage,
		unique: false,
		onSuccess : function(obj) { if( obj.responseText.length>20){ document.getElementById('keywordsUserShow').innerHTML=obj.responseText; } }
	});
}
function noSchoolReminder()
{
	advAJAX.get({
		url: defaultHost+"/index.php/schule_turnoff_reminder/",
		unique: false,
		onSuccess : function(obj) { TB_remove(); }
	});
}
function loadKeywordYotubes( keyword){
	if( typeof( keyword ) == "undefined"){
		loadKeyword=loadKeywordYotube;
	} else {
		loadKeyword=keyword;
	}
	advAJAX.get({
		url: defaultHost+"/index.php/yotube/"+loadKeyword,
		onSuccess : function(obj) { if( obj.responseText.length>20){ document.getElementById('youtube_content').innerHTML=obj.responseText; } }
	});
}
function loadForumsBox(){
	advAJAX.get({
		url: defaultHost+"/index.php/forum_public_box/"+loadForumBox,
		unique: false,
		onSuccess : function(obj) { if( obj.responseText.length>20){ document.getElementById('loadForumsBox').innerHTML=obj.responseText; } }
	});
}
function loadOpenConnections(){
	advAJAX.get({
		url: defaultHost+"/index.php/open_connection/"+loadOpenConnection,
		unique: false,
		onSuccess : function(obj) { if( obj.responseText.length>20){ document.getElementById('loadOpenConnections').innerHTML=obj.responseText; } }
	});
}
function loadAccessUserShows(){
	advAJAX.get({
		url: defaultHost+"/index.php/forum_private_users_show_box/"+loadAccessUserShow,
		unique: false,
		onSuccess : function(obj) { if( obj.responseText.length>20){ document.getElementById('accessUserShow').innerHTML=obj.responseText; } }
	});
}
function loadSchulePages(){
	advAJAX.get({
		url: defaultHost+"/index.php/schule_users_show_box/"+loadSchulePage,
		unique: false,
		onSuccess : function(obj) { if( obj.responseText.length>20){ document.getElementById('schuleUserShow').innerHTML=obj.responseText; } }
	});
}
function loadSchulePagesNew(){
	advAJAX.get({
		url: defaultHost+"/index.php/schule_users_show_box_new/"+loadSchulePageNew,
		unique: false,
		onSuccess : function(obj) { if( obj.responseText.length>20){ document.getElementById('schuleUserShow').innerHTML=obj.responseText; } }
	});
}
function friendsPageReload( page, objectLink){
	objectLink.disabled=true;
	advAJAX.get({
		url: defaultHost+"/index.php/friends_show_box/"+loadFriendsPage+"/"+page,
		unique: false,
		onSuccess : function(obj) { if( obj.responseText.length>20){ document.getElementById('freindsContents').innerHTML=obj.responseText; } TB_init(); }
	});
}
function friendsPageSmallReload( page, objectLink){
	objectLink.disabled=true;
	advAJAX.get({
		url: defaultHost+"/index.php/friends_show_box_small/"+loadFriendsPageSmall+"/"+page,
		unique: false,
		onSuccess : function(obj) { if( obj.responseText.length>20){ document.getElementById('freindsContents').innerHTML=obj.responseText; } }
	});
}
function keywordUserPageReload( page, objectLink){
	objectLink.disabled=true;
	advAJAX.get({
		url: defaultHost+"/index.php/keyword_users_show_box/"+loadKeywordUserPage+"/"+page,
		unique: false,
		onSuccess : function(obj) { if( obj.responseText.length>20){ document.getElementById('keywordsUserShow').innerHTML=obj.responseText; } }
	});
}
function schuleUserPageReload( page, objectLink){
	objectLink.disabled=true;
	advAJAX.get({
		url: defaultHost+"/index.php/schule_users_show_box/"+loadSchulePage+"/"+page,
		unique: false,
		onSuccess : function(obj) { if( obj.responseText.length>20){ document.getElementById('schuleUserShow').innerHTML=obj.responseText; } }
	});
}
function schuleUserPageReloadNew( page, objectLink){
	objectLink.disabled=true;
	advAJAX.get({
		url: defaultHost+"/index.php/schule_users_show_box_new/"+loadSchulePageNew+"/"+page,
		unique: false,
		onSuccess : function(obj) { if( obj.responseText.length>20){ document.getElementById('schuleUserShow').innerHTML=obj.responseText; } }
	});
}
function privateUserPageReload( page, objectLink){
	objectLink.disabled=true;
	advAJAX.get({
		url: defaultHost+"/index.php/forum_private_users_show_box/"+loadAccessUserShow+"/"+page,
		unique: false,
		onSuccess : function(obj) { if( obj.responseText.length>20){ document.getElementById('accessUserShow').innerHTML=obj.responseText; } }
	});
}
function findMsg( msglocalname,msgfullname,containerid){
		if (containerid==null)
		{
			containerid='pmcontainer';
		}
		else
		{
			containerid='pmcontainer_'+containerid;
		}
		advAJAX.get({
		    url: msglocalname,
		    onSuccess : function(obj) { if( obj.responseText.length>0){  var stopAtPos=obj.responseText.indexOf("<!-- -->"); if( stopAtPos >= 0){document.getElementById(containerid).innerHTML=obj.responseText.substring(0, stopAtPos);} else {document.getElementById(containerid).innerHTML=obj.responseText;} } else {a=0;} }
		});
	return;
}
function wrongPM()
{
		//alert('PM kann nicht gefunden werden!');
}
function loadFormPages(){
	advAJAX.get({
		url: defaultHost+"/index.php/register_empty/"+loadFormPage,
		unique: false,
		onSuccess : function(obj) { if( obj.responseText.length>20){ document.getElementById('smalRegistration').innerHTML=obj.responseText; } }
	});
}
function setPmAsReaded( newpmID){
	advAJAX.get({
		url: defaultHost+"/index.php/pm_dont_show/"+newpmID
	});
}
function setRmAsReaded(thread_id,user_id) {
	advAJAX.get({
		url: defaultHost+"/index.php/rm_dont_show/"+thread_id+"/"+user_id
	});
}
function showUserImage( userID, elementID, tempDir){
	var userPath=calculateUserPath( userID);
	if( document.getElementById(elementID)){
		document.getElementById(elementID).style.background='url('+tempDir+'/'+userPath+'/min_'+userID+'.jpg) 50% 50% no-repeat';
	}
}
function changeBoxOpacity(valueName) {
	ourBox=document.getElementById('changeable_box_tr');
	if( valueName == "custom"){
		ourBox.className="show_box_tr";
	} else {
		ourBox.className="hidden";
	}
}
function changeGalleryOpacity(valueName,elemID) {
	ourBox=document.getElementById('perm_friends_'+elemID);
	if( valueName == '1'){
		ourBox.style.display="block";
	} else {
		ourBox.style.display="none";
	}
}
function visibleRow(id){
	var row=document.getElementById(id);
			try{
				row.style.display="table-row";
			}catch(e){
				row.style.display="block";
			}
}
function redirectMe(target) {
	document.location=target;
}
var elementsArray=new Array();
function insertedValue( formValue, formMame){
	if( formValue.length>0){
		elementsArray[formMame]=formMame;
	}
	if( typeof(elementsArray[0]) != "undefined" && typeof(elementsArray[1]) != "undefined" && typeof(elementsArray[2]) != "undefined" ){
		document.getElementById('meldungButton').style.display='block';
	}
}
function sendNotice(){
	var formContents=document.getElementById('message_contents').value.toString();
	if( formContents == ''){
		alert("Bitte gebe einen E-Mailinhalt an");
		return;
	}
	if( formContents.search(/\[einladungslink\]/) == -1){
		alert("Der Abschnitt [einladungslink] mu im E-Mailtext enthalten sein");
		return;
	}
	if( formContents.length>10000){
		alert("Mail-Inhalt zu lang");
		return;
	}
	document.forms[2].submit();
}
var keywordToSearch="";
var keywordWasFound=false;
var timeout;
var logged 		= 0;
function searchPrompt( keyword, isLogged){
	document.getElementById('disabledSubmit').className="topSubmit";
	keywordWasFound=false;
	logged=isLogged;
	if( keyword.length>0){
		keywordToSearch=keyword;
		clearTimeout( timeout);
		timeout=setTimeout( "performAJAXSearch()", 1000);
	}
}
function performAJAXSearch(){
	advAJAX.get({
		url: defaultHost+"/index.php/keyword_search/",
		unique: false,
		parameters : {
		      "keyword" : keywordToSearch
		    },
		onSuccess : function(obj) { if( obj.responseText != "nope"){ keywordToSearch=obj.responseText;document.getElementById('hereComesText').innerHTML='Schlagwort gefunden - bitte warten...';document.getElementById('disabledSubmit').className="topSubmitShow"; keywordWasFound=true; performJump(); } else { newKeyword(keywordToSearch) } }
	});
}

function performAJAXSearch(){
	advAJAX.get({
		url: defaultHost+"/index.php/keyword_search/",
		unique: false,
		parameters : {
		      "keyword" : keywordToSearch
		    },
		onSuccess : function(obj) { if( obj.responseText != "nope"){ keywordToSearch=obj.responseText;document.getElementById('hereComesText').innerHTML='Schlagwort gefunden - bitte warten...';document.getElementById('disabledSubmit').className="topSubmitShow"; keywordWasFound=true; performJump(); } else { newKeyword(keywordToSearch) } }
	});
}
function checkContent(txt,el,bt){
	
	var tmp = bt.value;
	bt.value = 'Bitte warten...'
	bt.disabled = true;
	
	if(txt=='')
	{
		return false;
	}
	advAJAX.post({
		url: defaultHost+"/index.php/check-content",
		unique: false,
		parameters : {
		      "content" : txt
		    },
		onSuccess : function(obj) {
			if(obj.responseText!='ok')
			{
				alert("Ups!  Du hast in deinem Post ein Wort, welches auf unserer Blacklist steht: "+obj.responseText+" -> bitte halte dich an die dugg Regeln, achte darauf dass du nichts veröffentlichst was wir nicht dulden und entferne das Wort!") 
				
				bt.value = tmp;
				bt.disabled = false;
				return false;
			}
			else{
				
				el.submit();
				return true;
			}
				
		}
	});
	return true;
}

function performJump(){
	if( keywordWasFound){
		document.location.href='/schlagwort-anzeigen/'+keywordToSearch;
		return true;
	}
	return false;
}
function newKeyword(keyword) {
	if( logged == 1 && confirm('Es existiert zur Zeit kein User mit diesem Schlagwort. M?chtest du dieses zu deinen Schlagw?rtern hinzuf?gen?' )){
		advAJAX.post({
			url: defaultHost+"/index.php/schlagwort-hinzufuegen/?ajax=true",
			unique: false,
			parameters : {
			      "keywords" : keyword
			    },
			onSuccess : function(obj) { if( obj.responseText.length>10){ document.location.href='/'+obj.responseText; } else { alert('Keyword cannot be added.'); } }
		});
	}
}
function changeSearchSkin( skinEnabled){
	var tempImage=new Image();
	tempImage.src="/img/box_2.jpg";
	var elem=document.getElementById('box');
	if( skinEnabled){
		if( tempImage.complete){
			elem.style.background="url(/img/box_2.jpg) no-repeat";
		} else {
			tempImage.onload='elem.style.background="url(/img/box_2.jpg) no-repeat"';
		}
		return;
	}
	elem.style.background="url(/img/box_1.jpg) no-repeat";
}
function checkUserSearch(){
	if( !isNotEmptyField('usearch' )){
		alert('Bitte Suchwort eingeben.');
		setFocus('usearch');
		return false;
	}
	return true;
}
function checkDBSchuleValues( element){
	advAJAX.get({
		  url: defaultHost+"/index.php/schule/"+element.value,
		  unique: false,
		  onSuccess : function(obj) { if( obj.responseText.length>20){ document.getElementById('city').innerHTML=obj.responseText; document.getElementById('add_new').style.display="none"; } else { document.getElementById('city').innerHTML=''; document.getElementById('add_new').style.display="block";  } }
	});
	document.getElementById('schule_new_button').style.display='block';
	document.getElementById('city').style.display='block';
}
function determineSchuleType( element, showonly, maxCount){
	advAJAX.get({
		  url: defaultHost+"/index.php/schule/"+element+"?get_only",
		  unique: false,
		  onSuccess : function(obj) { if( obj.responseText.length>20){ document.getElementById('city').innerHTML=obj.responseText;document.getElementById('add_new').style.display="none"; } else { document.getElementById('city').innerHTML=''; document.getElementById('add_new').style.display="block";  } }
	});
	advAJAX.get({
		  url: defaultHost+"/index.php/schule_type/"+element,
		  unique: false,
		  onSuccess : function(obj) { showSelect(trim(removeNL(obj.responseText))); document.getElementById('schul_id').value=element; }
	});
}
function showSelectedID( selectedID, extID){
	hideAllIDs( selectedID);
	document.getElementById(selectedID+''+extID).style.display="inline";
}
function hideAllIDs( selectedID){
	for( var i=0; document.getElementById(selectedID+''+i); i++){
		document.getElementById(selectedID+''+i).style.display="none";
	}
}
function showSelect( fieldID){
	if( fieldID == null || fieldID == ''){return;}
	document.getElementById('show_sem').style.display='none';
	document.getElementById('show_class').style.display='none';
	srow=document.getElementById('show_submit');
	try{
		srow.style.display="table-row";
	}catch(e){
		srow.style.display="block";
	}
	row=document.getElementById(fieldID);
	try{
		row.style.display="table-row";
	}catch(e){
		row.style.display="block";
	}
}
function saveAjaxValues(){
	var sname=document.getElementById('sname').value;
	var splz=document.getElementById('splz').value;
	var sorty=document.getElementById('sortx').value;
	var sortx=document.getElementById('sort').value;
	var stype=document.getElementById('stype').value;
	advAJAX.post({
		  url: defaultHost+"/index.php/schule_add",
		  parameters : {
		      "sname" 	: sname,
		      "splz" 	: splz,
		      "sort" 	: sortx,
		      "sortx" 	: sorty,
		      "stype" 	: stype
		    },
		  onSuccess : function(obj) { if( obj.responseText.length>5){ document.getElementById('add_new').style.display="none";document.getElementById('schule').value=sname;checkDBSchuleValues(document.getElementById('schule'));} }
	});
}
function LTrim( value){
	var re=/\s*((\S+\s*)*)/;
	return value.replace(re, "$1");
}
function RTrim( value){
	var re=/((\s*\S+)*)\s*/;
	return value.replace(re, "$1");
}
function trim( value){
	return LTrim(RTrim(value));
}
function removeNL(s) {
	r="";
	for (i=0; i < s.length; i++) {
		if (	s.charAt(i) != '\n' &&
			s.charAt(i) != '\r' &&
			s.charAt(i) != '\t') {
				r += s.charAt(i);
		}
	}
	return r;
}
function checkEnter(e) {
	var code;
	if (!e) var e=window.event;
	if (e.keyCode) code=e.keyCode;
	else if (e.which) code=e.which;
	if( code == 13){
		checkDBSchuleValues(document.getElementById('schule'));
		e.stopPropagation();
		return false;
	}
}
var doSumbit=false;
function disableEnter(e)
{
     var code;
if (!e) var e=window.event
	if (e.keyCode) code=e.keyCode;
	else if (e.which) code=e.which;
     if(code == 13)
     {
          checkDBSchuleValues(document.getElementById('schule'));
          return false;
         }
     else
          return true;
}
function tglCbx(id,toggler){
	var tbl=document.getElementById(id);
	var cbxs=tbl.getElementsByTagName("TBODY")[0].getElementsByTagName("INPUT");
	var len=cbxs.length;
	for(var i=0;i<len;++i){
		if(cbxs[i].getAttribute('type')=='checkbox'){
			toggler.checked ?	cbxs[i].checked=true : cbxs[i].checked=false;
		}
	}
}
function deleteGallery( galID){
	if( confirm("Willst du dieses Foto wirklich l?schen?")){
		document.location.href='/gallery_delete/'+galID;
	}
}
function addToMyInfobox( arrayID){
	var indexPointer=document.getElementById('youtube_element_'+arrayID);
	var movieString=indexPointer.innerHTML;
	var infoboxPointer=document.getElementById('desc');
	if( typeof( infoboxPointer ) != "undefined"){
		infoboxPointer.innerHTML=infoboxPointer.innerHTML + '<object><param name="movie" value="http://www.youtube.com/v/'+movieString+'"></param><param name="wmode" value="transparent"></param><embed src="http://www.youtube.com/v/'+movieString+'" type="application/x-shockwave-flash" wmode="transparent"></embed></object>';
		advAJAX.post({
			  url: "/index.php/user_info_save?video",
			  parameters : {
			      "info" 	: infoboxPointer.innerHTML
			    },
			  onSuccess : function(obj) {}
		})
		return;
	}
	alert('Infobox not defined here!');
}
function addFilter(filterName,filterValue){
	advAJAX.get({
		url: defaultHost+"/index.php/calendar_add_filter/",
		parameters : {
		      "filterName" 	: filterName,
		      "filterValue" 	: filterValue},
		onSuccess : function(obj) { if(document.getElementById('currentDate'))gWeek(document.getElementById('currentDate').value,0)}
	});
}
function clearInfobox1(){
	if( confirm( "Willst du den Inhalt dieser Box wirklich l?schen?" )){
		advAJAX.get({
			url: "/index.php/user_info_save",
			parameters : {
			      "info" 	: ''},
			onSuccess : function(obj) { alert('Inhalt der Box gel?scht!'); }
		});
	}
}
function clearInfobox2(){
	if( confirm( "Willst du den Inhalt dieser Box wirklich l?schen?" )){
		advAJAX.get({
			url: "/index.php/user_info_save?video",
			parameters : {
			      "info" 	: ''},
			onSuccess : function(obj) { alert('Inhalt der Box gel?scht!'); }
		});
	}
}

