function appear(id) {
	document.getElementById(id).style.display = 'block';						 
}
function disappear(id) {
	document.getElementById(id).style.display = 'none';
}

var dlhooks = {};
var onloadHooks = [];

window.onload = function()
{
	checkCookie();

	if(dlhooks)
	{			
		for(var i in dlhooks)
		{
			dlhooks[i]();
		}
	}
	for(i = 0; i < onloadHooks.length; i++)
	{
		onloadHooks[i]();
	}

	
	// Link Änderung ohne ans Template zu müssen
	$$('.one').setProperty('href', 'http://www.unicef.de/');
	$('bubble1').setProperty('href', 'http://www.unicef.de/');
		
	$$('.two').setProperty('href', 'http://www.wunderbaer.de/');
	$('bubble2').setProperty('href', 'http://www.wunderbaer.de/');
	
	$$('.three').setProperty('href', 'http://www.unicef.de/kids/');
	$('bubble3').setProperty('href', 'http://www.unicef.de/kids/');
		
	
	//RAUS WENN CLUBS DA! 
	document.getElementById("ie7").getElementsByTagName("a")[5].style.display = "none";
	//document.getElementById("ie7").getElementsByTagName("a")[2].style.display = "none";
	
	addSocials();
	
}


function addSocials() {
	/*Element.implement({  
	 	appendHTML: function(html,where){
  		return this.grab(new Element('text',{'html':html}),where);
  	}
  });  
	$('foot').adopt(<div id="socials"></a>);
	*/
	
	var newfooter = '';
	newfooter = '<div id="ie7">';
	newfooter += '&copy; Copyright 2011 ';
	newfooter += '<a href="unicef.html"><img border="0" alt="" src="http://www.younicef.de/fileadmin/templates/img/uniceffooter.gif"/> UNICEF</a>';
	newfooter += '<a href="ueberyounicef.html">&Uuml;ber younicef</a>';
	newfooter += '<a href="sitemap.html">Sitemap</a>';
	newfooter += '<a href="kontakt.html">Kontakt</a>';
	newfooter += '<a href="impressum.html">Impressum</a>';
	newfooter += '<a href="datenschutz.html">Datenschutz</a>';
	newfooter += '<a href="javascript:window.print();">Seite drucken</a>';
	newfooter += '</div>';
	newfooter += '<div id="socials">';
	newfooter += '<a class="social_fb" title="UNICEF bei Facebook" href="http://www.facebook.com/juniorbotschafter" target="_blank"></a>';
	newfooter += '<a class="social_tw" title="UNICEF bei Twitter" href="http://twitter.com/UNICEFgermany" target="_blank"></a>';
	newfooter += '<a class="social_yt" title="UNICEF bei Youtube" href="http://www.youtube.com/user/unicefTV" target="_blank"></a>';
	newfooter += '<a class="social_vz" title="UNICEF bei studiVZ" href="http://www.studivz.net/unicef" target="_blank"></a>';
	newfooter += '<a class="social_vz2" title="UNICEF bei schülerVZ" href="http://www.schuelervz.net/unicef" target="_blank"></a>';
	newfooter += '</div>';
	
	$('foot').innerHTML = newfooter;
	
}




//cookie fn by ppk, quirksmode.org
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);
}

function checkCookie(failedLogin)
{
	if(document.getElementById("ydlibox") && document.getElementById("yduserbox"))
	{
		document.getElementById("ydhallobox").getElementsByTagName("a")[0].href = "/clubs.html?v=title%3DSpezial%3AAnmelden%26type%3Dsignup%26returnto%3DHauptseite";

		if(_readCookie("younicef_clubs_UserID"))
		{
			document.getElementById("ydwikiuser").innerHTML = _readCookie("younicef_clubs_UserName");
			document.getElementById("liform_user").style.background = "url(/fileadmin/templates/img/liuser2.gif) left top no-repeat #fff";
			document.getElementById("ydlibox").style.display = "none";
			//REIN WENN CLUBS DA! document.getElementById("yduserbox").style.display = "block";
			
			
			var wl = window.location.toString();
			if(wl.indexOf("clubs.html") > -1)
			{
				document.getElementById("yduserbox").getElementsByTagName('a')[0].target = "wikiframe";
			}
			
			document.getElementById("yduserbox").getElementsByTagName('a')[0].href = '/clubs/index.php/Special:Userlogout';
			

			
			
			
		}
		else
		{
			if(failedLogin)
			{
				alert('deine Anmeldung ist fehlgeschlagen!')
			}
			
			//REIN WENN CLUBS DA! document.getElementById("ydlibox").style.display = "block";
			document.getElementById("yduserbox").style.display = "none";		
			
			var wl = window.location.toString();
			if(wl.indexOf("clubs.html") > -1)
			{
				document.getElementById("ydliform").target = "wikiframe";
			}
			
			
			document.getElementById("ydliform").action = '/clubs/index.php?title=Special:Userlogin&action=submitlogin&type=login&returnto=Main_Page';
			document.getElementById("ydliform").getElementsByTagName('input')[2].name = 'wpLoginattempt';			
		}
	}
	
}
