
function random(){
	return Math.floor(Math.random()*2000000000);
}

function getfriendslist() {
 			var url = site_url+"index.php?load=Ajax&show=getfriendlist&time="+random(); 
			http.open("GET", url, true); 
			http.onreadystatechange = handlefriendlist; 
			http.send(null);         
			return false;
 }

 buddys = new Array ('');
  original = new Array ('');
  
  function handlefriendlist() {  	
  
	if (http.readyState == 2) { 
	}
	if (http.readyState == 4) { 
			
			var response = http.responseText.split("\n");
			for (i = 0; i < response.length; i++){
				if(response[i]){
					
					buddys[i] = response[i]; 
					original[i] = response[i]; 
				}
			}
			
			fillbuddys();
			
			
	}
}  

fillfirst = 0;
function fillbuddys(){
	var outputstring = " ";
	var buddycount = 0;
	for (i = 0; i < buddys.length; i++){
		var buddyinfo = buddys[i].split("|");
		var userid = buddyinfo[0];
		var username = buddyinfo[1];
		var userperms = buddyinfo[2];
		
		if(userperms == 1){
			var coloratr = "style='color:#fede49;'";
		}else{
			var coloratr = "style='color:#a8a8a8;'";
		}
		if(faceload_activated == 1){
		faceload = "onmouseover='face_load("+ userid + ","+myuserid+",\"community_buddy\",\"2\");' onmousemove='show_face();' onmouseout='hide_face();'";
		}else var faceload = "";
		
		if(username){
			outputstring = outputstring + "<tr id='fwdtr["+userid+"]' ><td style='width:20px; '><input type='checkbox' name='fwd["+userid+"]' value='1' id='fwd["+userid+"]' style='border:0px;background-color:transparent;' /></td><td style='width:100px; font-size:10px;'><a href='javascript: ShowProfile("+ userid + ")' "+ faceload +" "+coloratr+" >"+username+"</td></tr>";
			buddycount = buddycount+1;
		}
	}

	if(buddycount < 1){
		document.getElementById('content').innerHTML = "<br /><br /><br /><table cellspacing='0' cellpadding='0' style='width:100%;'><tr ><td align='center' style='width:100%;'>Keine gespeicherten Freunde.</td></tr></table>";
	}else{
		document.getElementById('content').innerHTML = "<table cellspacing='0' cellpadding='0' style='width:120px;'>" + outputstring + "</table>";
	}
	fillfirst = 1;
}



function filterbuddys(){	
 msgfwd = document.getElementById('fwduserfilter').value;
 msgfwd = msgfwd.toLowerCase();
	for(var i = 0; i < original.length; ++i)
	{
		var buddyinfo = buddys[i].split("|");
		var userid = buddyinfo[0];
		var username = buddyinfo[1];
		var userperms = buddyinfo[2];
		if(original[i].toLowerCase().search(msgfwd) > 0 || msgfwd == ""){
		document.getElementById('fwdtr['+userid+']').style.display = "inline";
		}else{
		document.getElementById('fwdtr['+userid+']').style.display = "none";
		}
	}
}

function request_uservalidation() {
	var username = escape(document.getElementById('input_username').value);
		
		if(username.length > 2){
 			var url = site_url+"index.php?load=Ajax&show=checkusername&username="+username+"&time="+random(); 
			http.open("GET", url, true); 
			http.onreadystatechange = handle_uservalidation; 
			http.send(null);         
			return false;
		}else{
			document.getElementById("input_username").style.border = "1px solid #DB1A00";
			alert("Benutzername zu kurz!");
		}
 }

function handle_uservalidation() { 
	if (http.readyState == 4) { 

			var response = http.responseText.split(".");
		if(response[0] == "0"){
			document.getElementById("input_username").style.border = "1px solid #80C422";
		}		

		if(response[0] == "1"){
			document.getElementById("input_username").style.border = "1px solid #DB1A00";
			alert("Der Benutzername ist bereits vergeben!");
		}
	
	}
}    

function msg_loadpictures(send){
	if(send == 5){
		document.getElementById('msgpics5').style.display = 'inline'; 
		document.getElementById('piclink5').innerHTML= '<strong>» Private Bilder (unter18)</strong>'; 
		document.getElementById('msgpics7').style.display = 'none'; 		
		document.getElementById('piclink7').innerHTML= 'Private Bilder (über18)'; 

		
		if(!document.getElementById('msgpics5').innerHTML){
			var url = site_url+"index.php?load=ProfileManager&show=ajax_postfach_bilder&send="+send+"&time="+random(); 
			http.open("GET", url, true);
			http.onreadystatechange = msg_loadpictures_handle5; 
			http.send(null);         
			return false;
		}
	}
	if(send == 7){
		document.getElementById('msgpics7').style.display = 'inline'; 
		document.getElementById('piclink7').innerHTML= '<strong>» Private Bilder (über18)</strong>'; 

		document.getElementById('msgpics5').style.display = 'none'; 
		document.getElementById('piclink5').innerHTML= 'Private Bilder (unter18)'; 

		if(!document.getElementById('msgpics7').innerHTML){
			var url = site_url+"index.php?load=ProfileManager&show=ajax_postfach_bilder&send="+send+"&time="+random(); 
			http.open("GET", url, true);
			http.onreadystatechange = msg_loadpictures_handle7; 
			http.send(null);         
			return false;
		}
	}

}

function msg_loadpictures_handle5(){

	if (http.readyState == 4) { 
	document.getElementById('msgpics5').innerHTML = http.responseText;
	}
} 
function msg_loadpictures_handle7(){

	if (http.readyState == 4) { 
	document.getElementById('msgpics7').innerHTML = http.responseText;

	}
}


function inplace_kommentar_showform(id){
	document.getElementById('inplace_showname'+id).style.display = "none";
	document.getElementById('inplace_formname'+id).style.display = "inline";
	document.getElementById('inplace_input'+id).select();
	document.getElementById('inplace_input'+id).focus();
}

function inplace_kommentar_save(id){
	lastid = id;
	var kommentar_value = escape(document.getElementById('inplace_input'+id).value);
	var url = site_url+"index.php?load=Ajax&show=savekommentar&id="+id+"&value_kommentar="+kommentar_value+"&time="+random(); 
	http.open("GET", url, true);
	http.onreadystatechange = inplace_kommentar_handle; 
	http.send(null);         
	return false;
}


function inplace_kommentar_handle(){
	if (http.readyState == 4) { 
		
	var response = http.responseText.split(".|");;
	document.getElementById('inplace_formname'+lastid).style.display = "none";
	document.getElementById('inplace_showname'+lastid).style.display = "inline";
	document.getElementById('inplace_inputshow'+lastid).value = response[0];

}
}



function inplace_kommentar_showform_blocked(id){
	document.getElementById('inplace_showname'+id).style.display = "none";
	document.getElementById('inplace_formname'+id).style.display = "inline";
	document.getElementById('inplace_input'+id).select();
	document.getElementById('inplace_input'+id).focus();
}
function inplace_kommentar_save_blocked(id){
lastid = id;
var kommentar_value = escape(document.getElementById('inplace_input'+id).value);
var url = site_url+"index.php?load=Ajax&show=savekommentarblocked&id="+id+"&value_kommentar="+kommentar_value+"&time="+random(); 
	http.open("GET", url, true);
	http.onreadystatechange = inplace_kommentar_handle; 
	http.send(null);         
	return false;
}
function inplace_kommentar_handle_blocked(){
	if (http.readyState == 4) { 
		
	var response = http.responseText.split(".|");;
	document.getElementById('inplace_formname'+lastid).style.display = "none";
	document.getElementById('inplace_showname'+lastid).style.display = "inline";
	document.getElementById('inplace_inputshow'+lastid).value = response[0];

}

}

function checkchars(id) {
var value_feld = document.getElementById("inplace_input"+id).value;
var chars = value_feld.length;
var maxlength = 59;
if (chars > maxlength) {
var neuerInhalt = value_feld.substr(0, maxlength);
document.getElementById("inplace_input"+id).value = neuerInhalt;
alert("Du hast die maximale Zeichenlänge erreicht!");
}

}


maintyp = 1;

function face_load(uid,auid,tabelle,typ){
	maintyp = typ;
	var url = site_url+"index.php?load=Ajax&show=face_loadinfo&uid="+uid+"&auid="+auid+"&tabelle="+tabelle+"&time="+random(); 
http.open("GET", url, true);
	http.onreadystatechange = face_handle; 
	http.send(null);         
	return false;
}

function face_handle(){
	if (http.readyState == 4) { 
		var response = http.responseText.split("|.|");
		if(response[3] != "undefined" || response[3] != "" ){
		document.getElementById('faceimg').src = response[0];		
		document.getElementById('faceimg').style.width = response[1];
		document.getElementById('faceimg').style.height = response[2];
		document.getElementById('facestats').innerHTML = response[3]+" &#9642; "+response[4]+" &#9642; "+response[5];
		document.getElementById('facenotiz').innerHTML = response[6];
		if(goout == 1 && response[7] == 1){
		document.getElementById('face').style.visibility = 'visible';
		}
		}

	}
}
	
		var cursor = {x:0, y:0};
		if (navigator.appName=="Netscape")
		{
			document.captureEvents( Event.MOUSEMOVE );
			document.onmousemove = getCoord;
		}

		function getCoord( event )
		{
			cursor.x = event.pageX;
			cursor.y = event.pageY;
		}

		
		function show_face() {
		goout = 1;
		var obj = document.getElementById('face').style;

		if (navigator.appName=="Netscape")
		{
			cursor.x -= 40;
			cursor.y += 30;
		}
		else
		{
		      	var de = document.documentElement;
		      	var b = document.body;
		       cursor.x = event.clientX + (de.scrollLeft || b.scrollLeft) - (de.clientLeft || 0) - 40	;
		       cursor.y = event.clientY + (de.scrollTop || b.scrollTop) - (de.clientTop || 0) + 30;
		}
	
			
			if(maintyp == 1){
			if(cursor.x < 40) obj.left = cursor.x + 'px';
			}
			if(maintyp == 2){
			if(cursor.x < 320) obj.left = cursor.x + 'px';
			}
			obj.top = cursor.y + 'px';
		}

		function hide_face()
		{
			goout = 2;
			var obj = document.getElementById('face').style;
			obj.visibility = 'hidden';
			  
		}





function screener_getfunction(fname){

	var url = site_url+"index.php?load=Ajax&show=screen&fname="+fname+"&time="+random(); 
	http.open("GET", url, true);
	http.onreadystatechange = screenerhandle; 
	http.send(null);         

}

function screener_dofunction(fname,value){

	var url = site_url+"index.php?load=Ajax&show=screen&fname="+fname+"&dofunction=1"+value+"&time="+random(); 
	http.open("GET", url, true);
	http.onreadystatechange = screenerhandle; 
	http.send(null);         

} 


function screenerhandle(){

		if (http.readyState == 4) { 	
		
		var response = http.responseText.split("/~/");
		
		document.getElementById('screener_top_headline').innerHTML  = response[0];
		document.getElementById('screener_html').innerHTML  = response[1];
		
		
		
		
		screen_show();
		screen_show();

		}
}




function getHTTPObject() {

  var xmlhttp;

  /*@cc_on

  @if (@_jscript_version >= 5)

    try {

      xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");

    } catch (e) {

      try {

        xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");

      } catch (E) {

        xmlhttp = false;

      }

    } 

  @else

  xmlhttp = false;

  @end @*/

  if (!xmlhttp && typeof XMLHttpRequest != 'undefined') {

    try {

      xmlhttp = new XMLHttpRequest();

    } catch (e) {

      xmlhttp = false;

    }

  }

  return xmlhttp;

}

var http = getHTTPObject(); // We create the HTTP Object
