window.addEvent('domready', function() {
	Element.implement({
		show: function()
		{
			this.setStyle('display', 'block');
		},
		hide: function()
		{
			this.setStyle('display', 'none');
		}
	});
	
	Array.prototype.remove = function(o)
	{
		var a = [];
		for(var i = 0; i < this.length; i++)
		{
			if(this[i] != o)
			{
				a.push(this[i]);
			}
		}

		return a;
	}
});  

function bookmark(dienst)
{
	var url = encodeURIComponent(location.href);
	var title = encodeURIComponent(document.title);
	
	switch(dienst)
	{
		case 'wong':
		window.open('http://www.mister-wong.de/index.php?action=addurl&bm_url=' + url + '&bm_description=' + title);
		break;
		
		case 'yigg':
		window.open('http://yigg.de/neu?exturl=' + url + '&exttitle=' + title);
		break;
		
		case 'linkarena':
		window.open('http://linkarena.com/bookmarks/addlink/?url=' + url + '&title=' + title);
		break;
		
		case 'google': 		
		window.open('http://www.google.com/bookmarks/mark?op=add&hl=de&bkmk=' + url + '&title=' + title);
		break;
		
		case 'delicious':
		window.open('http://del.icio.us/post?url=' + url + '&title=' + title);
		break;
		
		case 'yahoo':
		window.open('http://myweb2.search.yahoo.com/myresults/bookmarklet?u=' + url + '&t=' + title);
		break;
		
		case 'webnews': 		
		window.open('http://www.webnews.de/einstellen?url=' + url + '&title=' + title);
		break;
		
		case 'digg':
		window.open('http://digg.com/submit?phase=2&url=' + url + '&title=' + title);
		break;
		
		case 'shortnews':
		window.open('http://www.shortnews.de/submitsource.cfm?source=' + url + '&title=' + title);
		break;
		
		case 'facebook':
		window.open('http://de.facebook.com/sharer.php?u=' + url + '&t=' + title);
		break;
		
		case 'twitter':
		window.open('http://twitter.com/home?status=' + url);
		break;
	}
}

function popup(url, h)
{
	window.open(url, 'popup', 'width=400, height=' + h + ', resizable=yes, scrollbars=no');
}

function closeCloud()
{
	if(document.getElementById('cloud'))
	{
		document.getElementById('cloud').style.visibility = 'hidden';
	}
}

function setBodyBG(farbe)
{
	var farbe;

	document.body.style.backgroundColor = '#' + farbe;	
	$('commercialheader').style.backgroundColor = '#' + farbe;
}

function step_aside(butch)
{
	$('maindiv').style.margin = '0 0 0 ' + butch + 'px';
}

// Notification
function chatnote(receiver, sender)
{
	xmlHttp = getXMLRequester();
	xmlHttp.open("POST","/actions/msgner_response.php", true);
	xmlHttp.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
	xmlHttp.send('receiver=' + receiver + '&sender=' + sender);
		
	xmlHttp.onreadystatechange = function()
	{		
		if(xmlHttp.readyState == 4)
		{			
			$('notification').innerHTML = xmlHttp.responseText;
			$('notification').style.display = 'inline';
		}
	}
}

// Chat-Request
function chatrequest(userName)
{
	xmlHttp = getXMLRequester();
	xmlHttp.open("POST","/actions/chatuser.php", true);
	xmlHttp.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
	xmlHttp.send("id=" + userName);
		
	xmlHttp.onreadystatechange = function()
	{		
		if(xmlHttp.readyState == 4)
		{			
			if (xmlHttp.responseText != '' && isNaN(xmlHttp.responseText))
			{
				chatnote(userName,xmlHttp.responseText);
			}
		}
	}
}

// close Chat Notification
function closeChatrequest(receiver, caller)
{
	xmlHttp = getXMLRequester();
	xmlHttp.open("POST","/actions/chatuser.php", true);
	xmlHttp.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
	xmlHttp.send("close=" + receiver + "&user=" + caller);
	
	xmlHttp.onreadystatechange = function()
	{		
		if(xmlHttp.readyState == 4)
		{
			$('notification').style.display = 'none';
			$('notification').innerHTML = '';
		}
	}
}

function chat(user, partner)
{
	var jetzt = new Date();
	window.open('/user/popup_chat.html?user=' + partner, 'Chat' + jetzt.getTime(), 'width=513, height=417, resizable=no, scrollbars=no');
}


window.setTimeout("closeCloud()", 7000);
