

function showPostingPriview(h3, number) {
	var preview = document.getElementById('postingPreview_' + number);
	if(preview) {
		if(preview.style.display == 'block') {
			preview.style.display = 'none';
			h3.className = '';
		} else {
			preview.style.display = 'block';
			h3.className = 'selected';
		}
	}
}

function preparePostingPreviews(count) {
	if(count > 0) {
		for(var i = 0; i < count; i++) {
			var preview = document.getElementById('postingPreview_' + i);
			if(preview) {
				preview.style.display = 'none';
			}
		}
	}
}

function hideBlogNotificationSuccess() {
	var blogNotificationSuccess = document.getElementById("blogNotificationSuccess");
	if (blogNotificationSuccess) {
		var inputs = blogNotificationSuccess.getElementsByTagName("input");
		if (inputs.length > 0) {
			for (var i=0; i < inputs.length; i++) {
				var input = inputs[i];
				if (input.type == 'checkbox') {
					if (input.checked) {
						blogNotificationSuccess.style.display = "none";
						break;
					}
				}
			}
		}
	}
}

var newwin;

function showFilterBody(element) {
	var display = document.getElementById('filterBody').style.display;
	
	if(display == 'none') {
		document.getElementById('filterBody').style.display = 'block';
		element.innerHTML = 'ausblenden';
	} else {
		document.getElementById('filterBody').style.display = 'none';
		element.innerHTML = 'anzeigen';
	}
}
function open_multi_chat(url) {
	newwin = popUp2(url, 'MULTICHAT', 'width=705,height=600,statusbar=no,toolbar=no,menubar=no,scrollbars=no,resizable=no,location=no', 'MULTICHAT');
}

var i=0;

function open_single_chat(url, title) {
	newwin = popUp2(url, title, 'width=595,height=447,statusbar=no,toolbar=no,menubar=no,scrollbars=no,resizable=no,location=no', 'SINGLECHAT');
	if(newwin) {
		return true;
	} else {
		return false;
	}	
}

function getWindowHeight() {
	var windowHeight=0;
	if (typeof(window.innerHeight) == 'number') {
		windowHeight = window.innerHeight;
	} else {
		if (document.documentElement && document.documentElement.clientHeight) {
			windowHeight = document.documentElement.clientHeight;
		} else {
			if (document.body && document.body.clientHeight) {
				windowHeight=document.body.clientHeight;
			}
		}
	}
	return windowHeight;
}

function cc_toggleSubmenu(id) {
	var li = document.getElementById(id);
	if(li) {
		var ul = li.getElementsByTagName('ul')[0];
		if(ul.style.display == 'block' || ul.style.display == '') {
			ul.style.display = 'none';
		} else {
			ul.style.display = 'block';
		}
	}
	return false;
}

function selectAllHearts() {
	var heartsViewList = document.getElementById('heartsViewList');
	if(heartsViewList) {
		var inputs = heartsViewList.getElementsByTagName('input');
		if(inputs.length > 0) {
			for(var i = 0; i < inputs.length; i++) {
				var input = inputs[i];
				if(input.type == 'checkbox') {
					if(input.checked) {
						input.checked = false;
					} else {
						input.checked = true;
					}
				}
			}
		}
	}
}

 function showMessageForm(type, user_id) {
 	// return true; // Non-JS Method seems to be better, really !
    var messageDiv = null;
    var subjectInput = null;
 	if(user_id) {
 		if(type == 0) {
	 		messageDiv = document.getElementById('bubbleMessage_' + user_id);
 			subjectInput  = document.getElementById('subjectMessage');
 		} else if(type == 1) {
 			messageDiv = document.getElementById('bubbleHeart_' + user_id);
	 		subjectInput = document.getElementById('subjectHeart');
 		}
 		if(messageDiv) {
 			messageDiv.style.display = "block"; 			
 			var formObject = messageDiv.getElementsByTagName('form')[0];
 			if(formObject) {
	 			formObject.reset();
	 			
	 			if(subjectInput) {
		 			subjectInput.focus();
	 			}
	 			
	 			var inputs = messageDiv.getElementsByTagName('input');
	 			if(inputs.length > 0) {
	 				for(var i = 0; i < inputs.length; i++) {
	 					var inputObject = inputs[i];
	 					if(inputObject.name == 'user_id') {
	 						inputObject.value = user_id;
	 					}
	 				}
	 			}
 			}
 			return false; // Do not follow link to non-js method.
 		} else {
 			return true
 		}
 	} else {
	 	return true; // Use non-js method of sending message
 	}
 }

 function hideMessageForm(type, user_id) {
 	var messageDiv = null;
 	if(type == 0) {
 		messageDiv = document.getElementById('bubbleMessage_' + user_id);
	} else if(type == 1) {
		messageDiv = document.getElementById('bubbleHeart_' + user_id);
	}
	if(messageDiv) {
		messageDiv.style.display = "none";
		return true;
	}
	return false;
 }
 
 function scaleMessagesOverflow(id, puffer) {
	var overflowElement = document.getElementById(id);
	if(overflowElement) {
		// Hoehe setzen
		var sichtbareHoehe = document.documentElement.clientHeight;
		overflowElement.style.height = (sichtbareHoehe - puffer) + "px";
	}
}

function submitHeartsForm() {
	var heartsViewList = document.getElementById('heartsViewList');
	var heartForm = document.getElementById('heartForm');
	if(heartsViewList && heartForm) {
		heartForm.style.display = 'none';
		var inputs = heartsViewList.getElementsByTagName('input');
		if(inputs.length > 0) {
			for(var i = 0; i < inputs.length; i++) {
				var input = inputs[i];
				if(input.name == 'rowSel_messages[]' && input.checked && input.name == 'rowSel_messages[]') {
					/*
					var inputTemp = document.createElement('input');
					inputTemp.setAttribute('type', 'text');
					inputTemp.setAttribute('name', 'rowSel_messages[]');
					inputTemp.setAttribute('value', input.value);
					*/

					heartForm.appendChild(input);
					
				}
			}
			
			// Workaround for IE
			var tempInputs = heartForm.getElementsByTagName('input');
			if(tempInputs.length > 0) {
				for(var i = 0; i < tempInputs.length; i++) {
					var tempInput = tempInputs[i];
					tempInput.checked = true;
				}
			}
			
			heartForm.submit();
		}
	}
}

function showSuccessMessage(elID) {
//	window.setTimeout("show('" + elID + "')", 1500);
}

function validateFormFields(formname, fields, fields_length) {
	var form = document.forms[formname];
	if(form && fields.length > 0) {
		var flag = true;
		for(var i = 0; i < fields.length; i++) {
			var field = fields[i];
			var inputValue = form.elements[field].value;
			var fieldElement = form.elements[field];
			if(inputValue.length < fields_length[i] ) {
				fieldElement.setAttribute('oldClassName', fieldElement.className);
				fieldElement.className = 'errorField';				
				flag = false;
				break
			} else {
				fieldElement.className = fieldElement.getAttribute('oldClassName');
			}
		}
		return flag;
	}
	return false;
}

function submitMessageForm(forname, fields, fields_length, message_type, identifier, success_id) {
	if( ! validateFormFields(forname, fields, fields_length)) {		
		return false;
	}	
	if( ! hideMessageForm(message_type, identifier)) {
		return false;
	}
//	showSuccessMessage(success_id);
}

function showLoader() {
	show('waitingBlock');
	window.setTimeout("hide('waitingBlock')", 7000);
	
}

var __MessageQueue = new Array();
var __CheckInterval = 2000;
var __CurrentMessage;

function addQueue(messageInfo) {
	// Backwards compatibility, with only private chats there was no need for a type
	if(messageInfo.type == undefined) {
		messageInfo.type = 'PRIVATECHAT';
	}

	// Save which DIV element to use in the message
	switch(messageInfo.type) {
		case 'ANONYMOUSCALL':
			messageInfo.element = '__ajax_target';
			if(__CurrentMessage != null && __CurrentMessage.type == messageInfo.type && __CurrentMessage.callid == messageInfo.callid) {
				return;
			}
		break;
		case 'PRIVATECHAT':
			messageInfo.element = 'singleChatNotificationWrap';
			if(__CurrentMessage != null && __CurrentMessage.type == messageInfo.type && __CurrentMessage.userid == messageInfo.userid) {
				return;
			}
		break;
	}
	
	// Messages are unique by type and userid, reject any duplicates for current or stored messages
	if(__CurrentMessage != null && __CurrentMessage.userid == messageInfo.userid && __CurrentMessage.type == messageInfo.type) {
	//	return;
	}

	for(i=0;i<__MessageQueue.length;i++) {
		if(__MessageQueue[i].userid == messageInfo.userid && __MessageQueue[i].type == messageInfo.type) {
			return;
		}
	}
	
	// Add message to queue and call the processing function
	__MessageQueue.push(messageInfo);
	processQueue();
}

function processQueue() {
	window.setTimeout("processQueue()", __CheckInterval);
	if(__MessageQueue.length <= 0) {
		return;
	}

	// Already displaying a message
	if(__CurrentMessage != undefined && document.getElementById(__CurrentMessage.element).style.display == 'block') {
		return;
	}
	// Remove message from queue and show it
	__CurrentMessage = __MessageQueue.shift();
	showQueryWindow(__CurrentMessage);
	window.focus();
}

function removeQueue(userid, type) {
	// Go throught the queue and remove the first message you encounter of the same type and userid
	for(i=0;i<__MessageQueue.length;i++) {
		if(__MessageQueue[i].userid == userid && __MessageQueue[i].type == type) {
			__MessageQueue.splice(i, 1);
			break;
		}
	}
	
	// If we are already displaying a message of that type and userid, hide it
	if(__CurrentMessage != null && __CurrentMessage.userid == userid && __CurrentMessage.type == type) {
		hideQueryWindow();
	}
}

function showQueryWindow(message) {
	// anonymous call
	if (message.type == 'ANONYMOUSCALL') {
		var params = new Object();
		params['view'] = 'accept_deny_invitation';
		params['anonymouscalls_id'] = message.callid;
		moduleRequestPerAjax('phoneservice', params, '__ajax_target', 'Anonym telefonieren');		
  		return;
	}

	// The element that is shown can differ for each message
	var el = document.getElementById(message.element);
	if(el) {
		// Text setzen
		var spans = el.getElementsByTagName('span');
		for(var i = 0; i < spans.length; i++) {
			var span = spans[i];
			if(span.className == 'text') {
				setIntoSpan(span, message.text);
			} else if(span.className == 'user_name') {				
				setIntoSpan(span, message.from);
			} else if(span.className == 'gender') {
				setIntoSpan(span, message.gender);
			} else if(span.className == 'age') {
				setIntoSpan(span, message.age);
			} else if(span.className == 'zip') {
				setIntoSpan(span, message.zip);
			} else if(span.className == 'distance') {
				setIntoSpan(span, message.distance);
			} else if(span.className == 'city') {
				setIntoSpan(span, message.city);
			} else if(span.className == 'group') {
				setIntoSpan(span, message.group);
			} else if(span.className == 'country') {
				if(message.country == 'de') {
					message.country = 'Deutschland';
				} else if(message.country == 'at') {
					message.country = '&Ouml;sterreich';
				} else if(message.country == 'ch') {
					message.country = 'Schweiz';
				}
				setIntoSpan(span, message.country);
			} else if(span.className == 'groesse') {
				setIntoSpan(span, message.groesse + ' cm');
			} else if(span.className == 'gewicht') {
				setIntoSpan(span, message.gewicht + ' kg');
			} else if(span.className == 'figur') {
				setIntoSpan(span, message.figur);
			} else if(span.className == 'rasiert') {
				setIntoSpan(span, message.rasiert);
			} else if(span.className == 'geprueft') {
				setIntoSpan(span, message.geprueft);
			}
		}
		
		// Bilder setzten
		var images = el.getElementsByTagName('img');
		for(var i = 0; i < images.length; i++) {
			if (images[i].className=='photo') {
				images[i].src = message.imageurl;
			} else if(images[i].className=='gender') {
				if(message.gender == 'Mann') {
					images[i].src = '/modules/userprofile/images/male.gif';
				} else {
					images[i].src = '/modules/userprofile/images/female.gif';
				}
			} 
		}
		
		// Verification Bilder
		if (message.verify_foto == 'true') {
			var verifyFotoImg = document.getElementById('verify_foto'); 
			verifyFotoImg.src = '/modules/verification/images/verify_foto.gif';
		} 
		if (message.verify_call == 'true') {
			var verifyCallImg = document.getElementById('verify_call'); 
			verifyCallImg.src = '/modules/verification/images/verify_call.gif';			
		} 
		if (message.verify_mms == 'true') {
			var verifyMMSImg = document.getElementById('verify_mms'); 
			verifyMMSImg.src = '/modules/verification/images/verify_mms.gif';			
		}
		if (message.verify_fax == 'true') {
			var verifyFaxImg = document.getElementById('verify_fax'); 
			verifyFaxImg.src = '/modules/verification/images/verify_fax.gif';			
		}		
			
		
		// Links setzten
		var links = el.getElementsByTagName('a');
		for(var i = 0; i < links.length; i++) {
			switch(links[i].className) {
				case 'profile_link' : 
					links[i].setAttribute('user_id', message.userid);
					break;
				case 'accept_link':
				case 'cancel_link':
					links[i].setAttribute('user_id', message.userid);
					break;
			}
		}

		// Blockelement setzten
		var divs = el.getElementsByTagName('div');
		for(var i = 0; i < divs.length; i++) {
			switch(divs[i].className) {
				case 'notificationButtons' : 
					divs[i].style.display = "block";
					break;
				case 'closeTop' : 
				case 'closewindow':
					divs[i].style.display = "none";
					break;
				case 'accept_link':
				case 'cancel_link':
					links[i].setAttribute('user_id', message.userid);
					break;
				case 'waitATimeMessage':
				case 'startSingleChat':
					divs[i].style.display = "none";
					break;
			}
		}
	
		// Message shown on the webpage
		if(message.fromMessenger && message.type == 'PRIVATECHAT') {  
			setBackgroundIFrame(true, message.element, message.element + '_Frame');

			if(el) {
				el.style.display = "block";
			}
			
			//__CurrentMessage = null;
		} else {
			showBubble(message.element);
		}
	}
}

// NOTE: This is only for private chat
function progressQueryWindow(url, title) {
	// Something unforseen happened, the messenger client got the Chat Request but it wasn't added to the Queue or it wasn't displayed properly, but the user accepted the chat via the messenger client.
	if(!__CurrentMessage) {
		open_single_chat(url, title);
	} else {
		var startSingleChat = document.getElementById('startSingleChat');
		if(startSingleChat) {
			// Hide Notification buttons, they can be present if the user accepted via the messenger
			var notificationButtons = document.getElementById('notificationButtons');
			if(notificationButtons) {
				notificationButtons.style.display = "none";
			}
		
			// Hide Wait-Message
			var waitATimeMessage = document.getElementById('waitATimeMessage');
			if(waitATimeMessage) {
				waitATimeMessage.style.display = "none";
			}

			startSingleChat.style.display = "block";
					
			var buttonStartSingleChat = document.getElementById('buttonStartSingleChat');
			if(buttonStartSingleChat) {
				buttonStartSingleChat.href = url;
				buttonStartSingleChat.className = title;
				
				var owner = this;
				buttonStartSingleChat.onclick = function() {
					owner.hideQueryWindow();
					return !owner.open_single_chat(this.href, this.className);
				};
			}
			
			// Adjust top position of bubble (if in multichat), because it gets pushed down when we display the START button
			if(!__CurrentMessage.fromMessenger) {
				showBubble(__CurrentMessage.element);
			}
		}
	}
}

function hideQueryWindow() {
	var elID = __CurrentMessage.element;

	setBackgroundIFrame(false, elID, elID + '_Frame');
	
	var el = document.getElementById(elID);
	if(el) {
		el.style.display = "none";
	}
	
	__CurrentMessage = null;
}

// NOTE: This function places the bubble into the bottom right corner above the multichat flash client and is only intended for use with multichat
function showBubble(elID) {
	var el = document.getElementById(elID);
	if(el) {
		el.style.display = "block";
	}
	
	var flashContainer = document.getElementById('FlashContainer');
	if(flashContainer) {
		var flashContainerHeight = flashContainer.offsetHeight;
		var elHeight = el.offsetHeight;
		el.style.top = (flashContainerHeight - elHeight - 90) + "px"; 
	}
}

function setIntoSpan(span, content) {
	span.innerHTML = content;
}

function anonymousCallNotificationDeny(username, callid) {
	var params = new Object();
	params['view'] = 'deny_invitation';
	params['anonymouscalls_id'] = callid;
	params['rejected'] = 1;
	window.frames['contentIFrame'].moduleRequestPerAjax('phoneservice', params, '__ajax_target', 'Flirty Nachrichtenbox');		
  	return;
}

function anonymousCallNotificationAccept(username,callid,number,valid_until) {
	var params = new Object();
	params['view'] = 'invitation_accepted';
	params['anonymouscalls_id'] = callid;
	window.frames['contentIFrame'].moduleRequestPerAjax('phoneservice', params, '__ajax_target', 'Flirty Nachrichtenbox');		
  	return;
}
function anonymousCallNotificationError(reason) {}



function setRating(rating, wrapID, inputfieldID, imagepath) {
	var wrap = document.getElementById(wrapID);
	var inputfield = document.getElementById(inputfieldID);
	if(rating && wrap && inputfield) {
		var imgs = wrap.getElementsByTagName('img');
		if(imgs.length > 0) {
			for(var i=0; i<imgs.length; i++) {
				var img = imgs[i];
				if(i < rating) {
					img.src = imagepath + 'star_big_active.gif';
				} else {
					img.src = imagepath + 'star_big_inactive.gif';
				}						
			}
			
			inputfield.value = rating;
		}
		
	}
}

function showErrorForm(errorBlockName) {
    var errorDiv = null;

	if(!errorBlockName) {
		errorBlockName = 'sendError';
	}

	errorDiv = document.getElementById(errorBlockName);

	if(errorDiv) {
	    errorDiv.style.display = "block";
	    return false;
	}
    return true;
}

function hideErrorForm(errorBlockName) {
    var errorDiv = null;

	if(!errorBlockName) {
		errorBlockName = 'sendError';
	}

	errorDiv = document.getElementById(errorBlockName);

    errorDiv.style.display = "none";

    return false;
}


function checkThisRadioButton(el, tabelle) {
	var divs = document.getElementsByTagName('div');
	var anchor = document.getElementById('submitButtonBottom');
	goToAnchor('submitButtonBottom');
	if(divs) {
		for(var i = 0; i < divs.length; i++) {
			var div = divs[i];
			if(div.className == 'tarifWrapTop' || div.className == 'tarifWrapTopOver') {
				var thisTopDiv = div;
				var bottomDivs = div.getElementsByTagName('div');
				if(bottomDivs) {
					for(var k = 0; k < bottomDivs.length; k++) {
						var bottomDiv = bottomDivs[k];
						if(bottomDiv.className == 'tarifWrapBottom' || bottomDiv.className == 'tarifWrapBottomOver') {
							var thisBottomDiv = bottomDiv;
						}
					}
				}
				var inputs = div.getElementsByTagName('input');
				if(inputs.length > 0) {				
					for(var j = 0; j < inputs.length; j++) {
						var input = inputs[j];
						if(input.type == 'radio' && input.id == el) {
							input.checked = true;
							thisBottomDiv.className = "tarifWrapBottomOver";
							thisTopDiv.className = "tarifWrapTopOver";
							thisTopDiv.id = "selectedAbo";
						} else {
							thisBottomDiv.className = "tarifWrapBottom";
							thisTopDiv.className = "tarifWrapTop";
							thisTopDiv.id = "";
						}	
					}
				}
			}
		}	
	}
}

function hoverThisElement(el, hover) {
	var outerDiv = el;
	var innerDivs = el.getElementsByTagName('div');
	if(innerDivs) {
		for(var i = 0; i < innerDivs.length; i++) {
			var innerDiv = innerDivs[i];
			if(hover) {
				if(innerDiv.className == 'tarifWrapBottom') {
					innerDiv.className = "tarifWrapBottomOver";
					outerDiv.className = "tarifWrapTopOver";
				}
			} else {
				var inputs = innerDiv.getElementsByTagName('input');
				if(inputs.length > 0) {
					for(var j = 0; j < inputs.length; j++) {
						var input = inputs[j];
						if((input.type == 'radio' && input.checked == false) || input.type == 'image') {
							if(innerDiv.className == 'tarifWrapBottomOver') {
								innerDiv.className = "tarifWrapBottom";
								outerDiv.className = "tarifWrapTop";
							}
						}
					}
				} 
			}
		}
	}
}

function thisHover(el, hover, hoverClass) {
	if(hover) {
		el.className = hoverClass;
	} else {
		var inputs = el.getElementsByTagName('input');
		if(inputs.length > 0) {				
			for(var j = 0; j < inputs.length; j++) {
				var input = inputs[j];
				if(input.type == 'radio' && input.checked == false) {
					el.className ='';
				}
			}
		}
	}
}

function thisSelected(el, hoverClass, bereich, ueberschrift, paymentType) {
	var div = document.getElementById(bereich);
	var divCoins = document.getElementById('coinList');
	var divPhone = document.getElementById('phoneList');
	var creditCard = document.getElementById('paymentTypeCreditcard');
	var bankeinzug = document.getElementById('paymentTypeBankeinzug');
	if(div) {
		var lis = div.getElementsByTagName('li');
		if (lis){
			for(var j = 0; j < lis.length; j++) {
				var li = lis[j];
				if(li == el) {
					li.className = hoverClass;
					var inputs = li.getElementsByTagName('input');
					if(inputs) {
						for(var k = 0; k < inputs.length; k++) {
							var input = inputs[k];
							input.checked = true;
							if(divCoins && divPhone) {
								if(input.id == 'paymenttype_phone') {
									divPhone.style.display = 'block';
									divCoins.style.display = 'none';
								} else {
									divPhone.style.display = 'none';
									divCoins.style.display = 'block';
								}
							}
							if(creditCard && bankeinzug) {
								if(input.id == 'paymenttype_directdebit') {
									bankeinzug.style.display = 'inline';
									creditCard.style.display = 'none';
								} else {
									bankeinzug.style.display = 'none';
									creditCard.style.display = 'inline';
								}
							}
						}
					}
				} else {
					li.className = "";
				}
			}
		}
	}

	// Links manipulieren:

	if (paymentType) {
		if (paymentType == 'creditcard') {		
			 var searchStr = 'paymenttype=directdebit';
			 var replaceStr = 'paymenttype=creditcard';
			
			 var startAnchor = document.getElementById('StartAnchor');
			 var startAnchorHref = startAnchor.href;
			 var replaceHref = startAnchorHref.replace(searchStr, replaceStr);
			 startAnchor.href = replaceHref;

			 var goldAnchor = document.getElementById('GoldAnchor');
			 var goldAnchorHref = goldAnchor.href;
			 var replaceHref = goldAnchorHref.replace(searchStr, replaceStr);
			 goldAnchor.href = replaceHref;
			 
			 var platinAnchor = document.getElementById('PlatinAnchor');
			 var platinAnchorHref = platinAnchor.href;
			 var replaceHref = platinAnchorHref.replace(searchStr, replaceStr);
			 platinAnchor.href = replaceHref;
		} else if (paymentType == 'directdebit') {
			 var searchStr = 'paymenttype=creditcard';
			 var replaceStr = 'paymenttype=directdebit';
			
			 var startAnchor = document.getElementById('StartAnchor');
			 var startAnchorHref = startAnchor.href;
			 var replaceHref = startAnchorHref.replace(searchStr, replaceStr);
			 startAnchor.href = replaceHref;

			 var goldAnchor = document.getElementById('GoldAnchor');
			 var goldAnchorHref = goldAnchor.href;
			 var replaceHref = goldAnchorHref.replace(searchStr, replaceStr);
			 goldAnchor.href = replaceHref;
			 
			 var platinAnchor = document.getElementById('PlatinAnchor');
			 var platinAnchorHref = platinAnchor.href;
			 var replaceHref = platinAnchorHref.replace(searchStr, replaceStr);
			 platinAnchor.href = replaceHref;			
		}
	}		
}

function setInnerHTML(el, text) {
	el.innerHTML = text;
}


function easyHover(el, hoverId) {
	if(el) {
		el.id = hoverId;
	}
}

function goToAnchor(el) {
	var anchor = document.getElementById(el);
	if(anchor) {
		anchor.style.display = 'block';
		location.hash = el;
	}
}



/*
function loadUserGallery(el, url, width, height) {
	var div = document.getElementById(el);
	if(div) {		
		if(! browser.isIE) {
			var flashObject = document.createElement('object');
			flashObject.setAttribute("width", width);
			flashObject.setAttribute("height", height);
			flashObject.setAttribute("type", "application/x-shockwave-flash");
			flashObject.setAttribute("data", url);
			flashObject.setAttribute("wmode", "transparent");

			div.innerHTML = '';
			div.appendChild(flashObject);
			
		} else {
			CreateControl(el,
                "clsid:D27CDB6E-AE6D-11cf-96B8-444553540000",
                "EXAMPLE_OBJECT_ID",
                width,
                height,
                url);
		}
    }
}

function hideFotoNotificationSuccess() {
	var fotoNotificationSuccess = document.getElementById("fotoNotificationSuccess");
	if (fotoNotificationSuccess) {
		var inputs = fotoNotificationSuccess.getElementsByTagName("input");
		if (inputs.length > 0) {
			for (var i=0; i < inputs.length; i++) {
				var input = inputs[i];
				if (input.type == 'checkbox') {
					if (input.checked) {
						fotoNotificationSuccess.style.display = "none";
						break;
					}
				}
			}
		}
	}
}

*/


function linear_distance(x1, y1, x2, y2) {
    return Math.round(Math.sqrt((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2))*10)/10;
}


function PLZFieldUpdateInfo(elem, form, target) {
    window.status = elem.value;
    if (elem.value.length==5) {
        var url = '/index.php?main=geodata&page=plzinfo&postleitzahl='+urlencode(form.postleitzahl.value)+"&country_code="+urlencode(form.country_code.value);
        ajax_submit_to(url, target, 'innerHTML');

    }
}

function PLZFieldUpdateInfo(elem, form, target) {
	window.status = elem.value;
	if (elem.value.length==5) {
		var url = '/index.php?main=geodata&view=plzinfo&postleitzahl='+urlencode(form.postleitzahl.value)+"&country_code="+urlencode(form.country_code.value);
		ajax_submit_to(url, target, 'innerHTML');
	}
}

var PLZRemoteCheck_form = false;


	function PLZRemoteCheck(elem,target_id,required_field) {
		var url = '/index.php?main=geodata&fetchview=plzdata&view=ajax_result';
		
		if(PLZRemoteCheck.arguments[3] != null && (typeof PLZRemoteCheck.arguments[3] == 'function')) {
			url += "&limit=-1";
		}
		
		
		var ajaxArgs = new Object();
		var plzElem = false;
		var countryElem = false;	
		
		PLZRemoteCheck_form = elem.form;
		
		if (PLZRemoteCheck_form.plz) {
			plzElem = PLZRemoteCheck_form.plz;
		} else if (PLZRemoteCheck_form.postleitzahl) {
			plzElem = PLZRemoteCheck_form.postleitzahl;		
		} else if (PLZRemoteCheck_form.location_postleitzahl) {				
			plzElem = PLZRemoteCheck_form.location_postleitzahl;
		} else if (PLZRemoteCheck_form.location_plz) {		
			plzElem = PLZRemoteCheck_form.plzlocation_plz
		} else if (PLZRemoteCheck_form.agency_zip) {		
			plzElem = PLZRemoteCheck_form.agency_zip		
		}
		
		if (PLZRemoteCheck_form.country_code) {
			countryElem = PLZRemoteCheck_form.country_code;
		} else if (PLZRemoteCheck_form.location_country_code) {
			countryElem = PLZRemoteCheck_form.location_country_code;		
		} else if (PLZRemoteCheck_form.agency_country_code) {
			countryElem = PLZRemoteCheck_form.agency_country_code;		
		}
		
		if (plzElem && countryElem ) {
			plzElem.className = 'rpcFieldLoading';		
			ajaxArgs.postleitzahl = plzElem.value;
			ajaxArgs.country_code = countryElem.value;
			
			if (typeof(target_id) != 'undefined') {
				var target = document.getElementById(target_id);
				if (target) {
					ajaxArgs.target_id = target_id;
				}
			}
			if (typeof(required_field) != 'undefined') {
				if (required_field) {
					ajaxArgs.required_field = true;
				}
			}
			
			
			var callback = on_PLZRemoteCheck;
			
			if(PLZRemoteCheck.arguments[3] != null && (typeof PLZRemoteCheck.arguments[3] == 'function')) {				
				var proxy = PLZRemoteCheck.arguments[3]; 				
				proxy.source = elem;
				proxy.dataField = document.getElementById('ort');
				proxy.target = document.getElementById(target_id);								
				callback = function(responseText, responseXML) {					
					eval("var response="+responseText+";");					
					proxy.data = response;					
					proxy.call();
				};
			}
			
			ajax_submit(url, callback, ajaxArgs);						
		}
	
	}
	
	function on_PLZRemoteCheckExtended() {
		var data = on_PLZRemoteCheckExtended.data;
		var target = on_PLZRemoteCheckExtended.target;
		var source = on_PLZRemoteCheckExtended.source;
		var dataField = on_PLZRemoteCheckExtended.dataField;
		
		if(data.view.found) {
			dataField.value = data.view.results[0].city;
			
			if(data.view.results.length == 1) {				
				if(target.nodeName.toLowerCase() != 'span') {
					var oneCity = document.createElement("span");
					oneCity.setAttribute("id", target.id);
					
					oneCity.innerHTML = data.view.results[0].city;
					
					var targetParent = target.parentNode;
					targetParent.removeChild(target);
					targetParent.appendChild(multipleCities);
					
				} else {					
					target.innerHTML = data.view.results[0].city;	
					
				}				
				
			} else {
				if(target.nodeName.toLowerCase() != 'select') {					
					var multipleCities = document.createElement("select");
					multipleCities.setAttribute("name", "cities");
					multipleCities.setAttribute("id", target.id);
					multipleCities.onchange = function() {
						dataField.value = multipleCities.options[multipleCities.selectedIndex].value;
					};								
					for(var i = 0; i < data.view.results.length; i++) {					
						var temp = document.createElement("option");
						var tempCity = data.view.results[i].city;
						temp.setAttribute("value", tempCity);
						temp.innerHTML = tempCity;
						multipleCities.appendChild(temp);					
					}					
					var targetParent = target.parentNode;
					targetParent.removeChild(target);
					targetParent.appendChild(multipleCities);
					
				} else {					
					target.options = null;
					for(var i = 0; i < data.view.results.length; i++) {					
						var temp = document.createElement("option");
						var tempCity = data.view.results[i].city;
						temp.setAttribute("value", tempCity);
						temp.innerHTML = tempCity;
						target.appendChild(temp);
						target.onchange = function() {
							dataField.value = target.options[target.selectedIndex].value;
						};
					}					
				}
			}
			
		} else {
			dataField.value = "";
			if(target.nodeName.toLowerCase() != 'span') {
				var message = document.createElement("span");
				message.setAttribute("id", target.id);
				
				message.innerHTML = "--";
				
				var targetParent = target.parentNode;
				targetParent.removeChild(target);
				targetParent.appendChild(message);
			} else {
				target.innerHTML = "--";
			}
		}
		
		//Loader ausblenden
		source.className = 'text';
		return true;
	}
	
	function on_PLZRemoteCheck(responseText, responseXML) {
		var plzElem = false;
		var countryElem = false;
		var ortElem = false;	
		if (PLZRemoteCheck_form != false) {
			
			if (PLZRemoteCheck_form.plz) {
				plzElem = PLZRemoteCheck_form.plz;
			} else if (PLZRemoteCheck_form.postleitzahl) {
				plzElem = PLZRemoteCheck_form.postleitzahl;		
			} else if (PLZRemoteCheck_form.location_postleitzahl) {				
				plzElem = PLZRemoteCheck_form.location_postleitzahl;
			} else if (PLZRemoteCheck_form.location_plz) {		
				plzElem = PLZRemoteCheck_form.plzlocation_plz		
			}		
			
			if (PLZRemoteCheck_form.country_code) {
				countryElem = PLZRemoteCheck_form.country_code;
			} else if (PLZRemoteCheck_form.location_country_code) {
				countryElem = PLZRemoteCheck_form.location_country_code;		
			}		
			
			if (PLZRemoteCheck_form.ort) {
				ortElem = PLZRemoteCheck_form.ort;
			} else if (PLZRemoteCheck_form.location_ort) {
				ortElem = PLZRemoteCheck_form.location_ort;		
			}			
			
			eval("var response="+responseText+";");
			
			var target = false; 
			if (typeof(response.sentdata.target_id) != 'undefined') {
				var target = document.getElementById(response.sentdata.target_id);
			}			
			
			var required_field = false;
			if (typeof(response.sentdata.required_field) != 'undefined') {
				if (response.sentdata.required_field) { 
					required_field = true;
				}
			}			
			
			if (plzElem && countryElem && (ortElem || target) ) {
				plzElem.className = 'text';
				if (response.view.ort) {
					if (target) {
						target.innerHTML = response.view.ort;
					} else {
						ortElem.value = response.view.ort;
					}
				} else {				
					plzElem.className = (required_field == true) ? 'error' : 'text';
					if (target) {
						target.innerHTML = 'Postleitzahl nicht vorhanden';
					} else {
						ortElem.value = '';
					}
				}
			}
	
			PLZRemoteCheck_form = false;
		}
	}

function createCookie(name,value,days)
{
	if (days)
	{
		var date = new Date();
		date.setTime(date.getTime()+(days*24*60*60*1000));
		var expires = "; expires="+date.toGMTString();
	}
	else var expires = "";
	document.cookie = name+"="+value+expires+"; path=/";
}

function readCookie(name)
{
	var nameEQ = name + "=";
	var ca = document.cookie.split(';');
	for(var i=0;i < ca.length;i++)
	{
		var c = ca[i];
		while (c.charAt(0)==' ') c = c.substring(1,c.length);
		if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
	}
	return null;
}

function eraseCookie(name)
{
	createCookie(name,"",-1);
}


var no_origin = -12345678;
var origin_x = no_origin;
var origin_y = no_origin;

function ensure_geo_origin() {
    if (origin_x==no_origin) {
        var ox = readCookie("geo_origin_lin_x");
        if (ox) {
            origin_x = ox;
        }
    }
    if (origin_y==no_origin) {
        var oy = readCookie("geo_origin_lin_y");
        if (oy) {
            origin_y = oy;
        }
    }
}

function set_geo_origin(linear_x, linear_y) {
    createCookie("geo_origin_lin_x", linear_x, 365);
    createCookie("geo_origin_lin_y", linear_y, 365);
    set_tmp_geo_origin;
}

function set_tmp_geo_origin(linear_x, linear_y) {
    origin_x = linear_x;
    origin_y = linear_y;
}

function have_origin() {
    return ((origin_x!=no_origin) && (origin_y!=no_origin));
}

function origin_distance(linear_x, linear_y) {
    ensure_geo_origin();
    if (have_origin()) {
        return linear_distance(origin_x, origin_y, linear_x, linear_y);
    }
}

function write_distance(text_before, linear_x, linear_y, text_after, alternate_text) {
    ensure_geo_origin();
    if (!have_origin()) {
        document.write(alternate_text);
        return;
    }
    if (!text_after) {
        text_after = '';
    }
    if (!text_before) {
        text_before = '';
    }
    var distance = origin_distance(linear_x, linear_y);
    document.write(text_before+distance+text_after);
}






function showNotificationControlls(h3, divID) {
	var content = document.getElementById(divID);
	if(content) {
		if(content.style.display == 'block') {
			content.style.display = 'none';
			h3.className = '';
		} else {
			content.style.display = 'block';
			h3.className = 'selected';
		}
	}
}

/**
 * @author Martin Regner <m.regner@librics.de>
 * @copyright 2006 librics GmbH & CoKG
 * @version svn: $Id: ajax.js 9029 2007-07-04 13:52:09Z kuebing $
 * 
 */
	
	
	function setNotificationEvent(checkbox,eventname,user_id,sendas,times) {
		if (checkbox) {
			if (!checkbox.checked) {
				unregisterNotification(eventname,user_id);
			} else {
				registerNotification(eventname, checkbox.value, times, user_id);
			}
		}
	}
	
	function unregisterNotification(eventname,user_id) {
		if(typeof(unregisterNotificationAction) == 'undefined') {
			alert ("You have to define the action url for the unregisterNotification function in 'unregisterNotificationAction' somewhere in your template!");
			return;
		}		

		var wait_div_name = "wait_div_" + eventname;
		var wait_div = document.getElementById(wait_div_name);
		if(wait_div) {
			wait_div.style.display = 'block';
		}
		
		var ajaxArgs = new Object();
		ajaxArgs['eventName'] = eventname;
		ajaxArgs['user_id'] = user_id;
		
		ajax_submit(unregisterNotificationAction, on_notification_registered, ajaxArgs);		
		
	}
	
	function registerNotification(eventname, sendas, times, user_id) {
		if(typeof(registerNotificationAction) == 'undefined') {
			alert ("You have to define the action url for the registerNotification function in 'registerNotificationAction' somewhere in your template!");
			return;
		}

		var wait_div_name = "wait_div_" + eventname;
		show(wait_div_name);
		
		var ajaxArgs = new Object();
		ajaxArgs['eventName'] = eventname;
		ajaxArgs['sendAs[]'] = sendas;
		ajaxArgs['times'] = times;
		ajaxArgs['user_id'] = user_id;
		
		ajax_submit(registerNotificationAction, on_notification_registered, ajaxArgs);
	}
	
	function on_notification_registered(responseText, responseXML) {
		try {
			eval("var response="+responseText+";");
			var eventname = response['sentdata']['eventName'];
			var wait_div_name = "wait_div_" + eventname;
			hide(wait_div_name);
			
		} catch (exception) {
			var errorArea = document.getElementById('error_area');
			if(errorArea) {
				errorArea.innerHTML = responseText;
				errorArea.style.display = 'inline';
			} else {
				alert(responseText);
			}
		}
	}

function switchSearchView(buttonID, formID) {
	var button = document.getElementById(buttonID);
	if(button) {
		button.disabled = true;
		button.value = 'loading...';		
	}
	var search_view = document.getElementById('search_view_select');
	if(search_view) {
		var viewValue = search_view.options[search_view.selectedIndex].value;
		
		// Write in the Hidden-Field of the Form in the right column...
		var hidden_search_view = document.getElementById('hidden_search_view');
		if(hidden_search_view) {
			hidden_search_view.value = viewValue;
		}
		
		if(!formID) {
			fromID = 'right_column_search';
		}
		// Submit
		var form = document.getElementById(formID);
		if(form) {
			form.submit();
		}
	}
}

function switchTop100View(buttonID, formID) {
	var form = document.getElementById(formID);
	var button = document.getElementById(buttonID);
	if(button) {
		button.disabled = true;
		button.value = 'loading...';
	}
	
	var search_view = form.elements['limit'];
	var limit = form.elements['limit'];
	if(search_view.value == 'detail') {
		limit.value = 5;
	} else {
		limit.value = 25;
	}
	
	if(form) {
		form.submit();
	}
}

function presetAgeTo(fromSelect, toSelectID) {
	var toSelect = document.getElementById(toSelectID);
	if(toSelect) {
		var minAge = Number(fromSelect.options[fromSelect.selectedIndex].value);
		var ageDifference = null;
		if(minAge < 20) {
			ageDifference = 8;
		} else if(minAge < 30) {
			ageDifference = 10;
		} else if(minAge < 40) {
			ageDifference = 12;
		} else if(minAge < 50) {
			ageDifference = 15;
		} else {
			ageDifference = 20;
		}

		var maxAge = ageDifference + minAge;

		for(var i=0; i < toSelect.options.length; i++) {
			if( (ageDifference + minAge) == toSelect.options[i].value ) {
				toSelect.selectedIndex = i;
			}
		}
	}	
}

function allowSearchPerDistance(plzFieldId, distanceSelectId, countrySelectId) {
	var plzField = document.getElementById(plzFieldId);
	var distanceSelect = document.getElementById(distanceSelectId);
	var countrySelect = document.getElementById(countrySelectId);
				
	if(plzField && distanceSelect && countrySelect) {
		var disableDistance = false;
		if(countrySelect.value == 'de') {
			if(plzField.value.length < 5) {
				disableDistance = true;
			}
		} else if(countrySelect.value == 'at') {
			if(plzField.value.length < 4) {
				disableDistance = true;
			}
		}
		
		if(disableDistance) {
			distanceSelect.disabled = true;
		} else {
			distanceSelect.disabled = false;
		}
	} 
}

function submitExamples(searchString) {
	var formular = document.exampleForm;
	var hiddenInput = formular.tag_query;
	if(formular && hiddenInput) {
		hiddenInput.value = searchString;
		formular.submit();
	}
}



/*	Tabs-Steuerung */
/*
function initLocal() {
	setTabsControlling(
		'controllForProfileElements',
		new Array('persoenlicheAngaben', 'details', 'hobbiesInteressen')
	);
}
*/
/*
function setTabsControlling(controller, divs) {
	//
	// Hide all Divs, except the first one
	 //
	 for(var i=0; i < divs.length; i++) {
	 	var div = document.getElementById(divs[i]);
	 	if(div && i > 0) {
	 		div.style.display = 'none';
	 	}
	 }
	 
	 //
	 // Create the Tab-Controller
	 //
 	 var controller = document.getElementById(controller);
 	 if(controller) {
		var as = controller.getElementsByTagName('a');
		for(var j=0; j < as.length; j++) {
			var a = as[j];
				a.setAttribute('control', j);
				a.onclick = function() {
					showContent(divs[this.getAttribute('control')], divs);
					switchTab(this.parentNode, controller);
				};
		}
 	 }
}

function showContent(showElement, hideElements) {
	if(hideElements.length > 0) {
		for(var i=0; i < hideElements.length; i++) {
			var div = document.getElementById(hideElements[i]);
		 	if(div) {
		 		div.style.display = 'none';
		 	}
		}
		
		var div = document.getElementById(showElement);
		if(div) {
			div.style.display = 'block';
		}
	}
}

function switchTab(activeTab, controller) {
	var lis = controller.getElementsByTagName(li);
	alert(controller);
	if(lis.length > 0) {
		for(var i=0; i < lis.length; i++) {
			var li = lis[i];
			li.className = '';
		}
	}
	activeTab.className = 'active';
}
*/

function prepareHelp(id) {
	var rootEl = document.getElementById(id);
	if(rootEl) {
		var divs = rootEl.getElementsByTagName('div');
		if(divs.length > 0) {
			for(var i = 0; i < divs.length; i++) {
				var div = divs[i];
				if(div.className == 'help') {
					div.style.display = 'none';
				}
			}
		}
	}
}

function positionHelp(id, mode, border) {
	var help = document.getElementById(id);
	var helpCopy = help.cloneNode(true);
	var helpWrapper = document.getElementById('helpWrapper');
	if(help && helpWrapper) {
		if(mode) {
			helpWrapper.appendChild(helpCopy);
			helpCopy.style.display = "block";
		} else {
			var childs = helpWrapper.childNodes;
			for(var i = 0; i < childs.length; i++) {
				helpWrapper.removeChild(childs[i]);
			}
		}	
	}
}

function askForPhoto(fotoanfrageURL) {
	var ajaxParams = {};
	hide('askForPhotoInner');
	show('askForPhoto_load');
	ajax_submit(fotoanfrageURL, on_askForPhoto, ajaxParams);
}

function on_askForPhoto(responseText, responseXML) {
	hide('askForPhoto_load');
	try {
		eval("var response="+responseText+";");
		if (response.status == 'ok') {
			show('askForPhoto_success');
			setTimeout("hide('askForPhoto')",1500);
		} else {
			show('askForPhotoInner');
		}
	} catch (exception) {
		alert(exception.toString());
	}
}


// Flash Version Detector  v1.2.1
// documentation: http://www.dithered.com/javascript/flash_detect/index.html
// license: http://creativecommons.org/licenses/by/1.0/
// code by Chris Nott (chris[at]dithered[dot]com)
// with VBScript code from Alastair Hamilton (now somewhat modified)


function isDefined(property) {
  return (typeof property != 'undefined');
}

var flashVersion = 0;
function getFlashVersion() {
	var latestFlashVersion = 8;
   var agent = navigator.userAgent.toLowerCase(); 
	
   // NS3 needs flashVersion to be a local variable
   if (agent.indexOf("mozilla/3") != -1 && agent.indexOf("msie") == -1) {
      flashVersion = 0;
   }
   
	// NS3+, Opera3+, IE5+ Mac (support plugin array):  check for Flash plugin in plugin array
	if (navigator.plugins != null && navigator.plugins.length > 0) {
		var flashPlugin = navigator.plugins['Shockwave Flash'];
		if (typeof flashPlugin == 'object') { 
			for (var i = latestFlashVersion; i >= 3; i--) {
            if (flashPlugin.description.indexOf(i + '.') != -1) {
               flashVersion = i;
               break;
            }
         }
		}
	}

	// IE4+ Win32:  attempt to create an ActiveX object using VBScript
	else if (agent.indexOf("msie") != -1 && parseInt(navigator.appVersion) >= 4 && agent.indexOf("win")!=-1 && agent.indexOf("16bit")==-1) {
	   var doc = '<scr' + 'ipt language="VBScript"\> \n';
      doc += 'On Error Resume Next \n';
      doc += 'Dim obFlash \n';
      doc += 'For i = ' + latestFlashVersion + ' To 3 Step -1 \n';
      doc += '   Set obFlash = CreateObject("ShockwaveFlash.ShockwaveFlash." & i) \n';
      doc += '   If IsObject(obFlash) Then \n';
      doc += '      flashVersion = i \n';
      doc += '      Exit For \n';
      doc += '   End If \n';
      doc += 'Next \n';
      doc += '</scr' + 'ipt\> \n';
      document.write(doc);
   }
		
	// WebTV 2.5 supports flash 3
	else if (agent.indexOf("webtv/2.5") != -1) flashVersion = 3;

	// older WebTV supports flash 2
	else if (agent.indexOf("webtv") != -1) flashVersion = 2;

	// Can't detect in all other cases
	else {
		flashVersion = flashVersion_DONTKNOW;
	}

	return flashVersion;
}

flashVersion_DONTKNOW = -1;

if(typeof(window.NAMEDFIFO_DEFINED) == 'undefined') {
	window.NAMEDFIFO_DEFINED = true;

	NamedFIFO = function() {}
	
	NamedFIFO.push = function (name, element) {
		this.getQueue(name).push(element);
	}
	
	NamedFIFO.pop = function (name) {
		return this.getQueue(name).shift();
	}
	
	NamedFIFO.getQueue = function(name) {
		if(!this.namedQueues) {
			this.namedQueues = new Object();
		}
		if(!this.namedQueues[name]) {
			this.namedQueues[name] = new Array();
		}
		return this.namedQueues[name];
	}
	
	NamedFIFO.prototype.push = NamedFIFO.push;
	NamedFIFO.prototype.pop = NamedFIFO.pop;
	NamedFIFO.prototype.getQueue = NamedFIFO.getQueue;
}

/**
*	Init() for various crossbrowser-optimize functions
*/

var on_page_load = '';

function init() {
	initLocal();	
	enableTooltips();
	setPageTitle();
	if (on_page_load) {
		eval(on_page_load);
	}
	/*
	initMessengerDisplay();	
	if(! browser.isIE){
		initMessengerListsSortable();
	}	
	*/
	 
	/**
	* 	IE-Fix for Sub-Navigation-Rollover
	*/
	/*
	if(browser.isIE) {
		var subnavi = document.getElementById('subnavi');
		if(subnavi) {
			var lis = subnavi.getElementsByTagName('li');
			for(var i = 0; i < lis.length; i++) {
				var li = lis[i];
				li.onmouseover = function() {
				
					};
				li.onmouseout = function() {
						
					};
			}
		}
	}
	*/
}

function add_on_page_load(code) {
	on_page_load += code + "\n";
}

/**
*	Shold be overwritten by various Modules, Plug-Ins
*	etc. Helpfull for function requiring an already loaded
*	HTML-Sructure.
*/
function initLocal() {
	return true;
}

function openNewMessageNotifier() {
	show("newMessageBlock");
}


/**
*	Shold be overwritten by the Formclass.
*/
function enableTooltips() {
	return true;
}

/**
* 	Controlls displaying Messenger-Lists
*/

/*
function initMessengerDisplay() {
	var nameListPrefix = "messengerListWrap_";	
	var messenger = document.getElementById('messenger');
	if(messenger) {
		var h3s = messenger.getElementsByTagName('h3');
		if(h3s.length > 0) {
			for(var i = 0; i < h3s.length; i++) {
				var h3 = h3s[i];
				var h3Id = h3.id;
				var h3Number = h3Id.substring(h3Id.length - 1, h3Id.length);
				
				var listId = '' + nameListPrefix + h3Number;				
				list = document.getElementById(listId);
				list.style.display = 'none';
				
				if(inCookie('flirty_messanger_' + listId + '_display', 'block')) {
					list.style.display = 'block';
					toggleBackgroundImage(h3, '/images/meta/icons/messenger_plus.gif', '/images/meta/icons/messenger_minus.gif');						
				}
								
				h3.onclick = function() {
						// Toggle Background-Image ('+' or '-')
						toggleBackgroundImage(this, '/images/meta/icons/messenger_plus.gif', '/images/meta/icons/messenger_minus.gif');						
						
						// Slide-Effect
						var thisId = this.id;
						var thisNumber = thisId.substring(thisId.length - 1, thisId.length);
						var list = document.getElementById('' + nameListPrefix + thisNumber);					
						new Effect.toggle(list, 'Slide');
						
						// Store the display-Status in a cookie
						var display = list.style.display;
						if(display == 'none') {
							display = 'block';
						} else {
							display = 'none';
						}
						var id = list.id;
						var cookieString = 'flirty_messanger_' + id + '_display=' + display + '; path=/';
						document.cookie = cookieString;
					};
			}
		}
	}	
}
*/

/**
* 	Initialize sorting Messenger-Lists
*/
/*
function initMessengerListsSortable() { 
	Sortable.create("messengerList_1",
		{dropOnEmpty:true,containment:["messengerList_1","messengerList_2","messengerList_3","messengerList_4"], constraint:false});
	Sortable.create("messengerList_2",
		{dropOnEmpty:true,containment:["messengerList_1","messengerList_2","messengerList_3","messengerList_4"],constraint:false});
	Sortable.create("messengerList_3",
		{dropOnEmpty:true,containment:["messengerList_1","messengerList_2","messengerList_3","messengerList_4"], constraint:false});
	Sortable.create("messengerList_4",
		{dropOnEmpty:true,containment:["messengerList_1","messengerList_2","messengerList_3","messengerList_4"],constraint:false});
}
*/

/**
* 	Toggles Background-Images for element
*/
function toggleBackgroundImage(el) {
	if(el.style.backgroundImage != 'url(' + arguments[2] + ')') {
		el.style.backgroundImage = 'url(' + arguments[2] + ')';
	} else {
		el.style.backgroundImage = 'url(' + arguments[1] + ')';
	}
}

function hide(id) {
	var element = document.getElementById(id);
	if(element) {
		element.style.display = "none";
	}
}

function show(id,timeout_delay) {
	var default_delay=1500;
	var element = document.getElementById(id);
	if(element) {
		element.style.display = "block";
		if (typeof(timeout_delay) != 'undefined') {
			if (timeout_delay == true) {
				timeout_delay = default_delay;
			} else if (timeout_delay == false) {
				timeout_delay = 0
			} else if (timeout_delay <= 0) {
				timeout_delay = 0
			}
			
			if (timeout_delay > 0) {
				setTimeout("hide('"+id+"')",timeout_delay);
			}			
		}
	}
}

var profileBubbleTimeoutId;

function setProfileBubbleTimeout() {
	profileBubbleTimeoutId = window.setTimeout("hide('profileBubble')", 7000);
}

function clearProfileBubbleTimeout() {
	window.clearTimeout(profileBubbleTimeoutId);
}

function showProfileBubble(userName, relativeElement) {
	var eProfileBubble = document.getElementById('profileBubble');
	var eRelativeElement = document.getElementById(relativeElement);
	
	if(eProfileBubble) {
		var eProfileBubbleUserName = document.getElementById('profileBubbleUserName');
		var eTextRegister = document.getElementById('profileBubbleTextRegister');
		var eTextAlternative = document.getElementById('profileBubbleTextAlternative');
		
		if(eProfileBubbleUserName) {
			eProfileBubbleUserName.innerHTML = userName;
		}
		
		if(eTextRegister && eTextAlternative) {			
			if(document.location.href.indexOf('main') < 0 || document.location.href.indexOf('main=registration') >= 0 || document.location.href.indexOf('main=homepage') >= 0) {
				eTextRegister.style.display = 'block';
				eTextAlternative.style.display = 'none';
			} else {
				eTextRegister.style.display = 'none';
				eTextAlternative.style.display = 'block';
			}
		}
		
		eProfileBubble.style.display = 'block';
		eProfileBubble.style.left = absLeft(eRelativeElement) + 'px';
		eProfileBubble.style.top = absTop(eRelativeElement) + 'px';
		
		clearProfileBubbleTimeout();
		setProfileBubbleTimeout();
	}
}

// Browserunabhängig ein Element holen
function get(id) {
  if (document.all) {
  	return document.all[id];
  } else if (document.getElementById) {
  	return document.getElementById(id);
  } 
  return false;
}

/**
*	
*/
function inCookie(key, value) {
	var c = document.cookie;
	if(key && value) {
		var pattern = key + "=" + value;
		if(c.indexOf(pattern) != -1) {
			return true;
		} else {
			return false;
		}
	} else {
		return false;
	}
}

function resetField(field) {
	if(field) {
		field.value = "";
	}
}

/**
* 	Workaround for Mac IE,
*	doesn't support Array.push()
*/
if(typeof Array.prototype.push=='undefined')
  Array.prototype.push=function(){
    var i=0;
    b=this.length,a=arguments;
    for(i;i<a.length;i++)this[b+i]=a[i];
    return this.length
  };
   
 // These functions get inserted via a Smarty postfilter if DEBUG and DEBUG_HTML have been set to true
 function html_debug(element, event, templateName, moduleName) {
        event.cancelBubble = true;
        event.cancel = true;
        event.returnValue = false;
        var elementInfo = element.tagName;
        if (element.id) {
            elementInfo += " ID="+element.id;
        }
        if (element.name) {
            elementInfo += " NAME="+element.name;
        }
        if (element.className) {
            elementInfo += " CLASS="+element.className;
        }
        if (element.src) {
            elementInfo += " SRC="+element.src;
        }
        if (element.target) {
            elementInfo += " TARGET="+element.target;
        }
        var stat =  templateName+'  '+elementInfo;
        window.status = stat;
        setTimeout('window.status = "'+stat+'";', 200);
 }
 
  function html_undebug(element, event) {
    event.cancelBubble = true;
    event.cancel = true;
    event.returnValue = false;
    window.status = '';
 }
 
 // Pop-Up
function popUp(seite, fenstername, scrolling, breite, hoehe, tb) {
	var actToolbar = 0;
	if(tb) {
		actToolbar = tb;
	}
	return popUp2(seite, fenstername, 'toolbar=' + tb + ',location=0, directories=0,status=0,menubar=0,scrollbars=' + scrolling + ',resizable=0,width=' + breite + ',height=' + hoehe);
}

var popup;

function popUp2(url, title, params, type) {
	popup = window.open(url, title, params);
	var infoContainer = document.getElementById('popupChecker');
	if(!popup) {
		if(infoContainer) {
			infoContainer.style.display = "block";
		}
	} else {
		window.setTimeout('popup.focus();', 50);
	}
	return popup;
}

var globalPopUpBlocker = false;

var popupCheckDone = false;
function checkPopupBlocker(warningDiv, saveAsConfigParam, recheck) {	
    if (!recheck && popupCheckDone) {
        return globalPopUpBlocker;
    }
    popupCheckDone = true;
	var newPopup = window.open('', 'blockerTest', 'left=5000,top=5000,toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=0,resizable=0,width=1,height=1');
	window.focus();
	if(! newPopup) {
        globalPopUpBlocker = true;
        if (warningDiv) {
		    var div = document.getElementById(warningDiv);
		    if(div) {
			    div.style.display = "block";
		    }
        }
		if(saveAsConfigParam) {
			getFlirtyTopFrame().frames['actionIFrame'].location.href = "/index.php?action-userprofile=setUserConfigParam&main=userprofile&page=main&param=popupBlockerDeactivated&value=0";
		}
		return true;			
	} else {
        globalPopUpBlocker = false;
		newPopup.close();
        if (warningDiv) {
            var div = document.getElementById(warningDiv);
            if(div) {
			    div.style.display = "none";
		    }
        }
		if(saveAsConfigParam) {
			getFlirtyTopFrame().frames['actionIFrame'].location.href = "/index.php?action-userprofile=setUserConfigParam&main=userprofile&page=main&param=popupBlockerDeactivated&value=1";
		}
		return false;
	}
}				

function setPageTitle() {
	var content = document.getElementById('content');
	if(content) {
		var h1s = content.getElementsByTagName('h1');
		if(h1s.length > 0) {
			for(var i = 0; i < h1s.length; i++) {
				var h1 = h1s[i];
				if(h1.className == '' && h1.firstChild.data) {
					//var title = h1.firstChild.data.replace(/\s/, '');										
					var h1Img = h1.getElementsByTagName('img');					
					/* title sei entweder img tag vom fontalzed img oder standard h1-content */
					try {
						var title = h1Img[0].alt;						
					} catch (e) {
						var title = h1.firstChild.data;
					}					
					document.title += ' - ' + title;
					break;
				}
			}
		}
	}
}

function controlSkyscraper () {
	var x;
	if (self.innerHeight) {
		x = self.innerWidth;
	} else if (document.documentElement && document.documentElement.clientHeight) {
		x = document.documentElement.clientWidth;
	} else if (document.body) {
		x = document.body.clientWidth;
	}
	
	var skyscraper = document.getElementById('skyscraper');
	if(x < 1120) {
		skyscraper.style.display = "none";
	} else {
		skyscraper.style.display = "block";
	}
}

function absLeft(el) {
	return (el.offsetParent)? 
	el.offsetLeft+absLeft(el.offsetParent) : el.offsetLeft;
}

function absTop(el) {
	return (el.offsetParent)? 
	el.offsetTop+absTop(el.offsetParent) : el.offsetTop;
}

function moveAndShowTip(e, tipID, countdown) {
	if(browser.isIE) {
		x = window.event.x + document.documentElement.scrollLeft;
		y = window.event.y + document.documentElement.scrollTop;
	} else {
		x = e.pageX;
		y = e.pageY;
	}
		
	tip = document.getElementById(tipID);
	if(tip) {
		
		showAndHideAfterCountdown(tipID, countdown);
		tip.style.left = (x-20) + "px";
		tip.style.top = (y - tip.offsetHeight)  + "px";
		
	}
}

function showAndHideAfterCountdown(elementID, timeout) {
	if(elementID) {
		show(elementID);
	}
	
	// Hide after Countdown
	hideAfterCountdown(elementID, timeout);
}

function hideAfterCountdown(elementID, timeout) {
	if(timeout > 0) {		
		var element = document.getElementById(elementID);
		if(element) {
			var spans = element.getElementsByTagName('span');
			for(var i=0; i < spans.length; i++ ) {				
				var span = spans[i];
				if(span.className == 'countdown') {
					span.innerHTML = timeout;
				}
			}
		}
		timeout--;
		setTimeout("hideAfterCountdown('" + elementID+ "', " + timeout + " )", 1000);
	} else {
		hide(elementID);
	}
}

function url_encode(text) {
     text = escape(text);
     text = text.replace(/\//g,"%2F");
     text = text.replace(/\?/g,"%3F");
     text = text.replace(/=/g,"%3D");
     text = text.replace(/&/g,"%26");
     text = text.replace(/@/g,"%40");
     text = text.replace(/\+/g,"%2B");
     return text;
}

function getCookieValue(key) {
	if(document.cookie.length > 0) {
		splittedCookie = document.cookie.split(";");
		for (var index in splittedCookie) {
			keyvaluePair = splittedCookie[index];
			splittedPair = keyvaluePair.split('=');
			cookieKey = splittedPair[0].replace(/^\s+/, "");
			cookieValue = splittedPair[1];
			if(cookieKey == key) {
				return cookieValue;
			}
		}
	}
	return false;
}

function writeWebmasterID() {
	var webmaster_id = getCookieValue('webmaster_id');
	if(webmaster_id) {
		var element = document.getElementById('footer_webmaster_id');
		if(element) {
			element.innerHTML = "WMID: " + webmaster_id;
		}
	}
}

function setBackgroundIFrame(state, div, iframe) {
	if(browser.isIE) {
		var DivRef = document.getElementById(div);
		var IfrRef = document.getElementById(iframe);
		
		if(!DivRef || !IfrRef)
			return;
		
		if(state) {
			DivRef.style.display = "block";
			IfrRef.style.width = DivRef.offsetWidth;
			IfrRef.style.height = DivRef.offsetHeight;
			IfrRef.style.top = DivRef.style.top;
			IfrRef.style.left = DivRef.style.left;
			IfrRef.style.zIndex = DivRef.style.zIndex - 1;
			IfrRef.style.display = "block";
		} else {
			DivRef.style.display = "none";
			IfrRef.style.display = "none";
		}
	}
}

/// Behavious Library 

/*
   Behaviour v1.1 by Ben Nolan, June 2005. Based largely on the work
   of Simon Willison (see comments by Simon below).

   Description:
       
       Uses css selectors to apply javascript behaviours to enable
       unobtrusive javascript in html documents.
       
   Usage:   
   
    var myrules = {
        'b.someclass' : function(element){
            element.onclick = function(){
                alert(this.innerHTML);
            }
        },
        '#someid u' : function(element){
            element.onmouseover = function(){
                this.innerHTML = "BLAH!";
            }
        }
    };
    
    Behaviour.register(myrules);
    
    // Call Behaviour.apply() to re-apply the rules (if you
    // update the dom, etc).

   License:
   
       This file is entirely BSD licensed.
       
   More information:
       
       http://ripcord.co.nz/behaviour/
   
*/   

var Behaviour = {
    list : new Array,
    
    register : function(sheet){
        Behaviour.list.push(sheet);
    },
    
    start : function(){
        Behaviour.addLoadEvent(function(){
            Behaviour.apply();
        });
    },
    
    apply : function(){
        for (h=0;sheet=Behaviour.list[h];h++){
            for (selector in sheet){
                list = document.getElementsBySelector(selector);
                
                if (!list){
                    continue;
                }

                for (i=0;element=list[i];i++){
                    sheet[selector](element);
                }
            }
        }
    },
    
    addLoadEvent : function(func){
        var oldonload = window.onload;
        
        if (typeof window.onload != 'function') {
            window.onload = func;
        } else {
            window.onload = function() {
                oldonload();
                func();
            }
        }
    }
}

//Behaviour.start();

/*
   The following code is Copyright (C) Simon Willison 2004.

   document.getElementsBySelector(selector)
   - returns an array of element objects from the current document
     matching the CSS selector. Selectors can contain element names, 
     class names and ids and can be nested. For example:
     
       elements = document.getElementsBySelect('div#main p a.external')
     
     Will return an array of all 'a' elements with 'external' in their 
     class attribute that are contained inside 'p' elements that are 
     contained inside the 'div' element which has id="main"

   New in version 0.4: Support for CSS2 and CSS3 attribute selectors:
   See http://www.w3.org/TR/css3-selectors/#attribute-selectors

   Version 0.4 - Simon Willison, March 25th 2003
   -- Works in Phoenix 0.5, Mozilla 1.3, Opera 7, Internet Explorer 6, Internet Explorer 5 on Windows
   -- Opera 7 fails 
*/

function getAllChildren(e) {
  // Returns all children of element. Workaround required for IE5/Windows. Ugh.
  return e.all ? e.all : e.getElementsByTagName('*');
}

document.getElementsBySelector = function(selector) {
  // Attempt to fail gracefully in lesser browsers
  if (!document.getElementsByTagName) {
    return new Array();
  }
  // Split selector in to tokens
  var tokens = selector.split(' ');
  var currentContext = new Array(document);
  for (var i = 0; i < tokens.length; i++) {
    token = tokens[i].replace(/^\s+/,'').replace(/\s+$/,'');;
    if (token.indexOf('#') > -1) {
      // Token is an ID selector
      var bits = token.split('#');
      var tagName = bits[0];
      var id = bits[1];
      var element = document.getElementById(id);
      if (tagName && element.nodeName.toLowerCase() != tagName) {
        // tag with that ID not found, return false
        return new Array();
      }
      // Set currentContext to contain just this element
      currentContext = new Array(element);
      continue; // Skip to next token
    }
    if (token.indexOf('.') > -1) {
      // Token contains a class selector
      var bits = token.split('.');
      var tagName = bits[0];
      var className = bits[1];
      if (!tagName) {
        tagName = '*';
      }
      // Get elements matching tag, filter them for class selector
      var found = new Array;
      var foundCount = 0;
      for (var h = 0; h < currentContext.length; h++) {
        var elements;
        if (tagName == '*') {
            elements = getAllChildren(currentContext[h]);
        } else {
            elements = currentContext[h].getElementsByTagName(tagName);
        }
        for (var j = 0; j < elements.length; j++) {
          found[foundCount++] = elements[j];
        }
      }
      currentContext = new Array;
      var currentContextIndex = 0;
      for (var k = 0; k < found.length; k++) {
        if (found[k].className && found[k].className.match(new RegExp('\\b'+className+'\\b'))) {
          currentContext[currentContextIndex++] = found[k];
        }
      }
      continue; // Skip to next token
    }
    // Code to deal with attribute selectors
    if (token.match(/^(\w*)\[(\w+)([=~\|\^\$\*]?)=?"?([^\]"]*)"?\]$/)) {
      var tagName = RegExp.$1;
      var attrName = RegExp.$2;
      var attrOperator = RegExp.$3;
      var attrValue = RegExp.$4;
      if (!tagName) {
        tagName = '*';
      }
      // Grab all of the tagName elements within current context
      var found = new Array;
      var foundCount = 0;
      for (var h = 0; h < currentContext.length; h++) {
        var elements;
        if (tagName == '*') {
            elements = getAllChildren(currentContext[h]);
        } else {
            elements = currentContext[h].getElementsByTagName(tagName);
        }
        for (var j = 0; j < elements.length; j++) {
          found[foundCount++] = elements[j];
        }
      }
      currentContext = new Array;
      var currentContextIndex = 0;
      var checkFunction; // This function will be used to filter the elements
      switch (attrOperator) {
        case '=': // Equality
          checkFunction = function(e) { return (e.getAttribute(attrName) == attrValue); };
          break;
        case '~': // Match one of space seperated words 
          checkFunction = function(e) { return (e.getAttribute(attrName).match(new RegExp('\\b'+attrValue+'\\b'))); };
          break;
        case '|': // Match start with value followed by optional hyphen
          checkFunction = function(e) { return (e.getAttribute(attrName).match(new RegExp('^'+attrValue+'-?'))); };
          break;
        case '^': // Match starts with value
          checkFunction = function(e) { return (e.getAttribute(attrName).indexOf(attrValue) == 0); };
          break;
        case '$': // Match ends with value - fails with "Warning" in Opera 7
          checkFunction = function(e) { return (e.getAttribute(attrName).lastIndexOf(attrValue) == e.getAttribute(attrName).length - attrValue.length); };
          break;
        case '*': // Match ends with value
          checkFunction = function(e) { return (e.getAttribute(attrName).indexOf(attrValue) > -1); };
          break;
        default :
          // Just test for existence of attribute
          checkFunction = function(e) { return e.getAttribute(attrName); };
      }
      currentContext = new Array;
      var currentContextIndex = 0;
      for (var k = 0; k < found.length; k++) {
        if (checkFunction(found[k])) {
          currentContext[currentContextIndex++] = found[k];
        }
      }
      // alert('Attribute Selector: '+tagName+' '+attrName+' '+attrOperator+' '+attrValue);
      continue; // Skip to next token
    }
    
    if (!currentContext[0]){
        return;
    }
    
    // If we get here, token is JUST an element (not a class or ID selector)
    tagName = token;
    var found = new Array;
    var foundCount = 0;
    for (var h = 0; h < currentContext.length; h++) {
      var elements = currentContext[h].getElementsByTagName(tagName);
      for (var j = 0; j < elements.length; j++) {
        found[foundCount++] = elements[j];
      }
    }
    currentContext = found;
  }
  return currentContext;
}

/* That revolting regular expression explained 
/^(\w+)\[(\w+)([=~\|\^\$\*]?)=?"?([^\]"]*)"?\]$/
  \---/  \---/\-------------/    \-------/
    |      |         |               |
    |      |         |           The value
    |      |    ~,|,^,$,* or =
    |   Attribute 
   Tag
*/


/*	Erweiterung des LABEL-Handlings */

function LabelController()  {
	this.setLabelFor = LC_setLabelFor;
	this.setEventHandler = LC_setEventHandler;
}

function LC_setLabelFor(labelID, inputID) {
	var d = document;
	var input = d.getElementById(inputID);
	var labelelement = d.getElementById(labelID);
	if(input && labelelement && browser.isIE) {
		this.setEventHandler(labelelement, input);		
	}
}

function LC_setEventHandler(labelelement, inputelement) {
	labelelement.onclick = function() {
		var type = inputelement.type;
		if(type == 'radio' || type == 'checkbox'){
			inputelement.checked = true;
		}
	};
}

if(typeof(window.REQUESTPERAJAX_DEFINED) == 'undefined') {
	window.REQUESTPERAJAX_DEFINED = true;

	var ajaxResponseTargetQueues = false;
	var ajaxRequestStorage = new Object();
	
	function getAjaxResponseTargetQueues() {
		if(!ajaxResponseTargetQueues) {
			ajaxResponseTargetQueues = new NamedFIFO()
		}
		return ajaxResponseTargetQueues;
	}
	
	function actionPerAjax(element, __target_id, title, timeout) {

		if (!element || (element.nodeName != 'A' && element.nodeName != 'FORM')){
			alert("Invalid action element. Use Form or link.");
			return;
		}
		if(element.nodeName == 'A') {
			var url = element.href;
		} else if (element.nodeName == 'FORM') {

			var url = element.action;
			var conjunction = '?'
			if(url.match(/\?/)) {
				conjunction = '&';
			}

			for(var i=0;i < element.elements.length;i++) {
				var input = element.elements[i];
				url = url + conjunction + input.name + "=" + input.value;
				conjunction = '&';
			}
		} 
		requestPerAjax(url, __target_id, title, timeout);
	}
	
	function pushToAjaxQueue(html,__target_id,title,timeout)  {
		var response = {
			'view':html,
			'sentdata':{
						'__target_id':'__ajax_target',
						'title':''
					}
			};

		if (typeof(__target_id) != 'undefined') {
			if (__target_id) {
				response['sentdata']['__target_id'] = __target_id;
			}
		}		


		if (typeof(title) != 'undefined') {
			if (title) {
				response['sentdata']['title'] = title;
			}
		}

		if (typeof(timeout) != 'undefined') {
			if (timeout) {
				response['sentdata']['timeout'] = timeout;
			}
		}
		
		
		handleResponse(response);
	}
	
	
	function requestPerAjax(url, __target_id, title, timeout, __loader_id) {
		if(typeof(__target_id) == 'undefined') {
			return;
		}
		var urlParser = new URLParser();
		urlParser.parse(url);
	
		var storageKey = urlParser.query + "&__target_id=" + __target_id;
		storageKey = storageKey.replace(/[\?&=]/g,'');
		if(ajaxRequestStorage[storageKey] == 1) {
			var target_element = document.getElementById(__target_id);
			if(target_element && target_element.style.display != 'none' && __target_id == '__ajax_target') {
				return;
			}
		} else {
			ajaxRequestStorage[storageKey] = 1;
		}
	
		var ajaxAction = urlParser.baseurl;
		var ajaxArgs = urlParser.getQueryParams();
		
		var view = 'main';
		if(ajaxArgs['view']) {
			view = ajaxArgs['view'];
		} else if(ajaxArgs['page']) {
			view = ajaxArgs['page'];
			delete(ajaxArgs['page']);
		}
		ajaxArgs['view'] = 'ajax_result';
		ajaxArgs['fetchview'] = view;
		ajaxArgs['__target_id'] = __target_id;
		ajaxArgs['title'] = title;
		ajaxArgs['__loader_id'] = __loader_id;
		
		show(__loader_id);
		
		if(timeout) {
			ajaxArgs['timeout'] = timeout;
		}
		ajax_submit(ajaxAction, on_response, ajaxArgs);
	}
	
	function on_response(responseText, responseXML) {
		try {
			eval("var response="+responseText+";");
			if(typeof(response) == 'object') {
				handleResponse(response);
			} else {
				//Well well well what have we here...
			}
		} catch (exception) {
			alert(exception.toString());
		}
	}
	
	function handleResponse(response) {
		if(typeof(response) != 'object') return;
		try {
			var __target_id = response['sentdata']['__target_id'];
			var title = response['sentdata']['title'];
			
			hide(response['sentdata']['__loader_id']);
			
			var target_element = document.getElementById(__target_id);
			//We have a target for the response
			if(target_element) {
				//The target is free for our response
				if(target_element.style.display != 'none' && __target_id == '__ajax_target') {
					//We have to queue the response for the target
					getAjaxResponseTargetQueues().push(__target_id, response);				
				} else {
					var title_element = document.getElementById(__target_id + "_title");
					if(title_element) {
						title_element.innerHTML = title;
					}
					var content_element = document.getElementById(__target_id + "_content");
					if(content_element) {
						content_element.innerHTML = response['view'];
						if(content_element.scrollHeight > 400 && __target_id == '__ajax_target') {
							content_element.style.height = '400px';
							content_element.style.overflow = 'auto';
						}
						var timeout = response['sentdata']['timeout'];
						//target_element.style.display='inline';
						showTarget(__target_id, timeout);
					} else {
						target_element.innerHTML = response['view'];
					}
				}
			}
			//If no error occurred we can return true... the target element is
			//optional. if someone won't need it... well thats ok....
			return true;
		} catch (exception) {
			alert(exception.toString());
		}
		return false;
	}
	
	function showTarget(__target_id, timeout) {
		if(timeout > 0) {
			setTimeout("hideTarget('"+__target_id+"')", timeout);		
		}
		show(__target_id);
	}

	function hideTarget(__target_id) {
		hide(__target_id);
		checkAndHandleResponseQueue(__target_id);
	}

	function checkAndHandleResponseQueue(__target_id) {
		try {
			var response = getAjaxResponseTargetQueues().pop(__target_id);
			handleResponse(response);
		} catch (exception) {
			alert(exception.toString());
		}
	}

	function moduleRequestPerAjax(module, params, __target_id, title) {
		var ajaxAction = "http://" + window.location.host + "/index.php";
	
		params['useamps'] = false;
		
		var ajaxArgs = new Object();
		ajaxArgs['main'] = module;
		ajaxArgs['view'] = 'ajax_result';
		ajaxArgs['fetchview'] = 'ajax_url';
		ajaxArgs['urlparams'] = params;
		ajaxArgs['__target_id'] = __target_id;
		ajaxArgs['title'] = title;
		ajax_submit(ajaxAction, on_module_per_ajax_response, ajaxArgs);
	}
	
	function on_module_per_ajax_response(responseText, responseXML) {
		try {
			eval("var response="+responseText+";");
	
			var __target_id = response['sentdata']['__target_id'];
			var url = response['view'];
		    var title = response['sentdata']['title'];
	
			requestPerAjax(url, __target_id, title);
		} catch (exception) {
			alert(exception.toString());
		}
	}
	
	function show(id,timeout_delay) {
		var default_delay=1500;
		var element = document.getElementById(id);
		if(element) {
			element.style.display = "block";
			if (typeof(timeout_delay) != 'undefined') {
				if (timeout_delay == true) {
					timeout_delay = default_delay;
				} else if (timeout_delay == false) {
					timeout_delay = 0
				} else if (timeout_delay <= 0) {
					timeout_delay = 0
				}
				
				if (timeout_delay > 0) {
					setTimeout("hide('"+id+"')",timeout_delay);
				}			
			}
		}
	}
	
	function hide(id) {
		var element = document.getElementById(id);
		if(element) {
			element.style.display = "none";
		}
	}
}


/**
 * SWFObject v1.5: Flash Player detection and embed - http://blog.deconcept.com/swfobject/
 *
 * SWFObject is (c) 2007 Geoff Stearns and is released under the MIT License:
 * http://www.opensource.org/licenses/mit-license.php
 *
 */
if(typeof deconcept=="undefined"){var deconcept=new Object();}if(typeof deconcept.util=="undefined"){deconcept.util=new Object();}if(typeof deconcept.SWFObjectUtil=="undefined"){deconcept.SWFObjectUtil=new Object();}deconcept.SWFObject=function(_1,id,w,h,_5,c,_7,_8,_9,_a){if(!document.getElementById){return;}this.DETECT_KEY=_a?_a:"detectflash";this.skipDetect=deconcept.util.getRequestParameter(this.DETECT_KEY);this.params=new Object();this.variables=new Object();this.attributes=new Array();if(_1){this.setAttribute("swf",_1);}if(id){this.setAttribute("id",id);}if(w){this.setAttribute("width",w);}if(h){this.setAttribute("height",h);}if(_5){this.setAttribute("version",new deconcept.PlayerVersion(_5.toString().split(".")));}this.installedVer=deconcept.SWFObjectUtil.getPlayerVersion();if(!window.opera&&document.all&&this.installedVer.major>7){deconcept.SWFObject.doPrepUnload=true;}if(c){this.addParam("bgcolor",c);}var q=_7?_7:"high";this.addParam("quality",q);this.setAttribute("useExpressInstall",false);this.setAttribute("doExpressInstall",false);var _c=(_8)?_8:window.location;this.setAttribute("xiRedirectUrl",_c);this.setAttribute("redirectUrl","");if(_9){this.setAttribute("redirectUrl",_9);}};deconcept.SWFObject.prototype={useExpressInstall:function(_d){this.xiSWFPath=!_d?"expressinstall.swf":_d;this.setAttribute("useExpressInstall",true);},setAttribute:function(_e,_f){this.attributes[_e]=_f;},getAttribute:function(_10){return this.attributes[_10];},addParam:function(_11,_12){this.params[_11]=_12;},getParams:function(){return this.params;},addVariable:function(_13,_14){this.variables[_13]=_14;},getVariable:function(_15){return this.variables[_15];},getVariables:function(){return this.variables;},getVariablePairs:function(){var _16=new Array();var key;var _18=this.getVariables();for(key in _18){_16[_16.length]=key+"="+_18[key];}return _16;},getSWFHTML:function(){var _19="";if(navigator.plugins&&navigator.mimeTypes&&navigator.mimeTypes.length){if(this.getAttribute("doExpressInstall")){this.addVariable("MMplayerType","PlugIn");this.setAttribute("swf",this.xiSWFPath);}_19="<embed type=\"application/x-shockwave-flash\" src=\""+this.getAttribute("swf")+"\" width=\""+this.getAttribute("width")+"\" height=\""+this.getAttribute("height")+"\" style=\""+this.getAttribute("style")+"\"";_19+=" id=\""+this.getAttribute("id")+"\" name=\""+this.getAttribute("id")+"\" ";var _1a=this.getParams();for(var key in _1a){_19+=[key]+"=\""+_1a[key]+"\" ";}var _1c=this.getVariablePairs().join("&");if(_1c.length>0){_19+="flashvars=\""+_1c+"\"";}_19+="/>";}else{if(this.getAttribute("doExpressInstall")){this.addVariable("MMplayerType","ActiveX");this.setAttribute("swf",this.xiSWFPath);}_19="<object id=\""+this.getAttribute("id")+"\" classid=\"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\" width=\""+this.getAttribute("width")+"\" height=\""+this.getAttribute("height")+"\" style=\""+this.getAttribute("style")+"\">";_19+="<param name=\"movie\" value=\""+this.getAttribute("swf")+"\" />";var _1d=this.getParams();for(var key in _1d){_19+="<param name=\""+key+"\" value=\""+_1d[key]+"\" />";}var _1f=this.getVariablePairs().join("&");if(_1f.length>0){_19+="<param name=\"flashvars\" value=\""+_1f+"\" />";}_19+="</object>";}return _19;},write:function(_20){if(this.getAttribute("useExpressInstall")){var _21=new deconcept.PlayerVersion([6,0,65]);if(this.installedVer.versionIsValid(_21)&&!this.installedVer.versionIsValid(this.getAttribute("version"))){this.setAttribute("doExpressInstall",true);this.addVariable("MMredirectURL",escape(this.getAttribute("xiRedirectUrl")));document.title=document.title.slice(0,47)+" - Flash Player Installation";this.addVariable("MMdoctitle",document.title);}}if(this.skipDetect||this.getAttribute("doExpressInstall")||this.installedVer.versionIsValid(this.getAttribute("version"))){var n=(typeof _20=="string")?document.getElementById(_20):_20;n.innerHTML=this.getSWFHTML();return true;}else{if(this.getAttribute("redirectUrl")!=""){document.location.replace(this.getAttribute("redirectUrl"));}}return false;}};deconcept.SWFObjectUtil.getPlayerVersion=function(){var _23=new deconcept.PlayerVersion([0,0,0]);if(navigator.plugins&&navigator.mimeTypes.length){var x=navigator.plugins["Shockwave Flash"];if(x&&x.description){_23=new deconcept.PlayerVersion(x.description.replace(/([a-zA-Z]|\s)+/,"").replace(/(\s+r|\s+b[0-9]+)/,".").split("."));}}else{if(navigator.userAgent&&navigator.userAgent.indexOf("Windows CE")>=0){var axo=1;var _26=3;while(axo){try{_26++;axo=new ActiveXObject("ShockwaveFlash.ShockwaveFlash."+_26);_23=new deconcept.PlayerVersion([_26,0,0]);}catch(e){axo=null;}}}else{try{var axo=new ActiveXObject("ShockwaveFlash.ShockwaveFlash.7");}catch(e){try{var axo=new ActiveXObject("ShockwaveFlash.ShockwaveFlash.6");_23=new deconcept.PlayerVersion([6,0,21]);axo.AllowScriptAccess="always";}catch(e){if(_23.major==6){return _23;}}try{axo=new ActiveXObject("ShockwaveFlash.ShockwaveFlash");}catch(e){}}if(axo!=null){_23=new deconcept.PlayerVersion(axo.GetVariable("$version").split(" ")[1].split(","));}}}return _23;};deconcept.PlayerVersion=function(_29){this.major=_29[0]!=null?parseInt(_29[0]):0;this.minor=_29[1]!=null?parseInt(_29[1]):0;this.rev=_29[2]!=null?parseInt(_29[2]):0;};deconcept.PlayerVersion.prototype.versionIsValid=function(fv){if(this.major<fv.major){return false;}if(this.major>fv.major){return true;}if(this.minor<fv.minor){return false;}if(this.minor>fv.minor){return true;}if(this.rev<fv.rev){return false;}return true;};deconcept.util={getRequestParameter:function(_2b){var q=document.location.search||document.location.hash;if(_2b==null){return q;}if(q){var _2d=q.substring(1).split("&");for(var i=0;i<_2d.length;i++){if(_2d[i].substring(0,_2d[i].indexOf("="))==_2b){return _2d[i].substring((_2d[i].indexOf("=")+1));}}}return "";}};deconcept.SWFObjectUtil.cleanupSWFs=function(){var _2f=document.getElementsByTagName("OBJECT");for(var i=_2f.length-1;i>=0;i--){_2f[i].style.display="none";for(var x in _2f[i]){if(typeof _2f[i][x]=="function"){_2f[i][x]=function(){};}}}};if(deconcept.SWFObject.doPrepUnload){if(!deconcept.unloadSet){deconcept.SWFObjectUtil.prepUnload=function(){__flash_unloadHandler=function(){};__flash_savedUnloadHandler=function(){};window.attachEvent("onunload",deconcept.SWFObjectUtil.cleanupSWFs);};window.attachEvent("onbeforeunload",deconcept.SWFObjectUtil.prepUnload);deconcept.unloadSet=true;}}if(!document.getElementById&&document.all){document.getElementById=function(id){return document.all[id];};}var getQueryParamValue=deconcept.util.getRequestParameter;var FlashObject=deconcept.SWFObject;var SWFObject=deconcept.SWFObject;

var myDouble = false;
var windowInterval;

function scroller (url) {
	var speed     = 1;  // pixel
	var timeout   = 5;  // seconds; time left before requesting new content; 
	var loadCount = 10; // loading content count
	var initDelay = 2000;
	var debug = false;

	var wrapperEl = document.getElementById('scrollerWrapper');
		wrapperEl.offsetY = 0;
		wrapperEl.height = parseInt(wrapperEl.offsetHeight);
	var contentEl = document.getElementById('scrollerContent');
		contentEl.height = parseInt(contentEl.offsetHeight);
		contentEl.style.top = 0; //wrapperEl.height;
	var interval = 50;
	var i = 0;
	var j = 0;
	var	first = 1;
	var loop = false;
	var visibleHeight;
	var timeLeft;
	var content = new Array();
	var timer = 0;
	var awaitingResponse = false;
	
	this.go = function () {
		contentEl.style.top = parseInt(contentEl.style.top)-speed + 'px';

		if(++timer > 1000/interval || i==0) { 
			visibleHeight = contentEl.height + parseInt(contentEl.style.top);
			timeLeft = Math.round( (visibleHeight-wrapperEl.height) / (speed * 1000/interval));
	
			if(timeLeft+timeout < 0) { // stop scroller in case of no content
				window.clearInterval(windowInterval);
				verbose('scroller stopped');
			}
			if((loadCount <= i && !loop) || j >= loadCount) { // if maximum load count is reached, start looping
				loop = true;
				j = 0;
				verbose ('loop activated');
			}
			if (loop && (parseInt(contentEl.style.top)*(-1) >= contentEl.height)) { // returns content element to start position when end is reached
				contentEl.style.top=-1;
			}
			if ((timeLeft <= timeout || visibleHeight < wrapperEl.height)) { // if its time, request more content	
				addContent();
			}				
			verbose('time '+(timeLeft-timeout)+' +'+timeout+'s'+((awaitingResponse)?' waiting':''));
			timer = 0;
		}

	}	
	
	var addContent = function () {
		// removing old content for performance reasons
		var previousEl = document.getElementById('scrollerContent'+first);
		if(previousEl && parseInt(contentEl.style.top)*(-1)>previousEl.offsetHeight) {
			contentEl.style.top = parseInt(contentEl.style.top)+previousEl.offsetHeight + 10 + 'px';
			contentEl.removeChild(previousEl);
			verbose('removing data ('+first+')');
			first++;
		}
	
		// if looping, append content that has already been loaded
		if (loop) {
			i++;
			j++;		
			var newContent = content[j];
			newContent = newContent.replace(/index_i/g,i);
			newContent = newContent.replace(/index_j/g,j);
			contentEl.innerHTML += newContent;
			contentEl.height = parseInt(contentEl.offsetHeight);		
			verbose('appending data ('+j+')');				
		} else { // request new content
			ajaxRequestContent();
		}
	}	
	
	this.faster = function() { 
		if (speed<5) speed++;
		verbose('speed: '+speed+'px');
	}
	this.slower = function () {
		if (speed > 0) speed--;
		verbose('speed: '+speed+'px');		
	}
	this.stop = function () {
		speed = 0;
		verbose('speed: '+speed+'px');		
	}	

	function verbose (text,clear) { // show debug info
		if(!debug) return;
		var el = document.getElementById('scrollerVerbose');
		el.style.display='block';
		if(el.innerHTML.length > 1000) el.innerHTML = el.innerHTML.substr(0,200);
		if (clear) el.innerHTML = text;
		else el.innerHTML = text+"\n" + el.innerHTML;
	}
	
	function ajaxRequestContent() {
		if (awaitingResponse) return;
		verbose('requesting content');
		url += '&limit=10&pageindex=' + i + '&count='+ (loadCount*10);
		var urlParser = new URLParser();
		urlParser.parse(url);
	
		var ajaxAction = urlParser.baseurl;
		var ajaxArgs = urlParser.getQueryParams();
		
		var view = 'main';
		if(ajaxArgs['view']) {
			view = ajaxArgs['view'];
		} else if(ajaxArgs['page']) {
			view = ajaxArgs['page'];
			delete(ajaxArgs['page']);
		}
		ajaxArgs['view'] = 'ajax_result';
		ajaxArgs['fetchview'] = view;
		if(timeout) {
			ajaxArgs['timeout'] = timeout;
		}
		ajax_submit(ajaxAction, ajaxHandleResponse, ajaxArgs);
		awaitingResponse = true;
	}
	
	function ajaxHandleResponse(responseText, responseXML) {
		try {
			eval("var response="+responseText+";");
			if(typeof(response) != 'object') return;
		} catch (exception) {
			alert(exception.toString());
			return;
		}
		i++;		
		j++;			
		newContent = response['view'];
		// save content to array for loop mode
		content[i] = newContent;			
		newContent = newContent.replace(/index_i/g,i);
		newContent = newContent.replace(/index_j/g,j);
		// append new content
		contentEl.innerHTML += newContent;
		contentEl.height = parseInt(contentEl.offsetHeight);	
		awaitingResponse=false;	
		verbose('recieving');				
		verbose('appending data ('+j+')');				
		if (!windowInterval) { // if scroller is stopped, start it
			windowInterval=window.setInterval("double.go();",interval);
			verbose('starting scroller');
		}
	}
	
	myDouble = this;
	window.setTimeout("double.go();",initDelay);
}

// Browser Detect  v2.1.6
// documentation: http://www.dithered.com/javascript/browser_detect/index.html
// license: http://creativecommons.org/licenses/by/1.0/
// code by Chris Nott (chris[at]dithered[dot]com)


function BrowserDetect() {
   var ua = navigator.userAgent.toLowerCase(); 

   // browser engine name
   this.isGecko       = (ua.indexOf('gecko') != -1 && ua.indexOf('safari') == -1);
   this.isAppleWebKit = (ua.indexOf('applewebkit') != -1);

   // browser name
   this.isKonqueror   = (ua.indexOf('konqueror') != -1); 
   this.isSafari      = (ua.indexOf('safari') != - 1);
   this.isOmniweb     = (ua.indexOf('omniweb') != - 1);
   this.isOpera       = (ua.indexOf('opera') != -1); 
   this.isIcab        = (ua.indexOf('icab') != -1); 
   this.isAol         = (ua.indexOf('aol') != -1); 
   this.isIE          = (ua.indexOf('msie') != -1 && !this.isOpera && (ua.indexOf('webtv') == -1) ); 
   this.isMozilla     = (this.isGecko && ua.indexOf('gecko/') + 14 == ua.length);
   this.isFirebird    = (ua.indexOf('firebird/') != -1);
   this.isFirefox    = (ua.indexOf('firefox/') != -1);
   this.isNS          = ( (this.isGecko) ? (ua.indexOf('netscape') != -1) : ( (ua.indexOf('mozilla') != -1) && !this.isOpera && !this.isSafari && (ua.indexOf('spoofer') == -1) && (ua.indexOf('compatible') == -1) && (ua.indexOf('webtv') == -1) && (ua.indexOf('hotjava') == -1) ) );
   
   // spoofing and compatible browsers
   this.isIECompatible = ( (ua.indexOf('msie') != -1) && !this.isIE);
   this.isNSCompatible = ( (ua.indexOf('mozilla') != -1) && !this.isNS && !this.isMozilla);
   
   // rendering engine versions
   this.geckoVersion = ( (this.isGecko) ? ua.substring( (ua.lastIndexOf('gecko/') + 6), (ua.lastIndexOf('gecko/') + 14) ) : -1 );
   this.equivalentMozilla = ( (this.isGecko) ? parseFloat( ua.substring( ua.indexOf('rv:') + 3 ) ) : -1 );
   this.appleWebKitVersion = ( (this.isAppleWebKit) ? parseFloat( ua.substring( ua.indexOf('applewebkit/') + 12) ) : -1 );
   
   // browser version
   this.versionMinor = parseFloat(navigator.appVersion); 
   
   // correct version number
   if (this.isGecko && !this.isMozilla) {
      this.versionMinor = parseFloat( ua.substring( ua.indexOf('/', ua.indexOf('gecko/') + 6) + 1 ) );
   }
   else if (this.isMozilla) {
      this.versionMinor = parseFloat( ua.substring( ua.indexOf('rv:') + 3 ) );
   }
   else if (this.isIE && this.versionMinor >= 4) {
      this.versionMinor = parseFloat( ua.substring( ua.indexOf('msie ') + 5 ) );
   }
   else if (this.isKonqueror) {
      this.versionMinor = parseFloat( ua.substring( ua.indexOf('konqueror/') + 10 ) );
   }
   else if (this.isSafari) {
      this.versionMinor = parseFloat( ua.substring( ua.lastIndexOf('safari/') + 7 ) );
   }
   else if (this.isOmniweb) {
      this.versionMinor = parseFloat( ua.substring( ua.lastIndexOf('omniweb/') + 8 ) );
   }
   else if (this.isOpera) {
      this.versionMinor = parseFloat( ua.substring( ua.indexOf('opera') + 6 ) );
   }
   else if (this.isIcab) {
      this.versionMinor = parseFloat( ua.substring( ua.indexOf('icab') + 5 ) );
   }
   
   this.versionMajor = parseInt(this.versionMinor); 
   
   // dom support
   this.isDOM1 = (document.getElementById);
   this.isDOM2Event = (document.addEventListener && document.removeEventListener);
   
   // css compatibility mode
   this.mode = document.compatMode ? document.compatMode : 'BackCompat';

   // platform
   this.isWin    = (ua.indexOf('win') != -1);
   this.isWin32  = (this.isWin && ( ua.indexOf('95') != -1 || ua.indexOf('98') != -1 || ua.indexOf('nt') != -1 || ua.indexOf('win32') != -1 || ua.indexOf('32bit') != -1 || ua.indexOf('xp') != -1) );
   this.isMac    = (ua.indexOf('mac') != -1);
   this.isUnix   = (ua.indexOf('unix') != -1 || ua.indexOf('sunos') != -1 || ua.indexOf('bsd') != -1 || ua.indexOf('x11') != -1)
   this.isLinux  = (ua.indexOf('linux') != -1);
   
   // specific browser shortcuts
   this.isNS4x = (this.isNS && this.versionMajor == 4);
   this.isNS40x = (this.isNS4x && this.versionMinor < 4.5);
   this.isNS47x = (this.isNS4x && this.versionMinor >= 4.7);
   this.isNS4up = (this.isNS && this.versionMinor >= 4);
   this.isNS6x = (this.isNS && this.versionMajor == 6);
   this.isNS6up = (this.isNS && this.versionMajor >= 6);
   this.isNS7x = (this.isNS && this.versionMajor == 7);
   this.isNS7up = (this.isNS && this.versionMajor >= 7);
   
   this.isIE4x = (this.isIE && this.versionMajor == 4);
   this.isIE4up = (this.isIE && this.versionMajor >= 4);
   this.isIE5x = (this.isIE && this.versionMajor == 5);
   this.isIE55 = (this.isIE && this.versionMinor == 5.5);
   this.isIE5up = (this.isIE && this.versionMajor >= 5);
   this.isIE6x = (this.isIE && this.versionMajor == 6);
   this.isIE6up = (this.isIE && this.versionMajor >= 6);
   
   this.isIE4xMac = (this.isIE4x && this.isMac);
}
var browser = new BrowserDetect();

function getFlirtyTopFrame() {
	var flirtyFrameNames = new Array('contentIFrame', 'actionIFrame', 'messengerIFrame');
	do {
		var checkname = flirtyFrameNames.shift();
		if (window.name == checkname) {
			return parent;
		}
	} while(checkname);
	
	return window;
}

function getFlirtyTopFrameName() {
	var topFrameName =  getFlirtyTopFrame().name;
	if(!topFrameName) {
		topFrameName = "_top"
	}
	return topFrameName;
}

function setFlirtyTopFrameTarget(elID) {
	var el = document.getElementById(elID);
	if(el) {
		el.target = getFlirtyTopFrameName();
	}
}

function frame_check() {
	topFrame = getFlirtyTopFrame();
	
	if(topFrame == self) {		
        var loc = new String(self.location.href);
		var nloc = loc;
		nloc = nloc.replace(/&border=0/, '&border=1');
		nloc = nloc.replace(/\?border=0/, '?border=1');
		if(nloc==loc) {
			if(nloc.search(/\?/) != -1) {
				nloc += "&border=1";
			} else {
				nloc += "?border=1";				
			}			
		} 
		nloc = nloc.replace(/action-([a-zA-Z0-9]+)\=([^&]*)/, '');
		nloc = nloc.replace(/#([^&?]+)(.*)/, "$2#$1");
			
		topFrame.location.replace(nloc);
	}
}

function frame_escape() {
    topFrame = getFlirtyTopFrame();
    
	if(topFrame != self) {
		var loc = new String(self.location.href);
		var nloc = loc;
		nloc = nloc.replace(/action-([a-zA-Z0-9]+)\=([^&]*)/, '');
		nloc = nloc.replace(/#([^&?]+)(.*)/, "$2#$1");
		topFrame.location.replace(nloc);
	}
}

function frame_escape_redirect() {
	if(window.name != '') {
		topFrame = getFlirtyTopFrame();
		if(topFrame != self) {
			var loc = new String(self.location.href);
			topFrame.location.replace('/index.php?main=homepage&page=main');
		}
	}
}

function resize_iframe() {
	var iframe = getFlirtyTopFrame().document.getElementById('contentIFrame');

	if(iframe) {
		//iframe.contentWindow.document.body.style.margin = '0px';
		//iframe.contentWindow.document.body.style.padding = '0px';
		
		var the_height = iframe.contentWindow.document.body.scrollHeight;
		iframe.height = the_height;
	  	
	  	var the_width = iframe.contentWindow.document.body.scrollWidth;
	  	iframe.width = the_width;
	}
}

// load from template via ajax
function loadTabPerAjax (url, ajaxTarget, tabListName, activeListElement) {
	// display animation awaiting the ajax response
	document.getElementById(ajaxTarget+'_content').innerHTML = '<div class="ajaxLoader"></div>'
	// change className of activeListElement to 'active'
	toggleTabs(tabListName, activeListElement);
	// request per Ajax
	requestPerAjax(url,  ajaxTarget, '', '');
}

// load from hidden div
function loadTabFromElement(elementId, ajaxTarget, tabListName, activeListElement ) {
	// change className of activeListElement to 'active'
	toggleTabs(tabListName, activeListElement);
	// insert content in target wrapper
	document.getElementById(ajaxTarget+'_content').innerHTML = document.getElementById(elementId).innerHTML;	
}

function toggleTabs(tabListName, activeListElement) {
	var tabs = document.getElementById(tabListName).childNodes;
	for (var i=0; i < tabs.length; i++) {
		if(tabs[i].tagName == 'LI')	{
			tabs[i].className = '';
		}
	}
	activeListElement.parentNode.className='active';
}


if(typeof(window.URLPARSER_DEFINED) == 'undefined') {
	window.URLPARSER_DEFINED = true;
	
	URLParser = function () {}
	
	URLParser.parse = function(url) {
		this.url = url;
		
		var result = this.url.match(this.regexp);
		
		this.protocol = result[1];
		this.host = result[2];
		this.port = result[4];
		this.path = result[5];
		this.query = result[6];
		this.baseurl = this.protocol + "://" + this.host
		if(this.port) {
			this.baseurl = this.baseurl + ":" + this.port;
		}
		if(this.path) {
			this.baseurl = this.baseurl + "/" + this.path;
		}
		return this;
	}
	
	URLParser.getQueryParams = function() {
		if(typeof(this.query) == 'undefined' || this.query == '') {
			return false;
		}
		
		if(typeof(this.queryParams) == 'Object') {
			return this.queryParams;
		}
		
		var paramPairs = this.query.split("&");
		if(paramPairs.length > 0) {
			this.queryParams = new Object();
			for(var i = 0;i < paramPairs.length;i++) {
				var paramPair = paramPairs[i].split("=");
				this.queryParams[paramPair[0]] = paramPair[1];
			}
		}
		return this.queryParams;
	}
	
	URLParser.prototype.parse = URLParser.parse;
	URLParser.prototype.getQueryParams = URLParser.getQueryParams;
	URLParser.prototype.regexp = /(https?):\/\/([a-zA-Z0-9_\-\.]+)(:([0-9]+))?\/?([a-zA-Z0-9_\.]+)?\??(.*)?/;
}


/*
*	TabsController
*/

function tabsController() {
	this.controller = false;
	this.contentDivs = new Array;
	
	this.setController = TC_setController;
	this.setContentDivs = TC_setContentDivs;
	this.setActiveTabIndex = TC_setActiveTabIndex;
	this.initialize = TC_initialize;
	this.showDiv = TC_showDiv;
	this.setSimpleController = TC_setSimpleController;
	this.disableBlur = TC_disableBlur;
	this.checkAnchors = TC_checkAnchors;
}


function TC_setController(controllElement) {
	this.controller = controllElement;
}

function TC_setContentDivs(divs) {
	this.contentDivs = TC_setContentDivs.arguments;
}

function TC_initialize() {
	/*
	 * Hide all Divs, except the first one
	 */
	 for(var i=0; i < this.contentDivs.length; i++) {
	 	var div = document.getElementById(this.contentDivs[i]);
	 	if(div && i > 0) {
	 		div.style.display = 'none';
	 	}
	 }
	 	 
	 /*
	  * Create the Tab-Controller
	  */
 	 var rootElement = document.getElementById(this.controller);
 	 if(rootElement) {
		var as = rootElement.getElementsByTagName('a');
		for(var j=0; j < as.length; j++) {
			var a = as[j];
			if(a.className != 'notab') {
				a.setAttribute('control', this.contentDivs[j]);
				a.setAttribute('number', j);
				
				var owner = this;
				
				a.onclick = function() {
					owner.showDiv(this.getAttribute('control'));
					owner.setActiveTabIndex(this.getAttribute('number'));
					
					// Anpassen des InnerFrames
					if(typeof(resize_iframe) == 'function') {
						resize_iframe();
					}
					
					return false;
				};
			}	
			this.disableBlur(a);
		}
 	 }
 	 
 	 this.checkAnchors();
}

function TC_showDiv(divId) {
	
	/*
	 * Hide all Divs first
	 */
	 for(var i=0; i < this.contentDivs.length; i++) {
	 	var div = document.getElementById(this.contentDivs[i]);
	 	if(div) {
	 		div.style.display = 'none';
	 	}
	 }
	
	var div = document.getElementById(divId);
	if(div) {
		div.style.display = 'block';
	}
}

function TC_setActiveTabIndex(index) {
	var controller = document.getElementById(this.controller);
	if(controller) {
 		var lis = controller.getElementsByTagName('li');
		for(var i=0; i < lis.length; i++) {
			var li = lis[i];
			if(i == index) {
				li.className = 'active';
			} else {
				li.className = '';
		 	}
		}
	}
}

function TC_setSimpleController(id, contentId, index) {
	var rootElement = document.getElementById(id);
	if(rootElement) {
		var as = rootElement.getElementsByTagName('a');
		for(var j=0; j < as.length; j++) {
			var a = as[j];
			var owner = this;
						
			a.onclick = function() {
				owner.showDiv(contentId);
				owner.setActiveTabIndex(index);
				return false;
			};
			
			this.disableBlur(a);

		}
	}
}

function TC_disableBlur(e) {
	e.onfocus = function() {
		this.blur();
	};
}

function TC_checkAnchors() {
	var anchor = window.location.hash;
	if(anchor) {
		anchor = anchor.substr(1);
		for(var i=0; i < this.contentDivs.length; i++) {
			var actDiv = this.contentDivs[i];
			if(actDiv == anchor) {				
				this.showDiv(actDiv);
				this.setActiveTabIndex(i);
				break;
			}
		}
	}
}





function newInput(inputName) {
	
	var txt= document.createElement('input');

	txt.setAttribute("class","text");
	txt.setAttribute("name",inputName);


	return txt;
}

function newTd() {
	var td = document.createElement('td');
	return td
}

				
function newParam(isDataset) {
	var table = document.getElementById('newParams');
	var tbody = document.createElement('tbody');
			
	var tr = document.createElement('tr');
					
	var index = document.getElementById('helper').value;
	document.getElementById('helper').value = parseInt(index)+1;
	
	var tdName = document.createElement('td');
	var tdValue = document.createElement('td');
					
	var inpName = newInput("newParams["+index+"][name]");
	var inpValue = newInput("newParams["+index+"][value]");
	
	
	
	tdName.appendChild(inpName);
	tdValue.appendChild(inpValue);

	tr.appendChild(tdName);
	tr.appendChild(tdValue);
	
	if(isDataset != '') {
		var tdDefValue = document.createElement('td');
		tdDefValue.setAttribute('colspan',2);
		var inpDefValue = newInput("newParams["+index+"][defValue]");
		
		tdDefValue.appendChild(inpDefValue);
		tr.appendChild(tdDefValue);
	}
	
	tbody.appendChild(tr);				
	table.appendChild(tbody);
					
					
	document.getElementById('newParams').style.display = "";
}
		
function deleteParam(param) {
	var password = window.prompt("Bitte geben Sie ihr eigenes Passwort ein:","");
			
	var form = document.getElementById('deleteParamForm');
	form.password.value = password;
	form.param.value = param;
					
	form.submit();
}

function newInput(inputName) {
	
	var txt= document.createElement('input');

	txt.setAttribute("class","text");
	txt.setAttribute("name",inputName);


	return txt;
}

function newTd() {
	var td = document.createElement('td');
	return td
}

				
function newParam(isDataset) {
	var table = document.getElementById('newParams');
	var tbody = document.createElement('tbody');
			
	var tr = document.createElement('tr');
					
	var index = document.getElementById('helper').value;
	document.getElementById('helper').value = parseInt(index)+1;
	
	var tdName = document.createElement('td');
	var tdValue = document.createElement('td');
					
	var inpName = newInput("newParams["+index+"][name]");
	var inpValue = newInput("newParams["+index+"][value]");
	
	
	
	tdName.appendChild(inpName);
	tdValue.appendChild(inpValue);

	tr.appendChild(tdName);
	tr.appendChild(tdValue);
	
	if(isDataset != '') {
		var tdDefValue = document.createElement('td');
		tdDefValue.setAttribute('colspan',2);
		var inpDefValue = newInput("newParams["+index+"][defValue]");
		
		tdDefValue.appendChild(inpDefValue);
		tr.appendChild(tdDefValue);
	}
	
	tbody.appendChild(tr);				
	table.appendChild(tbody);
					
					
	document.getElementById('newParams').style.display = "";
}
		
function deleteParam(param) {
	var password = window.prompt("Bitte geben Sie ihr eigenes Passwort ein:","");
			
	var form = document.getElementById('deleteParamForm');
	form.password.value = password;
	form.param.value = param;
					
	form.submit();
}

function checkNumberValue(field) {
	if(field.value != '') {
		var newValue = field.value.match(/[0-9]+/);
		if(newValue != null) {
			field.value = newValue;
		} else {
			field.value = '';
		}
	}
}