var site_theme_name = "dex01";

/*#################################################################################################
##  Site Postion finder Functions
##																								 */
function findPos(obj) {
	var curleft = curtop = 0;
	if (obj.offsetParent) {
		curleft = obj.offsetLeft
		curtop = obj.offsetTop
		while (obj = obj.offsetParent) {
			curleft += obj.offsetLeft
			curtop += obj.offsetTop
		}
	}
	return [curleft,curtop];
}
/*#################################################################################################
##  Site Navigation Functions
##																								 */
var mm_val = null;
function oM(m_item){
	var to_load = $(m_item);
	menu_arr = new Array('mm_picsunder','mm_nightlife','mm_picsundermain', 'mm_video', 'mm_community', 'mm_mydruzise', 'mm_contact');
	for(i=0;i<menu_arr.length;i++){
		if(menu_arr[i] == "mm_nightlife" && m_item == "mm_picsunder"){
		}
		else {
			$(menu_arr[i]).style.display = "none";
		}
	}
	to_load.style.display = "block";
	window.clearTimeout(mm_val);
	mm_val = window.setTimeout("cM()",5000);
}

function cM(){
	window.clearTimeout(mm_val);
	menu_arr = new Array('mm_picsunder','mm_nightlife','mm_picsundermain', 'mm_video', 'mm_community', 'mm_mydruzise','mm_contact');
	for(i=0;i<menu_arr.length;i++){
		$(menu_arr[i]).style.display = "none";
	}
}

function menuOver(value){
	Element.setStyle(value+'td', {backgroundImage:'url(/themes/dex01/menu/'+value+'td_over.gif)'} );
}

function menuOut(value){
	Element.setStyle(value+'td', {backgroundImage:'url(/themes/dex01/menu/'+value+'td_out.gif)'} );
}
//-------------------------------------------------------------------------------------------------


/*#################################################################################################
##  Language and Area Chooser
##																								 */
function setLang(value){
	window.location.href = "/?setlang="+value;
}

function setArea(value){
	value = (value == 0)? 'all' : value;
	window.location.href = "?country="+value;
}
//-------------------------------------------------------------------------------------------------


/*#################################################################################################
##  Get GET Variables
##																								 */
function getQueryVar(variable) {
  var query = window.location.search.substring(1);
  var vars = query.split("&");
  for (var i=0;i<vars.length;i++) {
    var pair = vars[i].split("=");
    if (pair[0] == variable) {
      return pair[1];
    }
  } 
  error = "undefined";
  return error;
}
//-------------------------------------------------------------------------------------------------


/*#################################################################################################
##  Open Smilies Window
##																								 */
function showAllSmilies(forwhat) {
    // Errechnet Koordinaten, um das Popup zentriert zu platzieren
    url = "/elements/chat/smilies.php?chosen_field="+forwhat;
	hoehe = "500";
	breite = "500";
	links = 100;
    oben = (screen.height/2)-(hoehe/2);
	smilies_window = window.open(url,'smilies_popup','height='+hoehe+',width='+breite+',resizable=yes,scrollbars=yes,top ='+oben+',left ='+links);
}
//-------------------------------------------------------------------------------------------------



/*#################################################################################################
##  Shows an Information Box that can be filled with whatever content you like
##																								 */
function showInfoBox(file,breite,hoehe,postvars,offsetLeft,offsetTop){
	links = ((document.documentElement.offsetWidth/2)-(breite/2));
    oben = (document.documentElement.offsetHeight/2)-(hoehe/2);
	if(offsetTop != undefined && offsetTop != ""){
		oben += offsetTop;
	}
	if(offsetLeft != undefined && offsetLeft != ""){
		links += offsetLeft;
	}
	$('infobox').style.left = links+"px";
	$('infobox').style.top = (oben-100)+"px";
	var ajax = new Ajax.Updater(
         'infobox',        // DIV id (XXX: doesnt work?)
         '/elements/infoboxes/'+file,       // URL
         {									// options
         asynchronous: true,
		 method: 'post',
		 postBody: postvars,
		 onComplete: showResponse
		 });

	function showResponse(req){
		$('infobox').innerHTML = req.responseText;
		$('infobox').style.display = "block";
		new Effect.Move ($('infobox'),{ x: links, y: oben, mode: 'absolute'});
		Effect.Appear('infobox');
	}
}
//-------------------------------------------------------------------------------------------------


/*#################################################################################################
##  Shows an User Info Box
##																								 */
function showUsrMenu(user_id,obj,div){
	var div = div || false;
	var sp_offset = 0;
	if(div){ sp_offset = $(div).scrollTop; }
	var coors = findPos(obj);
	var ajax = new Ajax.Updater(
         'usr_info',        // DIV id (XXX: doesnt work?)
         '/common/getuser.php',       // URL
         {                // options
         asynchronous: true,
		 method: 'post',
		 postBody: 'user_id='+user_id,
		 onComplete: showResponse
		 });

	function showResponse(req){
		$('usr_info').innerHTML = req.responseText;
		$('usr_info').style.display = "block";
		if(pm_window == "active"){
			links = (document.documentElement.offsetWidth/2)-(275/2);
    		oben = (document.documentElement.offsetHeight/2)-(180/2);
			$('usr_info').style.left = links+"px";
			$('usr_info').style.top = oben+"px";
		}
		else{
			new Effect.Move ($('usr_info'),{ x: coors[0]+50, y: (coors[1]-sp_offset)-50, mode: 'absolute'});
		}
		Effect.Appear('usr_info');	
	}
}
//-------------------------------------------------------------------------------------------------



/*#################################################################################################
##  Shows/Hide an Information Box
##																								 */
function hideBCard(){
	$('usr_info').style.display= 'none';
}

function showBCard(user_id,friends,ignores){
	if($('usr_info').style.display == 'block'){
		$('usr_info').style.display= 'none';
		window.clearTimeout(bctime);
	}
	var coors = findPos($('ava_pos_'+user_id));
	var color = $('color_'+user_id).value;
	var menu = $('menu').value.split("|");
	var sex = $('sex_'+user_id).value;
	var username = $('usr_'+user_id).value;
	var musicstyles = $('styles_'+user_id).value;
	var age = $('age_'+user_id).value.split("|");
	var zodiac = $('zodiac_'+user_id).value.split("|");
	var lastonline = $('online_'+user_id).value.split("|");
	var avatar = $('ava_'+user_id).src;
	var karma = new Array();
	karma['src'] = $('karma_'+user_id).src.replace(/.gif/, "_middle_"+sex+".gif");
	karma['text'] = $('karma_'+user_id).title;
	var flag = new Array();
	flag['src'] = $('flag_'+user_id).src;
	flag['text'] = $('flag_'+user_id).title;
	
	interval = (BW == "ie")? 1000 : 500;
	
	bcardhtml = '<div style="width: 345px; height: 165px; float: left;" onmouseover="window.clearTimeout(bctime);" onmouseout="bctime = window.setTimeout(\'hideBCard()\','+interval+');"><center><div id="js_box_'+sex+'" style="width: 345px; background-color: clear;"><div style="background-color: '+color+'; height: 100px; width: 80px; overflow: hidden; float: left; background-image: url(/themes/'+site_theme_name+'/profile/'+sex+'_ava_bg.jpg); text-align: left;"><a href="/profile/'+username+'/"><img src="'+avatar+'" alt="'+username+'\'s Avatar" title="'+username+'" border="0"></a></div><div style="background-color: '+color+'; float: left; overflow: hidden; height: 100px; width: 265px; background-image: url(/themes/'+site_theme_name+'/profile/'+sex+'_bcard_bg.jpg);"><div style="position: relative; z-index: 1; height: 18px; width: 265px; filter: alpha(opacity=70); filter: progid:DXImageTransform.Microsoft.Alpha(opacity=70); -moz-opacity: 0.7; opacity:0.7; background-color: #fff;">&nbsp;</div><div style="position: relative; z-index: 2; height: 18px; margin-top: -18px; width: 265px; color: #000; font-weight: bold; text-align: left;">	<div style="width: 200px; float: left; line-height: 18px;">	&nbsp;<span class="'+sex+'" style="font-size: 11px;">['+username+']</span></div><div style="width: 60px; height: 18px; float: left; text-align: right; padding-top: 1px;">';
							
			if($('love_'+user_id)){	
				bcardhtml += '<img src="'+$('love_'+user_id).src.replace(/.gif/,"_"+sex+".gif")+'" border="0" title="'+$('love_'+user_id).title+' ">&nbsp;';
			}
						
			// Musicstyle
			if($('music_'+user_id)){
				bcardhtml += '<img src="/themes/'+site_theme_name+'/icons/music_'+sex+'.gif" border="0" title="'+$('music_'+user_id).title+' ">&nbsp;';
			}
											
			// druzi.se staff				
			if($('staff_'+user_id)){
				bcardhtml += '<img src="/themes/'+site_theme_name+'/icons/dsma_'+sex+'.gif" border="0" title="'+$('staff_'+user_id).title+' ">';
			}
	
	bcardhtml += '</div></div><div style="color: #fff; font-weight: bold; line-height: 15px; text-align: left; height: 64px;"><div style="float: left; width: 105px;">&nbsp;'+age[0]+':<br>&nbsp;'+zodiac[0]+':<br>&nbsp;'+lastonline[0]+':</div><div style="padding-left: 5px; float: left; width: 75px;">'+age[1]+'<br>'+zodiac[1]+'<br>'+lastonline[1]+'</div><div style="float: left; text-align: center; width: 80px; font-size: 12px; font-weight: bold; line-height: 20px;">Karma<br><img src="'+karma['src']+'" border="0" style="margin-bottom: -5px;"> '+karma['text'].replace(/Karma:/,"")+'</div></div><div style="height: 18px; text-align: left; color: #fff; font-weight: bold;">&nbsp;<img src="'+flag['src']+'" border="0" style="margin-bottom: -1px;"> '+flag['text']+'</div></div><div style="width: 345px; height: 40px; clear: left;"><div style="height: 20px; width: 346x; background-color: #eee; text-align: left; padding-top: 1px;"><div style="width: 150px; float: left;">&nbsp;<img src="/themes/'+site_theme_name+'/icons/profile_'+sex+'.gif" style="margin-bottom: -4px;"> <a href="javascript:viewProfile(\''+username+'\');"> '+menu[0]+'</a></div><div style="width: 190px; float: left;">&nbsp; ';
	if(friends == true){
		bcardhtml += '<img src="/themes/'+site_theme_name+'/icons/freundeskreis_out.gif" style="margin-bottom: -4px;"> <a href="javascript:delFriend('+user_id+');">'+menu[4]+'</a>';
	}
	else{
		bcardhtml += '<img src="/themes/'+site_theme_name+'/icons/freundeskreis.gif" style="margin-bottom: -4px;"> <a href="javascript:addFriend('+user_id+');">'+menu[1]+'</a>';
	}
	bcardhtml += '</div></div>	<div style="height: 18px; width: 345px; background-color: #ffffff; text-align: left; padding-top: 1px;"><div style="width: 150px; float: left;">&nbsp;<img src="/themes/'+site_theme_name+'/icons/message.gif" style="margin-bottom: -4px;"> <a href="javascript:openPM(\''+username+'\');">'+menu[2]+'</a></div><div style="width: 190px; float: left;">';
	if(ignores == true){
		bcardhtml += '&nbsp;&nbsp;<img src="/themes/'+site_theme_name+'/icons/join_'+sex+'.gif" style="margin-bottom: -4px;"> <a href="javascript:degnore('+user_id+');">'+menu[5]+'</a><br>';
	}
	else{
		bcardhtml += '&nbsp;&nbsp;<img src="/themes/'+site_theme_name+'/icons/banned_'+sex+'.gif" style="margin-bottom: -4px;"> <a href="javascript:ignore('+user_id+');">'+menu[3]+'</a><br>';
	}
	bcardhtml += '</div></div></div></div></center></div>';
	
	$('usr_info').innerHTML = bcardhtml;
	bctime = window.setTimeout('hideBCard()',interval);
	$('usr_info').style.left = (coors[0]-((BW == "ie")?0:1))+"px";
	$('usr_info').style.top = (coors[1]-((BW == "ie")?0:6))+"px";
	$('usr_info').style.display = "block";
}
//-------------------------------------------------------------------------------------------------



/*#################################################################################################
##  Shows/Hide an Information Box
##																								 */
function hideEventDetails(){
	$('usr_info').style.display= 'none';
}

function showEventDetails(id,flag,location,eventname,date,type){
	html = '<div style="padding: 3px; border: 1px solid #000; background-color: #FFFFDF; font: normal small-caps 900 11px Arial; text-align: left;">'+date+'<br>'+unescape(eventname)+'<br>'+flag+' '+unescape(location)+'</div>';
	$('usr_info').innerHTML = html;
	var coors = findPos($(type+'_'+id));
	$('usr_info').style.left = (coors[0]+((BW == "ie")?80:80))+"px";
	$('usr_info').style.top = (coors[1]+((BW == "ie")?90:90))+"px";
	$('usr_info').style.display = "block";
}
//-------------------------------------------------------------------------------------------------


/*#################################################################################################
##  Shows/Hide Advanced Search Box (Memberlist)
##																								 */
function hideMAS(){
	$('advanced_search').style.display= 'none';
}

function showMAS(){
	var coors = findPos($('advanced_search_link'));
	$('advanced_search').style.left = (coors[0]-((BW == "ie")?300:300))+"px";
	$('advanced_search').style.top = (coors[1]-((BW == "ie")?60:60))+"px";
	$('advanced_search').style.display = "block";
}
//-------------------------------------------------------------------------------------------------


/*#################################################################################################
##  Shows/Hide an Information Box
##																								 */
function hideVideoDetail(){
	$('usr_info').style.display= 'none';
}

function showVideoDetail(id,title,short){
	html = '<div style="padding: 3px; width: 280px; page-break-after: auto; border: 1px solid #000; background-color: #FFFFDF; font: normal small-caps 900 12px Arial; text-align: left;"><b>'+title+'</b><br><span style="font-size: 10px; color: #555;">'+unescape(short)+'</span></div>';
	$('usr_info').innerHTML = html;
	var coors = findPos($('vid_pos_'+id));
	$('usr_info').style.left = (coors[0]+((BW == "ie")?80:80))+"px";
	$('usr_info').style.top = (coors[1]+((BW == "ie")?90:90))+"px";
	$('usr_info').style.display = "block";
}
//-------------------------------------------------------------------------------------------------


/*#################################################################################################
##  Load Private Messages inside the private_chat DIV
##																								 */
function getPrivateMsg(){
	//$('private_chat').innerHTML = "<div style=\"height: 100%; background-color: #eee;\"><table width=\"710\" height=\"100%\"><tr valign=\"middle\" align=\"center\"><td><img src=\"/images/loading.gif\" width=\"18\" height=\"18\"></td></tr></table></div>";
	var ajax = new Ajax.Updater(
         'private_chat',        // DIV id (XXX: doesnt work?)
         '/elements/chat/private_chat.php?my_id='+my_user_id,       // URL
         {                // options
         asynchronous: true,
		 onComplete: showResponse
		 });

	function showResponse(req){
		$('private_chat').innerHTML = req.responseText;
		$('private_chat').scrollTop = 100000;
	}
}
//-------------------------------------------------------------------------------------------------


/*#################################################################################################
##  Send a Private MSG
##																								 */
function sendNewPrivateMsg(msg,receiver_id,receiver_name,receiver_sex){
	if(msg == "" || receiver_name == ""){
	}
	else {
		document.privateform.private_message.value = "";
		var ajax = new Ajax.Updater(									
	       	 'private_chat',        // DIV id (XXX: doesnt work?)
	         '/elements/chat/private_chat.php?my_id='+my_user_id+'&my_username='+my_username+'&my_sex='+my_sex,       // URL
	         {                // options
    	     asynchronous: true,
			 evalScripts: true,
			 method: 'post',
			 postBody: 'message='+msg+'&receiver_id='+receiver_id+'&receiver_name='+receiver_name+'&receiver_sex='+receiver_sex,
			 
			 onComplete: function(req){
				 			$('private_chat').innerHTML = req.responseText;
							$('private_chat').scrollTop = 100000;
						}
			 });
	}
}
//-------------------------------------------------------------------------------------------------


/*#################################################################################################
##  ADMIN Delete a private MSG
##																								 */
function delPrivate(msg_id){
	var ajax = new Ajax.Updater(
         'private_chat',        // DIV id (XXX: doesnt work?)
         '/elements/chat/private_chat.php?my_id='+my_user_id,       // URL
         {                // options
         asynchronous: true,
		 method: 'post',
		 postBody: 'delete=true&msg_id='+msg_id,
		 onComplete: showResponse
		 });

	function showResponse(req){
			$('private_chat').innerHTML = req.responseText;
			$('private_chat').scrollTop = 100000;
	}
}
//-------------------------------------------------------------------------------------------------


/*#################################################################################################
##  User Delete a private MSG
##																								 */
function hidePrivate(msg_id,status){
	var ajax = new Ajax.Updater(
         'private_chat',        // DIV id (XXX: doesnt work?)
         '/elements/chat/private_chat.php?my_id='+my_user_id,       // URL
         {                // options
         asynchronous: true,
		 method: 'post',
		 postBody: 'hide=true&msg_id='+msg_id+'&statuschange='+status,
		 onComplete: showResponse
		 });

	function showResponse(req){
			$('private_chat').innerHTML = req.responseText;
			$('private_chat').scrollTop = 100000;
	}
}
//-------------------------------------------------------------------------------------------------


/*#################################################################################################
##  Show Chat Conversation History with a specified User
##																								 */
function filterMessages(chosen_id) {
    // Errechnet Koordinaten, um das Popup zentriert zu platzieren
    url = "/elements/chat/filter.php?chosen_id="+chosen_id+"&my_id="+my_user_id;
	hoehe = "350";
	breite = "700";
	links = ((screen.width/2)-(breite/2))-120;
    oben = (screen.height/2)-(hoehe/2);
	fenster1 = window.open(url,'filter_popup','height=350,width=700,resizable=yes,scrollbars=yes,top ='+oben+',left ='+links);
}
//-------------------------------------------------------------------------------------------------


/*#################################################################################################
##  Shows Private Message Box and/or writes to a specified User
##																								 */
function openPM(username){
	if(pm_window == false){
		document.privateform.receiver_name.value = username;
	}
	else {
		links = (document.documentElement.offsetWidth/2)-(940/2);
    	oben = (document.documentElement.offsetHeight/2)-(380/2);
		
		if(username != undefined || username != ""){
			url = "http://chat.druzi.se/redirect.php?sid="+my_sid+"&sendto="+username;
		}
		else{
			url = "http://chat.druzi.se/redirect.php?sid="+my_sid;
		}
		hoehe = "380";
		breite = "940";
		links = ((screen.width/2)-(breite/2));
    	oben = (screen.height/2)-(hoehe/2);
		pm_fenster = window.open(url,'pm_popup','height='+hoehe+',width='+breite+',resizable=no,scrollbars=no,top ='+oben+',left ='+links);
		pm_fenster.focus();
	}
}
//-------------------------------------------------------------------------------------------------


/*#################################################################################################
##  Jump to the Profile page of a specified User
##																								 */
function viewProfile(username){
	if(pm_window == "active"){
		//window.location.href = "?winmodus=profile&username="+username;
		opener.location.href = "http://druzi.se/profile/"+username+"/";
		opener.focus();
	}
	else {
		window.location.href = "http://druzi.se/profile/"+username+"/";
	}
}
//-------------------------------------------------------------------------------------------------


/*#################################################################################################
##  Send a Friendrequest to the user specified. 
##																								 */
function addFriend(user_id){
	var ajax = new Ajax.Request(
		'/common/func.friends.php?my_id='+my_user_id,
		{
			method:'post', 
			postBody:'mode=add&user_id='+user_id,
			onSuccess: handlerFunc
		}
	);


	function handlerFunc(req){
			alert(req.responseText);
			location.href = document.URL;
	}
}
//-------------------------------------------------------------------------------------------------


/*#################################################################################################
##  Accept a Friendrequest 
##																								 */
function acceptFriend(user_id){
	var ajax = new Ajax.Request(
		'/common/func.friends.php?my_id='+my_user_id,
		{
			method:'post', 
			postBody:'mode=accept&user_id='+user_id,
			onSuccess: handlerFunc
		}
	);


	function handlerFunc(req){
			location.href = document.URL;
	}
}
//-------------------------------------------------------------------------------------------------


/*#################################################################################################
##  Delete a Friend  
##																								 */
function delFriend(user_id){
	var ajax = new Ajax.Updater(
         'friendslist',        // DIV id (XXX: doesnt work?)
         '/common/func.friends.php?my_id='+my_user_id,       // URL
         {                // options
         method:'post', 
		 postBody:'mode=del&user_id='+user_id,
		 asynchronous: true,
		 onComplete: showResponse
		 });

	function showResponse(req){
		location.href = document.URL;
	}
}

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


/*#################################################################################################
##  Delete a Friend  
##																								 */
function declineFriend(user_id){
	var ajax = new Ajax.Updater(
         'friendslist',        // DIV id (XXX: doesnt work?)
         '/common/func.friends.php?my_id='+my_user_id,       // URL
         {                // options
         method:'post', 
		 postBody:'mode=decline&user_id='+user_id,
		 asynchronous: true,
		 onComplete: showResponse
		 });

	function showResponse(req){
		location.href = document.URL;
	}
}

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


/*#################################################################################################
##  Ignore a user 
##																								 */
function ignore(user_id){
	var ajax = new Ajax.Request(
		'/common/func.ignore.php?my_id='+my_user_id,
		{
			method:'post', 
			postBody:'mode=add&user_id='+user_id,
			onSuccess: handlerFunc
		}
	);


	function handlerFunc(req){
		alert(req.responseText);
		location.href = document.URL;
	}
}
//-------------------------------------------------------------------------------------------------



/*#################################################################################################
##  Ignore a user 
##																								 */
function degnore(user_id){
	var ajax = new Ajax.Updater(
         'friendslist',        // DIV id (XXX: doesnt work?)
         '/common/func.ignore.php?my_id='+my_user_id,       // URL
         {                // options
         method:'post', 
		 postBody:'mode=del&user_id='+user_id,
		 asynchronous: true,
		 onComplete: showResponse
		 });

	function showResponse(req){
		location.href = document.URL;
	}
}
//-------------------------------------------------------------------------------------------------



/*#################################################################################################
##  Load Private Messages inside the private_chat DIV
##																								 */
function getMyUserList(){
	var ajax = new Ajax.Updater(
         'friendslist',        // DIV id (XXX: doesnt work?)
         '/elements/chat/friendslist.php?my_user_id='+my_user_id,       // URL
         {                // options
         asynchronous: true,
		 onComplete: showResponse
		 });

	function showResponse(req){
		$('friendslist').innerHTML = req.responseText;
	}
}



function getMyFriendsList(){
	var ajax = new Ajax.Updater(
         'usr_info',        // DIV id (XXX: doesnt work?)
         '/elements/chat/friendslist.php?my_user_id='+my_user_id,       // URL
         {                // options
         asynchronous: true,
		 onComplete: showResponse
		 });

	function showResponse(req){
		var coors = findPos($('friendlist'));
		$('usr_info').style.left = (coors[0]+((BW == "ie" || BW == "ie6")?-86:-125))+"px";
		$('usr_info').style.top = (coors[1]+((BW == "ie" || BW == "ie6")?0:0))+"px";
		$('usr_info').style.width = (((BW == "ie" || BW == "ie6")?218:212))+"px";
		$('usr_info').innerHTML = '<div class="standalone_private_userlist" style="text-align: right; height: 18px; background-color: #333; overflow: hidden; z-index: 100000;"><a href="#" onclick="javascript:$(\'usr_info\').style.display = \'none\';"><span style="font: normal small-caps 900 10px Arial; color: #fff;">[x]</span></a>&nbsp;</div><div id="friendslist" class="standalone_private_userlist" style="height: 200px; border:1px solid #666;">'+req.responseText+'</div>';
		$('usr_info').style.display = "block";
	}
}
//-------------------------------------------------------------------------------------------------



/*#################################################################################################
##  Update Karma and reshow it
##																								 */
function giveKarma(caster_id,receiver_id,vote){
	if(vote == "-"){
		vote = 0;
	}
	else{
		vote = 100;
	}
	var ajax = new Ajax.Updater(
         'karmafeld',        // DIV id (XXX: doesnt work?)
         '/common/func.karma.php',       // URL
         {                // options
		 method:'post', 
		 postBody:'caster_id='+caster_id+'&receiver_id='+receiver_id+'&vote='+vote,
		 asynchronous: true,
		 onComplete: showResponse
		 });

	function showResponse(req){
		$('karmafeld').innerHTML = req.responseText;
	}
}
//-------------------------------------------------------------------------------------------------



/*#################################################################################################
##  Load Guestbook Messages into guestbook DIV
##																								 */
function getGuestBookMsg(owner_id,section){
	section = section || false; 
	$('guestbook').innerHTML = "<div style=\"height: 100%; background-color: #eee;\"><table width=\"100%\" height=\"100%\"><tr valign=\"middle\" align=\"center\"><td><img src=\"/images/loading.gif\" width=\"18\" height=\"18\"></td></tr></table></div>";
	var ajax = new Ajax.Updater(
         'guestbook',        // DIV id (XXX: doesnt work?)
         '/elements/userprofile/func.guestbook.php?owner_id='+owner_id+'&my_id='+my_user_id+'&section='+section,       // URL
         {                // options
         asynchronous: true,
		 onComplete: showResponse
		 });

	function showResponse(req){
		if(section == false && req.responseText == ""){
			$('guestbookdiv').style.display = "none";
		}
		else{
			$('guestbook').innerHTML = req.responseText;
		}
	}
}
//-------------------------------------------------------------------------------------------------


/*#################################################################################################
##  Send a Guestbook MSG
##																								 */
function sendNewGuestbookMsg(msg,owner_id,section){
	if(msg == "" || owner_id == ""){
	}
	else {
		section = section || false; 
		document.privateform.private_message.value = "";
		var ajax = new Ajax.Updater(									
	       	 'guestbook',        // DIV id (XXX: doesnt work?)
	         '/elements/userprofile/func.guestbook.php?my_id='+my_user_id+'&my_username='+my_username+'&my_sex='+my_sex+'&section='+section,       // URL
	         {                // options
    	     asynchronous: true,
			 evalScripts: true,
			 method: 'post',
			 postBody: 'message='+msg+'&owner_id='+owner_id,
			 
			 onComplete: function(req){
				 			$('guestbook').innerHTML = req.responseText;
						}
			 });
	}
}
//-------------------------------------------------------------------------------------------------


/*#################################################################################################
##  Delete a Guestbook MSG
##																								 */
function delGuestbookMsg(msg_id,owner_id,section){
	section = section || false; 
	var ajax = new Ajax.Updater(
         'guestbook',        // DIV id (XXX: doesnt work?)
         '/elements/userprofile/func.guestbook.php?my_id='+my_user_id+'&section='+section,       // URL
         {                // options
         asynchronous: true,
		 method: 'post',
		 postBody: 'delete=true&msg_id='+msg_id+'&owner_id='+owner_id,
		 onComplete: showResponse
		 });

	function showResponse(req){
			$('guestbook').innerHTML = req.responseText;
	}
}
//-------------------------------------------------------------------------------------------------



/*#################################################################################################
##  Edit Personal Mini Info
##																								 */
function editWhoIAm(){
	var ajax = new Ajax.Updater(
         'whoami',        // DIV id (XXX: doesnt work?)
         '/elements/userprofile/func.whois.php?owner_id='+my_user_id,       // URL
         {                // options
         asynchronous: true,
		 evalScripts: true,
		 onComplete: showResponse
		 });

	function showResponse(req){
			$('whoami').innerHTML = req.responseText;
	}
}
//-------------------------------------------------------------------------------------------------


/*#################################################################################################
##  Submit Changes Edit Personal Mini Info
##																								 */
function submitWhoIAm(text,owner_id){
	var ajax = new Ajax.Updater(
         'whoami',        // DIV id (XXX: doesnt work?)
         '/elements/userprofile/func.whois.php',	// URL
         {                // options
         asynchronous: true,
		 evalScripts: true,
		 method: 'post',
		 postBody: 'text='+text+'&owner_id='+owner_id,
		 onComplete: showResponse
		 });

	function showResponse(req){
		$('whoami').innerHTML = req.responseText;
	}
}
//-------------------------------------------------------------------------------------------------




/*#################################################################################################
##  Check if a User has new Messages
##																								 */
function msgChecker(div,user_id,user_last_privmsg,type){
	type = (type) ? type : false;
	// prepare appropriate divs
	count_div = $(div+'_count');
	text_div = $(div+'_text');
	msg_div = $(div+'_messages');
	req_div = $(div+'_requests');
	div = $(div);
	//---------------------------------
	

	count_div.innerHTML = '<img src="/images/loading.gif" width="12" height="12">';
	if(msg_div != null){
		msg_div.innerHTML = '<img src="/images/loading.gif" width="12" height="12">';
		req_div.innerHTML = '<img src="/images/loading.gif" width="12" height="12">';
	}
	if(div != null){
		div.innerHTML = '<img src="/images/loading.gif" width="12" height="12">';
	}
	//-----------------------------------------------------------------------------------
	
	// AJAX Call
	var ajax = new Ajax.Updater(
         'msg_count',        // DIV id (XXX: doesnt work?)
         '/common/func.msg_checker.php',	// URL
         {                // options
         asynchronous: true,
		 method: 'post',
		 postBody: 'user_id='+user_id+'&user_last_privmsg='+user_last_privmsg,
		 onComplete: getMsgCount
		 });
	// -------------------------------------------------------------
	
	// process returns infos
	function getMsgCount(req){
		msgcounts = req.responseText.split("¦"); // [0] = messages // [1] = friendrequests
		msgcounts[0] = parseInt(msgcounts[0])
		msgcounts[1] = parseInt(msgcounts[1]);
		totalcount = msgcounts[0] + msgcounts[1];
		
		// update mainbar messages info
		if(totalcount == 0){
			text_div.className = "mb_links";
			count_div.innerHTML = ' <a class="mb_links" href="javascript:openPM();">'+totalcount+'</a>';
		}
		else {
			text_div.className = "mb_links2";
			text_div.style.fontSize = "12px;";
			count_div.innerHTML = ' <a class="mb_links2" style="font-size: 12px;" href="javascript:openPM();">'+totalcount+'</a>';
		}
		//-------------------------------------------------------------------------------------------------
		
		// in case we are on the profile index page show the split view
		if(msg_div != null){
			msg_div.innerHTML = '<a href="javascript:openPM();">'+msgcounts[0]+'</a>';
			req_div.innerHTML = '<a href="javascript:openPM();">'+msgcounts[1]+'</a>';
		}
		//------------------------------------------------------------------------------------------------
		if(div != null && type != false){
			if(type == "msgs"){
				div.innerHTML = '<a href="javascript:openPM();">'+msgcounts[0]+'</a>';
			}
			else if (type == "reqs"){
					div.innerHTML = '<a href="javascript:openPM();">'+msgcounts[1]+'</a>';
			}
			else{
				alert("type is not \"msgs\" or \"reqs\"!");
			}
		}
		//------------------------------------------------------------------------------------------------
	}
}
//-------------------------------------------------------------------------------------------------


/*#################################################################################################
##  Open Email Registration Window
##																								 */
function showEmailReg() {
    // Errechnet Koordinaten, um das Popup zentriert zu platzieren
    url = "/common/emailreg.php";
	hoehe = "250";
	breite = "500";
	links = 100;
    oben = (screen.height/2)-(hoehe/2);
	emailreg_window = window.open(url,'emailreg_popup','height='+hoehe+',width='+breite+',resizable=yes,scrollbars=yes,top ='+oben+',left ='+links);
}
//-------------------------------------------------------------------------------------------------


/*#################################################################################################
##  Open Email Registration Window
##																								 */
function showMobileReg() {
    // Errechnet Koordinaten, um das Popup zentriert zu platzieren
    url = "/common/mobilereg.php";
	hoehe = "250";
	breite = "500";
	links = 100;
    oben = (screen.height/2)-(hoehe/2);
	mobilereg_window = window.open(url,'mobilereg_popup','height='+hoehe+',width='+breite+',resizable=yes,scrollbars=yes,top ='+oben+',left ='+links);
}
//-------------------------------------------------------------------------------------------------





/*#################################################################################################
##  
##																								 */
function showWarnMsg(){
	warner = $('warnmsgs');
	Effect.Appear('warn-bgtrans',{duration:1.0, from:0.0, to:0.96});
	warner.style.display = "block";
}
//-------------------------------------------------------------------------------------------------



/*#################################################################################################
##  
##																								 */
function template(){
}
//-------------------------------------------------------------------------------------------------
