function encode_utf8(rohtext) {
	// dient der Normalisierung des Zeilenumbruchs
	rohtext = rohtext.replace(/\r\n/g,"\n");
	var utftext = "";
	for(var n=0; n<rohtext.length; n++)
	{
		// ermitteln des Unicodes des  aktuellen Zeichens
		var c=rohtext.charCodeAt(n);
		// alle Zeichen von 0-127 => 1byte
		if (c<128)
			utftext += String.fromCharCode(c);
		// alle Zeichen von 127 bis 2047 => 2byte
		else if((c>127) && (c<2048)) {
			utftext += String.fromCharCode((c>>6)|192);
			utftext += String.fromCharCode((c&63)|128);}
		// alle Zeichen von 2048 bis 66536 => 3byte
		else {
			utftext += String.fromCharCode((c>>12)|224);
			utftext += String.fromCharCode(((c>>6)&63)|128);
			utftext += String.fromCharCode((c&63)|128);}
		}
	return utftext;
}



function decode_utf8(utftext) {
	var plaintext = ""; var i=0; var c=c1=c2=0;
	// while-Schleife, weil einige Zeichen uebersprungen werden
	while(i<utftext.length)
	{
		c = utftext.charCodeAt(i);
		if (c<128) {
			plaintext += String.fromCharCode(c);
			i++;
		} else if((c>191) && (c<224)) {
			c2 = utftext.charCodeAt(i+1);
			plaintext += String.fromCharCode(((c&31)<<6) | (c2&63));
			i+=2;
		} else {
			c2 = utftext.charCodeAt(i+1); c3 = utftext.charCodeAt(i+2);
			plaintext += String.fromCharCode(((c&15)<<12) | ((c2&63)<<6) | (c3&63));
			i+=3;
		}
	}
	return plaintext;
}



/**
*	Constructor for the class.
*
*	@param {String} dataURL The path to the data that the class
*	will load (OPTIONAL)
*
*	@constructor
*/
function MessageLoader(dataURL)
{
	if(dataURL != undefined)
	{
		this._dataURL = dataURL;
	}


}

//where to load the data from
MessageLoader.prototype._dataURL = "";

//where to load the data from
MessageLoader.prototype._dataParameters = null;
//where to load the data from
MessageLoader.prototype._sessionParameters = null;

//var to hold an instance of the XMLHTTPRequest object
MessageLoader.prototype._request = undefined;

//targetdiv
MessageLoader.prototype._targetDIV = "";

//ID for the html div we will create to display the data
MessageLoader.prototype._containerID = "container";

//name of the css class for the HTML container
MessageLoader.prototype._containerClass = "ml_container";

/**************** Public APIs **********************/


/**
*	Tells the class to load its data and render the results.
*/
MessageLoader.prototype.load = function(url,parameters,targetdiv,targetfunction,session)
{

	//get a new XMLHTTPRequest and store it in an isntance var.
	this._request = this._getXMLHTTPRequest();

	//set the var so we can scope the callback
	var _this = this;

	this._targetDIV = targetdiv;
	this._dataURL = url;
	this._dataParameters = parameters;
	this._sessionParameters = session;

	//callback will be an anonymous function that calls back into our class
	//this allows the call back in which we handle the response (_onData())
	// to have the correct scope.

	if (typeof targetfunction == 'undefined'){
		try{	
	    	parent.document.getElementById("content").innerHTML = "<img src=/images/ajax.gif>";// <a href="+ url+"?"+parameters+" target=_pop>pop "+url+"</a>";
	    	//parent.document.getElementById("content").innerHTML = "wird geladen...<img src=/images/a-countr.gif> <a href="+ url+"?"+parameters+" target=_pop>pop "+url+"?"+parameters+"</a>";
		}
		catch(e)
		{;}
		window.defaultStatus = url;
		this._request.onreadystatechange = function(){_this._onData()};
	}else{
		this._request.onreadystatechange = function(){_this._onXML()};
	}

	//alert("access:"+this._generateDataUrl());
	this._request.open('POST', this._generateDataUrl(), true);
	this._request.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
	//this._request.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded; charset=utf-8');
	//this._request.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded; ; charset="iso-8859-1" ');
	//alert(this._generateDataParameters());
	this._request.send(this._generateDataParameters());

}


/***************Private Data Loading Handlers*******************/

//return the URL from which the data will be loaded
MessageLoader.prototype._generateDataUrl = function()
{
	return this._dataURL;
}

//return the parameters from which the data will be loaded
MessageLoader.prototype._generateDataParameters = function()
{
	if (typeof this._dataParameters == 'undefined'){
		return null;
	}else{
		return this._dataParameters;
	}
}


//callback for when the data is loaded from the server
MessageLoader.prototype._onData = function()
{
	window.defaultStatus = "";
	if(this._request.readyState == 4)
	{
		if(this._request.status == "200")
		{
			//alert(this._request.responseText);
			//parent.scroll(0,0);
			this._targetDIV.innerHTML = this._request.responseText;
		}
		else
		{
			//check if an error callback handler has been defined
			if(this.onError != undefined)
			{
				//pass an object to the callback handler with info
				//about the error
				this.onError({status:this_request.status,
						statusText:this._request.statusText});
			}else{
				this._targetDIV.innerHTML = "status:"+this._request.status;
				this._targetDIV.innerHTML = this._request.responseText;
			}
		}


		//clean up
		delete this._request;
	}
}




/**************** TEST *******************/


MessageLoader.prototype._onXML = function()
{
	window.defaultStatus = "";
	if(this._request.readyState == 4)
	{
		if(this._request.status == "200")
		{
						//IF no result in xml.text then check: Content-Type:text/xml in perlscript
	    			 	var xml = this._request.responseXML; //GET XML
	    			 	parseXML(xml,this._sessionParameters);
		}
		else
		{
			//check if an error callback handler has been defined
			if(this.onError != undefined)
			{
				//pass an object to the callback handler with info
				//about the error
				this.onError({status:this_request.status,
						statusText:this._request.statusText});
			}
		}

		//clean up
		delete this._request;
	}
}


/***************Private Data Util Functions ********************/


//returns an XMLHTTPRequest instance (based on browser)
MessageLoader.prototype._getXMLHTTPRequest = function()
{
	var xmlHttp;
	try
	{
		xmlHttp = new ActiveXObject("Msxml2.XMLHttp");
	}
	catch(e)
	{
		try
		{
			xmlHttp = new ActiveXObject("Microsoft.XMLHttp");
		}
		catch(e2)
		{
		}
	}

	if(xmlHttp == undefined && (typeof XMLHttpRequest != 'undefined'))
	{
		xmlHttp = new XMLHttpRequest();
	}

	return xmlHttp;
}


/*************************************************************************************/



var myArray=new Array()
var xmlHttpReqObj=new Array()

/*** DATATYPES ***/
function messageType(){
	this.IS_LOOKING_AT_YOU = "hat Ihre Visitenkarte angegeklickt.";
	this.INSTANT_MESSAGE = "sendet Ihnen eine Nachricht";
	this.WANTS_TO_CHAT = "möchte mit Ihnen chatten";
}

function durationList(){ //in sec
	this.IS_LOOKING_AT_YOU = "6";
	this.INSTANT_MESSAGE = "15";
	this.WANTS_TO_CHAT = "30";
}


var sysmessage = new messageType();
var sysduration = new durationList();


function userobject(firstname,lastname,image,type,message){
	this.firstname=firstname;
	this.lastname=lastname;
	this.image=image;
	this.type=type;
	this.message=message;
	this.time=sysduration[type];
	this.playsound=0;
	this.endtime="0";
}

function xmlHttpReqObj(id){
	this.id=id;
}

function resetTime(){
	secs=10;
}

function selectWert(sObj) {
    with (sObj) return options[selectedIndex].value;
}

/*** OBJECTS ***/


function addEvent(firstname,lastname,image,type,message){
	myArray[myArray.length] = new userobject(firstname,lastname,image,type,message);
}

function removeElement(){
  if (myArray.length > 0 ){
	myArray.splice(0,1);
  }
}

/*** HELPERS **/

function openCloseDiv(name)
{
	var visible = document.getElementById(name).style.visibility;
	if ((visible == "visible")||(visible == "")){
		document.getElementById(name).style.visibility =  "hidden";
	}else{
		document.getElementById(name).style.visibility = "visible";
	}

}

function showHideDiv(name,nwidth,nheight)
{
	var height = document.getElementById(name).style.height;
	height = height.replace(/px/g,"");
	if (height > 0){
		document.getElementById(name).style.height =  0;
		document.getElementById(name).style.width =  0;
	}else{
		document.getElementById(name).style.height =  nheight;
		document.getElementById(name).style.width =  nwidth;
	}

}


function playSound(soundname) {
 var sound = eval("document." + soundname);

 // make an effort to stop and rewind any playback
 // already in progress so that the sound starts over.
 // Otherwise this call has no effect when the sound
 // is already in progress. You can remove these lines
 // if you don't like this behavior.
 try {
  sound.Stop();
  sound.Rewind();
 } catch (e) {
  // A player that doesn't support
  // Stop and Rewind
 }

 try {
  // For RealPlayer-enabled browsers.
  // Some versions of RealPlayer do not
  // offer a Play() function and will
  // fail to play sound if we try to
  // call Play().
  sound.DoPlay();
 } catch (e) {
  // If DoPlay doesn't work, call Play.
  // This works for all other audio
  // plug-ins.

	 try {
 		sound.Play();
	 } catch (e) {
	 }


 }
}



/******* Events *******/

	function clearEventWindow(){
		
			removeElement();
	}

	function updateEvents(str){
		str = "";
		var now = new Date();

		if (myArray.length > 0 ){

			if (myArray[0].endtime != 0){
				var diff = parseInt(myArray[0].endtime) - parseInt(now.getTime());
				//alert(diff);
				if (diff <= 0) {
					removeElement();
				}
			}

			if (myArray.length > 0 ){
				if (myArray[0].endtime == 0){
					myArray[0].endtime = parseInt(now.getTime()) + parseInt(myArray[0].time)*1000;
				}

				str += "<table><tr><td><img src=\""+myArray[0].image+"\"></td><td>";
				str += ""+myArray[0].firstname+" "+myArray[0].lastname+"";
				str += " "+sysmessage[myArray[0].type]+"";
				if (myArray[0].type == "INSTANT_MESSAGE"){
					str += ": "+myArray[0].message;
				}
				if (myArray[0].type == "WANTS_TO_CHAT"){
					str += ": <a href=\"/tools/chat.pl?chattype=private&"+getSessionData()+"&chatid="+myArray[0].message+"\" onclick=\"perlCall('/tools/chat.pl?chattype=private"+getSessionData()+"&chatid="+myArray[0].message+"&sysim=Gespraechspartner+hat+den+Chat+betreten'); divopen('/tools/chat.pl?chattype=private&"+getSessionData()+"&chatid="+myArray[0].message+"'); clearEventWindow(); return false;\">Hier klicken</a>";
					str += " oder ";
					str += " <a href=\"/tools/chat.pl?chattype=private&"+getSessionData()+"&chatid="+myArray[0].message+"\" onclick=\"perlCall('/tools/chat.pl?chattype=private"+getSessionData()+"&chatid="+myArray[0].message+"&sysim=Gespraechspartner+hat+abgelehnt'); clearEventWindow(); return false;\">ablehnen</a>";
				}
				str += "</td></tr></table><br>";


				/*for (x in myArray)
				{
				    str += myArray[x].type
					str += "<br>";
				}*/

				if (myArray[0].playsound==0){
					playSound('windbackSND');
					myArray[0].playsound=1;
				}
			}
		}
	    	document.getElementById("messenger_1").innerHTML = str;


	}


/*** PARSE XML ***/


function getNodeValue(node){
	var value="";
	if (node.hasChildNodes()){
		value = node.firstChild.nodeValue;
	}
	return value;
}

function parseXML(xml,session){

	try{

	//help: http://www.w3schools.com/dom/dom_node.asp

	var out="";


	//xmlHttp.responseXML.selectSingleNode("/NEWS_ITEM/NEWS_TITLE")

	/***************** parse buddies *******************/

	var anchors = xml.getElementsByTagName("buddies");
	if (anchors.length > 0) {
		var subNode;
		for (var i = 0; i < anchors.length; i++)
        {
			subNode = anchors[i];
			//alert(subNode.text);
			if(subNode.hasChildNodes()){

				var child = subNode.firstChild;
				while (child != null) //iterate every person
				{
					//alert(child.text);
					//out += child.text+"<br>";


					if (child.hasChildNodes()){
					var firstname="";
					var lastname="";
					var userid="";
					var image="";
					var mode="";
					var status="";
					var targeturl ="";

					var subchild = child.firstChild;
					while (subchild != null) //iterate every person
					{
						if (subchild.nodeName == "firstname"){
							firstname = getNodeValue(subchild);
						}
						if (subchild.nodeName == "lastname"){
							lastname = getNodeValue(subchild);
						}
						if (subchild.nodeName == "userid"){
							userid = getNodeValue(subchild);
						}
						if (subchild.nodeName == "image"){
							image = getNodeValue(subchild);
						}
						if (subchild.nodeName == "mode"){
							mode = getNodeValue(subchild);
						}
						if (subchild.nodeName == "status"){
							status = getNodeValue(subchild);
						}
						if (subchild.nodeName == "targeturl"){
							targeturl = getNodeValue(subchild);
						}


						subchild = subchild.nextSibling;
					}

					out += "<table><tr><td><a href=\"\" onclick=\"return bopen('"+targeturl+""+session+"')\"><img src=\""+image+"\" border=\"0\"></a></td><td>";
					if (mode == "online"){
						out += "<img src=\"http://www.ovenga.de/images/im_online.gif\" alt=\"jetzt online\">";
					}else{
						out += "<img src=\"http://www.ovenga.de/images/im_offline.gif\" alt=\"leider offline\">";
					}
					out += "</td><td>";
					out += "<a href=\"\" onclick=\"return bopen('"+targeturl+""+session+"')\">"+firstname+" "+lastname+"</a>";

					if (status != ""){
						out += " ("+status+")<br>";
					}
					out += "</td></tr></table><br>";

					}

					child = child.nextSibling;
				}
            }
        }

        document.getElementById("messenger_2").innerHTML = out;
    }



	/***************** parse online *******************/

	var anchors = xml.getElementsByTagName("online");
	if (anchors.length > 0) {
		var subNode;
		for (var i = 0; i < anchors.length; i++)
        {
			//alert(child.text);
			subNode = anchors[i];
			//alert(subNode.text);
			if(subNode.hasChildNodes()){
			//		alert(child.text);

				var child = subNode.firstChild;
				while (child != null) //iterate every person
				{
					//alert(child.text);
					//out += child.text+"<br>";

					if (child.hasChildNodes()){

					var firstname="";
					var lastname="";
					var userid="";
					var image="";
					var mode="";
					var status="";
					var targeturl="";

					var subchild = child.firstChild;
					while (subchild != null) //iterate every person
					{
						if (subchild.nodeName == "firstname"){
							firstname = getNodeValue(subchild);
						}
						if (subchild.nodeName == "lastname"){
							lastname = getNodeValue(subchild);
						}
						if (subchild.nodeName == "userid"){
							userid = getNodeValue(subchild);
						}
						if (subchild.nodeName == "image"){
							image = getNodeValue(subchild);
						}
						if (subchild.nodeName == "mode"){
							mode = getNodeValue(subchild);
						}
						if (subchild.nodeName == "status"){
							status = getNodeValue(subchild);
						}
						if (subchild.nodeName == "targeturl"){
							targeturl = getNodeValue(subchild);
						}


						subchild = subchild.nextSibling;
					}

					out += "<table><tr><td><a href=\"\" onclick=\"return bopen('"+targeturl+""+session+"')\"><img src=\""+image+"\" border=\"0\"></a></td><td>";
						out += "<img src=\"http://www.ovenga.de/images/im_online.gif\" alt=\"jetzt online\">";
					out += "</td><td>";
					out += "<a href=\"\" onclick=\"return bopen('"+targeturl+""+session+"')\">"+firstname+" "+lastname+"</a>";

					if (status != ""){
						out += " ("+status+")<br>";
					}
					out += "</td></tr></table><br>";

					}

					child = child.nextSibling;
				}
            }
        }

        document.getElementById("messenger_4").innerHTML = out;
    }



    /***************** parse Events *******************/


	var anchors = xml.getElementsByTagName("events");
	if (anchors.length > 0) {
		var subNode;
		for (var i = 0; i < anchors.length; i++)
        {
			subNode = anchors[i];
			//alert(subNode.text);
			if(subNode.hasChildNodes()){

				var child = subNode.firstChild;
				while (child != null) //iterate every person
				{
					//alert(child.text);
					//out += child.text+"<br>";


					if (child.hasChildNodes()){
					var firstname="";
					var lastname="";
					var userid="";
					var image="";
					var eventtype="";
					var message="";

					var subchild = child.firstChild;
					while (subchild != null) //iterate every person
					{
						if (subchild.nodeName == "firstname"){
							firstname = getNodeValue(subchild);
						}
						if (subchild.nodeName == "lastname"){
							lastname = getNodeValue(subchild);
						}
						if (subchild.nodeName == "userid"){
							userid = getNodeValue(subchild);
						}
						if (subchild.nodeName == "image"){
							image = getNodeValue(subchild);
						}
						if (subchild.nodeName == "eventtype"){
							eventtype = getNodeValue(subchild);
						}
						if (subchild.nodeName == "message"){
							message = getNodeValue(subchild);
						}

						subchild = subchild.nextSibling;
					}


					addEvent(firstname,lastname,image,eventtype,message);
					}
					child = child.nextSibling;
				}
            }
        }



		//document.getElementById("messenger_1").innerHTML = out;
    }

	}
	catch(e)
	{
	}


}


/** Syncronous AJAX Call - only use if necessary **/

function xmlhttpPost(strURL,strParameters) {
		
		//window.opener.defaultStatus = "";
    	var xmlHttpReq = false;
	    var self = this;
    	// Mozilla/Safari
	    if (window.XMLHttpRequest) {
    	    self.xmlHttpReq = new XMLHttpRequest();
	    }
    	// IE
	    else if (window.ActiveXObject) {
    	    self.xmlHttpReq = new ActiveXObject("Microsoft.XMLHTTP");
	    }

  	    self.xmlHttpReq.open('POST', strURL, true);
	    self.xmlHttpReq.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
    	self.xmlHttpReq.onreadystatechange = function() {
	      if (self.xmlHttpReq.readyState == 4) {
    	           syncupdatepage(self.xmlHttpReq.responseText);
        	}
	    }
		
		//window.opener.getElementById("content").innerHTML = "wird geladen...<img src=/images/a-countr.gif> <a href="+ url+"?"+parameters+" target=_pop>pop "+url+"?"+parameters+"</a>";
    	self.xmlHttpReq.send(strParameters);
		return false;	
	}

	function syncupdatepage(str){
    	window.opener.getElementById("content").innerHTML = str;
	}


/*****************************************************/



function getSessionData(){
	var str="";
    var form = document.forms['sessionform'];
    var user = "";
	var session ="";
	
	try{
			user = form.user.value;
			session = form.session.value;
			str = "&user="+user+"&session="+session+"&";
	}
	catch(e)
	{
		;
	}
	return str;
}

function perlCall(url){
		var ml = new MessageLoader();
		var words = url.split("?");
//		alert("P:"+words[1]);
		ml.load(words[0],words[1],"messenger_5","my",getSessionData() );
}

function loadBuddies(){
		var ml = new MessageLoader();
		ml.load("/tools/xmlout.pl","area=buddies"+getSessionData(),undefined,"my",getSessionData() );
}
function loadOnline(){
		var ml = new MessageLoader();
		ml.load("/tools/xmlout.pl","area=online"+getSessionData(),undefined,"my",getSessionData() );
//		var target=parent.document.getElementById("content");
//		ml.load("/tools/xmlout.pl","area=online"+getSessionData(),target,undefined );
}
function loadEvents(){
		var ml = new MessageLoader();
		ml.load("/tools/xmlout.pl","area=events"+getSessionData(),undefined,"my",getSessionData() );
}

function loadAll(){
		loadBuddies();
		loadOnline();
		loadEvents();
}

/****** TIMER ****/

var secs;
var timerID = null;
var timerRunning = false;
var delay = 1000;

function onTimer(secs){

	if (secs == 0){
		startURL();
		//showHideDiv('messenger_1',600,400);
		//showHideDiv('messenger_2',600,400);
		showHideDiv('messenger_3',600,400);
		showHideDiv('messenger_5',600,400);
		//openCloseDiv('messenger_1'); 
		//openCloseDiv('messenger_2'); 
		openCloseDiv('messenger_3'); 
		openCloseDiv('messenger_5'); 
	}

	updateEvents(myArray.length);

	if (secs % 60 == 1){
		loadBuddies();
	}

	if (secs % 60 == 3){
		loadOnline();
	}

	if (secs % 20 == 6){
		loadEvents();
	}


	//SessionTimeOut
	if (secs == (60*60*2)) {
		StopTheClock();
		document.getElementById("messenger_1").innerHTML = '';
		document.getElementById("messenger_2").innerHTML = '';
		document.getElementById("messenger_3").innerHTML = '';
		document.getElementById("messenger_4").innerHTML = '';
	}

	document.getElementById("messenger_3").innerHTML = secs;

}

function InitializeTimer()
{
    // Set the length of the timer, in seconds
    secs = 0;
    StopTheClock()
    StartTheTimer()
}

function StopTheClock()
{
    if(timerRunning)
        clearTimeout(timerID)
    timerRunning = false
}

function StartTheTimer()
{
        timerRunning = true;
        loadAll();
        timerID = self.setTimeout("doTimer()", delay);
}

function doTimer()
{
	if (timerRunning == true){
		onTimer(secs);
        secs ++;
        timerID = self.setTimeout("doTimer()", delay);
    }
}

//******* EASY PAGE UPDATE *******/


function startURL() {
	var is_input = document.URL.indexOf('?');
	//var str="";
	if (is_input != -1)
	{ 
		addr_str = document.URL.substring(is_input+1, document.URL.length);
		var words = addr_str.split("&");
		for (count = 0; count < words.length; count++) 
		{
				var keyval = words[count].split("=");
	//			str += keyval[0]+" -> "+keyval[1]+"<br>";

				if (keyval[0] == "loadpage"){
					var words = addr_str.split("loadpage="+keyval[1]);
					aopen(keyval[1],getSessionData()+words[1]);
				}
		}
	}
	else 
	if (document.getElementById("content").innerHTML == ""){
					aopen('/tools/startpage.pl',getSessionData());
	}

   	//document.getElementById("content").innerHTML = str+"HIER"+document.URL;
}


function pagehttpPost2(strURL,parameters) {

	var ml = new MessageLoader();
	var target=document.getElementById("content");
	ml.load(strURL,undefined,target,undefined,getSessionData() );
}

function aopen(url,parameters)
{
	var ml = new MessageLoader();
	var target=parent.document.getElementById("content");
	ml.load(url,parameters,target,undefined,getSessionData() );
}



function voteOne(voteid,targetdivid,value)
{
	var ml = new MessageLoader();
	var target=parent.document.getElementById(targetdivid);
	var url= "/tools/voteOne.pl";
	var parameters="id="+voteid+"&value="+value;
	ml.load(url,parameters,target,undefined,undefined );
}


function voteTwo(voteid,targetdivid,value)
{
	var ml = new MessageLoader();
	var target=parent.document.getElementById(targetdivid);
	var url= "/tools/voteOne.pl";
	var parameters="id="+voteid+"&mode=percent&value="+value;
	ml.load(url,parameters,target,undefined,undefined );
}

function voteThree(voteid,targetdivid,value)
{
	var ml = new MessageLoader();
	var target=parent.document.getElementById(targetdivid);
	var url= "/tools/voteOne.pl";
	var parameters="id="+voteid+"&mode=stars&value="+value;
	ml.load(url,parameters,target,undefined,undefined );
}




function voteOneChangeImage(target,helper,id)
{
	if (helper.value != "1"){
	//alert(id+' |'+helper.value+'|');
		if (id == 'red'){
			target.src='/images/thumbsdownred.png';
		}
		if (id == 'green'){
			target.src='/images/thumbsupgreen.png';
		}
		if (id == 'up'){
			target.src='/images/thumbsupgray.png';
		}
		if (id == 'down'){
			target.src='/images/thumbsdowngray.png';
		}
	}
}

function articleInteractiveChangeImage(target,id)
{

	if (id == 'a1'){
		document.getElementById(target).src='/images/top_hplus.png';
	}
	if (id == 'p1'){
		document.getElementById(target).src='/images/top_hplusgray.png';
	}
	if (id == 'a2'){
		document.getElementById(target).src='/images/top_email.png';
	}
	if (id == 'p2'){
		document.getElementById(target).src='/images/top_emailgray.png';
	}
	if (id == 'a3'){
		document.getElementById(target).src='/images/top_comment.png';
	}
	if (id == 'p3'){
		document.getElementById(target).src='/images/top_commentgray.png';
	}
	if (id == 'a4'){
		document.getElementById(target).src='/images/forbidsign116ng.gif';
	}
	if (id == 'p4'){
		document.getElementById(target).src='/images/forbidsign116dg.gif';
	}

	if (id == 's0'){
		document.getElementById(target).src='/images/starratingonegray.png';
	}
	if (id == 's1'){
		document.getElementById(target).src='/images/starratingone.png';

	}

}


    function showDiv(id) {
        wmtt = document.getElementById(id);
        wmtt.style.display = "block"
    }
    function hideDiv(id) {
        wmtt = document.getElementById(id);
        wmtt.style.display = "none"
    }


function bopen(str){

	var words = str.split("?");
	aopen(words[0],words[1]);

	return false; //dont delete
}


//USES SYNC AJAX_CALL _ ONLY USE FROM POPUP
function popupopen(str,target){

	var words = str.split("?");
	xmlhttpPost(words[0],words[1]);
	return false; //dont delete
}
//USES SYNC AJAX_CALL _ ONLY USE FROM POPUP



function divopen(str){
	//parent.scroll(0,0);

    var html  = "<iframe width=560 frameborder=2 height=1000 src=\""+str+"\" name=\"myframe\" id=\"myframe\"> </iframe>";
    document.getElementById("content").innerHTML = html;
    /*document.getElementById("content").innerHTML = "";

    var feed = document.getElementById('content');

            var a = document.createElement('iframe');
            a.setAttribute('src', str);
            a.setAttribute('width', '560');
            a.setAttribute('frameborder', '0');
            a.setAttribute('height', '800');
            a.setAttribute('name', 'myframe');
            a.setAttribute('id', 'myframe');
            //a.appendChild(document.createTextNode('myFrame'));

    feed.appendChild(a);
*/
	//var words = str.split("?");
	//var ml = new MessageLoader();
	//var target=document.getElementById("content2");
	//ml.load(words[0],words[1],target,undefined );

	return false; //dont delete
}


//******* EASY PAGE UPDATE *******/

function submitForm(formname,url){
    //www.devguru.com/Technologies/ecmascript/quickref/select.html

    var form = document.forms[formname];
    var value="";
    var name="";

    var felements = new Array();

    for(i=0; i<form.elements.length; i++){
        value = "";
        name = form.elements[i].name;

        if (form.elements[i].type == "select-one"){
            try{
                value = selectWert(form.elements[i]);
            } catch (e) {
                ;
            }
        }else
        if (form.elements[i].type == "checkbox"){
            //check if there are more with the same name
            for(j=0; j<form.elements.length; j++){
                if (form.elements[j].name == form.elements[i].name){
                    if (form.elements[j].checked == true){
						if (value != ""){ //ad seperator if ther is more then one value
	                        value += "|";
						} 
                        value += form.elements[j].value;
                    }
                }
            }
        }
        else
        if (form.elements[i].type == "radio"){
            if (form.elements[i].checked == true){
                value = form.elements[i].value;
            }
        }else{
            value = form.elements[i].value;
        }

        if (value != ""){
            felements[""+name+""] = value;
        }

    }

    var str="";
    for(i in felements)
    {
        str += ""+i+"="+felements[i]+"&";
    }

//	alert(str);

    var ml = new MessageLoader();
    var target=document.getElementById("content");
    ml.load(url,str,target,undefined,getSessionData() );

    return false; //DONT DELETE!
}



function popUp2(URL) {
	day = new Date();
	id = day.getTime();
	eval("page" + id + " = window.open(URL, '" + id + "', 'toolbar=0,scrollbars=1,location=0,statusbar=0,menubar=0,resizable=1,width=540,height=570,left = 475,top = 345');");
}

function PopUp(URL) {
	popUp(URL);
}

function popUp(URL) {
	day = new Date();
	id = day.getTime();
	ok = window.open(URL, id , 'toolbar=0,scrollbars=1,location=0,statusbar=0,menubar=0,resizable=1,width=710,height=490,left = 300,top = 150');
	//return false;
	//if (ok) return false;
  //else return true;

}


//functions for separeated pages

//Invitations
    function predefine()
    {
        document.invitemailsform.subject.value = "";
        document.invitemailsform.message.value = "";

		var personal_firstname = document.invitemailsform.personal_firstname.value;
		var personal_lastname = document.invitemailsform.personal_lastname.value;

        if (document.invitemailsform.predefines.selectedIndex == 1)
        {
            document.invitemailsform.subject.value = "Einladung von "+personal_firstname+" "+personal_lastname+"";
            document.invitemailsform.message.value = "Hallo,\n\nkennen Sie schon Ovenga! ? Mit Ovenga! kann man ein Netzwerk mit Kollegen, Bekannten und Freunden gründen und so seine Kontakte jederzeit im Griff haben.\nIch habe dort auch schon viele Geschäftskontakte knüpfen können.\nProbieren Sie es einfach aus und klicken Sie unten auf meine persönliche Einladung.\nAch ja, Ovenga! ist kostenlos.\n\nViele Grüße, \r\n"+personal_firstname+" "+personal_lastname+"";
        }
        else if (document.invitemailsform.predefines.selectedIndex == 2)
        {
            document.invitemailsform.subject.value = "Einladung von "+personal_firstname+" "+personal_lastname+"";
            document.invitemailsform.message.value = "Hallo,\n\nkennst du schon Ovenga! ? Mit Ovenga! kann man ein Netzwerk mit Freunden, Kollegen und Bekannten gründen und so seine Kontakte jederzeit im Griff haben.\nIch habe dort auch schon viele alte Freunde und Kollegen gefunden, aber auch neu Kontakte knüpfen können.\nProbier es einfach aus und klick unten auf meine persönliche Einladung.\nAch ja, Ovenga! ist kostenlos.\n\nViele Grüße, \r\n"+personal_firstname+" "+personal_lastname+"";
        }

        document.invitemailsform.message.focus();
        document.invitemailsform.message.select();
    }

//SMS SEND
function CountMax() {
    var wert,max;
    max = 100;

    var body=document.invitemailsform.TEXT;

    if (body.value.length>max) {
        body.value=body.value.substring(0,max);
        alert('Maximale Länge überschritten!');
    }

    document.invitemailsform.rv_counter.value = max-body.value.length;
}

