<!--//--><![CDATA[//><!--
	var image = null;

	// Show games
	function Gk_PopTart(mypage, myname, w, h, scroll)
	{
		LeftPosition = (screen.width) ? (screen.width-w)/2 : 0;
		TopPosition = (screen.height) ? (screen.height-h)/2 : 0;
		settings = 'height='+h+',width='+w+',top='+TopPosition+',left='+LeftPosition+',scrollbars='+scroll+',resizable=no';
		win = window.open(mypage, myname, settings);
	}

	function show_content(id)
	{
		display_box = (document.getElementById(id).style.display == 'none') ? 'block' : 'none';
		document.getElementById(id).style.display = display_box;
	}

	// Set display of page element
	// s[-1,0,1] = hide,toggle display,show
	function dE(n,s) 
	{
		var e = document.getElementById(n);
		if(!s) s = (e.style.display=='') ? -1:1;
		e.style.display = (s==1) ? '':'none';
	}

	function popup(url, width, height, target)
	{
		window.open(url, target, 'height=' + height + ',resizable=yes,scrollbars=no, width=' + width);
		return false;
	}

	function externalLinks() 
	{
		if (!document.getElementsByTagName) return;
		var anchors = document.getElementsByTagName("a");
		for (var i=0; i<anchors.length; i++) {
			var anchor = anchors[i];
			if (anchor.getAttribute("href") && anchor.getAttribute("rel") == "external")
				anchor.target = "_blank";
		}
	}

	function parentLinks() 
	{
		if (!document.getElementsByTagName) return;
		var anchors = document.getElementsByTagName("a");
		for (var i=0; i<anchors.length; i++) {
			var anchor = anchors[i];
			if (anchor.getAttribute("href") && anchor.getAttribute("rel") == "parent")
				anchor.target = "_parent";
		}
	}

	function roundedCorners() 
	{
		var divs = document.getElementsByTagName('div');
		var rounded_divs = [];
		// First locate all divs with 'rounded' in their class attribute
		for (var i = 0; i < divs.length; i++) 
		{
			if (/\brounded\b/.exec(divs[i].className)) 
			{
				rounded_divs[rounded_divs.length] = divs[i];
			}
		}

		// Now add additional divs to each of the divs we have found
		for (i = 0; i < rounded_divs.length; i++) 
		{
			var original = rounded_divs[i];
			
			// Make it the inner div of the four
			original.className = original.className.replace('rounded', '');
			
			// Now create the outer-most div
			var tr = document.createElement('div');
			tr.className = 'rounded2';
			
			// Swap out the original (we'll put it back later)
			original.parentNode.replaceChild(tr, original);
			
			// Create the two other inner nodes
			var tl = document.createElement('div');
			var br = document.createElement('div');
			
			// Now glue the nodes back in to the document
			tr.appendChild(tl);
			tl.appendChild(br);
			br.appendChild(original);
		}
	}
	
	function changeElements()
	{
		externalLinks();
		parentLinks();
		// roundedCorners();
	}

	window.onload = changeElements;

	function adjust_popup()
	{
		var w, h, fixedW, fixedH, diffW, diffH;

		if (document.all) 
		{
			fixedW = document.body.clientWidth;
			fixedH = document.body.clientHeight;
			window.resizeTo(fixedW, fixedH);
			diffW = fixedW - document.body.clientWidth;
			diffH = fixedH - document.body.clientHeight + 40;
		} 
		else 
		{
			fixedW = window.innerWidth;
			fixedH = window.innerHeight;
			window.resizeTo(fixedW, fixedH);
			diffW = fixedW - window.innerWidth;
			diffH = fixedH - window.innerHeight + 40;
		}
		
		w = fixedW + diffW;
		h = fixedH + diffH;
		if (h >= screen.availHeight) w += 16;
		if (w >= screen.availWidth)  h += 16;
		w = Math.min(w,screen.availWidth);
		h = Math.min(h,screen.availHeight);
		window.resizeTo(w,h);
		window.moveTo((screen.availWidth-w)/2, (screen.availHeight-h)/2);
	}

	function writeCookie(name, data, noDays)
	{
		var cookieStr = name + "="+ data
		if (writeCookie.arguments.length > 2)
		{
			cookieStr += "; expires=" + getCookieExpireDate(noDays)
		}
		document.cookie = cookieStr
	}

	function readCookie(cookieName)
	{
		var searchName = cookieName + "="
		var cookies = document.cookie
		var start = cookies.indexOf(cookieName)
		if (start == -1){ // cookie not found
			return ""
		}
		start += searchName.length //start of the cookie data
		var end = cookies.indexOf(";", start)
		if (end == -1)
		{
			end = cookies.length
		}
		return cookies.substring(start, end)
	}

	function blocking(nr, cookie, vis_state)
	{
		if (document.layers)
		{
			current = (document.layers[nr].display == 'none') ? vis_state : 'none';
			if (cookie != '')
				writeCookie(nr, current);
			document.layers[nr].display = current;
		}
		else if (document.all)
		{
			current = (document.all[nr].style.display == 'none') ? vis_state : 'none';
			if (cookie != '')
				writeCookie(nr, current);
			document.all[nr].style.display = current;
		}
		else if (document.getElementById)
		{
			display = (document.getElementById(nr).style.display == 'none') ? vis_state : 'none';
			if (cookie != '')
				writeCookie(nr, display);
			document.getElementById(nr).style.display = display;
		}
	}

	function sectionblocking(nr, cookie, vis_state, tab)
	{
		if (document.layers)
		{
			current = (document.layers[nr].display == 'none') ? vis_state : 'none';
			if (cookie != '')
				writeCookie(nr, current);
			document.layers[nr].display = current;
		}
		else if (document.all)
		{
			current = (document.all[nr].style.display == 'none') ? vis_state : 'none';
			if (cookie != '')
				writeCookie(nr, current);
			document.all[nr].style.display = current;
			class_name = (tab.className != 'active') ? 'active' : '';
			tab.className = class_name;
		}
		else if (document.getElementById)
		{
			display = (document.getElementById(nr).style.display == 'none') ? vis_state : 'none';
			if (cookie != '')
				writeCookie(nr, display);
			document.getElementById(nr).style.display = display;				
			class_name = (tab.className != 'active') ? 'active' : '';
			tab.className = class_name;
		}
	}

	// Clipboard copycode based on: 
	// http://www.codebase.nl/index.php/command/viewcode/id/174
	// http://www.xulplanet.com/tutorials/xultu/clipboard.html

	function copyCode(id)
	{
		var copytext;
		var allowed = true;
		var e = document.getElementById(id);

		if (window.clipboardData)
		{
			// IE users
			copytext = e.innerText;
			window.clipboardData.setData("Text", copytext);
		} 
		else if (window.netscape)
		{
			copytext = e.innerHTML;

			// The tight security settings in mozilla mean you have to sign the javascript to make it work
			// You can change your Moz settings by typing: about:config in the address bar
			try
			{
				netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect');
			}
			catch (error)
			{
				alert("Dein Browser erlaubt das kopieren in die Zwischenablage nicht.\n\nDu kannst dies ändern, indem du in die Adresszeile deines Browsers 'about:config' eingibst und \n'signed.applets.codebase_principal_support' auf true setzt.");
				allowed = false;
			}
			
			if( !allowed ) return false;
			
			// First, we need to create an XPCOM object to wrap what we want to copy
			var str = new Object();
			var str = Components.classes["@mozilla.org/supports-string;1"].createInstance(Components.interfaces.nsISupportsString);
			if(!str) return false;
			str.data = copytext;
			
			// Create a transfer object and set the format of the data transfer
			// See: http://www.mozilla.org/xpfe/xptoolkit/introClipDD.html
			var trans = Components.classes["@mozilla.org/widget/transferable;1"].createInstance(Components.interfaces.nsITransferable);
			if(!trans) return false;
			trans.addDataFlavor("text/unicode");
			trans.setTransferData("text/unicode",str,copytext.length*2);
			
			// Create a clipboard object that refers to the system clipboard and transfer the content to it
			var clipid=Components.interfaces.nsIClipboard;
			var clip = Components.classes["@mozilla.org/widget/clipboard;1"].getService(clipid);
			if(!clip) return false;
			clip.setData(trans,null,clipid.kGlobalClipboard);
		} 
		else 
		{
			return false;
		}

		alert("Der Quelltext wurde in die Zwischenablage kopiert.");
	}

	function switchControl(id, mode, style)
	{
		if (element = document.getElementById(id))
		{
			element.style.display = (mode ? (style ? style : 'block') : 'none');
			element.enabled = mode;
		}
	}

	function show_img_tooltip(element, show)
	{
		if (element.nextSibling) {
			image = element.nextSibling;
		}
		else {
			image = null;
		}

		if (show && image)
		{
			image.style.display = "block";
			image.style.position = "fixed";
			document.onmousemove = setPosition;
		}
		else if (image)
		{
			image.style.display = "none";
		}
	}

	function setPosition(e)
	{
		x = (document.all) ? window.event.x + document.body.scrollLeft : e.pageX;
		y = (document.all) ? window.event.y + document.body.scrollTop  : e.pageY - window.pageYOffset;

		if (image != null)
		{
			image.style.left = (x + 13) + "px";
			image.style.top 	= (y + 20) + "px";
		}
	}

	function setSrc(element, src)
	{
		if (element.src)
		{
			element.src = src;
		}
		else if(element.firstChild)
		{
			element.firstChild.src = src;
		}
	}

	function open_progress_popup(form, upload_id)
	{
		var w = 350;
		var h = 240;
		var x = self.screen ? (screen.width - w) >> 1 : 0;
		var y = self.screen ? (screen.height - h) >> 1 : 0;
		var args = 'width=' + w + ',height=' + h + ',left=' + x + ',top=' + y;
		var i, total_files = 0;
		for (i = 0; i < form.elements.length; i++)
		   if ((form.elements[i].type == 'file') && (form.elements[i].value))
			   total_files++;
		window.open('progress.php?UPLOAD_IDENTIFIER=' + upload_id + '&UPLOAD_METER_FILES_TOTAL=' + total_files, '_blank', args).focus();
	}

	function open_image_selector(user_id, album_id)
	{
		var w = 650;
		var h = 544;
		var x = self.screen ? (screen.width - w) >> 1 : 0;
		var y = self.screen ? (screen.height - h) >> 1 : 0;
		var args = 'width=' + w + ',height=' + h + ',left=' + x + ',top=' + y;
		window.open('image_selector.php?uid=' + user_id + '&uaid=' + album_id, '_blank', args).focus();
	}

//--><!]]>