// get position of mouse
	function setObjectPosition(obj, object){
		$(obj).click(function(e){
			$(object).css({'left' : (e.pageX - 196), 'top' : e.pageY});
		});
	}
// fadeto
	function fadeTo(element, opacity) {
		$(element).fadeTo("slow", opacity);
	}
// jquery ajax get-request
	function jquery_ajax_get(URL, container){
		$.get(URL, function(text){
			$(container).fadeOut('fast',function(){
				$(container).html(text).fadeIn('normal');
			});
		});
	}

// checkbox-action training
	function checkboxTraining(chkID, kategorie_id, betrieb_id, training_id, inhalt_id, training_inhalt_id, thema_highlighted, thema_id){
		if(chkID.checked == true){
			var todo = 'add';
			var bg_color = '#dcdcdc';
			e = document.getElementById('anzahl_kat_' + kategorie_id);
			e.innerHTML = Number(e.innerHTML) + 1;
		}else{
			var todo = 'rem';
			var bg_color = '';
			e = document.getElementById('anzahl_kat_' + kategorie_id);
			e.innerHTML = Number(e.innerHTML) - 1;
		}
		get(['layerId','training-content', 'betrieb_id',betrieb_id, 'training_id',training_id, 'inhalt_id',inhalt_id, 'training_inhalt_id',training_inhalt_id, 'do',todo], 'training-content', './app/ajax.php', 'showTrainingContent', false);
		document.getElementById('inhalt_' + inhalt_id).style.backgroundColor = bg_color;
		
		// thema highlight
		t_id = document.getElementById(thema_highlighted).value;
		t_id_split = t_id.split(',');
		j = 0;
		u = 0;
		for(i=0; i<t_id_split.length; i++){
			if(document.getElementById(t_id_split[i]).checked == true){
				j++;
			}else{
				u++;
			}
		}

		if(j == 0){
			document.getElementById('thema_header_' + thema_id).style.backgroundColor = '';
			ea = document.getElementById('anzahl_themen');
			ea.innerHTML = Number(ea.innerHTML) - 1;
		}else if(document.getElementById('thema_header_' + thema_id).style.backgroundColor == '' && j>0){
			document.getElementById('thema_header_' + thema_id).style.backgroundColor = '#dcdcdc';
			ea = document.getElementById('anzahl_themen');
			ea.innerHTML = Number(ea.innerHTML) + 1;
		}
	}

// url-variablen abfragen
	function getURLVar(urlVarName) {
		//divide the URL in half at the '?' 
		var urlHalves = String(document.location).split('?');
		var urlVarValue = '';
		if(urlHalves[1]){
			//load all the name/value pairs into an array 
			var urlVars = urlHalves[1].split('&');
			//loop over the list, and find the specified url variable 
			for(i=0; i<=(urlVars.length); i++){
				if(urlVars[i]){
					//load the name/value pair into an array 
					var urlVarPair = urlVars[i].split('=');
					if (urlVarPair[0] && urlVarPair[0] == urlVarName) {
						//I found a variable that matches, load it's value into the return variable 
						urlVarValue = urlVarPair[1];
					}
				}
			}
		}
		return urlVarValue;   
	}
// --------------------------------------------------------------------------------------

// layer bei klick ausserhalb ausblenden - freelancer-info-box
	function hideLayer_clickOutside_FlInfo(e){ 
		var target = (e && e.target) || (event && event.srcElement); 
		void(el = document.getElementsByClassName('ajaxFlInfoBox'));
		for(i=0;i<el.length;i++){
			if(target!=el[i]){el[i].style.display='none'}
		}
	}
// --------------------------------------------------------------------------------------

// layer bei klick ausserhalb ausblenden - weitere spalten bei uplan listing
	function hideLayer_clickOutside_MysInfo(e){ 
		var target = (e && e.target) || (event && event.srcElement); 
		void(el = document.getElementsByClassName('ajaxMystestBox'));
		for(i=0;i<el.length;i++){
			if(target!=el[i]){el[i].style.display='none'}
		}
	}
// --------------------------------------------------------------------------------------

// elemente nach class-name
	function getElementsByClassName(classname, node)  {
	    if(!node) node = document.getElementsByTagName("body")[0];
	    var a = [];
	    var re = new RegExp('\\b' + classname + '\\b');
	    var els = node.getElementsByTagName("*");
	    for(var i=0,j=els.length; i<j; i++)
	        if(re.test(els[i].className))a.push(els[i]);
	    return a;
	}
// --------------------------------------------------------------------------------------

// text nicht markierbar machen
	function disableTextSelection(e) {
		e.onselectstart = function() { return false; } // ie
		e.onmousedown = function() { return false; } // mozilla
	}
// --------------------------------------------------------------------------------------

// image replace 
	function imgReplace(ID, image){
		document.getElementById(ID).src = image;
	}
// --------------------------------------------------------------------------------------

// check fuer single user sms
	function checkSingleUserSMS() {
		var m_nummer = document.getElementById('m_nummer');
		if(m_nummer.value != ''){
			document.getElementById('freelancer_id').disabled = true;
		}else{
			document.getElementById('freelancer_id').disabled = false;
		}
		
		var freelancer_id = document.getElementById('freelancer_id');
		if(freelancer_id.value > 0){
			document.getElementById('m_nummer').disabled = true;
			document.getElementById('m_vorwahl').disabled = true;
		}else{
			document.getElementById('m_nummer').disabled = false;
			document.getElementById('m_vorwahl').disabled = false;
		}
	}
// --------------------------------------------------------------------------------------


// zeichen-convertierung ----------------------------------------------------------------
	function convertText(input){
		
		/*input=input.replace('ö',"%C3%B6");
		input=input.replace('Ö',"%C3%96");
		input=input.replace('ü',"%C3%BC");
		input=input.replace('Ü',"%C3%9C");
		input=input.replace('ä',"%C3%A4");
		input=input.replace('Ä',"%C3%84");
		input=input.replace('ß',"%C3%9F");*/
		
		input = escape(input);
		
		linebs = '<br>';
		
		var noBreaks = input;
		noBreaks = noBreaks.replace(/\r\n/g,"[-LB-]");
		noBreaks = noBreaks.replace(/\n/g,"[-LB-]");
		noBreaks = noBreaks.replace(/\r/g,"[-LB-]");
		
		re1 = /\s+/g;
		noBreaks = noBreaks.replace(re1," ");
		re4 = /\[-LB-\]\[-LB-\]/gi;
		noBreaks = noBreaks.replace(re4,linebs+"\r\n"+linebs+"\r\n");
		
		re5 = /\[-LB-\]/gi;
		noBreaks = noBreaks.replace(re5,linebs+"\r\n");
		
		return noBreaks;
		
	}
// --------------------------------------------------------------------------------------

// http Requests über js ----------------------------------------------------------------
	//var http_request = false;
	
	function makeRequest(url, parameters, targetID) {
		http_request = false;
		if (window.XMLHttpRequest) { // Mozilla, Safari,...
			http_request = new XMLHttpRequest();
			if (http_request.overrideMimeType) {
				// set type accordingly to anticipated content type
				//http_request.overrideMimeType('text/xml');
				http_request.overrideMimeType('text/html');
			}
		} else if (window.ActiveXObject) { // IE
			try {
				http_request = new ActiveXObject("Msxml2.XMLHTTP");
			} catch (e) {
				try {
					http_request = new ActiveXObject("Microsoft.XMLHTTP");
				} catch (e) {}
			}
		}
		if (!http_request) {
			alert('Cannot create XMLHTTP instance');
			return false;
		}
		http_request.onreadystatechange = function(){
			if (http_request.readyState == 4) {
				if (http_request.status == 200) {
					//alert(http_request.responseText);
					result = http_request.responseText;
					if(targetID){
						document.getElementById(targetID).style.display = 'block';
						document.getElementById(targetID).innerHTML = result;
					} else {
						return result;
					}
				} else {
					alert('There was a problem with the request. - '.http_request.status);
				}
			}
		}
		//http_request.setRequestHeader("Content-Type", "application/x-www-form-urlencoded; charset=UTF-8");
		http_request.open('GET', url + parameters, true);
		http_request.send(null);
		
	}

	function alertContents() {
		if (http_request.readyState == 4) {
			if (http_request.status == 200) {
				//alert(http_request.responseText);
				result = http_request.responseText;
				document.getElementById(targetID).innerHTML = result;            
			} else {
				alert('There was a problem with the request.');
			}
		}
	}
   
	function get(obj, targetID, post_file, action, form) {
		var getstr = "?";
		if(form == false){
			for (i=0; i<obj.length; i++){
				if(obj[i] != ""){
					getstr += obj[i] + "=" + obj[++i] + "&";
				}
			}
			
		}else{
			for (i=0; i<obj.childNodes.length; i++) {
				if (obj.childNodes[i].tagName == "INPUT") {
					if (obj.childNodes[i].type == "text") {
						getstr += obj.childNodes[i].name + "=" + convertText(obj.childNodes[i].value) + "&";
					}
					if (obj.childNodes[i].type == "checkbox") {
						if (obj.childNodes[i].checked) {
							getstr += obj.childNodes[i].name + "=" + obj.childNodes[i].value + "&";
						} else {
							getstr += obj.childNodes[i].name + "=&";
						}
					}
					if (obj.childNodes[i].type == "radio") {
						if (obj.childNodes[i].checked) {
							getstr += obj.childNodes[i].name + "=" + obj.childNodes[i].value + "&";
						}
					}
					if (obj.childNodes[i].type == "hidden") {
						getstr += obj.childNodes[i].name + "=" + obj.childNodes[i].value + "&";
					}
				}
				
				if (obj.childNodes[i].tagName == "TEXTAREA") {
					getstr += obj.childNodes[i].name + "=" + convertText(obj.childNodes[i].value) + "&";
				}
				
				if (obj.childNodes[i].tagName == "SELECT") {
					var sel = obj.childNodes[i];
					for(j=0; sel.options[j]; j++){
						if(sel.options[j].selected == true){
							getstr += sel.name + "=" + sel.options[j].value + "&";
						}
					}
					
				}
			}
		}
		
		if(action != ""){
			getstr += 'action=' + action + '&';
		}
		
		if(post_file == ""){ post_file = "get.php"; }
		makeRequest(post_file, getstr, targetID);
		//makeRequest('get.php', getstr);
	}
	
	function showRequestLayer(ID){
		document.getElementById(ID).style.display = "block";
		document.getElementById(ID).style.visibility = "visible";
		document.getElementById(ID).style.zIndex = "3000";
	}
	
	function resetRequestLayer(ID){
		document.getElementById(ID).innerHTML = "wird geladen ...";
		document.getElementById(ID).style.display = "none";
		document.getElementById(ID).style.visibility = "hidden";
	}
// --------------------------------------------------------------------------------------

// fahrtkostenpauschale enablen, wenn test abgerechnet werden soll
	function setStatusCheckbox(checkbox1, checkbox2){
		if(document.getElementById(checkbox1).checked == true){
			document.getElementById(checkbox2).disabled = false;
		}else{
			document.getElementById(checkbox2).disabled = true;
		}
	}

// überprüfen ob datum im eingabefeld kleiner gleich heute
	function checkDate_Spesenerfassung(datum){
		datum2 = datum.value;
		datum2 = datum2.split(".");
		datum2 = new Date(datum2[2], datum2[1], datum2[0]);
		heute = new Date();
		if(datum2 > heute){
			datum.value = '';
			alert('Es ist nicht möglich, ein Datum in der Zukunft zu wählen!');
		}
	}

// preload der icons 
	function preloadImgSpesenerfassung() {
		namen = new Array("http://www.marktforschungonline.at/fieldmanager/layout/img/icons/minical.gif","http://www.marktforschungonline.at/fieldmanager/layout/img/icons/del.gif");
		bilder = new Array(namen.length);

		for (i=0;i<namen.length;i++) {
			bilder[i]=new Image();
			bilder[i].src=namen[i];
		}
	}

// wert eines form-feldes in ein anderes schreiben
	function setValueF1_F2( feld1, feld2 ){
		feld2.value = feld1.value;
	}

// hinzufügen von tabellen-zeilen für f2f ausprägungen
	function addF2fAuspraegung( table, rowIndex ){
		
		random_num = (Math.round((Math.random()*99)+1));
		Stamp = new Date();
		thisID = 'abc' + Stamp.getSeconds() + random_num;
		
		row = table.insertRow( rowIndex );
		row.id = thisID;
		
		cell = row.insertCell( 0 );
		input = document.createElement( 'INPUT' );
		input.type = 'text';
		input.name = 'fields_a[' + thisID + '][quoten_auspraegung]';
		input.size = '33';
		input.id = 'quoten_auspraegung_' + thisID;
		cell.appendChild( input );
		
		cell = row.insertCell( 1 );
		input = document.createElement( 'INPUT' );
		input.type = 'text';
		input.name = 'fields_a[' + thisID + '][auspraegung_prozent]';
		input.size = '8';
		input.id = 'auspraegung_prozent_' + thisID;
		cell.appendChild( input );

		cell = row.insertCell( 2 );
		input = document.createElement( 'INPUT' );
		input.type = 'text';
		input.name = 'fields_a[' + thisID + '][auspraegung_gerechnet]';
		input.size = '8';
		input.id = 'auspraegung_gerechnet_' + thisID;
		input.onfocus = function onfocus(event) { this.blur(); };
		cell.appendChild( input );

		cell = row.insertCell( 3 );
		input = document.createElement( 'INPUT' );
		input.type = 'text';
		input.name = 'fields_a[' + thisID + '][auspraegung_gerundet]';
		input.size = '8';
		input.id = 'auspraegung_gerundet_' + thisID;
		input.onfocus = function onfocus(event) { this.blur(); };
		cell.appendChild( input );

		cell = row.insertCell( 4 );
		a_text = document.createTextNode(' ');
		/*
		a_text = document.createElement( 'A' );
		a_text.href = "javascript:setValueF1_F2( "+ document.getElementById('auspraegung_gerundet_' + thisID) +", "+ document.getElementById('auspraegung_bearbeitet_' + thisID) +" )";
		a_text.title = "Wert übernehmen";
		text = document.createTextNode('»');
		a_text.appendChild( text );
		*/
		cell.appendChild( a_text );
		
		cell = row.insertCell( 5 );
		input = document.createElement( 'INPUT' );
		input.type = 'text';
		input.name = 'fields_a[' + thisID + '][auspraegung_bearbeitet]';
		input.size = '8';
		input.id = 'auspraegung_bearbeitet_' + thisID;
		cell.appendChild( input );
		
		cell = row.insertCell( 6 );
		newa = document.createElement('A');
		newa.href = "javascript:removeElement("+ thisID +")";
		tdel = document.createTextNode('löschen');
		newa.appendChild( tdel );
		cell.appendChild( newa );
}

// ###############################  M Y S T E R Y  S P E S E N  ###############################
// hinzufügen von tabellen-zeilen für die spesenerfassung
	function addParameterFahrtspesen2( table, rowIndex ) {
	
		random_num = (Math.round((Math.random()*99)+1));
		Stamp = new Date();
		thisID = 'abc' + Stamp.getSeconds() + random_num;
		
		row = table.insertRow( rowIndex );
		row.id = thisID;
		
		cell = row.insertCell( 0 );
		
		hinput = document.createElement( 'INPUT' );
		hinput.type = 'hidden';
		hinput.name = 'fields_fahrtspesen2[' + thisID + '][auftrag_spesen_id]';
		cell.appendChild(hinput);
		h2input = document.createElement( 'INPUT' );
		h2input.type = 'hidden';
		h2input.name = 'fields_fahrtspesen2[' + thisID + '][auftrag_spesen_art_id]';
		h2input.value = '1';
		cell.appendChild(h2input);
		input = document.createElement( 'INPUT' );
		input.type = 'text';
		input.name = 'fields_fahrtspesen2[' + thisID + '][datum]';
		input.size = '9';
		input.id = 'fahrtspesen2_' + thisID;
		cell.appendChild( input );
		aCal = document.createElement('A');
		aCal.href = "javascript:if(self.gfPop)gfPop.fPopCalendar(document.spesen.fahrtspesen2_" + thisID +  ");";
		aCal.title = "Kalender";
		tKal = document.createTextNode('Kal');
		aCal.appendChild( tKal );
		/*
		imgCal = document.createElement( 'IMG' );
		imgCal.src = 'http://www.marktforschungonline.at/fieldmanager/layout/img/icons/minical.gif';
		//imgCal.src = '/home/www/web157/html/fieldmanager/layout/img/icons/minical.gif';
		imgCal.border = '0';
		imgCal.title = 'Kalender';
		aCal.appendChild( imgCal );
		*/
		cell.appendChild( aCal );
		
		cell = row.insertCell( 1 );
		input = document.createElement( 'INPUT' );
		input.type = 'text';
		input.name = 'fields_fahrtspesen2[' + thisID + '][tests]';
		input.size = '10';
		cell.appendChild( input );
		
		cell = row.insertCell( 2 );
		input = document.createElement( 'INPUT' );
		input.type = 'text';
		input.name = 'fields_fahrtspesen2[' + thisID + '][gefahren_von]';
		input.size = '17';
		cell.appendChild( input );
		
		cell = row.insertCell( 3 );
		input = document.createElement( 'INPUT' );
		input.type = 'text';
		input.name = 'fields_fahrtspesen2[' + thisID + '][gefahren_nach]';
		input.size = '17';
		cell.appendChild( input );
		
		cell = row.insertCell( 4 );
		input = document.createElement( 'INPUT' );
		input.type = 'text';
		input.name = 'fields_fahrtspesen2[' + thisID + '][km]';
		input.size = '8';
		cell.appendChild( input );
		
		/*
		cell = row.insertCell( 5 );
		input = document.createElement( 'INPUT' );
		input.type = 'text';
		input.name = 'fields_fahrtspesen2[' + thisID + '][km_geld]';
		input.size = '8';
		cell.appendChild( input );
		
		cell = row.insertCell( 6 );
		input = document.createElement( 'INPUT' );
		input.type = 'text';
		input.name = 'fields_fahrtspesen2[' + thisID + '][km_geld_gesamt]';
		input.size = '8';
		cell.appendChild( input );
		*/
		
		cell = row.insertCell( 5 );
		newa = document.createElement('A');
		newa.href = "javascript:removeElement("+ thisID +")";
		tdel = document.createTextNode('löschen');
		newa.appendChild( tdel );
		/*
		img = document.createElement('IMG');
		img.src = 'http://www.marktforschungonline.at/fieldmanager/layout/img/icons/del.gif';
		//img.src = '/home/www/web157/html/fieldmanager/layout/img/icons/del.gif';
		img.border = '0';
		img.title = 'löschen';
		newa.appendChild( img );
		*/
		cell.appendChild( newa );
		
		getDocHeight('afterPostLayer');
	}
	function addParameterPost( table, rowIndex ) {
	
		random_num = (Math.round((Math.random()*99)+1));
		Stamp = new Date();
		thisID = Stamp.getSeconds() + random_num;
		
		row = table.insertRow( rowIndex );
		row.id = thisID;
		
		cell = row.insertCell( 0 );
		hinput = document.createElement( 'INPUT' );
		hinput.type = 'hidden';
		hinput.name = 'fields_post[' + thisID + '][auftrag_spesen_id]';
		cell.appendChild(hinput);
		h2input = document.createElement( 'INPUT' );
		h2input.type = 'hidden';
		h2input.name = 'fields_post[' + thisID + '][auftrag_spesen_art_id]';
		h2input.value = '4';
		cell.appendChild(h2input);
		input = document.createElement( 'INPUT' );
		input.type = 'text';
		input.name = 'fields_post[' + thisID + '][datum]';
		input.size = '9';
		input.id = 'post_' + thisID;
		cell.appendChild( input );
		
		aCal = document.createElement('A');
		aCal.href = "javascript:if(self.gfPop)gfPop.fPopCalendar(document.spesen.post_" + thisID +  ");";
		aCal.title = "Kalender";
		tKal = document.createTextNode('Kal');
		aCal.appendChild( tKal );
		/*
		imgCal = document.createElement( 'IMG' );
		imgCal.src = 'http://www.marktforschungonline.at/fieldmanager/layout/img/icons/minical.gif';
		//imgCal.src = '/home/www/web157/html/fieldmanager/layout/img/icons/minical.gif';
		imgCal.border = '0';
		imgCal.title = 'Kalender';
		aCal.appendChild( imgCal );
		*/
		//aCal.onclick = if(self.gfPop)gfPop.fPopCalendar(document.spesen.fahrtspesen2_ + thisID +  );return false;
		cell.appendChild( aCal );
		
		cell = row.insertCell( 1 );
		input = document.createElement( 'INPUT' );
		input.type = 'text';
		input.name = 'fields_post[' + thisID + '][tests]';
		input.size = '10';
		cell.appendChild( input );
		
		cell = row.insertCell( 2 );
		input = document.createElement( 'INPUT' );
		input.type = 'text';
		input.name = 'fields_post[' + thisID + '][text]';
		input.size = '17';
		cell.appendChild( input );
		
		/*
		cell = row.insertCell( 3 );
		input = document.createElement( 'INPUT' );
		input.type = 'text';
		input.name = 'fields_post[' + thisID + '][betrag_netto]';
		input.size = '8';
		input.value = '0';
		cell.appendChild( input );
		
		cell = row.insertCell( 4 );
		input = document.createElement( 'INPUT' );
		input.type = 'text';
		input.name = 'fields_post[' + thisID + '][betrag_ust]';
		input.size = '8';
		input.value = '0';
		cell.appendChild( input );
		*/
		
		cell = row.insertCell( 3 );
		input = document.createElement( 'INPUT' );
		input.type = 'text';
		input.name = 'fields_post[' + thisID + '][betrag]';
		input.size = '8';
		cell.appendChild( input );
		
		cell = row.insertCell( 4 );
		newa = document.createElement('A');
		newa.href = "javascript:removeElement("+ thisID +")";
		tdel = document.createTextNode('löschen');
		newa.appendChild( tdel );
		/*
		img = document.createElement('IMG');
		img.src = 'http://www.marktforschungonline.at/fieldmanager/layout/img/icons/del.gif';
		//img.src = '/home/www/web157/html/fieldmanager/layout/img/icons/del.gif';
		img.border = '0';
		img.title = 'löschen';
		text = document.createTextNode( 'del' );
		newa.appendChild( img );
		*/
		cell.appendChild( newa );
		
		getDocHeight('afterPostLayer');
	}
	function addParameterSpesen( table, rowIndex ) {
	
		random_num = (Math.round((Math.random()*99)+1));
		Stamp = new Date();
		thisID = Stamp.getSeconds() + random_num;
		
		row = table.insertRow( rowIndex );
		row.id = thisID;
		
		cell = row.insertCell( 0 );
		hinput = document.createElement( 'INPUT' );
		hinput.type = 'hidden';
		hinput.name = 'fields_spesen[' + thisID + '][auftrag_spesen_id]';
		cell.appendChild(hinput);
		h2input = document.createElement( 'INPUT' );
		h2input.type = 'hidden';
		h2input.name = 'fields_spesen[' + thisID + '][auftrag_spesen_art_id]';
		h2input.value = '3';
		cell.appendChild(h2input);
		input = document.createElement( 'INPUT' );
		input.type = 'text';
		input.name = 'fields_spesen[' + thisID + '][datum]';
		input.size = '9';
		input.id = 'spesen_' + thisID;
		cell.appendChild( input );
		
		aCal = document.createElement('A');
		aCal.href = "javascript:if(self.gfPop)gfPop.fPopCalendar(document.spesen.spesen_" + thisID +  ");";
		aCal.title = "Kalender";
		tKal = document.createTextNode('Kal');
		aCal.appendChild( tKal );
		/*
		imgCal = document.createElement( 'IMG' );
		imgCal.src = 'http://www.marktforschungonline.at/fieldmanager/layout/img/icons/minical.gif';
		//imgCal.src = '/home/www/web157/html/fieldmanager/layout/img/icons/minical.gif';
		imgCal.border = '0';
		imgCal.title = 'Kalender';
		aCal.appendChild( imgCal );
		aCal.href = "javascript:if(self.gfPop)gfPop.fPopCalendar(document.spesen.spesen_" + thisID +  ");";
		//aCal.onclick = if(self.gfPop)gfPop.fPopCalendar(document.spesen.fahrtspesen2_ + thisID +  );return false;
		*/
		cell.appendChild( aCal );
		
		cell = row.insertCell( 1 );
		input = document.createElement( 'INPUT' );
		input.type = 'text';
		input.name = 'fields_spesen[' + thisID + '][tests]';
		input.size = '10';
		cell.appendChild( input );
		
		cell = row.insertCell( 2 );
		input = document.createElement( 'INPUT' );
		input.type = 'text';
		input.name = 'fields_spesen[' + thisID + '][text]';
		input.size = '17';
		cell.appendChild( input );
		
		/*
		cell = row.insertCell( 3 );
		input = document.createElement( 'INPUT' );
		input.type = 'text';
		input.name = 'fields_spesen[' + thisID + '][betrag_netto]';
		input.size = '8';
		input.value = '0';
		cell.appendChild( input );
		
		cell = row.insertCell( 4 );
		input = document.createElement( 'INPUT' );
		input.type = 'text';
		input.name = 'fields_spesen[' + thisID + '][betrag_ust]';
		input.size = '8';
		input.value = '0';
		cell.appendChild( input );
		*/
		
		cell = row.insertCell( 3 );
		input = document.createElement( 'INPUT' );
		input.type = 'text';
		input.name = 'fields_spesen[' + thisID + '][betrag]';
		input.size = '8';
		cell.appendChild( input );
		
		cell = row.insertCell( 4 );
		newa = document.createElement('A');
		newa.href = "javascript:removeElement("+ thisID +")";
		tdel = document.createTextNode('löschen');
		newa.appendChild( tdel );
		/*
		img = document.createElement('IMG');
		img.src = 'http://www.marktforschungonline.at/fieldmanager/layout/img/icons/del.gif';
		//img.src = '/home/www/web157/html/fieldmanager/layout/img/icons/del.gif';
		img.border = '0';
		img.title = 'löschen';
		text = document.createTextNode( 'del' );
		newa.appendChild( img );
		*/
		cell.appendChild( newa );
		
		getDocHeight('afterPostLayer');
	}
	function addParameterAuslagen( table, rowIndex ) {
	
		random_num = (Math.round((Math.random()*99)+1));
		Stamp = new Date();
		thisID = Stamp.getSeconds() + random_num;
		
		row = table.insertRow( rowIndex );
		row.id = thisID;
		
		cell = row.insertCell( 0 );
		hinput = document.createElement( 'INPUT' );
		hinput.type = 'hidden';
		hinput.name = 'fields_auslagen[' + thisID + '][auftrag_spesen_id]';
		cell.appendChild(hinput);
		h2input = document.createElement( 'INPUT' );
		h2input.type = 'hidden';
		h2input.name = 'fields_auslagen[' + thisID + '][auftrag_spesen_art_id]';
		h2input.value = '5';
		cell.appendChild(h2input);
		input = document.createElement( 'INPUT' );
		input.type = 'text';
		input.name = 'fields_auslagen[' + thisID + '][datum]';
		input.size = '9';
		input.id = 'auslagen_' + thisID;
		cell.appendChild( input );
		
		aCal = document.createElement('A');
		aCal.href = "javascript:if(self.gfPop)gfPop.fPopCalendar(document.spesen.auslagen_" + thisID +  ");";
		aCal.title = "Kalender";
		tKal = document.createTextNode('Kal');
		aCal.appendChild( tKal );
		/*
		imgCal = document.createElement( 'IMG' );
		imgCal.src = 'http://www.marktforschungonline.at/fieldmanager/layout/img/icons/minical.gif';
		//imgCal.src = '/home/www/web157/html/fieldmanager/layout/img/icons/minical.gif';
		imgCal.border = '0';
		imgCal.title = 'Kalender';
		aCal.appendChild( imgCal );
		//aCal.onclick = if(self.gfPop)gfPop.fPopCalendar(document.spesen.fahrtspesen2_ + thisID +  );return false;
		*/
		cell.appendChild( aCal );
		
		cell = row.insertCell( 1 );
		input = document.createElement( 'INPUT' );
		input.type = 'text';
		input.name = 'fields_auslagen[' + thisID + '][tests]';
		input.size = '10';
		cell.appendChild( input );
		
		cell = row.insertCell( 2 );
		input = document.createElement( 'INPUT' );
		input.type = 'text';
		input.name = 'fields_auslagen[' + thisID + '][text]';
		input.size = '17';
		cell.appendChild( input );
		
		/*
		cell = row.insertCell( 3 );
		input = document.createElement( 'INPUT' );
		input.type = 'text';
		input.name = 'fields_auslagen[' + thisID + '][betrag_netto]';
		input.size = '8';
		input.value = '0';
		cell.appendChild( input );
		
		cell = row.insertCell( 4 );
		input = document.createElement( 'INPUT' );
		input.type = 'text';
		input.name = 'fields_auslagen[' + thisID + '][betrag_ust]';
		input.size = '8';
		input.value = '0';
		cell.appendChild( input );
		*/
		
		cell = row.insertCell( 3 );
		input = document.createElement( 'INPUT' );
		input.type = 'text';
		input.name = 'fields_auslagen[' + thisID + '][betrag]';
		input.size = '8';
		cell.appendChild( input );
		
		cell = row.insertCell( 4 );
		newa = document.createElement('A');
		newa.href = "javascript:removeElement("+ thisID +")";
		tdel = document.createTextNode('löschen');
		newa.appendChild( tdel );
		/*
		img = document.createElement('IMG');
		img.src = 'http://www.marktforschungonline.at/fieldmanager/layout/img/icons/del.gif';
		//img.src = '/home/www/web157/html/fieldmanager/layout/img/icons/del.gif';
		img.border = '0';
		img.title = 'löschen';
		text = document.createTextNode( 'del' );
		newa.appendChild( img );
		*/
		cell.appendChild( newa );
	
		getDocHeight('afterPostLayer');
	}
// ############################################################################################

// ###################################  F 2 F  S P E S E N  ###################################
// hinzufügen von tabellen-zeilen für die spesenerfassung
	function addParameterFahrtspesen2_f2f( table, rowIndex ) {
	
		random_num = (Math.round((Math.random()*99)+1));
		Stamp = new Date();
		thisID = 'abc' + Stamp.getSeconds() + random_num;
		
		row = table.insertRow( rowIndex );
		row.id = thisID;
		
		cell = row.insertCell( 0 );
		
		hinput = document.createElement( 'INPUT' );
		hinput.type = 'hidden';
		hinput.name = 'fields_fahrtspesen2[' + thisID + '][auftrag_spesen_id]';
		cell.appendChild(hinput);
		h2input = document.createElement( 'INPUT' );
		h2input.type = 'hidden';
		h2input.name = 'fields_fahrtspesen2[' + thisID + '][auftrag_spesen_art_id]';
		h2input.value = '1';
		cell.appendChild(h2input);
		input = document.createElement( 'INPUT' );
		input.type = 'text';
		input.name = 'fields_fahrtspesen2[' + thisID + '][datum]';
		input.size = '9';
		input.id = 'fahrtspesen2_' + thisID;
		cell.appendChild( input );
		aCal = document.createElement('A');
		aCal.href = "javascript:if(self.gfPop)gfPop.fPopCalendar(document.spesen.fahrtspesen2_" + thisID +  ");";
		aCal.title = "Kalender";
		tKal = document.createTextNode('Kal');
		aCal.appendChild( tKal );
		cell.appendChild( aCal );
		
		cell = row.insertCell( 1 );
		input = document.createElement( 'INPUT' );
		input.type = 'text';
		input.name = 'fields_fahrtspesen2[' + thisID + '][gefahren_von]';
		input.size = '17';
		cell.appendChild( input );
		
		cell = row.insertCell( 2 );
		input = document.createElement( 'INPUT' );
		input.type = 'text';
		input.name = 'fields_fahrtspesen2[' + thisID + '][gefahren_nach]';
		input.size = '17';
		cell.appendChild( input );
		
		cell = row.insertCell( 3 );
		input = document.createElement( 'INPUT' );
		input.type = 'text';
		input.name = 'fields_fahrtspesen2[' + thisID + '][km]';
		input.size = '8';
		cell.appendChild( input );
		
		cell = row.insertCell( 4 );
		newa = document.createElement('A');
		newa.href = "javascript:removeElement("+ thisID +")";
		tdel = document.createTextNode('löschen');
		newa.appendChild( tdel );
		cell.appendChild( newa );
		
		getDocHeight('afterPostLayer');
	}
	function addParameterPost_f2f( table, rowIndex ) {
	
		random_num = (Math.round((Math.random()*99)+1));
		Stamp = new Date();
		thisID = Stamp.getSeconds() + random_num;
		
		row = table.insertRow( rowIndex );
		row.id = thisID;
		
		cell = row.insertCell( 0 );
		hinput = document.createElement( 'INPUT' );
		hinput.type = 'hidden';
		hinput.name = 'fields_post[' + thisID + '][auftrag_spesen_id]';
		cell.appendChild(hinput);
		h2input = document.createElement( 'INPUT' );
		h2input.type = 'hidden';
		h2input.name = 'fields_post[' + thisID + '][auftrag_spesen_art_id]';
		h2input.value = '4';
		cell.appendChild(h2input);
		input = document.createElement( 'INPUT' );
		input.type = 'text';
		input.name = 'fields_post[' + thisID + '][datum]';
		input.size = '9';
		input.id = 'post_' + thisID;
		cell.appendChild( input );
		
		aCal = document.createElement('A');
		aCal.href = "javascript:if(self.gfPop)gfPop.fPopCalendar(document.spesen.post_" + thisID +  ");";
		aCal.title = "Kalender";
		tKal = document.createTextNode('Kal');
		aCal.appendChild( tKal );
		cell.appendChild( aCal );
		
		cell = row.insertCell( 1 );
		input = document.createElement( 'INPUT' );
		input.type = 'text';
		input.name = 'fields_post[' + thisID + '][text]';
		input.size = '17';
		cell.appendChild( input );
		
		cell = row.insertCell( 2 );
		input = document.createElement( 'INPUT' );
		input.type = 'text';
		input.name = 'fields_post[' + thisID + '][betrag]';
		input.size = '8';
		cell.appendChild( input );
		
		cell = row.insertCell( 3 );
		newa = document.createElement('A');
		newa.href = "javascript:removeElement("+ thisID +")";
		tdel = document.createTextNode('löschen');
		newa.appendChild( tdel );
		cell.appendChild( newa );
		
		getDocHeight('afterPostLayer');
	}
	function addParameterSpesen_f2f( table, rowIndex ) {
	
		random_num = (Math.round((Math.random()*99)+1));
		Stamp = new Date();
		thisID = Stamp.getSeconds() + random_num;
		
		row = table.insertRow( rowIndex );
		row.id = thisID;
		
		cell = row.insertCell( 0 );
		hinput = document.createElement( 'INPUT' );
		hinput.type = 'hidden';
		hinput.name = 'fields_spesen[' + thisID + '][auftrag_spesen_id]';
		cell.appendChild(hinput);
		h2input = document.createElement( 'INPUT' );
		h2input.type = 'hidden';
		h2input.name = 'fields_spesen[' + thisID + '][auftrag_spesen_art_id]';
		h2input.value = '3';
		cell.appendChild(h2input);
		input = document.createElement( 'INPUT' );
		input.type = 'text';
		input.name = 'fields_spesen[' + thisID + '][datum]';
		input.size = '9';
		input.id = 'spesen_' + thisID;
		cell.appendChild( input );
		
		aCal = document.createElement('A');
		aCal.href = "javascript:if(self.gfPop)gfPop.fPopCalendar(document.spesen.spesen_" + thisID +  ");";
		aCal.title = "Kalender";
		tKal = document.createTextNode('Kal');
		aCal.appendChild( tKal );
		cell.appendChild( aCal );
		
		cell = row.insertCell( 1 );
		input = document.createElement( 'INPUT' );
		input.type = 'text';
		input.name = 'fields_spesen[' + thisID + '][text]';
		input.size = '17';
		cell.appendChild( input );
		
		cell = row.insertCell( 2 );
		input = document.createElement( 'INPUT' );
		input.type = 'text';
		input.name = 'fields_spesen[' + thisID + '][betrag]';
		input.size = '8';
		cell.appendChild( input );
		
		cell = row.insertCell( 3 );
		newa = document.createElement('A');
		newa.href = "javascript:removeElement("+ thisID +")";
		tdel = document.createTextNode('löschen');
		newa.appendChild( tdel );
		cell.appendChild( newa );
		
		getDocHeight('afterPostLayer');
	}
	function addParameterAuslagen_f2f( table, rowIndex ) {
	
		random_num = (Math.round((Math.random()*99)+1));
		Stamp = new Date();
		thisID = Stamp.getSeconds() + random_num;
		
		row = table.insertRow( rowIndex );
		row.id = thisID;
		
		cell = row.insertCell( 0 );
		hinput = document.createElement( 'INPUT' );
		hinput.type = 'hidden';
		hinput.name = 'fields_auslagen[' + thisID + '][auftrag_spesen_id]';
		cell.appendChild(hinput);
		h2input = document.createElement( 'INPUT' );
		h2input.type = 'hidden';
		h2input.name = 'fields_auslagen[' + thisID + '][auftrag_spesen_art_id]';
		h2input.value = '5';
		cell.appendChild(h2input);
		input = document.createElement( 'INPUT' );
		input.type = 'text';
		input.name = 'fields_auslagen[' + thisID + '][datum]';
		input.size = '9';
		input.id = 'auslagen_' + thisID;
		cell.appendChild( input );
		
		aCal = document.createElement('A');
		aCal.href = "javascript:if(self.gfPop)gfPop.fPopCalendar(document.spesen.auslagen_" + thisID +  ");";
		aCal.title = "Kalender";
		tKal = document.createTextNode('Kal');
		aCal.appendChild( tKal );
		cell.appendChild( aCal );
		
		cell = row.insertCell( 1 );
		input = document.createElement( 'INPUT' );
		input.type = 'text';
		input.name = 'fields_auslagen[' + thisID + '][text]';
		input.size = '17';
		cell.appendChild( input );
		
		cell = row.insertCell( 2 );
		input = document.createElement( 'INPUT' );
		input.type = 'text';
		input.name = 'fields_auslagen[' + thisID + '][betrag]';
		input.size = '8';
		cell.appendChild( input );
		
		cell = row.insertCell( 3 );
		newa = document.createElement('A');
		newa.href = "javascript:removeElement("+ thisID +")";
		tdel = document.createTextNode('löschen');
		newa.appendChild( tdel );
		cell.appendChild( newa );
	
		getDocHeight('afterPostLayer');
	}
// ############################################################################################


// auswahl des bundeslandes und der bezirke; deselektieren des bezirkes
	function selectBezirk(element1, element){
		if(document.getElementById(element1).checked == true){
			void(area = document.getElementById(element));
			void(el = area.getElementsByTagName('INPUT'));
			for(i=0;i<el.length;i++)
				void(el[i].checked=1) 
		}else{
			void(area = document.getElementById(element));
			void(el = area.getElementsByTagName('INPUT'));
			for(i=0;i<el.length;i++)
				void(el[i].checked=0) 
		}
	}
	
	function deselectCheckbox_bundesland(element1, element){
		void(area = document.getElementById(element));
		void(el = area.getElementsByTagName('INPUT'));
		for(i=0;i<el.length;i++){
			if(el[i].checked == false){
				document.getElementById(element1).checked = false;
			}
		}
	}


// bei interviewausweis == false - eingabefelder auf disabled stellen
	function FS_interviewausweis(element){
		if(element == 1){
			document.getElementById('ed_int_datum').disabled = false;
			document.getElementById('ed_int_gueltig').disabled = false;
		} else if(element == 2){
			document.getElementById('ed_int_datum').disabled = true;
			document.getElementById('ed_int_gueltig').disabled = true;
		}
	}
// bei nebenadress == false - eingabefelder auf disabled stellen
	function FS_nebenadresse(element){
		if(element == 1){
			document.getElementById('na_strasse').disabled = false;
			document.getElementById('na_plz').disabled = false;
			document.getElementById('na_ort').disabled = false;
			document.getElementById('na_land').disabled = false;
			document.getElementById('na_bundesland').disabled = false;
			document.getElementById('na_zeitraum').disabled = false;
		} else {
			document.getElementById('na_strasse').disabled = true;
			document.getElementById('na_plz').disabled = true;
			document.getElementById('na_ort').disabled = true;
			document.getElementById('na_land').disabled = true;
			document.getElementById('na_bundesland').disabled = true;
			document.getElementById('na_zeitraum').disabled = true;
		}
	}

// bei firmendaten == false - eingabefelder auf disalbed stellen
	function FS_firmendaten(element){
		if(element == 1){
			document.getElementById('fd_firmenname').disabled = false;
			document.getElementById('fd_UID').disabled = false;
			document.getElementById('fd_strasse').disabled = false;
			document.getElementById('fd_plz').disabled = false;
			document.getElementById('fd_ort').disabled = false;
			document.getElementById('fd_land').disabled = false;
			document.getElementById('fd_bundesland').disabled = false;
		} else {
			document.getElementById('fd_firmenname').disabled = true;
			document.getElementById('fd_UID').disabled = true;
			document.getElementById('fd_strasse').disabled = true;
			document.getElementById('fd_plz').disabled = true;
			document.getElementById('fd_ort').disabled = true;
			document.getElementById('fd_land').disabled = true;
			document.getElementById('fd_bundesland').disabled = true;
		}
	}

// bundesland-feld auf disabled stellen wenn das land nicht österreich ist
	function disableBundesland(element1, element2){
		val_element1 = element1.options[element1.selectedIndex].value;
		if(val_element1 != 1){
			element2.disabled = true;
		}else if(val_element1 == 1){
			element2.disabled = false;
		}
	}

// onlick checked / unchecked
	function onclickCheckUncheck(element){
		if(document.getElementById(element).checked == 1){
			document.getElementById(element).checked=0;
		}else{
			document.getElementById(element).checked=1;
		}
	}

// layer nachdem der submit-button gedrückt wurde
	function afterPostLayer(){
		document.getElementById('afterPostLayer').style.display = "block";
	}
//------------------------------------------------------------------------------------------


// funktion zum erstellen einer direkten gruppe (händisches erstellen der abfrage/gruppe)
	function addToTextfield(element, wert){
		document.getElementById(element).value=document.getElementById(element).value+' '+wert;
		document.getElementById(element).focus();
		return;
	}
//------------------------------------------------------------------------------------------

// anzahl der tage berechnen und in ein formularfeld schreiben
	function calculateDays(){
		var start = document.getElementById('geburtstag').value;
		var ende = document.getElementById('now').value;
		var result = document.getElementById('age');
		
		start = start.split(".");
		start = new Date(start[2], start[1], start[0]);
		ende = ende.split(".");
		ende = new Date(ende[2], ende[1], ende[0]);
		starttime = start.getTime();
		endetime = ende.getTime();
		
		differenz = ((endetime - starttime) / (1000*60*60*24*365));
		result.value = Math.round(differenz);
	}
//------------------------------------------------------------------------------------------

// berechnen des alters 
	function calculateAge(){
		var start = document.getElementById('geburtstag').value;
		var ende = document.getElementById('now').value;
		var result = document.getElementById('age');
		
		start = start.split(".");
		ende = ende.split(".");
		
		differenz = ende[2] - start[2]
		result.value = Math.round(differenz);
	}
//------------------------------------------------------------------------------------------

// getElements -> getElementsByName
	function getElements(element){
		var x=document.getElementsByName(element);
		return x;
	}

// funktionen für die quicktests (hinzufügen und löschen von jobs)
// funktionen zum kopieren einer tabelle
	function neueZeile_Quicktest(ID, bild, bild2, anzahl){
		for(i=0; i<anzahl; i++){
			random_num = (Math.round((Math.random()*99)+1));
			Stamp = new Date();
			thisID = Stamp.getSeconds() + random_num;
			
			content  = '<table id="' + thisID + '" cellpadding="0" cellspacing="0" border="0">';
			content += '	<tr>';
			content += '		<td valign="top" width="190">Antwort</td>';
			content += '		<td><textarea name="fields_quicktest_aw[' + thisID + '][antwort]" rows="2" style="width: 300px;"></textarea></td>';
			content += '		<td><input type="checkbox" name="fields_quicktest_aw[' + thisID + '][is_true]" value="1" /></td>';
			content += '		<td width="15" align="center"><a href="javascript:;" onClick="removeElement(' + thisID + ')"><img src="' + bild + '" width="16" height="16" border="0"></a></td>';
			content += '	</tr>';
			content += '</table>';
			
			d = document.getElementById(ID).innerHTML += content;
		}
		getDocHeight('afterPostLayer');
	}

// funktionen für die jobliste (hinzufügen und löschen von jobs)
// funktionen zum kopieren einer tabelle
	function neueZeile(ID, bild, bild2, anzahl){
		defValueVon = document.getElementById('default_von').value;
		defValueBis = document.getElementById('default_bis').value;
		
		for(i=0; i<anzahl; i++){
			random_num = (Math.round((Math.random()*99)+1));
			Stamp = new Date();
			thisID = Stamp.getSeconds() + random_num;
			
			content  = '<table id="' + thisID + '" cellpadding="0" cellspacing="0" border="0">';
			content += '	<tr>';
			content += '		<td valign="top" width="190">Job</td>';
			content += '		<td><textarea name="fields_job_todo[' + thisID + '][text]" rows="2" style="width: 300px;"></textarea></td>';
			content += '			<td>';
			content += '				<table cellpadding="0" cellspacing="0" border="0">';
			content += '					<tr>';
			content += '						<td width="30" align="right">von&nbsp;</td>';
			content += '						<td>';
			content += '							<input type="text" name="fields_job_todo[' + thisID + '][von_datum]" id="von_datum' + thisID + '" style="width: 80px;" value="' + defValueVon + '" />';
			content += '							<a href="javascript:void(0)" onclick="if(self.gfPop)gfPop.fStartPop(document.add.von_datum' + thisID + ',document.add.bis_datum' + thisID + ');return false;" HIDEFOCUS><img align="absmiddle" src="' + bild2 + '" border="0" width="14"></a>';
			content += '						</td>';
			content += '					</tr>';
			content += '					<tr>';
			content += '						<td width="30" align="right">bis&nbsp;</td>';
			content += '						<td>';
			content += '							<input type="text" name="fields_job_todo[' + thisID + '][bis_datum]" id="bis_datum' + thisID + '" style="width: 80px;" value="' + defValueBis + '" />';
			content += '							<a href="javascript:void(0)" onclick="if(self.gfPop)gfPop.fEndPop(document.add.von_datum' + thisID + ',document.add.bis_datum' + thisID + ');return false;" HIDEFOCUS><img align="absmiddle" src="' + bild2 + '" border="0" width="14"></a>';
			content += '						</td>';
			content += '					</tr>';
			content += '				</table>';
			content += '			</td>';
			content += '		<td width="15" align="center"><a href="javascript:removeElement(\'' + thisID + '\')" onClick="removeElement(' + thisID + ')"><img src="' + bild + '" width="10" height="10" border="0"></a></td>';
			content += '	</tr>';
			content += '</table>';
			
			d = document.getElementById(ID).innerHTML += content;
		}
		getDocHeight('afterPostLayer');
	}

// id-element löschen
	function removeElement() {
		var arg=arguments, elm;
		elm=document.getElementById(arg[0])||arg[0];
		elm.parentNode.removeChild(elm);
		getDocHeight('afterPostLayer');
	}


// linkTo javascript
	function linkTo(url){
		location.href = url;
	}

// checkboxen bei link-klick selektieren oder deselektieren
	function check_boxes_check(){
	  void(d=document);
	  void(el=d.getElementsByTagName('INPUT'));
	  for(i=0;i<el.length;i++)
		void(el[i].checked=1) 
	}
	function check_boxes_uncheck(){
	  void(d=document);
	  void(el=d.getElementsByTagName('INPUT'));
	  for(i=0;i<el.length;i++)
		void(el[i].checked=0) 
	}
	// alle input-objekte in einem id-bereich selectieren oder deselctieren
	function selectAllInId(element){
		void(area = document.getElementById(element));
		void(el = area.getElementsByTagName('INPUT'));
		for(i=0;i<el.length;i++)
			void(el[i].checked=1) 
	}
	function deselectAllInId(element){
		void(area = document.getElementById(element));
		void(el = area.getElementsByTagName('INPUT'));
		for(i=0;i<el.length;i++)
			void(el[i].checked=0) 
	}


// wechselnder tr-hintergrund bei mouseover und mouseout
	function setTrBg(element, action, outColor){
	
		var backColor = new Array(); // don't change this
		//overColor = '#ADC8E8';
		var overColor = '#afd6f9';
	
		if(action == "over"){
			document.getElementById(element).style.backgroundColor = overColor;
		}else if(action == "out"){
			document.getElementById(element).style.backgroundColor = outColor;
		}
		
	}
//------------------------------------------------------------------------------------------

// inhalt zweier felder addieren und inhalt in ein drittes feld ausgeben
	function calculateToFormfields(ID1, operant, ID2, ID3){
		var var1 = document.getElementById(ID1).value;
		var var2 = document.getElementById(ID2).value;
		var result = document.getElementById(ID3);
		
		if(operant == "+"){
			differenz = var1 + var2;
		}else if(operant == "-"){
			differenz = var1 - var2;
		}else if(operant == "*"){
			differenz = var1 * var2;
		}else if(operant == "/"){
			differenz = var1 / var2;
		}
		
		result.value = differenz;
	}
//------------------------------------------------------------------------------------------

// inhalt eines iframes drucken
	function iFramePrint(frame){
		parent.frames[frame].focus();
		parent.frames[frame].print();
	}
//------------------------------------------------------------------------------------------

// text in die zwischenablage kopieren
	// funktion 1
	function copyToClipbord(meintext) {
		if(window.clipboardData) {
			window.clipboardData.setData("Text", meintext);
		} else if (window.netscape) { 
			netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect');
			var clip = Components.classes['@mozilla.org/widget/clipboard;1'].createInstance(Components.interfaces.nsIClipboard);
			if (!clip) return;
			var trans = Components.classes['@mozilla.org/widget/transferable;1'].createInstance(Components.interfaces.nsITransferable);
			if (!trans) return;
			trans.addDataFlavor('text/unicode');
			var str = new Object();
			var len = new Object();
			var str = Components.classes["@mozilla.org/supports-string;1"].createInstance(Components.interfaces.nsISupportsString);
			var copytext=meintext;
			str.data=copytext;
			trans.setTransferData("text/unicode",str,copytext.length*2);
			var clipid=Components.interfaces.nsIClipboard;
			if (!clip) return false;
			clip.setData(trans,null,clipid.kGlobalClipboard);
		}
		return false;
	}
//------------------------------------------------------------------------------------------


// Buffer-Funktion
	function getBuffer(buffer, input_field){
		var content = document.getElementById(buffer);
		if(content){
			content = base64_encode(content.innerText);
			input_field.value = content;
		}
	}
//------------------------------------------------------------------------------------------


// getElements -> getElementsByName
	function getElements(element){
		var x=document.getElementsByName(element);
		return x;
	}
	// html-tag über id entfernen
	function removeElement() {
		var arg=arguments, elm;
		elm=document.getElementById(arg[0])||arg[0];
		elm.parentNode.removeChild(elm)
	}

//------------------------------------------------------------------------------------------


// disable links and input-fields
	function disableLinksInId(element){
		var buffer = document.getElementById(element);
		if(buffer){
			d1 = buffer.getElementsByTagName('A');
			for(i=0;i<d1.length;i++){
				d1[i].setAttribute("href","javascript:;");
				d1[i].setAttribute("onClick","return false;");
				d1[i].setAttribute("onMouseOver","return false;");
				d1[i].setAttribute("onMouseOut","return false;");
				d1[i].onclick = new Function("return false;");
			}
			d2 = buffer.getElementsByTagName('INPUT');
			for(i=0;i<d2.length;i++){
				d2[i].setAttribute("disabled","true");
			}
			d3 = buffer.getElementsByTagName('TEXTAREA');
			for(i=0;i<d3.length;i++){
				d3[i].setAttribute("disabled","true");
			}
			d4 = buffer.getElementsByTagName('SELECT');
			for(i=0;i<d4.length;i++){
				d4[i].setAttribute("disabled","true");
			}
		}
	}
//------------------------------------------------------------------------------------------


// base64 funktionen
	var base64_keyStr = "ABCDEFGHIJKLMNOP" +
				 "QRSTUVWXYZabcdef" +
				 "ghijklmnopqrstuv" +
				 "wxyz0123456789+/" +
				 "=";

	function base64_encode(input) {
		var output = "";
		var chr1, chr2, chr3 = "";
		var enc1, enc2, enc3, enc4 = "";
		var i = 0;

		do {
			chr1 = input.charCodeAt(i++);
			chr2 = input.charCodeAt(i++);
			chr3 = input.charCodeAt(i++);

			enc1 = chr1 >> 2;
			enc2 = ((chr1 & 3) << 4) | (chr2 >> 4);
			enc3 = ((chr2 & 15) << 2) | (chr3 >> 6);
			enc4 = chr3 & 63;

			if (isNaN(chr2)) {
				enc3 = enc4 = 64;
			} else if (isNaN(chr3)) {
				enc4 = 64;
			}

			output = output + 
			base64_keyStr.charAt(enc1) + 
			base64_keyStr.charAt(enc2) + 
			base64_keyStr.charAt(enc3) + 
			base64_keyStr.charAt(enc4);
			chr1 = chr2 = chr3 = "";
			enc1 = enc2 = enc3 = enc4 = "";
		}
		while (i < input.length);
		return output;
	}

	function base64_decode(input) {
		var output = "";
		var chr1, chr2, chr3 = "";
		var enc1, enc2, enc3, enc4 = "";
		var i = 0;

		// remove all characters that are not A-Z, a-z, 0-9, +, /, or =
		var base64test = /[^A-Za-z0-9\+\/\=]/g;
		if (base64test.exec(input)) {
		alert("There were invalid base64 characters in the input text.\n" +
			  "Valid base64 characters are A-Z, a-z, 0-9, '+', '/', and '='\n" +
			  "Expect errors in decoding.");
		}
		input = input.replace(/[^A-Za-z0-9\+\/\=]/g, "");

		do {
			enc1 = base64_keyStr.indexOf(input.charAt(i++));
			enc2 = base64_keyStr.indexOf(input.charAt(i++));
			enc3 = base64_keyStr.indexOf(input.charAt(i++));
			enc4 = base64_keyStr.indexOf(input.charAt(i++));

			chr1 = (enc1 << 2) | (enc2 >> 4);
			chr2 = ((enc2 & 15) << 4) | (enc3 >> 2);
			chr3 = ((enc3 & 3) << 6) | enc4;

			output = output + String.fromCharCode(chr1);

			if (enc3 != 64) {
				output = output + String.fromCharCode(chr2);
			}
			if (enc4 != 64) {
				output = output + String.fromCharCode(chr3);
			}

			chr1 = chr2 = chr3 = "";
			enc1 = enc2 = enc3 = enc4 = "";

		}
		while (i < input.length);
		return output;
	}
//------------------------------------------------------------------------------------------

// select jump menu
	function MM_jumpMenu(targ,selObj,restore){ //v3.0
			eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
			if (restore) selObj.selectedIndex=0;
	}
//------------------------------------------------------------------------------------------

// bei größenänderung seite neu laden
	function MM_reloadPage(init) { 
	  if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
		document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}
	  else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
	}
	MM_reloadPage(true);
//------------------------------------------------------------------------------------------


// Popup Form Submit
	function SubmitMyForm(f) {
		f.target = 'foo';
		window.open('',f.target,'menubar=no,scrollbars=no,width=250,height=120');
		f.submit();
		return false;
	}
//------------------------------------------------------------------------------------------

// Show Hide Layer
	var isIE = false;
	var isOther = false;
	var isNS4 = false;
	var isNS6 = false;
	if(document.getElementById){
		if(!document.all){
			isNS6=true;
		}
		if(document.all){
			isIE=true;
		}
	}else{
		if(document.layers){
			isNS4=true;
		}else{
			isOther=true;
		}
	}
	function aLs(layerID){
		var returnLayer;
		if(isIE){
			returnLayer = eval("document.all." + layerID + ".style");
		}
		if(isNS6){
			returnLayer = eval("document.getElementById('" + layerID + "').style");
		}
		if(isNS4){
			returnLayer = eval("document." + layerID);
		}
		if(isOther){
			returnLayer = "null";
			alert("-[Error]-\nDue to your browser you will probably not\nbe able to view all of the following page\nas it was designed to be viewed. We regret\nthis error sincerely.");
		}
		return returnLayer;
	}
	function HideShow(ID, ID2, bgcolor){
		if((aLs(ID).display == "block") || (aLs(ID).display == "")){
			aLs(ID).display = "none";
			aLs(ID).visibility = "hidden";
			if(bgcolor != 'false'){
				aLs(ID2).backgroundColor = '';
			}
			//SetCookie(ID,'closed',null,'/');
			//getDocHeight('afterPostLayer');
		}else{
			aLs(ID).display = "block";
			aLs(ID).visibility = "visible";
			if(bgcolor != 'false'){
				aLs(ID2).backgroundColor = '#dcdcdc';
			}
			//SetCookie(ID,'opened',null,'/');
			//getDocHeight('afterPostLayer');
		}
	}
	function Show(ID){
		aLs(ID).display = "block";
		SetCookie(ID,'opened',null,'/');
		getDocHeight('afterPostLayer');
	}
	function Hide(ID){
		aLs(ID).display = "none";
		SetCookie(ID,'closed',null,'/');
		getDocHeight('afterPostLayer');
	}
	// alle elemente mit best. class name verstecken
	function hideByClassName(className, className2){
		el = getElementsByClassName(className);
		for(i=0;i<el.length;i++){
			el[i].style.display='none';
			el[i].style.visibility='hidden';
		}
		el2 = getElementsByClassName(className2);
		for(j=0;j<el2.length;j++){
			el2[j].style.backgroundColor='';
		}
	}
//------------------------------------------------------------------------------------------

// Cookie Funktionen
	function getCookieVal (offset) { 
		var endstr = document.cookie.indexOf (";", offset); 
		if (endstr == -1) 
		endstr = document.cookie.length; 
		return unescape(document.cookie.substring(offset, endstr));
	}
	function GetCookie (name) { 
		var arg = name + "="; 
		var alen = arg.length; 
		var clen = document.cookie.length; 
		var i = 0; 
		while (i < clen) { 
		var j = i + alen; 
		if (document.cookie.substring(i, j) == arg) 
		return getCookieVal (j); 
		i = document.cookie.indexOf(" ", i) + 1; 
		if (i == 0) break; 
		} 
		return null;
	}
/*	function SetCookie (name, value) { 
		var argv = SetCookie.arguments; 
		var argc = SetCookie.arguments.length; 
		var expires = (argc > 2) ? argv[2] : null; 
		var path = (argc > 3) ? argv[3] : null; 
		var domain = (argc > 4) ? argv[4] : null; 
		var secure = (argc > 5) ? argv[5] : false; 
		document.cookie = name + "=" + escape (value) + 
		((expires == null) ? "" : ("; expires=" + expires.toGMTString())) + 
		((path == null) ? "" : ("; path=" + path)) + 
		((domain == null) ? "" : ("; domain=" + domain)) + 
		((secure == true) ? "; secure" : "");
	}
*/
	function SetCookie( name, value, expires, path, domain, secure ) {
		document.cookie = name+'='+escape( value ) +
			( ( expires ) ? ';expires='+cookie_live(expires) : '' ) + //expires.toGMTString()
			( ( path ) ? ';path=' + path : '' ) +
			( ( domain ) ? ';domain=' + domain : '' ) +
			( ( secure ) ? ';secure' : '' );
	}
	function cookie_live(LIVEDAYS) {
		var date=new Date();
		date.setDate(date.getDate()+LIVEDAYS);
		var gmt=date.toGMTString();
		var k1=gmt.indexOf(" ");
		var k2=gmt.indexOf(" ", k1+1);
		var k3=gmt.indexOf(" ", k2+1);
		var str=gmt.substring(0,k2)+"-"+gmt.substring(k2+1,k3)+"-"+gmt.substring(k3+3,gmt.length);
		return str;
	}
	function DeleteCookie (name) { 
		var exp = new Date(); 
		exp.setTime (exp.getTime() - 1); 
		var cval = GetCookie (name); 
		document.cookie = name + "=" + cval + "; expires=" + exp.toGMTString();
	}
//------------------------------------------------------------------------------------------
