var xJS=true;
var showTooltipId=0;

function ivwclick(){
   var IVW="http://ruhrnach.ivwbox.de/cgi-bin/ivw/CP/nr-uc-na-lr;";
   var d="&d="+new Date().getTime();
   var zaehlpixelIVW = new Image();
   zaehlpixelIVW.src = IVW+"?r="+escape(document.referrer)+""+d;
}


function GetAbsPosition(object) {
 	// Liefert absolute Position eines Objekts zurück (kann fehler liefern bei Resize des Browsers ohne Refresh)
	var position = new Object;
	position.x = 0;
	position.y = 0;
	
	if( object ) {
		position.x = object.offsetLeft;
		position.y = object.offsetTop;
	
		if( object.offsetParent ) {
			var parentpos = GetAbsPosition(object.offsetParent);
			position.x += parentpos.x;
			position.y += parentpos.y;
		}
	}
	
	position.cx = object.offsetWidth;
	position.cy = object.offsetHeight;
	
	return position;
}

function xstooltip_hide(id) {
 	showTooltipId=showTooltipId+1;
    it = document.getElementById(id); 
    it.style.visibility = 'hidden'; 
}

function xstooltip_show(tooltipId, parentId) {
 	showTooltipId=showTooltipId+1;
	window.setTimeout("xstooltip_realshow('"+tooltipId+"','"+parentId+"',-20,20,"+showTooltipId+")", 500);
}

function xstooltip_realshow(tooltipId, parentId, posX, posY,verifyShowTooltip) {
	if (showTooltipId==verifyShowTooltip) {
		it = document.getElementById(tooltipId);	    

        img = document.getElementById(parentId); 
    
        // if tooltip is too wide, shift left to be within parent 
        //if (posX + it.offsetWidth > img.offsetWidth) posX = img.offsetWidth - it.offsetWidth;
        //if (posX < 0 ) posX = 0; 
        
		position = GetAbsPosition(img);
		x = position.x + document.body.scrollLeft + document.documentElement.scrollLeft + posX;
		//y = position.y + document.body.scrollTop + document.documentElement.scrollTop + posY;
		y = position.y + posY;

        it.style.top = y + 'px';
        it.style.left = x + 'px';
	    it.style.visibility = 'visible'; 
	}
}

function entsub(event,ourform) {
   	// Enter sendet Form
  	if (window.event && window.event.keyCode == 13)
    	ourform.submit();
	else {
	if (event && event.which == 13)
    		ourform.submit();		
    	else
		return true;
	}
	return true;
}

function unsetcheckboxes(strClassname) {
 	// Checkboxen mit Klassennamen deselektieren
	for (i=0;i<document.getElementsByTagName('input').length; i++) {
		if (document.getElementsByTagName('input').item(i).className == strClassname) {
			document.getElementsByTagName('input').item(i).checked = false;
		}
	}
}

function setcheckboxes(strClassname) {
 	// Checkboxen mit Klassennamen selektieren
	for (i=0;i<document.getElementsByTagName('input').length; i++) {
		if (document.getElementsByTagName('input').item(i).className == strClassname) {
			document.getElementsByTagName('input').item(i).checked = true;
		}
	}
}

function invertcheckboxes(strClassname) {
  	// Checkboxen mit Klassennamen Auswahl invertieren
	for (i=0;i<document.getElementsByTagName('input').length; i++) {
		if (document.getElementsByTagName('input').item(i).className == strClassname) {
		 	if (document.getElementsByTagName('input').item(i).checked == true) {
				document.getElementsByTagName('input').item(i).checked = false;
			} else {
			 	document.getElementsByTagName('input').item(i).checked = true;
			}				
		}
	}
}

function hideelement(id) {
	//safe function to hide an element with a specified id
	if (document.getElementById) { // DOM3 = IE5, NS6
		document.getElementById(id).style.display = 'none';
	}
	else {
		if (document.layers) { // Netscape 4
			document.id.display = 'none';
		}
		else { // IE 4
			document.all.id.style.display = 'none';
		}
	}
}

function showelement(id) {
	//safe function to show an element with a specified id
	if (document.getElementById) { // DOM3 = IE5, NS6
		document.getElementById(id).style.display = 'block';
	}
	else {
		if (document.layers) { // Netscape 4
			document.id.display = 'block';
		}
		else { // IE 4
			document.all.id.style.display = 'block';
		}
	}
}

function processLoginForm(satelliteId,formId) {
	// Blendet Login-Form aus und hängt Satelliten-ID hinter Nutzernamen
	var username = document.getElementById(formId+'user').value;
	document.getElementById(formId+'user').style.color='#ffffff';
	hideelement(formId+'user');
	hideelement(formId);	
	if (username.substring(username.length-(satelliteId.length+2)) != '@@'+satelliteId)
		document.getElementById(formId+'user').value+='@@'+satelliteId;		
}

function togglevisibility(id) {
	if (document.getElementById)
 		if (document.getElementById(id).style.display == 'block')
 	 		hideelement(id);
	 	else
		 	showelement(id);
	else
		if (document.layers) { // Netscape 4
			if (document.id.display == 'block')
				hideelement(id);
			else
			 	showelement(id);	
		}
		else { // IE 4
			if (document.all.id.style.display == 'block')
				hideelement(id);
			else
			 	showelement(id);
		}
}

function hidedivsbyclassname(strClassname) {
	for (i=0;i<document.getElementsByTagName('div').length; i++) {
		if (document.getElementsByTagName('div').item(i).className == strClassname) {
			document.getElementsByTagName('div').item(i).style.display = 'none';
			document.getElementsByTagName('div').item(i).display = 'none';
		}
	}
}

function showdivsbyclassname(strClassname) {
	for (i=0;i<document.getElementsByTagName('div').length; i++) {
		if (document.getElementsByTagName('div').item(i).className == strClassname) {
			document.getElementsByTagName('div').item(i).style.display = 'block';
			document.getElementsByTagName('div').item(i).display = 'block';
		}
	}	
}

// Set height of iframe
function goSetHeight() {
//    if (parent == window) return;
//    else parent.setIframeHeight('serviceframe');
} 


// Check if function swfu_start2 exists and execute if existing. This function is called in onload of every page
function swfu_start() {
	goSetHeight();
	xJS=true;
	// Standard SWFUpload initilaisieren
	if (window.swfu_start2)
		swfu_start2();
	// Fotografen SWFUpload initilaisieren
	if (window.proswfu_start2)
		proswfu_start2();
}

// Prüfen ob Enter gedrückt wurde
function onEnter (event, frm) {
	if (window.event && window.event.keyCode == 13)
    	return true;
	else
		if (event && event.which == 13)
	    	return true;
		else
			return false;
	
}

// Regulären Ausdruck parsen
function procRegExp(myRegExp, myRepVal, procVal) {
 	var ret = new RegExp(myRegExp, "gi");
	procVal = procVal.replace(ret, myRepVal);
	return procVal;
}


function decodeDateValues(InputOutputObject) {
 	// Zerlegt Datum/Zeitraum-Ausdruck in angegebenen Textobjekt und schreibt Ergebnis in dieses zurück

	inVal = InputOutputObject.value;

	// Wenn Zeitraum (angegeben durch "-" oder "bis"), dann splitten und einzeln verarbeiten
	if ((inVal.indexOf("-",0)>0) || (inVal.indexOf("bis",0)>0)) {
		if (inVal.indexOf("-",0)>0)
			arrInVals = inVal.split("-");
		else
			arrInVals = inVal.split("bis");

 		procVal1 = trim(arrInVals[0]);
 		procVal2 = trim(arrInVals[1]);
 	} else {
 		// Als Zeitpunkt behandeln
		procVal1 = trim(inVal);
		procVal2 = "";
	}

	// Einen oder zwei Datumswerte transformieren
	if (procVal2 == "") {
		procVal = processDateValue(procVal1);
	} else {
		procVal1 = processDateValue(procVal1);
		if (procVal1.indexOf("-",0)>0) {
			arrInVals = procVal1.split("-");
			procVal1 = arrInVals[0];
		}
		procVal2 = processDateValue(procVal2);
		if (procVal2.indexOf("-",0)>0) {
			arrInVals = procVal2.split("-");
			procVal2 = arrInVals[1];
		}
 		procVal = processDateValue(procVal1)+" - "+processDateValue(procVal2);
 	}

	// Ausgeben
	InputOutputObject.value = procVal;
}

function processDateValue(procVal) {
	// Umwandlung nahezu beliebiger deutscher Datumsformate in standardisiertes Format dd-mm-yyyy

	// Alle Zeichen ausser Buchstaben und Zahlen in Leerzeichen umwandeln
	procVal = procRegExp("[^a-zA-ZäöüÄÖÜß0-9 |]", " ", procVal);

	// Bei zweistelliger Zahl hinter Monat gehen wir davon aus, dass 19xx gemeint ist. Beispiel: August '65
	procVal = procRegExp("(Ja|Jä|Fe|Mä|Ap|Ma|Ju|Ju|Au|Se|Ok|No|De)([a-z]*) *(\\d{2}) *$", "$1$2 19$3", procVal);

	// Monate in Zahlen umwandeln
	procVal = procRegExp("Jan[a-z]*?\\b", "01 ", procVal);
	procVal = procRegExp("Jän[a-z]*?\\b", "01 ", procVal);
	procVal = procRegExp("Feb[a-z]*?\\b", "02 ", procVal);
	procVal = procRegExp("Mär[a-z]*?\\b", "03 ", procVal);
	procVal = procRegExp("Apr[a-z]*?\\b", "04 ", procVal);
	procVal = procRegExp("Mai[a-z]*?\\b", "05 ", procVal);
	procVal = procRegExp("Jun[a-z]*?\\b", "06 ", procVal);
	procVal = procRegExp("Jul[a-z]*?\\b", "07 ", procVal);
	procVal = procRegExp("Aug[a-z]*?\\b", "08 ", procVal);
	procVal = procRegExp("Sep[a-z]*?\\b", "09 ", procVal);
	procVal = procRegExp("Okt[a-z]*?\\b", "10 ", procVal);
	procVal = procRegExp("Nov[a-z]*?\\b", "11 ", procVal);
	procVal = procRegExp("Dez[a-z]*?\\b", "12 ", procVal);

	// Bei einstelligen Ziffern eine Null voranstellen
	procVal = procRegExp("\\b(\\d) ", "0$1 ", procVal);

	// Mehrere aufeinanderfolgende Leerzeichen durch ein einzelnes ersetzen
	procVal = procRegExp(" +", " ", procVal);

	// Leerzeichen am Zeilenanfang eliminieren
	procVal = procRegExp("^ ", "", procVal);

	// Leerzeichen am Zeilenende eliminieren
	procVal = procRegExp(" +$", "", procVal);

	// tt mm jjjj  -> tt.mm.jjjj
	procVal = procRegExp("(\\d{2}) (\\d{2}) (\\d{4})", "$1\.$2\.$3", procVal);

	// 01.01.08 -> 01.01.1908 (wir davon aus, dass ab 2000 der EXIF Header in Digitalfotos ausgelesen werden kann)
	//procVal = procRegExp("^(\\d{2}) (\\d{2}) (\\d{2})$", "$1\.$2\.19$3", procVal);

	// 01.01.08 -> 01.01.2008 
	// 01.01.52 -> 01.01.1952	
	var arrDateParts = procVal.split(' ');
	var curDate = new Date();
	var curYear =curDate.getFullYear();
	var twodigitYear = curYear.toString().slice(2);
	if (arrDateParts[2] <= twodigitYear) {		
		procVal = procRegExp("^(\\d{2}) (\\d{2}) (\\d{2})$", "$1\.$2\.20$3", procVal);		
	} else {
		procVal = procRegExp("^(\\d{2}) (\\d{2}) (\\d{2})$", "$1\.$2\.19$3", procVal);
	}	

	// mm jjjj  -> 01.mm.jjjj  -> Zeitraum!
	procVal = procRegExp("(01|03|05|07|08|10|12) (\\d{4})", "01\.$1\.$2 - 31\.$1\.$2", procVal);
	procVal = procRegExp("(02) (\\d{4})", "01\.$1\.$2 - 29\.$1\.$2", procVal);	// Achtung Schaltjahr ist nicht beruecksichtigt!
	procVal = procRegExp("(04|06|09|11) (\\d{4})", "01\.$1\.$2 - 30\.$1\.$2", procVal);
		
	// jjjj  -> 01.01.jjjj -> Zeitraum!
	procVal = procRegExp("^(\\d{4})$", "01\.01\.$1 - 31\.12\.$1", procVal);
		
	// jjjj mm tt -> tt.mm.jjjj
	procVal = procRegExp("^(\\d{4}) (\\d{2}) (\\d{2})$", "$3\.$2\.$1", procVal);

	// Frühling (20.03. - 20.06.)
	procVal = procRegExp("^Frü[a-z]*? *(\\d{2})$", "20\.03\.19$1-20\.06\.19$1", procVal);
	procVal = procRegExp("^Frü[a-z]*? *(\\d{4})$", "20\.03\.$1-20\.06\.$1", procVal);
	// Sommer (21.06 - 22.09.)
	procVal = procRegExp("^Som[a-z]*? *(\\d{2})$", "21\.06\.19$1-22\.09\.19$1", procVal);
	procVal = procRegExp("^Som[a-z]*? *(\\d{4})$", "21\.06\.$1-22\.09\.$1", procVal);
	// Herbst (23.09. - 21.12.)
	procVal = procRegExp("^Her[a-z]*? *(\\d{2})$", "23\.09\.19$1-21\.12\.19$1", procVal);
	procVal = procRegExp("^Her[a-z]*? *(\\d{4})$", "23\.09\.$1-21\.12\.$1", procVal);	
	// Winter (22.12. - 19.03.)
	procVal = procRegExp("^Win[a-z]*? *(\\d{2})$", "22\.12\.19$1-19\.03\.19$1", procVal);	// Problematisch: Jahr falsch?
	procVal = procRegExp("^Win[a-z]*? *(\\d{4})$", "22\.12\.$1-19\.03\.$1", procVal);		// Problematisch: Jahr falsch?

	// Abschließende Ersetzung aller Zeitraum definierenden Zeichen durch Standard " bis "
	procVal = procRegExp("(\\d\\d\\d\\d) *\\W*[bis]* *(\\d\\d\\.)", "$1 - $2", procVal);
	
	return procVal;	
}


// Checks the dates on the image admin page
function checkValidImageDates() {
 	var check1;
 	var check2;
 	var check3;
	if (document.getElementById("timesel1").checked == true) {
	 	// Zeitpunkt
		return checkValidDate("input_cal0");	 	
	} else {
	 	// Zeitraum
	 	check1 = checkValidDate("input_cal1");
	 	check2 = checkValidDate("input_cal2");
	 	check3 = checkValidDate("input_cal3");
		if (check1 && check2 && check3)
			return true;
		else
			return false;		 	 	
		//return (check1 && checkValidDate("input_cal2") && checkValidDate("input_cal3"));	
	}
}
 

// Checks for valid date 
// http://fluppe.wordpress.com/2006/04/13/javascript-check-on-valid-date/
function isDate(dateStr) {
	var datePat = /^(\d{1,2})(\/|-)(\d{1,2})(\/|-)(\d{4})$/;
	var matchArray = dateStr.match(datePat); // is the format ok?
	
	if (matchArray == null) {
	// alert(”Please enter your birth date as dd/mm/yyyy. Your current selection reads: ” + dateStr);
	return false;
	}
	
	day = matchArray[1]; // p@rse date into variables
	month = matchArray[3];
	year = matchArray[5];
	
	if (month < 1 || month > 12) { // check month range
	// alert(”Month must be between 1 and 12.”);
	return false;
	}
	
	if (day < 1 || day > 31) {
	// alert(”Day must be between 1 and 31.”);
	return false;
	}
	
	if ((month==4 || month==6 || month==9 || month==11) && day==31) {
	// alert(”Month “+month+” doesn`t have 31 days!”);
	return false;
	}
	
	if (month == 2) { // check for february 29th
	var isleap = (year % 4 == 0 && (year % 100 != 0 || year % 400 == 0));
	if (day > 29 || (day==29 && !isleap)) {
	// alert(”February ” + year + ” doesn`t have ” + day + ” days!”);
	return false;
	}
	}
	return true; // date is valid
}


// Checks if valid European Date (including month length)
// Source http://javascript.internet.com/forms/validate-date.html
function checkValidDate(id) {
	var field = document.getElementById(id);
	var checkstr = "0123456789";
	var DateField = field;
	var Datevalue = "";
	var DateTemp = "";
	var seperator = ".";
	var day;
	var month;
	var year;
	var leap = 0;
	var err = 0;
	var i;
   err = 0;
   DateValue = DateField.value;
   /* Delete all chars except 0..9 */
   for (i = 0; i < DateValue.length; i++) {
	  if (checkstr.indexOf(DateValue.substr(i,1)) >= 0) {
	     DateTemp = DateTemp + DateValue.substr(i,1);
	  }
   }
   DateValue = DateTemp;
   /* Always change date to 8 digits - string*/
   /* if year is entered as 2-digit / always assume 20xx */
   if (DateValue.length < 6) {
      err = 18;   }	
   if (DateValue.length == 6) {
      DateValue = DateValue.substr(0,4) + '20' + DateValue.substr(4,2); }
   if (DateValue.length != 8) {
      err = 19;}
   /* year is wrong if year = 0000 */
   year = DateValue.substr(4,4);
   if ((year == 0) || (year < 1900) || (year > 2010)) {
      err = 20;
   }
   /* Validation of month*/
   month = DateValue.substr(2,2);
   if ((month < 1) || (month > 12)) {
      err = 21;
   }
   /* Validation of day*/
   day = DateValue.substr(0,2);
   if (day < 1) {
     err = 22;
   }
   /* Validation leap-year / february / day */
   if ((year % 4 == 0) || (year % 100 == 0) || (year % 400 == 0)) {
      leap = 1;
   }
   if ((month == 2) && (leap == 1) && (day > 29)) {
      err = 23;
   }
   if ((month == 2) && (leap != 1) && (day > 28)) {
      err = 24;
   }
   /* Validation of other months */
   if ((day > 31) && ((month == "01") || (month == "03") || (month == "05") || (month == "07") || (month == "08") || (month == "10") || (month == "12"))) {
      err = 25;
   }
   if ((day > 30) && ((month == "04") || (month == "06") || (month == "09") || (month == "11"))) {
      err = 26;
   }
   /* if 00 ist entered, no error, deleting the entry */
   if ((day == 0) && (month == 0) && (year == 00)) {
      err = 0; day = ""; month = ""; year = ""; seperator = "";
   }
   /* if no error, write the completed date to Input-Field (e.g. 13.12.2001) */
   if (err == 0) {
		if (DateField.value != "") {
			DateField.value = day + seperator + month + seperator + year;
			return true;
		} else {
	       alert(document.getElementById("dateerrormessage").value);
	      DateField.select();
		  DateField.focus();
		  return false;
		}
   }
   /* Error-message if err != 0 */
   else {    
      alert(document.getElementById("dateerrormessage").value);
      DateField.select();
	  DateField.focus();
	  return false;
   }
}


// Checks if valid German Date
function checkValidGermanDate(id) {
	strfff = document.getElementById(id).value;
	if (strfff != "") {
		spsls = strfff.split(".");
		
		if (isNaN(spsls[0]) | isNaN(spsls[1]) | isNaN(spsls[2]) ) {		
			alert(document.getElementById("dateerrormessage").value);
			return false;
		}
		if (spsls[0]<1 | spsls[1]<1 | spsls[1]>12 | spsls[0]>31) {		 
			alert(document.getElementById("dateerrormessage").value);
			return false;
		}	
	} else {
 		alert(document.getElementById("dateerrormessage").value);
		return false;
	}
	return true;
}


/* http://simon.incutio.com/archive/2004/05/26/addLoadEvent */
function addLoadEvent(func) {
	var oldonload = window.onload;
	if (typeof window.onload != 'function') {
		window.onload = func;
	}
	else {
		window.onload = function() {
			if (oldonload) {
			    oldonload();
			}
			func();
		}
	}
}

/* http://www.dustindiaz.com/getelementsbyclass/ */
function getElementsByClass(searchClass,node,tag) {
	var classElements = new Array();
	if ( node == null )
		node = document;
	if ( tag == null )
		tag = '*';
	var els = node.getElementsByTagName(tag);
	var elsLen = els.length;
	var pattern = new RegExp("(^|\\s)"+searchClass+"(\\s|$)");
	for (i = 0, j = 0; i < elsLen; i++) {
		if ( pattern.test(els[i].className) ) {
			classElements[j] = els[i];
			j++;
		}
	}
	return classElements;
}

/* Add the type to input elements */
function changeInputs() {
	var els = document.getElementsByTagName('input');
	var elsLen = els.length;
	var i = 0;
	for ( i=0;i<elsLen;i++ ) {
		if ( els[i].getAttribute('type') ) {
			if ( els[i].getAttribute('type') == "text" ) {
				els[i].className = 'text';
			}
		}
	}
}

// Ajax für Kategorienauswahl
function xmlhttpPost(strURL,intIndex,intMode) {
    var xmlHttpReq = false;
    var self = this;
    // Mozilla/Safari
    if (window.XMLHttpRequest) {
        self.xmlHttpReq = new XMLHttpRequest();
    }
    // IE
    else if (window.ActiveXObject) {
        self.xmlHttpReq = new ActiveXObject("Microsoft.XMLHTTP");
    }
    self.xmlHttpReq.open('POST', strURL, true);
    self.xmlHttpReq.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded; charset=UTF-8');

    self.xmlHttpReq.onreadystatechange = function() {
        if (self.xmlHttpReq.readyState == 4) {
         	if (intMode == 0)
	            updatepagecat(self.xmlHttpReq.responseText,intIndex);
	        if (intMode == 1)
	            updatepageplace(self.xmlHttpReq.responseText);
	        if (intMode == 2)
	            updatepagealbumnext(self.xmlHttpReq.responseText);	            
	        if (intMode == 3)
	            updatepagealbumprev(self.xmlHttpReq.responseText);	  	            
		if (intMode == 4)
	            updatepagetimelinenext(self.xmlHttpReq.responseText);	            
	        if (intMode == 5)
	            updatepagetimelineprev(self.xmlHttpReq.responseText);
	        if (intMode == 6)
	            updatepagesubplace(self.xmlHttpReq.responseText);
		if (intMode == 7)
	            updatepagesubplacemap(self.xmlHttpReq.responseText);		    
        }
    }
    if (intMode == 0)
	    self.xmlHttpReq.send(getquerystringcat(intIndex));
    if (intMode == 1)	    
	    self.xmlHttpReq.send(getquerystringplace());    
    if (intMode == 2)	    
	    self.xmlHttpReq.send(getquerystringalbumnext(intIndex));    
    if (intMode == 3)	    
	    self.xmlHttpReq.send(getquerystringalbumprev(intIndex));    	    
    if (intMode == 4)	    
	    self.xmlHttpReq.send(getquerystringtimelinenext(intIndex));    
    if (intMode == 5)	    
	    self.xmlHttpReq.send(getquerystringtimelineprev(intIndex));
    if (intMode == 6)	    
	    self.xmlHttpReq.send(getquerystringsubplace());
    if (intMode == 7)
	    self.xmlHttpReq.send(getquerystringsubplacemap());	    
}

function getquerystringcat(intIndex) {
   	var w = document.getElementById("category_"+intIndex+"_0").selectedIndex;
    qstr = 'w='+escape(document.getElementById("category_"+intIndex+"_0").options[w].value)+'&i='+escape(intIndex)+'&l='+document.getElementById("dblanguageid").value; 
    return qstr;
}

function updatepagecat(str,intIndex){
    document.getElementById("subcategories_"+intIndex).innerHTML = str;
}

function getquerystringplace() {
   	var w = document.getElementById("countryList").selectedIndex;
    qstr = 'w='+escape(document.getElementById("countryList").options[w].value)+'&l='+document.getElementById("dblanguageid").value;
    return qstr;
}

function getquerystringsubplace() {
    var w = document.getElementById("placeList").selectedIndex;
    qstr = 'w='+escape(document.getElementById("placeList").options[w].value)+'&l='+document.getElementById("dblanguageid").value;
    return qstr;
}

function getquerystringsubplacemap() {	
    var w = document.getElementById("subPlaceList").selectedIndex;
    qstr = 'w='+escape(document.getElementById("subPlaceList").options[w].value)+'&l='+document.getElementById("dblanguageid").value;
    return qstr;
}

function updatepageplace(str){
    // Aktualisierung der Ortsliste nach Länderwahl: immer Subortliste und Subortkarte ausblenden
    hidedivsbyclassname("placeaddmap");
    document.getElementById("subPlaceMapLat_sec").value = "";
    document.getElementById("subPlaceMapLong_sec").value = "";	    
    hidedivsbyclassname("placeadd");	
    document.getElementById("subPlaceList_sec").value = "";    
    
    document.getElementById("placeListContainer").innerHTML = str;
}

function updatepagesubplace(str){
    // Aktualisierung der Sub-Ortsliste nach Ortswahl:  immer Subortkarte ausblenden
    hidedivsbyclassname("placeaddmap");
    document.getElementById("subPlaceMapLat_sec").value = "";
    document.getElementById("subPlaceMapLong_sec").value = "";	
    if (str=='') {	
    	hidedivsbyclassname("placeadd");	
	document.getElementById("subPlaceList_sec").value = "";
    } else {	
	showdivsbyclassname("placeadd");
	document.getElementById("subPlaceListContainer").innerHTML = str;	
    }
}

function updatepagesubplacemap(str){
    // Karte zur Subortliste ggf. ausblenden
    if (str=='') {
    	hidedivsbyclassname("placeaddmap");
	document.getElementById("subPlaceMapLat_sec").value = "";
	document.getElementById("subPlaceMapLong_sec").value = "";		
    } else {
	showdivsbyclassname("placeaddmap");
	document.getElementById("subPlaceMapContainer").innerHTML = str;	
    }
}

function getquerystringalbumnext(intAlbumId) {
   	var a = parseInt(document.getElementById("photoalbumpreview").className);
    qstr = 'p='+escape(a+1)+'&a='+intAlbumId; 
    return qstr;
}

function getquerystringalbumprev(intAlbumId) {
   	var a = parseInt(document.getElementById("photoalbumpreview").className);
    qstr = 'p='+escape(a-1)+'&a='+intAlbumId; 
    return qstr;
}

function updatepagealbumnext(str){
   	var a = parseInt(document.getElementById("photoalbumpreview").className);
 	// Button "Prev" enabled
 	var buttonSourceOrig = document.getElementById("photoalbumbtnprev").src;
 	var buttonSourceNew = buttonSourceOrig.replace(/_0./g, "_1.");
 	document.getElementById("photoalbumbtnprev").src = buttonSourceNew;

 	var hasEmptyImage = str.search(/_empty_/);
	if (hasEmptyImage!=-1) {
	 	// Keine weiteren Bilder / keine nächste Seite 	
	 	// Button "next" disablen	 	
 		var buttonSourceOrig = document.getElementById("photoalbumbtnnext").src;
		var buttonSourceNew = buttonSourceOrig.replace(/_1./g, "_0.");
		document.getElementById("photoalbumbtnnext").src = buttonSourceNew;		 	
	} 
    document.getElementById("photoalbumpreview").className = (a+1);
    if (str!='') {
	    document.getElementById("photoalbumpreview").innerHTML = str;
	} else {	 
	    document.getElementById("photoalbumpreview").className = (a);
	}
}

function updatepagealbumprev(str){
   	var a = parseInt(document.getElementById("photoalbumpreview").className);
	if ((a-1)==0) {
	 	// Button "Prev" disablen
 		var buttonSourceOrig = document.getElementById("photoalbumbtnprev").src;
		var buttonSourceNew = buttonSourceOrig.replace(/_1./g, "_0.");
		document.getElementById("photoalbumbtnprev").src = buttonSourceNew;		
	}   	
	if (str!='') {
	 	// Weitere Bilder	 		 	
	    document.getElementById("photoalbumpreview").innerHTML = str;	 
	    document.getElementById("photoalbumpreview").className = (a-1);
	}
	// Button "next" enablen
	var buttonSourceOrig = document.getElementById("photoalbumbtnnext").src;
	var buttonSourceNew = buttonSourceOrig.replace(/_0./g, "_1.");
	document.getElementById("photoalbumbtnnext").src = buttonSourceNew;		
}

function getquerystringtimelineprev(intAlbumId) { 
   	var y = parseInt(document.getElementById("statictimelinetable").className);
    qstr = 'y='+escape(y-1)+'&p='+escape(document.getElementById("pidsearchresults").className)+'&msg='+escape(document.getElementById("amountmessage").className);
    return qstr;
}

function getquerystringtimelinenext(intAlbumId) {
   	var y = parseInt(document.getElementById("statictimelinetable").className);
    qstr = 'y='+escape(y+1)+'&p='+escape(document.getElementById("pidsearchresults").className)+'&msg='+escape(document.getElementById("amountmessage").className);
    return qstr;
}

function updatepagetimelinenext(str){
   	var a = parseInt(document.getElementById("statictimelinetable").className);
 	// Button "Prev" enabled
 	var buttonSourceOrig = document.getElementById("timelinebtnprev").src;
 	var buttonSourceNew = buttonSourceOrig.replace(/_0./g, "_1.");
 	document.getElementById("timelinebtnprev").src = buttonSourceNew;

 	var hasEmptyImage = str.search(/_empty_/);
	if (hasEmptyImage!=-1) {
	 	// Keine weiteren Bilder / keine nächste Seite 	
	 	// Button "next" disablen	 	
 		var buttonSourceOrig = document.getElementById("timelinebtnnext").src;
		var buttonSourceNew = buttonSourceOrig.replace(/_1./g, "_0.");
		document.getElementById("timelinebtnnext").src = buttonSourceNew;		 	
	} 
    document.getElementById("statictimelinetable").className = (a+1);
    if (str!='') {
	    document.getElementById("statictimelinetable").innerHTML = str;
	} else {	 
	    document.getElementById("statictimelinetable").className = (a);
	}
}

function updatepagetimelineprev(str){
   	var a = parseInt(document.getElementById("statictimelinetable").className);
	if ((a-1)==0) {
	 	// Button "Prev" disablen
 		var buttonSourceOrig = document.getElementById("timelinebtnprev").src;
		var buttonSourceNew = buttonSourceOrig.replace(/_1./g, "_0.");
		document.getElementById("timelinebtnprev").src = buttonSourceNew;		
	}   	
	if (str!='') {
	 	// Weitere Bilder	 		 	
	    document.getElementById("statictimelinetable").innerHTML = str;	 
	    document.getElementById("statictimelinetable").className = (a-1);
	}
	// Button "next" enablen
	var buttonSourceOrig = document.getElementById("timelinebtnnext").src;
	var buttonSourceNew = buttonSourceOrig.replace(/_0./g, "_1.");
	document.getElementById("timelinebtnnext").src = buttonSourceNew;		
}

function trim(stringToTrim) {
	return stringToTrim.replace(/^\s+|\s+$/g,"");
}

