// ===== COOLIRIS FUNKTIONEN =======================================

/* PicLens Lite: version 1.3.1 (14221)
 * Copyright (c) 2008 Cooliris, Inc.  All Rights Reserved.
 * 
 * The JavaScript part of PicLens Lite (i.e., this file) is BSD licensed (see: http://lite.piclens.com/bsdlicense)
 * This launcher includes and interacts with SWFObject (MIT), BrowserDetect (BSD Compatible), and Lytebox (CC Attribution 3.0).
 * 
 * There are two versions of this JS: 
 * http://lite.piclens.com/current/piclens.js				full commented file 		(~39KB)
 * http://lite.piclens.com/current/piclens_optimized.js		lighter deployment file		(~21KB)
 */

var PicLensLite = {
	// PUBLIC API

	// PicLens Lite can be deployed in one of two ways:
	// 1) include http://lite.piclens.com/current/piclens.js in the <head> of your webpage
	// 2) download the zip file and deploy it on your own website (unzip it anywhere, and point to the JS file in the <head> of your page)
	//    see: http://lite.piclens.com/releases/current.zip
	// 
	// For example: the directory layout looks like:
	//	 lite.piclens.com/current/ contains the SWF, JS, and image files
	//					 /lytebox/ contains slideshow support for browsers w/o Flash
	// 
	// Pointing to the JS directly will configure Lite relative to that URL.
	// Alternatively, you can customize the URLs with PicLensLite.setLiteURLs
	
	// 1) Call PicLensLite.start() to launch the default feed (specified in the head)
	// 2) Call PicLensLite.start({feedUrl:'http://myWebsite.com/myFeed.rss', ...}) to launch a specific feed
	//	Option 2 supports the following named arguments:
	//		feedUrl  : String  // is the URL to the specific Media RSS feed you want to launch
	//		feedData : String  // is the Media RSS feed itself (do not use feedUrl if you want to programmatically generate & pass in the feed text)
	//		guid	 : String  // starts from the item in the feed that is tagged w/ this unique id
	//		maxScale : Number  // normally, images fill the stage; 0 -> never scale up; any other positive number S --> scale up to S times the original size of the photo (but never bigger than the stage)
	//		loadFeedInFlash : Boolean // if true, we ask Flash to load the feed, instead of AJAX (expert option)
	//		loop	 : Boolean // if true, we turn looping on by default
	//		paused	 : Boolean // if true, we start the slideshow in paused mode
	// To enable smoothing for images. a crossdomain.xml file is required at the root of your image server.
	// Lite detects this crossdomain.xml and applies smoothing automatically.
	start : function (namedArgs) {
		this.determineBrowserParams();
		clearTimeout(this.REMOVE_TIMER_ID);
		clearTimeout(this.AUTO_CLOSE_TIMER_ID);
		this.ARGS = {}; // clear out previous args

		// handle named arguments
		if (typeof namedArgs !== "undefined" && namedArgs !== null) {
			this.ARGS = namedArgs;

			// if feedUrl is specified, it launches immediately
			if (namedArgs.feedUrl) {
				this.THE_FEED_URL = namedArgs.feedUrl;
				if (this.checkForPluginAndLaunchIfPossible(namedArgs.feedUrl, namedArgs.guid)) {
					return;
				}
				if (namedArgs.loadFeedInFlash) {
					// read up on flash crossdomain.xml if you choose this option
					// Flash can only load feeds from servers hosting a crossdomain.xml
					// pass the URL as a FlashVar, and load the contents via a GET request
					this.showFlashUI("");
				} else {
					// load the contents of the URL via AJAX, and launch the Flash UI afterward....
					this.loadViaXHR(namedArgs.feedUrl);
				}
			}
			// pass in the feed XML directly through Javascript
			// use feedUrl OR feedData, but not both!
			if (typeof namedArgs.feedData !== 'undefined') {
				this.showFlashUI(namedArgs.feedData);
			}
			
		} else {
			// find the feed from the header, since none was specified
			// build list of XML feeds
			var feeds = this.indexFeeds();
			if (feeds.length !== 0) { // view the first feed, if available
				var feed = feeds[0];
				this.THE_FEED_URL = feed.url;
				if (this.checkForPluginAndLaunchIfPossible(feed.url)) {
					return;
				}
				this.loadViaXHR(feed.url);
			}
		}
	},
	// check if the slideshow is currently running
	isRunning : function () {
		return this.LITE_IS_RUNNING;
	},
	// check if the browser plug-in is installed
	hasClient : function () {
		return this.hasCooliris();
	},
	// call this before starting lite. we currently support a single custom button
	// the icon is a 24x24 PNG
	// we will perform a GET request of a provided URL (w/ the item's GUID) when the user clicks
	// http://yourwebserver.com/buttonURL?itemGUID=guidVal
	addCustomButton : function (buttonRESTUrl, buttonLabel, buttonIcon) {
		this.CUSTOM_BUTTON = {targetURL: buttonRESTUrl, labelText: buttonLabel, iconImage: buttonIcon};
	},
	// OPTIONAL: provide callbacks to be notified in certain situations. Call this BEFORE PicLensLite.start(...)
	// 	onNoPlugins():Boolean
	//		is called when the user invokes Lite but does not have PicLens / Flash installed
	// 	onExit(itemUID):void
	//		is called when the user exits from Lite
	//		we provide the item's GUID if it exists, and the item's content URL otherwise
	//		itemUID is undefined if the user exited before Lite launched, or if the user did not have Flash
	setCallbacks : function (args) {
		if (args.onNoPlugins) {
			this.ON_NO_PLUGINS = args.onNoPlugins;
		}
		if (args.onExit) {
			this.ON_EXIT = args.onExit;
		}
	},
	// OPTIONAL: customize the location of resources. Call this BEFORE PicLensLite.start(...)
	// Normally, we locate the PicLensLite files relative to the JS file 
	// To use this function, pass in an object with the following named arguments:
	// args = {
	//		lite	: other paths can be determined from this (make sure it ends in a slash)
	//		swf		: the URL of the SWF file					1
	//		button	: image allowing users to download piclens	1
	//		lbox	: where to find lytebox						1
	//		lboxcss	: the CSS file								2
	//		lboxjs	: the JS file								2
	// }
	// 1: Can be determined from args.lite
	// 2: Can be determined from args.lbox or args.lite
	setLiteURLs : function (args) {
		if (!this.LITE_URL) {
			if (args.swf) {
				this.LITE_URL = args.swf;
			} else if (args.lite) {
				this.LITE_URL = args.lite + "PicLensLite.swf";
			} // if both lite & swf aren't set, it won't work
		}
		if (!this.BUTTON_URL) {
			if (args.button) {
				this.BUTTON_URL = args.button;
			} else if (args.lite) {
				this.BUTTON_URL = args.lite + "NoFlash.jpg";
			}
		}

		var lboxUrl = "";
		if (args.lbox) {
			lboxUrl = args.lbox;
		} else if (args.lite) {
			lboxUrl = args.lite + "../lytebox/";
		}
		
		if (!this.LBOX_CSS_URL) {
			if (args.lboxcss) {
				this.LBOX_CSS_URL = args.lboxcss;
			} else if (lboxUrl != "") {
				this.LBOX_CSS_URL = lboxUrl + "lytebox.css";
			}
		}

		if (!this.LBOX_JS_URL) {
			if (args.lboxjs) {
				this.LBOX_JS_URL = args.lboxjs;
			} else if (lboxUrl != "") {
				this.LBOX_JS_URL = lboxUrl + "lytebox.js";
			}
		}
	},



	//////////////////////////////////////////////////////////////////////////////////////////////////////////
	// The PRIVATE API is below
	// DO NOT USE these functions/variables directly; they WILL change in future releases
	// Email us to request changes to the public API
	ARGS			: {},
	DEBUG_NOCLIENT	: false,	// if true, we will NEVER launch the PicLens Client (for testing Lite)
	DEBUG_NOFLASH	: false,	// if true, we will assume the user does not have Flash (for testing Lite)
	HPAD			: 60,		// horizontal padding
	VPAD			: 20,		// vertical padding
	LITE_BG_DIV		: null,		// the grey/black background overlay
	LITE_FG_DIV		: null,		// the foreground div that contains the flash component
	LITE_URL		: null,		// the location of PicLensLite.SWF
	BUTTON_URL		: null,		// image to display if the user doesn't have flash
	LBOX_CSS_URL	: null,		// where to find lytebox css/js files
	LBOX_JS_URL		: null,
	LBOX_COUNT		: 0,		// try to start lytebox, but if it doesn't exist after a few tries, give up...
	SHOW_LBOX		: false,	// if true, skip flash altogether
	OS_WIN			: false,	// OS Detect
	OS_MAC			: false,	// sadly, sometimes we have to do something different depending on our Browser/OS/Configuration
	BROWSER_FFX		: false,	// Browser Detect
	BROWSER_SAF		: false,
	BROWSER_IE		: false,
	BROWSER_IE6		: false,
	OLD_B_MARGIN	: null,
	OLD_B_OVERFLOW	: null,
	OLD_B_HEIGHT	: null,
	OLD_H_OVERFLOW	: null,
	OLD_H_HEIGHT	: null,
	THE_FEED		: "",			// the feed text
	THE_FEED_URL	: "",			// the feed url
	LITE_IS_RUNNING		: false,	// use isRunning()
	piclensIsRunning_	: false,	// maintain compatibility with the Wordpress Plugin for a few iterations...
	FLASH_ID_1		: "pllflash1",	// outer
	FLASH_ID_2		: "pllflash2",	// inner
	FLASH_VER		: null,			// the version of Flash we're running 
	FLASH_URL		: "http://www.adobe.com/go/getflashplayer",
	PL_URL			: "http://download.piclens.com/partner/",   // downloads PL immediately
	PLC				: null,			// PicLens Client
	LEARN_PL_URL	: "http://affiliate.piclens.com/partner/",  // landing page to read about / download PL
	FONT			: "font-family: Lucida Grande, Myriad Pro, Verdana, Helvetica, Arial, sans-serif;",
	KEY_HANDLERS	: "",	// save the old key handlers, if any
	ON_NO_PLUGINS	: null, // callback
	ON_EXIT			: null, // callback
	AUTO_CLOSE_TIMER_ID		: 0,	// 
	REMOVE_TIMER_ID			: 0,	// the timer for removing the children...
	RESIZE_TIMER_IE6		: null,	// every second, autoresizes the UI
	RESIZE_HANDLER_EXISTS	: false,// add a handler to detect user resize events in safari
	CUSTOM_BUTTON			: null,	// add an action to the UI

	addKeyHandlers : function() {
		var self = this;
		if (typeof document.onkeydown !== 'undefined') { // save & later restore key handlers...
			this.KEY_HANDLERS = document.onkeydown;
		}
		document.onkeydown = function(e) {
			var keycode;
			if (typeof e === "undefined" || e === null) { // ie
				keycode = window.event.keyCode;
			} else { // mozilla
				keycode = e.which;
			}
			var val=self.handleKeyPress(keycode);
			if (typeof e != "undefined" && e != null) {
				e.returnValue = val;
			}
			return val;
		};
	},
	addMouseHandlers : function() {
		if (window.addEventListener) {		// Firefox/Opera
			window.addEventListener("DOMMouseScroll", this.handleMouseWheel, false);
		} else if (document.attachEvent) {	// IE
			document.attachEvent("onmousewheel", this.handleMouseWheel);
		}
		// must be outside of the if-else
        window.onmousewheel = document.onmousewheel = this.handleMouseWheel; // Safari & Others
	},
	// call this at the last possible moment (especially for Win/Firefox)
	appendElementsToDocument : function() { 
		if (this.BROWSER_FFX && this.OS_MAC) {	// avoid redraw bug by not showing the background
			this.LITE_BG_DIV.style.display = "none";
		}
		document.body.appendChild(this.LITE_BG_DIV);
		document.body.appendChild(this.LITE_FG_DIV);
	},
	autoResize : function() { // for the IE6 auto resize
		if (!this.isRunning()) {
			// unregister the timer
			clearInterval(this.RESIZE_TIMER_IE6);
			return;
		}
		
		// resize the BG and FG divs
		var size = this.getPageSize();
		var bg = this.LITE_BG_DIV;
		if (bg) {
			bg.style.height = size.h + 'px';
			bg.style.width  = size.w + 'px';
		}
		if (this.LITE_FG_DIV) {
			var fgs = this.LITE_FG_DIV.style;
			this.resizeToPaddedBox(fgs);
			this.resizeToFitPaddedBox(fgs, size);
			this.resizeFlashToFitPaddedBox();
		}
	},
	checkForPluginAndLaunchIfPossible : function (url, guid) {
		// if we have the correct version of piclens, pass it onto the client and do not use LITE
		if (this.hasCooliris()) {
			if (typeof(guid) != "undefined") {
				this.PLC.launch(url,'uid',guid);
			} else {
				this.PLC.launch(url,'','');
			}

			return true; // launched!
		}
		return false;
	},
	createBackgroundOverlay : function () {
		// create a background that covers the page
		var bg = document.createElement('div');
		this.LITE_BG_DIV = bg;
		bg.id = "lite_bg_div";
		
		var bgs = bg.style;
		bgs.position = 'fixed';

		// stick to the sides when the window resizes
		bgs.width = bgs.height = "100%";

		if (this.BROWSER_IE6) {
			var b = document.body;
			var bs = b.currentStyle;
			var de = document.documentElement;
			var ds = de.currentStyle;
			
			// save previous document styles
			this.OLD_B_MARGIN = bs.margin;
			this.OLD_B_OVERFLOW = bs.overflow;
			this.OLD_B_HEIGHT = bs.height;
			this.OLD_H_OVERFLOW = ds.overflow;
			this.OLD_H_HEIGHT = ds.height;
			this.OLD_SCROLL_Y = de.scrollTop;
			
			// simulate position:fixed...
			b.style.margin = "0";
			b.style.overflow = "auto";
			b.style.height = "100%";
			de.style.overflow = "auto";
			de.style.height = "100%";

			bgs.position = 'absolute';
			var page = this.getPageSize();
			bgs.height = page.h + 'px';
			bgs.width  = page.w + 'px';
		}
		
		bgs.left = bgs.right = bgs.top = bgs.bottom = '0';
		bgs.backgroundColor = '#000';
		bgs.zIndex = 1000;
		bgs.opacity = '0.5';
		bgs.filter = 'alpha(opacity=50)';		// IE7

		var self = this;
		bg.onclick = function () {
			self.exitPicLensLite();
		};
	},
	createForegroundFlashComponent : function () { // configure the box
		var fg = document.createElement('div');
		this.LITE_FG_DIV = fg;
		fg.id = "lite_fg_div";

		var fgs = fg.style;
		fgs.backgroundColor = '#000';
		fgs.position = 'fixed';
		fgs.border = '2px solid #555';
		fgs.zIndex = 1001;	   // above the bg

		this.resizeToPaddedBox(fgs);

		if (this.BROWSER_IE6) {
			fgs.position = 'absolute';
			this.resizeToFitPaddedBox(fgs);
		}
	},
	// this just removes the HTML elements
	// we call this from Flash (thus, we need to allow the function to return before removing the children)
	closeFlashUI : function (itemID) {
		var doc = document;
		
		// remove the keyboard & mouse handlers...
		doc.onkeydown = this.KEY_HANDLERS;
		window.onmousewheel = doc.onmousewheel = "";
		if (window.removeEventListener) {
			window.removeEventListener("DOMMouseScroll", this.handleMouseWheel, false);
		}
		if (doc.detachEvent) { // IE/Opera
			doc.detachEvent("onmousewheel", this.handleMouseWheel);
		}

		// hide the div now; remove them later
		this.LITE_BG_DIV.style.display = this.LITE_FG_DIV.style.display = 'none';
		this.REMOVE_TIMER_ID = setTimeout(function (){PicLensLite.removeChildren();}, 150); // 0.15s

		if (this.BROWSER_IE6) { // restore styles
			var b = document.body;
			var de = document.documentElement;
			b.style.margin = this.OLD_B_MARGIN;
			b.style.overflow = this.OLD_B_OVERFLOW;
			b.style.height = this.OLD_B_HEIGHT;
			de.style.overflow = this.OLD_H_OVERFLOW;
			de.style.height = this.OLD_H_HEIGHT;
			window.scrollTo(0, this.OLD_SCROLL_Y);
		}

		if (this.ON_EXIT !== null) {
			this.ON_EXIT(itemID); // call on exit
		}
		this.setRunningFlag(false);
	},
	// for handling cross-browser quirks...
	determineBrowserParams : function () {
		// BrowserDetect {.OS, .browser, .version} e.g., "Mac Firefox 2" and "Windows Explorer 7"
		var os = BrowserDetect.OS;
		var b = BrowserDetect.browser;
		this.OS_MAC = (os == "Mac");
		this.OS_WIN = (os == "Windows");
		this.BROWSER_FFX = (b == "Firefox");
		this.BROWSER_SAF = (b == "Safari");
		this.BROWSER_IE = (b == "Explorer");
		this.BROWSER_IE6 = (this.BROWSER_IE && BrowserDetect.version == "6");
		this.FLASH_VER = swfobjlite.getFlashPlayerVersion(); // what version of Flash is the browser running?
	},
	// we should tell Flash we are exiting when this is called...
	// this should only be called when the user clicks outside of the flash component
	// all other exits are handled through Flash
	exitPicLensLite : function () {
		var fl = this.getFlash();
		if (fl !== null && fl.fl_exitPicLensLite) {	// binding exists
			// tell flash that we are quitting
			fl.fl_exitPicLensLite();
			// close after .5 seconds, if nothing happened
			// TODO: make sure this doesn't crash any browsers
			// TODO: Check the Return Value to Fire this Timer?
			this.AUTO_CLOSE_TIMER_ID = setTimeout(function (){if (PicLensLite.isRunning()) {PicLensLite.closeFlashUI();}}, 500); // 0.5s
		} else {
			// if it's not running already, we just remove the DIVs (flash isn't defined)
			this.closeFlashUI();
		}
	},
	// a website should include the absolute URL of the piclens.js in its header
	// This function looks for the script tag and extracts the ROOT_URL
	// <script type="text/javascript" src="ROOT_URL/piclens.js"></script>
	// we assume the SWF and JPEG/PNG/GIF files are relative to this ROOT_URL...
	findScriptLocation : function () {
		var scriptTags = document.getElementsByTagName("script");
		for (var i = 0; i != scriptTags.length; ++i) {
			var script = scriptTags[i];
			var type = script.getAttribute("type");
			if (type == "text/javascript") {
				var src = script.getAttribute("src");
				if (src === null) {
					continue;
				}
				var index = src.indexOf("piclens.js"); 
				if (index != -1) {
					this.setLiteURLs({lite:src.substring(0,index)});
					return;
				} else {
					index = src.indexOf("piclens_optimized.js");
					if (index != -1) {
						this.setLiteURLs({lite:src.substring(0,index)});
						return;
					}
				}
			}
		}
	},
	// returns an object describing the page size of the browser window
	getPageSize : function () {
		var xScroll, yScroll, winW, winH;
		var doc = document;
		var body = doc.body;
		var html;
		if (window.innerHeight && window.scrollMaxY) {
			xScroll = doc.scrollWidth;
			yScroll = (this.isFrame ? parent.innerHeight : self.innerHeight) + (this.isFrame ? parent.scrollMaxY : self.scrollMaxY);
		} else if (body.scrollHeight > body.offsetHeight){
			xScroll = body.scrollWidth;
			yScroll = body.scrollHeight;
		} else {
			html = doc.getElementsByTagName("html").item(0);
			xScroll = html.offsetWidth;
			yScroll = html.offsetHeight;
			xScroll = (xScroll < body.offsetWidth) ? body.offsetWidth : xScroll;
			yScroll = (yScroll < body.offsetHeight) ? body.offsetHeight : yScroll;
		}
		var docElement = doc.documentElement;
		if (self.innerHeight) {
			winW = (this.isFrame) ? parent.innerWidth : self.innerWidth;
			winH = (this.isFrame) ? parent.innerHeight : self.innerHeight;
		} else if (docElement && docElement.clientHeight) {
			winW = docElement.clientWidth;
			winH = docElement.clientHeight;
		} else if (body) {
			html = doc.getElementsByTagName("html").item(0);
			winW = html.clientWidth;
			winH = html.clientHeight;
			winW = (winW == 0) ? body.clientWidth : winW;
			winH = (winH == 0) ? body.clientHeight : winH;
		}
		var pageHeight = (yScroll < winH) ? winH : yScroll;
		var pageWidth = (xScroll < winW) ? winW : xScroll;
		return {pw:pageWidth, ph:pageHeight, w:winW, h:winH}; // pw and ph are the larger pair. use w and h.
	},
	getElementsFromXMLFeed : function () {
		var xmlDoc;
		if (window.ActiveXObject) { // IE
		  	xmlDoc=new ActiveXObject("Microsoft.XMLDOM");
		  	xmlDoc.async=false;
		  	xmlDoc.loadXML(PicLensLite.THE_FEED);
		} else { // Mozilla, Firefox, Opera, etc.
			var parser = new DOMParser();
			xmlDoc = parser.parseFromString(PicLensLite.THE_FEED, "text/xml");
		}
		var elements = xmlDoc.getElementsByTagName('*');
		return elements;
	},
	getBasicSlideShowHTML : function () {
		if (!this.LBOX_JS_URL || !this.LBOX_CSS_URL) {
			return "";
		}
		
		// make sure the lytebox JS is included
		var head = document.getElementsByTagName('head').item(0);

		// add the script tag
		var script  = document.createElement('script');
		script.src  = this.LBOX_JS_URL;
		script.type = 'text/javascript';
		head.appendChild(script);
		
		// add the lytebox CSS too
		var link = document.createElement('link');
		link.rel = "stylesheet";
		link.href = this.LBOX_CSS_URL;
		link.type = "text/css";
		link.media = "screen";
		head.appendChild(link);

		// find all image URLs from the feed.
		var xmlElements = this.getElementsFromXMLFeed();

		var i;
		var hiddenURLs = "";
		for (i = 0; i < xmlElements.length; i++) {
			if (xmlElements[i].nodeName == "media:content") {	// what about the namespace?
				var url = xmlElements[i].getAttribute("url");
				if (url.indexOf(".flv") == -1) {				// images only... avoid FLV files
					hiddenURLs += '<a id="lboxImage" href="' + url + '" rel="lytebox[lite]"></a> ';
				}
			}
		}
		// rel="lytebox[lite]"
		var basicSlideShow = "<div id='lightbox_images' align='center' style='display: none; padding-top:10px; color:#FFFFFF; font-size:.8em; " +this.FONT+ " color:#999999;'>";
		basicSlideShow +=  '( Alternatively, <a onclick="javascript:PicLensLite.invokeLytebox();return false;" href="#" style="color:#656588">click here for a basic slideshow</a>. )';
		basicSlideShow += hiddenURLs;
		basicSlideShow += "</div><br>";

		return basicSlideShow;
	},
	generateAlternativeContent : function () {
		var altContentHTML = '<div id="altContent" style="text-align:center; margin: 0 0 0 0; padding: 0 0 0 0; background-color: #000; min-width:860px;">';
		altContentHTML += '<div align="center" style="width: 100%; padding-top:60px; '+this.FONT+'">';

		var v = this.FLASH_VER;
		var flashMessage;
		if (v.major > 0) { // has some version of Flash
			flashMessage = "update your Flash Player from version "+ v.major + '.' + v.minor + '.' + v.release + " to version 9.0.28 or newer";
		} else {
			flashMessage = "install the most recent Flash Player";
		}
		
		var basicSlideShow = "";
		if (this.THE_FEED !== "") {   // do this if we've loaded the feed in AJAX
			basicSlideShow = this.getBasicSlideShowHTML();
		}
		
		var downloadPL = this.PL_URL;
		var learnPL = this.LEARN_PL_URL;
		var pid = this.ARGS.pid;
		if (pid) {
			downloadPL += pid + "/";
			learnPL += pid + "/";
		} else {
			var x = "000000000001/";
			downloadPL += x;
			learnPL += x;
		}
		
		if (this.SHOW_LBOX) {
			// don't show the image, because we will invoke lytebox immediately
		} else {
			var sp = "<span style='padding-left:25px; color:#C6C6C6; font-size:";
			altContentHTML += 
				"<div style='padding:10px;'>" + 
					sp+"1.5em; font-weight: bold; " +this.FONT+ "'>You're clicks away from going full screen!</span><br>" + 
					sp+".9em; padding-bottom: 15px; " +this.FONT+ "'>You must get the <a href='"+downloadPL+"' style='color:#656588'>Cooliris</a> browser plugin, or "+flashMessage+".</span>" +
				"</div>";
			if (!this.BUTTON_URL) {
				altContentHTML +=
				'<a href="' + downloadPL + '" style="color:#ACD">Get Cooliris Now!</a>';
			} else {
				var area = '<area shape="rect" coords=';
				altContentHTML +=
				'<img src="'+this.BUTTON_URL+'" alt="" border="0" usemap="#Map">' + 
				'<map name="Map" id="Map">' + 
					area+'"0,0,33,33" href="#" onclick="javascript:PicLensLite.closeFlashUI();" />' +
					area+'"35,35,325,325" href="' + downloadPL +'" />' +
					area+'"593,209,825,301" href="' + this.FLASH_URL +'" />' +
					area+'"327,148,448,178" href="' + learnPL +'" />' +
				'</map>';
			}
		}

		altContentHTML += '</div>';
		altContentHTML += basicSlideShow;
		altContentHTML += '<div align="center" style="color:#666666; font-size:11px; '+this.FONT+'">&copy; 2008 Cooliris, Inc. All trademarks are property of their respective holders.<br><br><br></div>';
		altContentHTML += '</div>';
		return altContentHTML;		
	},
	generateFlashVars : function () {
		var fv = '';
		var args = this.ARGS;
		if (typeof args.guid !== 'undefined') {
			fv += "&startItemGUID=" + args.guid;
		}
		if (args.loadFeedInFlash) {
			fv += "&feedURL=" + encodeURIComponent(this.THE_FEED_URL);	// may need crossdomain.xml to allow loading of feed
		}
		if (args.paused) {
			fv += "&paused=" + args.paused;
		}
		if (args.loop) {
			fv += "&loop=" + args.loop;
		}
		if (args.delay) { // seconds: from 1-10
			fv += "&delay=" + args.delay;
		}
		if (args.pid) {
			fv += "&pid=" + args.pid;
		}
		if (typeof args.maxScale != 'undefined') {	// allow 0
			fv += "&maxScale=" + args.maxScale;
		}
		if (typeof args.overlayToolbars != 'undefined') {
			fv += "&overlayToolbars=" + args.overlayToolbars;
		}
		var cb = this.CUSTOM_BUTTON;
		if (cb != null) {
			fv += "&cButtonURL=" + encodeURIComponent(cb.targetURL);
			if (cb.labelText != null) {
				fv += "&cButtonLabel=" + encodeURIComponent(cb.labelText);
			}
			if (cb.iconImage != null) {
				fv += "&cButtonIcon=" + encodeURIComponent(cb.iconImage);
			}
		}
		fv += "&swfURL="+encodeURIComponent(this.LITE_URL);
		fv = fv.substring(1); // kill the first &
		return fv;
	},
	// does the right thing for each browser
	// returns the Flash object, so we can communicate with it over the ExternalInterface
	getFlash : function () {
		// we should determine which one to pass back depending on Browser/OS configuration
		if (this.BROWSER_SAF || this.BROWSER_IE) {
			return document.getElementById(this.FLASH_ID_1); // outer <object>
		} else {
			return document.getElementById(this.FLASH_ID_2); // inner <object>
		}
	},
	getWindowSize : function () { // inner size
		var docElement = document.documentElement;
		var docBody = document.body;
		var w = 0, h = 0;
		if (typeof(window.innerWidth) == 'number') {
			// not IE
			w = window.innerWidth;
			h = window.innerHeight;
		} else if (docElement && (docElement.clientWidth || docElement.clientHeight)) {
			// IE 6+ in 'standards compliant mode'
			w = docElement.clientWidth;
			h = docElement.clientHeight;
		} else if (docBody && (docBody.clientWidth || docBody.clientHeight)) {
			// IE 4 compatible
			w = docBody.clientWidth;
			h = docBody.clientHeight;
		}
		return {w:w, h:h};
	},
	handleKeyPress : function (code) {
		if (!this.isRunning()) {return true;}
		var fl = this.getFlash();
		if (fl != null && fl.fl_keyPressed) {
			fl.fl_keyPressed(code); // forward to Flash
		} else {
			if (code == 27) { // ESC to close
				this.closeFlashUI();
				return false;
			}
		}
		if (code == 9 || code == 13) { // trap tab, enter
			return false;
		}
		return true; // allow the browser to process the key
	},
	handleMouseWheel : function (e) {
		// e.wheelDelta
		// Safari/Windows (MouseWheel Up is +120; Down is -120)
		var delta = 0;
		if (!e) {
			e = window.event;
		}
		if (e.wheelDelta) { // IE/Opera
			delta = e.wheelDelta/120;
			if (window.opera) {
				delta = -delta;
			}
		} else if (e.detail) { // Firefox/Moz
			var d = e.detail;
			// on mac, don't divide by 3...
			if (Math.abs(d) < 3) {
				delta = -d;
			} else {
				delta = -d/3;
			}
		}
		if (delta) {
			// don't send abs values < 1; otherwise, you can only scroll next
			PicLensLite.sendMouseScrollToFlash(delta);		
		}
		if (e.preventDefault) {
			e.preventDefault();
		}
		e.returnValue = false;
		return false;
	},
	hasPicLensClient : function () { // DEPRECATED! Use hasClient()
		return this.hasCooliris();
	},
	// check if Cooliris Client is available
	hasCooliris : function () {
		// a flag to turn off the client
		if (this.DEBUG_NOCLIENT) {
			return false;
		}
		
		// check if the bridge has already been defined
		var clientExists = false;
		if (this.PLC) {
			clientExists = true;
		} else if (window.piclens && window.piclens.launch) {
			this.PLC = window.piclens;
			clientExists = true;
		} else { // if not, try to define it here...
			var context = null;
			if (typeof PicLensContext != 'undefined') { // Firefox
				context = new PicLensContext();
			} else {									
				try { 
					context = new ActiveXObject("PicLens.Context"); // IE
				} catch (e) {
					if (navigator.mimeTypes['application/x-cooliris']) { // Safari
						context = document.createElement('object');
						context.style.display = 'none';
						context.width = 0;
						context.height = 0;
						context.type = 'application/x-cooliris';
						document.documentElement.appendChild(context);
					} else {
						context = null;
					}
				}
			}
			
			this.PLC = context;
			if (this.PLC) {
				clientExists = true;
			}
		}
		
		if (clientExists) { // check the version number
			if (this.BROWSER_SAF) { // for Safari, we just return true (the first v. was 1.8)
				return true;
			}
				
			var version;
			try {version = this.PLC.version;} catch (e) {return false;}
						
			var parts = version.split('.'); // minimum ver. is: 1.6.0.824
			if (parts[0] > 1) {			    // a ver. 2.X product
				return true;
			} else if (parts[0] == 1) {	    // a 1.X product
				if (parts[1] > 6) {		    // a 1.7.X product
					return true;
				} else if (parts[1] == 6) { // a 1.6 product
					if (parts[2] > 0) {	    // a 1.6.1.X product
						return true;
					} else if (parts[2] == 0) {
						if (parts[3] >= 824) { // 1.6.0.824 or newer...
							return true;
						}
					}
				}
			}
			return false; // a 0.X product
		} else {
			return false;
		}
	},
	invokeLytebox : function () {
		this.SHOW_LBOX = true; // user has specified that she wants to use the basic slideshow
		myLytebox.start(document.getElementById("lboxImage"), false, false);
		this.closeFlashUI();
	},
	showLyteboxLink : function () {
		myLytebox.updateLyteboxItems();
		myLytebox.doAnimations = false;
		var lboxImages = document.getElementById('lightbox_images');
		if (lboxImages != null) {
			lboxImages.style.display = "block";
			if (this.SHOW_LBOX && this.getFlash()==null) { // the user has clicked on lbox once, so we assume it going forward
				this.invokeLytebox();
			}
		}
	},
	startLytebox : function () { // allows us to include lytebox, unmodified
		if (typeof myLytebox != "undefined") {
			this.showLyteboxLink();
		} else {
			if (typeof initLytebox != "undefined") {
				initLytebox();
				this.showLyteboxLink();
			} else {
				if (this.LBOX_COUNT >= 4) {
					return; // give up after 600 ms
				}
				setTimeout(function (){PicLensLite.startLytebox();}, 150); // try again in 150 ms
				this.LBOX_COUNT++;
			}
		}
	},
	injectFlashPlayer : function () {
		var fg = this.LITE_FG_DIV;
		
		// determine the width and height of the flash component
		var flashWInner;
		var flashHInner;
		flashWInner = flashHInner = '100%';
		if (this.BROWSER_IE6) {
			flashWInner = flashHInner = '0';
		}
		
		var flashVars = this.generateFlashVars();
		var altContentHTML = this.generateAlternativeContent(); // non-flash content

		if (this.meetsReqs()) {
			var par = '<param name=';
			fg.innerHTML = 
				'<object id="'+ this.FLASH_ID_1 +'" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" width="100%" height="100%">' + // SAF & IE
					par+'"movie" value="' + this.LITE_URL + '" />' +
					par+'"quality" value="high"/> ' +
					par+'"bgcolor" value="#000000"/> ' +
					par+'"allowScriptAccess" value="always"/> ' +
					par+'"FlashVars" value="' + flashVars + '"/> ' +
					par+'"allowFullScreen" value="true"/> ' +
					par+'"wmode" value="window"/> ' +
					par+'"scale" value="noscale"/> ' +
						'<object type="application/x-shockwave-flash" data="' + this.LITE_URL + '" width="'+flashWInner+'" height="'+flashHInner+'" ' + // NOT IE
							'quality="high" ' +
							'bgcolor="#000000" id="'+ this.FLASH_ID_2 + '" ' + 
							'quality="high" ' +
							'FlashVars="' + flashVars + '" ' +
							'allowFullScreen="true" ' +
							'scale="noscale" ' + 
							'wmode="window" ' +
							'allowScriptAccess="always">' +
							altContentHTML + // IE
						'</object>'+ // NOT IE
				'</object>';
		} else {
			if (this.ON_NO_PLUGINS) {
				this.ON_NO_PLUGINS(); // callback instead of showing NoFlash.jpg
			} else {
				fg.innerHTML = altContentHTML;
				fg.style.minWidth = "860px";
				fg.style.minHeight = "550px";
			}
		}
		
		if (this.BROWSER_SAF) {
			this.resizeUI(); // fixes layout 
		}
	},
	// find the RSS feeds on this page, and return an array
	indexFeeds : function () {
		var linkTags = document.getElementsByTagName("link");
		var feeds = [];
		for (var i = 0; i != linkTags.length; ++i) {
			var link = linkTags[i], type = link.getAttribute("type");
			if (type == "application/rss+xml" || type == "text/xml") {
				feeds.push({title: link.getAttribute("title"), url: link.getAttribute("href")});
			}
		}
		return feeds;
	},
	// once we get the response text, we launch flash
	loadViaXHR : function (url) {
		var self = this;
		var request = window.XMLHttpRequest ? new XMLHttpRequest() : new ActiveXObject("MSXML2.XMLHTTP.3.0");
		try {
			request.open("GET", url, true);
			request.onreadystatechange = function () {
				if (request.readyState == 4) {
					if ((request.status == 200 || request.status == 0)) { // 0 -> File System Testing
						if (request.responseText) {
							// at this point, we have the text
							self.showFlashUI(request.responseText);
						}
					} else {
						if (console) {console.log("PicLens Lite could not load the RSS Feed: " + url);}
					}
				}
			};
			request.send("");
		} catch (err) { // probably a crossdomain issue, so ask flash to try loading
			this.ARGS.loadFeedInFlash = true;
			this.showFlashUI("");
		}
	},
	meetsReqs : function () {
		if (this.DEBUG_NOFLASH) {
			return false;
		}
		// if IE7 and Flash detect returns v0, we show the Flash
		var ie7FlashDetectionWorkaround = (this.FLASH_VER.major == 0) && this.BROWSER_IE;
		var hasFlash = swfobjlite.hasFlashPlayerVersion("9.0.28");
		return hasFlash || ie7FlashDetectionWorkaround;
	},
	removeChildren : function () {
		this.REMOVE_TIMER_ID = 0;
		// remove the divs after a timeout
		if (this.LITE_BG_DIV !== null) {
			document.body.removeChild(this.LITE_BG_DIV);
			this.LITE_BG_DIV = null;
		}
		if (this.LITE_FG_DIV !== null) {
			document.body.removeChild(this.LITE_FG_DIV);
			this.LITE_FG_DIV = null;
		}
	},
	resizeFlashToFitPaddedBox : function () {
		var flash = this.getFlash();
		if (flash) {
			var size = this.getPageSize();
			var w = size.w - this.HPAD * 2;
			var h = size.h - this.VPAD * 2;
			flash.style.width = w;flash.style.height = h;
			flash.width = w;flash.height = h;
		}
	},
	resizeToFitPaddedBox : function (s, size) {
		if (typeof size == 'undefined') {
			size = this.getPageSize();
		}
		s.width = (size.w - this.HPAD * 2) + 'px';
		s.height = (size.h - this.VPAD * 2) + 'px';
	},
	resizeToPaddedBox : function (s) {
		s.left = s.right = this.HPAD + 'px';
		s.top = s.bottom = this.VPAD + 'px';
	},
	resizeUI : function () { // resize handler for Safari
		if (this.LITE_FG_DIV) {
			var fgs = this.LITE_FG_DIV.style;
			this.resizeToPaddedBox(fgs);
			this.resizeToFitPaddedBox(fgs);
			this.resizeFlashToFitPaddedBox();
		}
	},
	setRunningFlag : function (flag) {
		this.LITE_IS_RUNNING = flag;
		this.piclensIsRunning_ = flag;
	},
	setResizeHandler : function () { // for safari
		if (!this.RESIZE_HANDLER_EXISTS && this.BROWSER_SAF) {
			var self = this;
			window.addEventListener('resize', function () {self.resizeUI();}, false);
			this.RESIZE_HANDLER_EXISTS = true;
		}
	},
	setResizeTimer : function () { // only do it for IE6...
		if (this.BROWSER_IE6) {
			this.RESIZE_TIMER_IE6 = setInterval(function () {PicLensLite.autoResize();}, 1000);
		}
	},
	showFlashUI : function (feedText) {
		this.THE_FEED = feedText; // is "" if we are loading the feed in Flash
		this.findScriptLocation();
		this.createBackgroundOverlay();
		this.createForegroundFlashComponent();
		if (this.BROWSER_IE) {
			this.appendElementsToDocument();
		}
		this.injectFlashPlayer();
		if (!this.BROWSER_IE) {
			// Win Firefox needs this to be last
			// Other Browsers are OK with this
			this.appendElementsToDocument(); 
		}
		this.addKeyHandlers();
		this.addMouseHandlers();
		this.setRunningFlag(true);
		this.setResizeTimer();
		this.setResizeHandler();
		this.startLytebox();
	},
	sendMouseScrollToFlash : function (delta) {
		if (!this.isRunning()) {return;}
		var fl = this.getFlash();
		if (fl != null && fl.fl_mouseMoved) {
			fl.fl_mouseMoved(delta);
		}
	}
	// don't end the last function with a comma; it messes up IE7
};

/* SWFObject v2.0 <http://code.google.com/p/swfobject/> / Copyright 2007 Geoff Stearns, Michael Williams, and Bobby van der Sluis / MIT License */
var swfobjlite = function() {
	var UNDEF = "undefined",
		OBJECT = "object",
		SHOCKWAVE_FLASH = "Shockwave Flash",
		SHOCKWAVE_FLASH_AX = "ShockwaveFlash.ShockwaveFlash",
		win = window,
		doc = document,
		nav = navigator;
	
	var ua = function() {
		var w3cdom = typeof doc.getElementById != UNDEF && typeof doc.getElementsByTagName != UNDEF && typeof doc.createElement != UNDEF && typeof doc.appendChild != UNDEF
					&& typeof doc.replaceChild != UNDEF && typeof doc.removeChild != UNDEF && typeof doc.cloneNode != UNDEF,
			playerVersion = [0,0,0],
			d = null;
		if (typeof nav.plugins != UNDEF && typeof nav.plugins[SHOCKWAVE_FLASH] == OBJECT) {
			d = nav.plugins[SHOCKWAVE_FLASH].description;
			if (d) {
				d = d.replace(/^.*\s+(\S+\s+\S+$)/, "$1");
				playerVersion[0] = parseInt(d.replace(/^(.*)\..*$/, "$1"), 10);
				playerVersion[1] = parseInt(d.replace(/^.*\.(.*)\s.*$/, "$1"), 10);
				playerVersion[2] = /r/.test(d) ? parseInt(d.replace(/^.*r(.*)$/, "$1"), 10) : 0;
			}
		}
		else if (typeof win.ActiveXObject != UNDEF) {
			var a = null, fp6Crash = false;
			try {
				a = new ActiveXObject(SHOCKWAVE_FLASH_AX + ".7");
			}
			catch(e) {
				try { 
					a = new ActiveXObject(SHOCKWAVE_FLASH_AX + ".6");
					playerVersion = [6,0,21];
					a.AllowScriptAccess = "always";  // Introduced in fp6.0.47
				}
				catch(e) {
					if (playerVersion[0] == 6) {
						fp6Crash = true;
					}
				}
				if (!fp6Crash) {
					try {
						a = new ActiveXObject(SHOCKWAVE_FLASH_AX);
					}
					catch(e) {}
				}
			}
			if (!fp6Crash && a) { // a will return null when ActiveX is disabled
				try {
					d = a.GetVariable("$version");  // Will crash fp6.0.21/23/29
					if (d) {
						d = d.split(" ")[1].split(",");
						playerVersion = [parseInt(d[0], 10), parseInt(d[1], 10), parseInt(d[2], 10)];
					}
				}
				catch(e) {}
			}
		}
		var u = nav.userAgent.toLowerCase(),
			p = nav.platform.toLowerCase(),
			webkit = /webkit/.test(u) ? parseFloat(u.replace(/^.*webkit\/(\d+(\.\d+)?).*$/, "$1")) : false, // returns either the webkit version or false if not webkit
			ie = false,
			windows = p ? /win/.test(p) : /win/.test(u),
			mac = p ? /mac/.test(p) : /mac/.test(u);
		/*@cc_on
			ie = true;
			@if (@_win32)
				windows = true;
			@elif (@_mac)
				mac = true;
			@end
		@*/
		return {w3cdom:w3cdom, pv:playerVersion, webkit:webkit, ie:ie, win:windows, mac:mac};
	}();

	return { // PUBLIC API
		hasFlashPlayerVersion : function(rv) {
			var pv = ua.pv, v = rv.split(".");
			v[0] = parseInt(v[0], 10);
			v[1] = parseInt(v[1], 10);
			v[2] = parseInt(v[2], 10);
			return (pv[0] > v[0] || (pv[0] == v[0] && pv[1] > v[1]) || (pv[0] == v[0] && pv[1] == v[1] && pv[2] >= v[2])) ? true : false;
		},
		getFlashPlayerVersion: function() {
			return {major:ua.pv[0], minor:ua.pv[1], release:ua.pv[2]};
		}
	};
}();

/* BrowserDetect: http://www.quirksmode.org/js/detect.html */
var BrowserDetect={
	init:function() {this.browser = this.searchString(this.dataBrowser) || "Unknown Browser";this.version = this.searchVersion(navigator.userAgent) || this.searchVersion(navigator.appVersion) || "Unknown Version";this.OS = this.searchString(this.dataOS) || "Unknown OS";},
	searchString:function(data) {for (var i=0;i<data.length;i++)	{var dataString = data[i].string;var dataProp = data[i].prop;this.versionSearchString = data[i].versionSearch || data[i].identity;if (dataString) {if (dataString.indexOf(data[i].subString) != -1) {return data[i].identity;}} else if (dataProp) {return data[i].identity;}}},
	searchVersion:function(dataString) {var index = dataString.indexOf(this.versionSearchString);if (index == -1) {return;}return parseFloat(dataString.substring(index+this.versionSearchString.length+1));},
	dataBrowser:[
		{string: navigator.userAgent, subString: "OmniWeb", versionSearch: "OmniWeb/", identity: "OmniWeb"},
		{string: navigator.vendor, subString: "Apple", identity: "Safari"},
		{prop: window.opera, identity: "Opera"},
		{string: navigator.vendor, subString: "iCab", identity: "iCab"},
		{string: navigator.vendor, subString: "KDE", identity: "Konqueror"},
		{string: navigator.userAgent, subString: "Firefox", identity: "Firefox"},
		{string: navigator.vendor, subString: "Camino", identity: "Camino"},
		{string: navigator.userAgent, subString: "Netscape", identity: "Netscape"}, // newer Netscapes (6+)
		{string: navigator.userAgent, subString: "MSIE", identity: "Explorer", versionSearch: "MSIE"},
		{string: navigator.userAgent, subString: "Gecko", identity: "Mozilla", versionSearch: "rv"},
		{string: navigator.userAgent, subString: "Mozilla", identity: "Netscape", versionSearch: "Mozilla"} // older Netscapes (4-)
	],
	dataOS:[{string: navigator.platform, subString: "Win", identity: "Windows"}, {string: navigator.platform, subString: "Mac", identity: "Mac"}, {string: navigator.platform, subString: "Linux", identity: "Linux"} ]
};

// ===== CPAINT BIBLIOTHEK =========================================

/**
* CPAINT - Cross-Platform Asynchronous INterface Toolkit
*
* http://sf.net/projects/cpaint
* 
* released under the terms of the LGPL
* see http://www.fsf.org/licensing/licenses/lgpl.txt for details
*
* @package      CPAINT
* @access       public
* @copyright    Copyright (c) 2005-2006 Paul Sullivan, Dominique Stender - http://sf.net/projects/cpaint
* @author       Paul Sullivan <wiley14@gmail.com>
* @author       Dominique Stender <dstender@st-webdevelopment.de>
* @author		Stephan Tijink <stijink@googlemail.com>
* @version      2.0.3
*/
function cpaint() {
  /**
  * CPAINT version
  * 
  * @access     protected
  * @var        string      version
  */
  this.version = '2.0.3';
  
  /**
  * configuration options both for this class but also for  the cpaint_call() objects.
  *
  * @access     protected
  * @var        array       config
  */
  var config                      = new Array();
  config['debugging']             = -1;
  config['proxy_url']             = '';
  config['transfer_mode']         = 'GET';
  config['async']                 = true;
  config['response_type']         = 'OBJECT';
  config['persistent_connection'] = false;
  config['use_cpaint_api']        = true;
  
  /**
  * maintains the next free index in the stack
  *
  * @access   protected
  * @var      integer   stack_count
  */
  var stack_count = 0;

  /**
  * property returns whether or not the browser is AJAX capable
  * 
  * @access		public
  * @return		boolean
  */
  this.capable = -1;
  

  /**
  * sets the transfer_mode (GET|POST).
  *
  * @access   public
  * @param    string    transfer_mode    transfer_mode
  * @return   void
  */
  this.set_transfer_mode = function() {
    
    if (arguments[0].toUpperCase() == 'GET' || arguments[0].toUpperCase() == 'POST') {

      config['transfer_mode'] = arguments[0].toUpperCase();
    }
  };

  /**
  * sets the flag whether or not to use asynchronous calls.
  *
  * @access   public
  * @param    boolean    async    syncronization flag
  * @return   void
  */
  this.set_async = function() {
    
    if (typeof arguments[0] == 'boolean') {
      config['async'] = arguments[0];
    }
  };

  /**
  * defines the response type.
  *
  * allowed values are:
  *   TEXT    = raw text response
  *   XML     = raw XMLHttpObject
  *   OBJECT  = parsed JavaScript object structure from XMLHttpObject
  *
  * the default is OBJECT.
  *
  * @access   public
  * @param    string    response_type    response type
  * @return   void
  */
  this.set_response_type = function() {
    
    if (arguments[0].toUpperCase() == 'TEXT' || arguments[0].toUpperCase() == 'XML' || arguments[0].toUpperCase() == 'OBJECT') {

      config['response_type'] = arguments[0].toUpperCase();
    }
  };

  /**
  * sets the flag whether or not to use a persistent connection.
  *
  * @access   public
  * @param    boolean    persistent_connection    persistance flag
  * @return   void
  */
  this.set_persistent_connection = function() {
    
    if (typeof arguments[0] == 'boolean') {
      config['persistent_connection'] = arguments[0];
    }
  };
  
  /**
  * takes the arguments supplied and triggers a call to the CPAINT backend
  * based on the settings.
  *
  * upon response cpaint_call.callback() will automatically be called
  * to perform post-processing operations.
  *
  * @access   public
  * @param    string    url                 remote URL to call
  * @param    string    remote_method       remote method to call
  * @param    object    client_callback     client side callback method to deliver the remote response to. do NOT supply a string!
  * @param    mixed     argN                remote parameters from now on
  * @return   void
  */
  this.call = function() {
    var use_stack = -1;
    
    if (config['persistent_connection'] === true && __cpaint_stack[0] != null) {

      switch (__cpaint_stack[0].get_http_state()) {
        case -1:
          // no XMLHttpObject object has already been instanciated
          // create new object and configure it
          use_stack = 0;
          break;
          
        case 4:
          // object is ready for a new request, no need to do anything
          use_stack = 0;
          break;
      }
      
    } else if (config['persistent_connection'] === true) {
      // persistent connection is active, but no object has been instanciated
      use_stack = 0;
      __cpaint_stack[use_stack] = new cpaint_call(use_stack, config, this.version);
    
    } else {
      // no connection persistance
      use_stack = stack_count;
      __cpaint_stack[use_stack] = new cpaint_call(use_stack, config, this.version);
    }

    // configure cpaint_call if allowed to
    if (use_stack != -1) {
      __cpaint_stack[use_stack].set_client_callback(arguments[2]);
      
        __cpaint_stack[use_stack].call_direct(arguments);

      // increase stack counter
      stack_count++;
    }
  };
}

/**
* internal FIFO stack of cpaint_call() objects.
*
* @access   protected
* @var      array    __cpaint_stack
*/
var __cpaint_stack = new Array();

/**
* local instance of cpaint_transformer
* MSIE is unable to handle static classes... sheesh.
*
* @access   public
* @var      object    __cpaint_transformer
*/
var __cpaint_transformer = new cpaint_transformer();

/**
* transport agent class
*
* creates the request object, takes care of the response, handles the 
* client callback. Is configured by the cpaint() object.
*
* @package      CPAINT
* @access       public
* @copyright    Copyright (c) 2005-2006 Paul Sullivan, Dominique Stender - http://sf.net/projects/cpaint
* @author       Dominique Stender <dstender@st-webdevelopment.de>
* @author       Paul Sullivan <wiley14@gmail.com>
* @param        integer     stack_id      stack Id in cpaint
* @param        array       config        configuration array for this call
* @param        string      version       CPAINT API version
*/
function cpaint_call() {
  /**
  * CPAINT version
  * 
  * @access     protected
  * @var        string      version
  */
  var version = arguments[2];
  
  /**
  * configuration options both for this class objects.
  *
  * @access     protected
  * @var        array       config
  */
  var config                      = new Array();
  config['debugging']             = arguments[1]['debugging'];
  config['proxy_url']             = arguments[1]['proxy_url'];
  config['transfer_mode']         = arguments[1]['transfer_mode'];
  config['async']                 = arguments[1]['async'];
  config['response_type']         = arguments[1]['response_type'];
  config['persistent_connection'] = arguments[1]['persistent_connection'];
  config['use_cpaint_api']        = arguments[1]['use_cpaint_api'];

  /**
  * XMLHttpObject used for this request.
  *
  * @access   protected
  * @var      object     httpobj
  */
  var httpobj    = false;

  /**
  * client callback function.
  *
  * @access   public
  * @var      function    client_callback
  */
  var client_callback;

  /**
  * stores the stack Id within the cpaint object
  *
  * @access   protected
  * @var      stack_id
  */
  var stack_id = arguments[0];
  
  /**
  * sets the client callback function.
  *
  * @access   public
  * @param    function    client_callback     the client callback function
  * @return   void
  */
  this.set_client_callback = function() {
    
    if (typeof arguments[0] == 'function') {
      client_callback = arguments[0];
    }
  };

  /**
  * returns the ready state of the internal XMLHttpObject
  *
  * if no such object was set up already, -1 is returned
  * 
  * @access     public
  * @return     integer
  */
  this.get_http_state = function() {
    var return_value = -1;
    
    if (typeof httpobj == 'object') {
      return_value = httpobj.readyState;
    }
    
    return return_value;
  };
  
  /**
  * internal method for remote calls to the local server without use of the proxy script.
  *
  * @access   public
  * @param    array    call_arguments    array of arguments initially passed to cpaint.call()
  * @return   void
  */
  this.call_direct = function(call_arguments) {
    var url             = call_arguments[0];
    var remote_method   = call_arguments[1];
    var querystring     = '';
    var i               = 0;
    
    // correct link to self
    if (url == 'SELF') {
      url = document.location.href;
    }
  
	  // backend uses cpaint api
	  // pass parameters to remote method
	  for (i = 3; i < call_arguments.length; i++) {
	
	    if ((typeof call_arguments[i] == 'string'
	          && call_arguments[i] != ''
	          && call_arguments[i].search(/^\s+$/g) == -1)
	      && !isNaN(call_arguments[i])
	      && isFinite(call_arguments[i])) {
	      // numerical value, convert it first
	      querystring += '&cpaint_argument[]=' + encodeURIComponent(JSON.stringify(Number(call_arguments[i])));
	    
	    } else {
	      querystring += '&cpaint_argument[]=' + encodeURIComponent(JSON.stringify(call_arguments[i]));
	    }
	  }
	
	  // add response type to querystring
	  querystring += '&cpaint_response_type=' + config['response_type'];
	
	  // build header
	  if (config['transfer_mode'] == 'GET') {
				
	    if(url.indexOf('?') != -1) {
					url = url + '&cpaint_function=' + remote_method +	querystring;
				
	    } else {
					url = url + '?cpaint_function=' + remote_method +	querystring; 
				}
	  
	  } else {
	    querystring = 'cpaint_function=' + remote_method + querystring;
	  }
  
    // open connection 
    get_connection_object();

    // open connection to remote target
    httpobj.open(config['transfer_mode'], url, config['async']);

    // send "urlencoded" header if necessary (if POST)
    if (config['transfer_mode'] == 'POST') {

        httpobj.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
    }

    // callback handling for asynchronous calls
    httpobj.onreadystatechange = callback;

    // send content
    if (config['transfer_mode'] == 'GET') {
      httpobj.send(null);

    } else {
      httpobj.send(querystring);
    }

    if (config['async'] === true) {
      // manual callback handling for synchronized calls
      callback();
    }
  };
    
  /**
  * creates a new connection object.
  *
  * @access   protected
  * @return   boolean
  */
  var get_connection_object = function() {
    var return_value    = false;
    var new_connection  = false;

    // open new connection only if necessary
    if (config['persistent_connection'] === false) {
      // no persistance, create a new object every time
      new_connection = true;

    } else {
      // persistent connection object, only open one if no object exists

      if (typeof httpobj != 'object') {
        new_connection = true;
      }
    }

    if (new_connection === true) {
		
	 try {
        httpobj = new XMLHttpRequest();
      } catch (e1) {

		  try {
			httpobj = new ActiveXObject('Msxml2.XMLHTTP');
	  
		  } catch (e) {
			
			try {  
			  httpobj = new ActiveXObject('Microsoft.XMLHTTP');
 
			} catch (oc) {
			  httpobj = null;
			} 
		 }
	  }
     
  
      if (!httpobj) {
      
      } else {
        return_value = true;
      }
    }

    if (httpobj.readyState != 4) {
      httpobj.abort();
    }

    return return_value;
  };

  /**
  * internal callback function.
  *
  * will perform some consistency checks (response code, NULL value testing)
  * and if response_type = 'OBJECT' it will automatically call
  * cpaint_call.parse_ajax_xml() to have a JavaScript object structure generated.
  *
  * after all that is done the client side callback function will be called 
  * with the generated response as single value.
  *
  * @access   protected
  * @return   void
  */
  var callback = function() {
    var response = null;

    if (httpobj.readyState == 4
      && httpobj.status == 200) {
      
      // fetch correct response
      switch (config['response_type']) {
        case 'XML':
          response = __cpaint_transformer.xml_conversion(httpobj.responseXML);
          break;
          
        case 'OBJECT':
          response = __cpaint_transformer.object_conversion(httpobj.responseXML);
          break;
        
        case 'TEXT':
          response = __cpaint_transformer.text_conversion(httpobj.responseText);
          break;
      }
      
      // call client side callback
      if (response != null 
        && typeof client_callback == 'function') {
        client_callback(response, httpobj.responseText);
      }
      
      // remove ourselves from the stack
      remove_from_stack();
    
    } else if (httpobj.readyState == 4
      && httpobj.status != 200) {
    }
  };

  /**
  * removes an entry from the stack
  *
  * @access     protected
  * @return     void
  */
  var remove_from_stack = function() {
    // remove only if everything is okay and we're not configured as persistent connection
    if (typeof stack_id == 'number'
      && __cpaint_stack[stack_id]
      && config['persistent_connection'] === false) {
      
      __cpaint_stack[stack_id] = null;
    }
  };
}

/**
* CPAINT transformation object
*
* @package      CPAINT
* @access       public
* @copyright    Copyright (c) 2005-2006 Paul Sullivan, Dominique Stender - http://sf.net/projects/cpaint
* @author       Paul Sullivan <wiley14@gmail.com>
* @author       Dominique Stender <dstender@st-webdevelopment.de>
*/
function cpaint_transformer() {

  /**
  * will take a XMLHttpObject and generate a JavaScript
  * object structure from it.
  *
  * is internally called by cpaint_call.callback() if necessary.
  * will call cpaint_call.create_object_structure() to create nested object structures.
  *
  * @access   public
  * @param    object    xml_document  a XMLHttpObject
  * @return   object
  */
  this.object_conversion = function(xml_document) {
    var return_value  = new cpaint_result_object();
    var i             = 0;
    var firstNodeName = '';
    
    if (typeof xml_document == 'object' && xml_document != null) {

      // find the first element node - for MSIE the <?xml?> node is the very first...
      for (i = 0; i < xml_document.childNodes.length; i++) {

        if (xml_document.childNodes[i].nodeType == 1) {
          firstNodeName = xml_document.childNodes[i].nodeName;
          break;
        }
      }
      
      var ajax_response = xml_document.getElementsByTagName(firstNodeName);

      return_value[firstNodeName] = new Array();
    
      for (i = 0; i < ajax_response.length; i++) {
        var tmp_node = create_object_structure(ajax_response[i]);
        tmp_node.id  = ajax_response[i].getAttribute('id');
        return_value[firstNodeName].push(tmp_node);
      }

    }

    return return_value;
  };

  /**
  * performs the necessary conversions for the XML response type
  *
  * @access   public
  * @param    object    xml_document  a XMLHttpObject
  * @return   object
  */
  this.xml_conversion = function(xml_document) {
    return xml_document;
  };
  
  /**
  * performs the necessary conversions for the TEXT response type
  *
  * @access   public
  * @param    string    text  the response text
  * @return   string
  */
  this.text_conversion = function(text) {
    return decode(text);
  };

  
  /**
  * this method takes a HTML / XML node object and creates a
  * JavaScript object structure from it.
  *
  * @access   public
  * @param    object    stream    a node in the XML structure
  * @return   object
  */
  var create_object_structure = function(stream) {
    var return_value = new cpaint_result_object();
    var node_name = '';
    var i         = 0;
    var attrib    = 0;
    
    if (stream.hasChildNodes() === true) {
      for (i = 0; i < stream.childNodes.length; i++) {
  
        node_name = stream.childNodes[i].nodeName;
        node_name = node_name.replace(/[^a-zA-Z0-9_]*/g, '');
        
        // reset / create subnode
        if (typeof return_value[node_name] != 'object') {
          return_value[node_name] = new Array();
        }
        
        if (stream.childNodes[i].nodeType == 1) {
          var tmp_node  = create_object_structure(stream.childNodes[i]);

          for (attrib = 0; attrib < stream.childNodes[i].attributes.length; attrib++) {
            tmp_node.set_attribute(stream.childNodes[i].attributes[attrib].nodeName, stream.childNodes[i].attributes[attrib].nodeValue);
          }
          
          return_value[node_name].push(tmp_node);
        
        } else if (stream.childNodes[i].nodeType == 3) {
          return_value.data  = decode(String(stream.firstChild.data));
        }
      }
    }
    
    return return_value;
  };

  /**
  * converts an encoded text back to viewable characters.
  *
  * @access     public
  * @param      string      rawtext     raw text as provided by the backend
  * @return     mixed
  */
  var decode = function(rawtext) {
    var plaintext = ''; 
    var i         = 0; 
    var c1        = 0;
    var c2        = 0;
    var c3        = 0;
    var u         = 0;
    var t         = 0;

    // remove special JavaScript encoded non-printable characters
    while (i < rawtext.length) {
      if (rawtext.charAt(i) == '\\'
        && rawtext.charAt(i + 1) == 'u') {
        
        u = 0;
        
        for (j = 2; j < 6; j += 1) {
          t = parseInt(rawtext.charAt(i + j), 16);
          
          if (!isFinite(t)) {
            break;
          }
          u = u * 16 + t;
        }

        plaintext += String.fromCharCode(u);
        i       += 6;
      
      } else {
        plaintext += rawtext.charAt(i);
        i++;
      }
    }

    // convert numeric data to number type
    if (plaintext != ''
      && plaintext.search(/^\s+$/g) == -1
      && !isNaN(plaintext) 
      && isFinite(plaintext)) {
      
      plaintext = Number(plaintext);
    }
  
    return plaintext;
  };
}

/**
* this is the basic prototype for a cpaint node object
* as used in cpaint_call.parse_ajax_xml()
*
* @package      CPAINT
* @access       public
* @copyright    Copyright (c) 2005-2006 Paul Sullivan, Dominique Stender - http://sf.net/projects/cpaint
* @author       Paul Sullivan <wiley14@gmail.com>
* @author       Dominique Stender <dstender@st-webdevelopment.de>
*/
function cpaint_result_object() {
  this.id           = 0;
  this.data         = '';
  var __attributes  = new Array();
  
  /**
  * retrieves the value of an attribute.
  *
  * @access   public
  * @param    string    name    name of the attribute
  * @return   mixed
  */
  this.get_attribute = function() {
    var return_value  = null;
    var id            = arguments[0];
    
    if (typeof __attributes[id] != 'undefined') {
      return_value = __attributes[id];
    }
    
    return return_value;
  };
  
  /**
  * assigns a value to an attribute.
  *
  * if that attribute does not exist it will be created.
  *
  * @access     public
  * @param      string    name    name of the attribute
  * @param      string    value   value of the attribute
  * @return     void
  */
  this.set_attribute = function() {
    __attributes[arguments[0]] = arguments[1];
  };
}


/*
Copyright (c) 2005 JSON.org

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The Software shall be used for Good, not Evil.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/

Array.prototype.______array = '______array';

var JSON = {

  stringify: function (arg) {
    var c, i, l, s = '', v;
    var numeric = true;
    
    switch (typeof arg) {
    case 'object':
      if (arg) {
        if (arg.______array == '______array') {
          // do a test whether all array keys are numeric
          for (i in arg) {
            if (i != '______array'
              && (isNaN(i) 
                || !isFinite(i))) {
              numeric = false;
              break;
            }
          }
          
          if (numeric === true) {
            for (i = 0; i < arg.length; ++i) {
              if (typeof arg[i] != 'undefined') {
                v = this.stringify(arg[i]);
                if (s) {
                  s += ',';
                }
                s += v;
              } else {
                s += ',null';
              }
            }
            return '[' + s + ']';
          } else {
            for (i in arg) {
              if (i != '______array') {
                v = arg[i];
                if (typeof v != 'undefined' && typeof v != 'function') {
                  v = this.stringify(v);
                  if (s) {
                    s += ',';
                  }
                  s += this.stringify(i) + ':' + v;
                }
              }
            }
            // return as object
            return '{' + s + '}';
          }
        } else if (typeof arg.toString != 'undefined') {
          for (i in arg) {
            v = arg[i];
            if (typeof v != 'undefined' && typeof v != 'function') {
              v = this.stringify(v);
              if (s) {
                s += ',';
              }
              s += this.stringify(i) + ':' + v;
            }
          }
          return '{' + s + '}';
        }
      }
      return 'null';
    case 'number':
      return isFinite(arg) ? String(arg) : 'null';
    case 'string':
      l = arg.length;
      s = '"';
      for (i = 0; i < l; i += 1) {
        c = arg.charAt(i);
        if (c >= ' ') {
          if (c == '\\' || c == '"') {
            s += '\\';
          }
          s += c;
        } else {
          switch (c) {
            case '\b':
              s += '\\b';
              break;
            case '\f':
              s += '\\f';
              break;
            case '\n':
              s += '\\n';
              break;
            case '\r':
              s += '\\r';
              break;
            case '\t':
              s += '\\t';
              break;
            default:
              c = c.charCodeAt();
              s += '\\u00' + Math.floor(c / 16).toString(16) + (c % 16).toString(16);
          }
        }
      }
      return s + '"';
    case 'boolean':
      return String(arg);
    default:
      return 'null';
    }
  }
};

// ===== AJAX FUNKTIONALITAET ======================================

// Browser auf Ajax-Kompatibilitaet testen und initialisieren
initAjax();

function initAjax ()
{
    // Blacklist with non-compatible browsers
    var browserBlackList = new Array ("MSIE||Mac_PowerPC", "Opera||7||Windows", "MSIE 5.0", "Konqueror/3.2", "Safari/100.1");

    // review Blacklist
    for (i=0; i < browserBlackList.length; i++) {
        var results = 0;
        var arguments = browserBlackList[i].split ("||");

        for (j=0; j < arguments.length; j++) {
            if (navigator.userAgent.indexOf(arguments[j]) > -1) {results++;}
        }
    }

    // create cpaint object
    cp = new cpaint();
    cp.set_transfer_mode('GET');
    cp.set_response_type('OBJECT');
}

// ===== FORMULARE =================================================

function form_expand_optional() {

	var optional_area 	= document.getElementById("id_form_optional-foldeable");
	var icon_expand   	= document.getElementById("form_icon_expand"); 
	var icon_lock		= document.getElementById("form_icon_lock"); 
	
	if (optional_area.style.display == "none") {
		optional_area.style.display = "inline";
		icon_lock.style.display 	= "inline";
		icon_expand.src 			= "/gfx/form/form_icon_unexpand.gif";
	}
	else {
		optional_area.style.display = "none";
		icon_lock.style.display 	= "none";
		icon_expand.src 			= "/gfx/form/form_icon_expand.gif";
	}
	
	return (false);
}

function form_expand_optional2() {

	var optional_area 	= document.getElementById("id_form_optional-foldeable2");
	var icon_expand   	= document.getElementById("form_icon_expand2"); 
	
	if (optional_area.style.display == "none") {
		optional_area.style.display = "inline";
		icon_expand.src 			= "/gfx/form/form_icon_unexpand.gif";
	}
	else {
		optional_area.style.display = "none";
		icon_expand.src 			= "/gfx/form/form_icon_expand.gif";
	}
	
	return (false);
}

function form_lock_unlock() {

	var formular_status = document.getElementById("formular_status");
	var icon_lock	  	= document.getElementById("form_icon_lock"); 
	
	if (formular_status.value == "1") {
		formular_status.value 	= "0";
		icon_lock.src 			= "/gfx/form/form_icon_unlocked.gif";
	}
	else {
		formular_status.value 	= "1";
		icon_lock.src 			= "/gfx/form/form_icon_locked.gif";
	}
}

function form_cancel (url) {

	window.location.href = url;
	return (false);
}

// ===== FOTO ANZEIGE ==============================================

	function checkKey(keycode) {
		if (keycode == chr(13)) {
			return j_wait();
		} else {
			return false;
		}
	}

	function j_wait() {
		document.getElementById("wait").innerHTML = "<?php echo $t_e_comment_button_passive; ?>";
		document.getElementById("wait").style.paddingTop = "4px";
		document.getElementById("butt").style.position = "absolute";
		document.getElementById("butt").style.visibility = "hidden";
		return true;
	}

// ===== UPDATE SETTINGS ===========================================

function checkmailoption() {
	if (document.getElementById('datesec').checked == false) {
		document.getElementById('datesec2').checked = false;
	}
}
function checkmailoption2() {
	if (document.getElementById('datesec2').checked == true) {
		document.getElementById('datesec').checked = true;
	}
}

// ===== MEDIEN-KOOPERATION (INFOSCREEN) ===========================

function takeit (descr) {
var from = '';
	from +=	'<table align="left" width="140" border="0" cellspacing="0" cellpadding="2">';
	from +=	'	<tr bgcolor="#666666">';
	from +=	'		<td><b><font color="#FFFFFF">verwendung in: <br> ';
	from +=	'<select name="takeit_verw" size="1">';
	for (var i = 1; i <= 56; i++) {
		from +=	'<option value="'+i+'">'+i+'. KW</option>';
	}
	from +=	'</select><input type="submit" class="Button" value="Absenden" onclick="takeit2('+descr+');"></font></b></td>';
	from +=	'	</tr>';
	from +=	'</table>';
	from +=	'';
	from +=	'';
	document.getElementById("takeit"+descr).innerHTML = from;

	}
function takeit2 (result) {
	cp.call ('/pc/inc/ajax_castandcrew.inc.php', 'takeit',resulttakeit,result,document.getElementsByName("takeit_verw")[0].value);
	}
function resulttakeit (result) {
	used = result.ajaxResponse[0].listitem[0].used[0].data;
	descr = result.ajaxResponse[0].listitem[0].descr[0].data;
	if (used == 1) {
		document.getElementById("takeit"+descr).innerHTML = '<font color=\"#00FF00\"><a onclick="takeit('+descr+');">[verwenden]</a></font>';
	}else {
		document.getElementById("takeit"+descr).innerHTML = '<font color=\"#FF0000\"><a onclick="takeit('+descr+');">[in Verwendung]</a></font>';
	}

}

// ===== EGALLERY ==================================================

function ClipBoard(id)
{
	Copied = id.createTextRange();
	Copied.execCommand("Copy");
}

function ClipPaste(id)
{
	var cbData = window.clipboardData.getData('Text');
	id.innerText = cbData;
}

// ===== FOTOMAIL FUNKTIONEN =======================================

function checkemail(){
	if (document.getElementById('empfaengeer').value == -2) {
		document.getElementById("email").style.display = "inline";
		document.getElementById("email_description").style.display = "inline";
		document.getElementById("name").style.display = "inline";
		document.getElementById("name_description").style.display = "inline";
	} else {
		document.getElementById("email").style.display = "none";
		document.getElementById("email_description").style.display = "none";
		document.getElementById("name").style.display = "none";
		document.getElementById("name_description").style.display = "none";
	}
	
}

function zitieren() {
  	        
  	  document.getElementById("nachricht").value = document.getElementById("nachricht").value + document.getElementById("hide").value;
  	  document.getElementById("nachricht").focus();
}

// ===== SUCHE =====================================================

function search_checkInput(formName,fieldNameX) {

	var fieldName = document.getElementById(fieldNameX);
        
        if (fieldName.value.length < 3) {
		fieldName.focus();
		return false;
	}
	else {
            var searchString = unescape(fieldName.value);
            
            var searchString2 = searchString.replace(/\//g, " ");
            var goodSearchString = searchString2.replace(/\./g, " ");
            var today = new Date();
            var expirationDate = new Date( parseInt(today.getTime() +10000) );
            document.cookie="searchTerm"+ "=" + fieldName.value+"; expires ="+ expirationDate.toGMTString() +"; path =/;";
            
            //zusaetzliche felder auswerten
            if(document.forms[formName].channel){
            	var selectedChannel = document.forms[formName].channel.value;
            }
            else{
            	var selectedChannel=0;
            }
            
            var oldAction = document.forms[formName].action;
            var newAction = oldAction + goodSearchString + '.html';
            
            var trenner = "?";
            
            if(selectedChannel > 0){
            	newAction = newAction + trenner + 'channel=' + selectedChannel;
            	trenner = "&";
            }
            if(document.forms[formName].user){
            	if(document.forms[formName].user.checked == true){
            		newAction = newAction + trenner + 'user=1';
            		trenner = "&";
            	}
            }
            if(document.forms[formName].sellable){
            	if(document.forms[formName].sellable.checked == true){
            		newAction = newAction + trenner + 'sellable=-1';
            	}
            }
            
            document.forms[formName].action = encodeURI(newAction);
            return true;
    }
}

function search_checkInput_and_submit(formName,fieldNameX) {

	var fieldName = document.getElementById(fieldNameX);
        
        if (fieldName.value.length < 3) {
		fieldName.focus();
		return false;
	}
	else {
            
            var searchString = unescape(fieldName.value);
            var searchString2 = searchString.replace(/\//g, " ");
            var goodSearchString = searchString2.replace(/\./g, " ");
            var oldAction = document.forms[formName].action;
            var newAction = oldAction + goodSearchString + '.html';
            document.forms[formName].action = encodeURI(newAction);
            //alert('encoded action: '+encodeURI(newAction));
            document.forms[formName].submit();
    }
}

// ===== LOGGING FOOTER ============================================

function show_full_log () {

	document.getElementById("sql_log").style.display = 'inline';
	document.getElementById("memcache_log").style.display = 'inline';
	document.getElementById("search_log").style.display = 'inline';
}

// ===== CALDENDAR PAPER ===========================================

function MM_reloadPage(init) {  //reloads the window if Nav4 resized
  if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
    document.MM_pgW=innerWidth;document.MM_pgH=innerHeight;onresize=MM_reloadPage;}}
  else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
}

// ===== VIDEO PLAYER ==============================================

function doCheck(){
   var sendText = "349547";
   window.document.myPlayer.SetVariable("revisor", sendText);
}

// =====CREATIVE COMMONS ===========================================

function creativecommons_toggle_licence_status() {
	
	var select_commercial 	 = 'licence_selection_commercial';
	var select_modifications = 'licence_selection_modifications';
	var licence_type		 = 'licence_selection';
	
	var licence_type_value	 = document.getElementById(licence_type).value;
	
	if (licence_type_value == 0) {
		
		// Keine Creative Commons. Die unteren beiden Select-Boxen werden deaktivert.
		document.getElementById(select_commercial).disabled 		= true;
		document.getElementById(select_modifications).disabled 		= true;
		
		document.getElementById(select_commercial).style.color 			= "#999999";
		document.getElementById(select_modifications).style.color 		= "#999999";
		
		document.getElementById(select_commercial).style.background 	= "#E9E9E9";
		document.getElementById(select_modifications).style.background 	= "#E9E9E9";
				
	}
	else {
		
		// Creative Commons ausgewaehlt. Die beiden Select-Boxen werden aktiviert.
		document.getElementById(select_commercial).disabled 	= false;
		document.getElementById(select_modifications).disabled 	= false;
		
		document.getElementById(select_commercial).style.color 			= "#000000";
		document.getElementById(select_modifications).style.color 		= "#000000";
		
		document.getElementById(select_commercial).style.background 	= "#FFFFFF";
		document.getElementById(select_modifications).style.background 	= "#FFFFFF";
	}
}

// =====FEED FILTER ===========================================
function check_all_checkboxes(formularname){
	var myform=document.forms[1]; //das erste formular ist immer das such-formular
	if (myform.feed_checkall.checked == true){
		var checkall = true;
	}
	else{
		var checkall = false;
	}
	for(var i=0;i<myform.length;i++){
		if(myform[i].name.substr(0,14) == 'formdata[feed_'){		
			myform[i].checked = checkall;
		}
	}
	return;
}

// =====MYPROFILE-Seite ===========================================

//eigene activity loeschen
function deleteActivity(line,which,userid){

	var zeile = "line_" + line;
	var sDiv = document.getElementById( zeile );
	var animOut = new YAHOO.util.Anim( sDiv, {opacity: {to: 0}}, 0.25, YAHOO.util.Easing.easeOut);
	animOut.animate();
	window.setTimeout("setDisplayNone('"+ zeile +"')", 300);
	cp.call('/pc/inc/ajax_deleteactivity.inc.php', 'delete_activity',checkRestActivity, which, userid);
}

//wenn es die letzte activity war, komplette box deaktivieren
function checkRestActivity(resultObject){
	var ajaxdata 		= resultObject.ajaxResponse[0].data;
	if(ajaxdata == 0){
		setDisplayNone('activities');
	}
}

//funktion zum unsichtbar-machen eines divs
function setDisplayNone(was){
	document.getElementById(was).style.display = 'none';
}


// =====FOTOCOMMUNITY MENUE ===========================================

// Angaben zu Grafiken und Icons
var gfx_base_url				= "/gfx";
var gfx_menu_url				= gfx_base_url+"/menu";

var menu_cookie_lifetime		= 30; // 30 Tage
var menu_cookie_prefix			= 'm_';

var icon_arrow_left				= gfx_menu_url+"/arrow_left.gif";
var icon_arrow_down 			= gfx_menu_url+"/arrow_down.gif";
var icon_arrow_left_small		= gfx_menu_url+"/arrow_left_small.gif";
var icon_arrow_down_small		= gfx_menu_url+"/arrow_down_small.gif";
var menu_header_img_left		= gfx_base_url+"/header/header_menu_left.gif";
var menu_header_img_down		= gfx_base_url+"/header/header_menu_down.gif";
var menu_header_img_left_mail	= gfx_base_url+"/header/header_menu_left_mail.gif";
var menu_header_img_down_mail	= gfx_base_url+"/header/header_menu_down_mail.gif";

// Angaben zu Farben
var textcolor_default		= "#FFFFFF";
var textcolor_active		= "#000000";

var backgroundcolor_active	= "#FF7920";
var backgroundcolor_alert	= "#FFCC00";
var backgroundcolor_level1	= "#585757";
var backgroundcolor_level2	= "#333333";


String.prototype.basicTrim = function () {
            return (this.replace(/\s+$/,"").replace(/^\s+/,""));
}  

// Hervorheben des Menu-Buttons bei Events
// wie erhalten einer Fotomail oder Quickmessage
function menu_hoover_button() {
	
	document.getElementById("fc_header_menukopf").style.backgroundImage = "url("+menu_header_img_down_mail+")";
}


function menu_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 menu_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 menu_change_menuImage () {
	
	var currentUsedClass = document.getElementById('fc_header_menukopf').className;
	
	if (currentUsedClass == 'fc_header_menukopf_hidden') {
		
		document.getElementById('fc_header_menukopf').style.backgroundImage = "url("+menu_header_img_down+")";
	}
	
	if (currentUsedClass == 'fc_header_menukopf_hidden_mail') {
		
		document.getElementById('fc_header_menukopf').style.backgroundImage = "url("+menu_header_img_down_mail+")";
	}	
}

function menu_change (name, level) {

	// Das DIV-Element, welches das Untermenue enthaelt
	if(name=='main') {
		var submenu = document.getElementById('menulayer_'+name);

	} else {
		var submenu = document.getElementById('ml_'+name);		
	}

	// Menue soll ausgeklappt werden. Pruefen, ob das Menue vorhanden ist, oder nachgeladen werden muss
	if (submenu.className == 'm_hide' || (submenu.className == 'menu' && name=='main')) {
		
		var menu_content = submenu.innerHTML.basicTrim();
	
		// Menu muss nachgeladen werden.
		if (menu_content.length < 2 || menu_content=='&nbsp;') {
			
			// Untermenu mittels AJAX nachladen
			cp.call('/pc/inc/ajax_menu.inc.php', 'menu_load', menu_render, name, level, menu_current_channel, menu_current_section, false);

		} else {			

			// Menue einblenden und Cookie setzen
			menu_createCookie (menu_cookie_prefix + name, 1, menu_cookie_lifetime);

			submenu.className = 'm_show';
		}

	}
	
	// Menue soll eingeklappt werden
	else {
		
		menu_createCookie (menu_cookie_prefix + name, 0, menu_cookie_lifetime);
		submenu.className = 'm_hide';

		// Fuer den IE 6 muss das Menue-HTML beim zuklappen komplett geleert werden,
		// sonst kommt es zu Darstellungs-Problemen.

		if (navigator.appName == 'Microsoft Internet Explorer' && navigator.appVersion.indexOf('MSIE 6.0') > 0) {		
			submenu.innerHTML = '&nbsp;';

		} else {

		}

	}
	
	// Wurde die Sichtbarkeit des gesamten Menues angepasst, dann Menu-Grafik anpassen. Dies ist auf den Foto-Detail Seiten der Fall.
	if (name == 'main') {menu_change_menuImage();}
}


function menu_render (resultObject) {
	
	var ajaxdata 		= resultObject.ajaxResponse[0];
	var menu_baseurl	= ajaxdata.b[0].data;
	
	// Aufruf der eigentlichen Render-Funktion.
	// diese kann rekrusiv aufgerufen werden, wenn
	// es offene untergeordnete Menues gibt.
	var submenu_html 	= menu_render_recrusivly (ajaxdata, menu_baseurl);
	
	var menu_name	= ajaxdata.n[0].data;
	var menu_level 	= ajaxdata.lvl[0].data;
	if(menu_name=='main') {
		var submenu		= document.getElementById('menulayer_'+ menu_name);

	} else {
		var submenu		= document.getElementById('ml_'+ menu_name);		
	}
	var menu_container	= document.getElementById('menu_container');
	
	// HTML Code in Seite schreiben
	submenu.innerHTML = submenu_html;

	// Untergeordnetes Menue einblenden
	if (navigator.appName == 'Microsoft Internet Explorer' && navigator.appVersion.indexOf('MSIE 6.0') > 0) {			
		submenu.className = 'm_show';

	} else {
		submenu.className = 'm_show';
	}

	menu_container.style.display = 'block';
	
	// Cookie setzen, damit das Menue zukuenftig immer offen bleibt.
	if (menu_level > 0) {	
		menu_createCookie (menu_cookie_prefix + menu_name, 1, menu_cookie_lifetime);
	}

}

function menu_render_recrusivly (ajaxdata, menu_baseurl) {
	
	// Daten entgegennehmen
	var menu_name 		= ajaxdata.n[0].data;
	var menu_level 		= ajaxdata.lvl[0].data;
	var number_items		= ajaxdata.i.length;

	// Spaeter benoetigte Variablen initialisieren
	var i;					// Schleifen-Zaehler
	var submenu_html = '';	// Enthaelt den generierten HTML-Code
	var submenu_key;		// Bezeichner des Untermenues
	var submenu_name;		// Name des Untermenues
	var submenu_link;		// Link des Untermenues
	var submenu_onclick;	// onclick des Untermenues
	var submenu_submenu;
	var submenu_alert;		// alert des Untermenues
	var submenu_children;	// children des Untermenues
	var submenu_cookie;
	var objects_to_render = new Array();
	var objects_to_render_counter = 0;
	
	// Wenn untergeordnete Menue-Punkte vorhanden sind,
	// diese abarbeiten
	if (number_items > 0) {
		
		// Schleife ueber alle untergeordneten Menue-Punkte
		for (i=0; i < number_items; i++) {
		
			// Default-Werte fuer die Variablen setzen
			submenu_link	 = '#';
			submenu_onclick	 = '';
			submenu_submenu	 = 0;
			submenu_alert	 = 0;
			submenu_children = 0;
			onclick_call	 = '';
			
			// Daten auslesen
			submenu_key		= ajaxdata.i[i].k[0].data;
			submenu_name	= ajaxdata.i[i].n[0].data;

			if (typeof ajaxdata.i[i].l != 'undefined') {
				submenu_link	 = ajaxdata.i[i].l[0].data;
				
				// Platzhalter durch tatsaechliche BASEURL ersetzen,
				// wenn notwendig.
				submenu_link = submenu_link.replace (/%URL%/, menu_baseurl);
			}
			
			if ( typeof ajaxdata.i[i].cl != 'undefined') {
				
				submenu_onclick	 = ajaxdata.i[i].cl[0].data;
				
				// Platzhalter durch tatsaechliche BASEURL ersetzen,
				// wenn notwendig.
				submenu_onclick = submenu_onclick.replace (/%URL%/, menu_baseurl);
			}
			
			if (typeof ajaxdata.i[i].a != 'undefined') { 
				submenu_alert	 = ajaxdata.i[i].a[0].data;
			}
			
			if (typeof ajaxdata.i[i].c != 'undefined') { 
				submenu_children = ajaxdata.i[i].c[0].data;
			}
			
			// Wenn das OnClick-Ereignis bis jetzt noch nicht gesetzt wurde,
			// dann die "menu_change" als Default-Aktion verwenden.
			if (submenu_link == '#' && submenu_onclick == '') {
				submenu_onclick	 = 'menu_change("' + submenu_key + '", "' + menu_level + '"); return (false);';
			}
			
			// OnClick-Variable befuellen, die spaeter ins Menue eingefuegt wird.
			if (submenu_onclick != '') {
				onclick_call = "onclick='" + submenu_onclick + "'";
			}
			
			// Festlegen, ob Menue-Punkte farblich hervorgehoben werden sollen
			if (submenu_alert == 1) {				
				var div_class_level_0		= 'm_style0_alert';
				var div_class_level_1		= 'm_style1_alert';
				var div_class_level_2		= 'm_style2_alert';
				var link_class			= 'm_link_b';

			} else {			
				var div_class_level_0		= 'm_style0_nact';
				var div_class_level_1		= 'm_style1_nact';
				var div_class_level_2		= 'm_style2_nact';
				var link_class			= 'm_link_w';
			}
		
			
			if(i==0) {
				submenu_html += '<ul>';
			}
	

			// Unterscheidung, fuer welches Level der Menuepunkt
			// aufgebaut werden soll.
			if (menu_level == 0) {
				
				if (submenu_children == 0) {
					
					submenu_html += '<li id="m_' + submenu_key + '" class="'+div_class_level_0+'" OnMouseOver="m_ac(\'' + submenu_key + '\', \'0\')" OnMouseOut="m_na(\'' + submenu_key + '\', \'' + menu_level + '\', \'' + submenu_alert + '\', \'0\')">';
					submenu_html += '<a id="m_link_' + submenu_key + '" href="' + submenu_link + '" class="m_link_c0 ' + link_class + '" '+ onclick_call +'>&nbsp;&nbsp;' + submenu_name + '</a>';
					submenu_html += '<a id="m_icon_' + submenu_key + '" href="' + submenu_link + '" class="m_icon_c0 m_link_w"><img src="' + gfx_menu_url + '/' + submenu_key + '.gif" class="m_icon" id="icon_' + submenu_key + '" alt="' + submenu_name + '"></a>';
					submenu_html += '</li>';
					
				}
				else {
					
					submenu_html += '<li id="m_' + submenu_key + '" class="'+div_class_level_0+'">';
					submenu_html += '<a id="m_link_' + submenu_key + '" href="' + submenu_link + '" class="m_link_c0 ' + link_class + '" '+ onclick_call +' OnMouseOver="m_ac(\'' + submenu_key + '\', \'' + menu_level + '\')" OnMouseOut="m_na(\'' + submenu_key + '\', \'' + menu_level + '\', \'' + submenu_alert + '\', \'0\')">&nbsp;&nbsp;' + submenu_name + '</a>';
					submenu_html += '<a id="m_icon_' + submenu_key + '" href="#" class="' + link_class + ' m_icon_c0" onClick="menu_change(\'' + submenu_key + '\', \'0\'); return(false);" OnMouseOver="m_iover(\'' + submenu_key + '\')" OnMouseOut="m_iout(\'' + submenu_key + '\')">';
					submenu_html += '<img src="' + gfx_menu_url + '/' + submenu_key + '.gif" class="m_icon" id="icon_' + submenu_key + '" alt="' + submenu_name + '"></a>';
					submenu_html += '</li>';
				}
			}
			else if (menu_level == 1) {
				
				// Unterscheidung, ob der Menue-Eintrag ebenfalls Kind-Elemente
				// enthaelt.
				if (submenu_children == 0) {
				
					submenu_html += '<li id="m_' + submenu_key + '" class="' + div_class_level_1 + '" OnMouseOver="m_ac(\'' + submenu_key + '\', \'' + menu_level + '\')" OnMouseOut="m_na(\'' + submenu_key + '\', \'' + menu_level + '\', \'' + submenu_alert + '\', \'0\')">';
					submenu_html += '<a id="m_link_' + submenu_key + '" href="' + submenu_link + '" class="m_link_c1 ' + link_class + '" '+ onclick_call +'>&nbsp;&nbsp;' + submenu_name + '</a>';
					submenu_html += '</li>';
				}
				else {
					
					submenu_html += '<li id="m_' + submenu_key + '" class="' + div_class_level_1 + '">';
					submenu_html += '<a id="m_link_' + submenu_key + '" href="' + submenu_link + '" class="m_link_c1 ' + link_class + '" '+ onclick_call +' OnMouseOver="m_ac(\'' + submenu_key + '\', \'' + menu_level + '\')" OnMouseOut="m_na(\'' + submenu_key + '\', \'' + menu_level + '\', \'' + submenu_alert + '\', \'0\')">&nbsp;&nbsp;' + submenu_name + '</a>';
					submenu_html += '<a id="m_icon_' + submenu_key + '" href="#" onClick="menu_change(\'' + submenu_key + '\', \'' + menu_level + '\'); return(false);" OnMouseOver="m_iover(\'' + submenu_key + '\')" OnMouseOut="m_iout(\'' + submenu_key + '\')">';
					submenu_html += '<img src="' + icon_arrow_left_small + '" class="m_arrow" id="icon_' + submenu_key + '" border="0" alt="' + submenu_name + '">';
					submenu_html += '</a>';
					submenu_html += '</li>';
				}
			}
			else if (menu_level == 2) {
				
				submenu_html += '<li id="m_' + submenu_key + '" class="' + div_class_level_2 + '" OnMouseOver="m_ac(\'' + submenu_key + '\', \'' + menu_level + '\')" OnMouseOut="m_na(\'' + submenu_key + '\', \'' + menu_level + '\', \'' + submenu_alert + '\', \'0\')">';
				submenu_html += '<a id="m_link_' + submenu_key + '" href="' + submenu_link + '" class="m_link_c2 ' + link_class + '" '+ onclick_call +'>&nbsp;&nbsp;&nbsp;&nbsp;' + submenu_name + '</a>';
				submenu_html += '</li>';
			}
			
			
			// Container fuer das untergeordnete Menue einbinden, wenn das Menue Kind-Elemente besitzt
			if (submenu_children == 1) {
				
				// Gibt es offene Kind-Elemente ? Wenn ja, diese ebenfalls rendern.
				// Dies erfolgt mit einem rekrusiven Aufruf der Funktion.

				if (typeof ajaxdata.i[i].s != 'undefined') {
					
					submenu_html += '<li class="m_show" id="ml_' + submenu_key + '">';
					submenu_html += menu_render_recrusivly(ajaxdata.i[i].s[0], menu_baseurl);
					
				} else {					
					submenu_html += '<li class="m_hide" id="ml_' + submenu_key + '">&nbsp;';
				}
				
				submenu_html += '</li>';

			}			
	
		}

		submenu_html += '</ul>';
	}

	// generierten HTML Code an die uebergeordnete Funktion zurueckgeben.
	return (submenu_html);
}


function m_iover (elementName) {
	
	elementName = elementName.replace(/m_/, "");
	
	var icon 		= document.getElementById ("icon_"+elementName);
	var icon_default 	= gfx_menu_url+"/"+elementName+".gif";

	var a_tag		= document.getElementById ("m_icon_"+elementName);
	var a_class_default 	= "m_icon_c0 mi_"+elementName;

	var layername 		= "ml_"+elementName;
	var menulayer 		= document.getElementById(layername);
	var menu_item 	= document.getElementById ("m_"+elementName);
	var menu_link 		= document.getElementById ("m_link_"+elementName);

	if (a_tag != null && icon != null) {
		
		// Bestimmen, welches Icon angezeigt werden soll
		if (a_tag.className == a_class_default) {
			
			// Pruefen, ob das Menue gerade aufgeklappt oder zugeklappt ist. Dementsprechend dann die Pfeil-Grafik setzen.
			if (menulayer.style.width == '150px'||menulayer.className == 'm_show') {
				a_tag.className = "m_icon_c0 mi_arrow_l";

			} else {
				a_tag.className = "m_icon_c0 mi_arrow_d";
			}
		}
		else if (icon.src == icon_arrow_down_small || icon.src == icon_arrow_left_small) {
		
			if (menulayer.style.width == '150px'||menulayer.className == 'm_show') {
				icon.src = icon_arrow_left_small;

			} else {
				icon.src = icon_arrow_down_small;
			}

			if(menu_readCookie(menu_cookie_prefix+elementName)==1) {
				menu_link.style.color 			= textcolor_active;
				menu_item.className 		= 'm_style1_act';

			} else {
				menu_link.style.color 			= textcolor_default;
				menu_item.className 		= 'm_style1_nact';
			}
		}
	}
}

function m_iout (elementName) {

	elementName = elementName.replace(/m_/, "");
	
	var icon 		= document.getElementById ("icon_"+elementName);
	var icon_default 	= gfx_menu_url+"/"+elementName+".gif";

	var a_tag		= document.getElementById ("m_icon_"+elementName);
	var a_class_default 	= "m_icon_c0 mi_"+elementName;

	var layername 		= "ml_"+elementName;
	var menulayer 		= document.getElementById(layername);
	var menu_item 	= document.getElementById ("m_"+elementName);
	var menu_link 		= document.getElementById ("m_link_"+elementName);
	
	if (a_tag != null && icon != null) {
		
		// Bestimmen, welches Icon angezeigt werden soll
		if (a_tag.className == "m_icon_c0 mi_arrow_l" || a_tag.className == "m_icon_c0 mi_arrow_d") {
			a_tag.className = a_class_default;

		}
		else if (icon.src == icon_arrow_down_small || icon.src == icon_arrow_left_small) {
			if (menulayer.style.width == '150px'||menulayer.className == 'm_show') {
				icon.src = icon_arrow_down_small;

			} else {
				icon.src = icon_arrow_left_small;
			}

			if(menu_readCookie(menu_cookie_prefix+elementName)==1) {
				menu_link.style.color 			= textcolor_active;
				menu_item.className 		= 'm_style1_act';

			} else {
				menu_link.style.color 			= textcolor_default;
				menu_item.className 		= 'm_style1_nact';
			}
		}
	}
}


function m_ac (elementName, elementLevel) {

	elementName = elementName.replace(/m_/, "");

	var layername 		= "ml_"+elementName;
	var menulayer 		= document.getElementById(layername);
	var menu_item 	= document.getElementById ("m_"+elementName);
	var menu_link 		= document.getElementById ("m_link_"+elementName);

	menu_link.style.color 			= textcolor_active;
	menu_item.className 		= 'm_style'+elementLevel+'_act';
}


function m_na (elementName, elementLevel, alertStatus, activeStatus) {

	elementName = elementName.replace(/m_/, "");

	var layername 		= "ml_"+elementName;
	var menulayer 		= document.getElementById(layername);
	var menu_item 	= document.getElementById ("m_"+elementName);
	var menu_link 		= document.getElementById ("m_link_"+elementName);

	if (alertStatus == 1) {
		menu_link.style.color		= textcolor_active;
		menu_item.className		= 'm_style'+elementLevel+'_alert';

	} else if (activeStatus == 1) {
		menu_link.style.color		= textcolor_active;			
		menu_item.className		= 'm_style'+elementLevel+'_act';

	} else {
		menu_link.style.color		= textcolor_default;
		menu_item.className		= 'm_style'+elementLevel+'_nact';
	}		
}

function menu_hide_quickmessage () {

	var menu_quickmessage = document.getElementById("menu_quickmessage");
	
	// Falls das Element im DOM vorhanden ist, dieses nun ausblenden
	if (menu_quickmessage !== null) {
	
		menu_quickmessage.style.display = "none";
	}
}

function make_me_invisible(my_id){
	document.getElementById(my_id).style.visibility="hidden";
	return true;
}

// ===== MODEL-DATENBANK ===========================================


// Hinzufuegen eines Fotografen in die Referenz-Liste des Models.
function sedcard_add_reference () {
	
	// Uebernahme des Eingabe-Wertes
	var userid = document.getElementById('fc_fotograf').value;
	
	// Es muss eine Eingabe vorliegen, bevor Daten verschickt werden.
	if (userid.length > 0) {
		
		cp.call ('/pc/inc/ajax_sedcard.inc.php', 'sedcard_add_reference', sedcard_reference_added, userid);
		
	}
}
	
// Hinzufuegen eines Fotografen in die Referenz-Liste des Models (aus Dropdown-Feld).
function sedcard_add_reference_dropdown () {
	
	// Uebernahme des Eingabe-Wertes
	var userid = document.getElementById('sedcard_referenz_dropdown').value;
	
	// Es muss eine Eingabe vorliegen, bevor Daten verschickt werden.
	if (userid.length > 0) {
		
		cp.call ('/pc/inc/ajax_sedcard.inc.php', 'sedcard_add_reference', sedcard_reference_added, userid);
		
	}
}


// Pruefen, ob ein Fotograf erfolgreich auf die Referenz-Liste
// des Models gesetzt wurde.
function sedcard_reference_added (ajaxresult) {
	
	// Pruefen, ob ueberhaupt ein gueltiges AJAX Result vorliegt
	if (typeof ajaxresult != 'undefined') {
		
		var reference_added = ajaxresult.ajaxResponse[0].data;
		
		if (reference_added == 1) {
			
			// Aufruf der Funktion zum auslesen der gesamten
			// Referenz-Liste. Die Liste wird im Anschluss
			// komplett neun aufgebaut.
			sedcard_get_referencelist();
		}
	}
}


function sedcard_get_referencelist () {
	
	cp.call ('/pc/inc/ajax_sedcard.inc.php', 'sedcard_get_referencelist', sedcard_render_referencelist, 0);
}


function sedcard_render_referencelist (ajaxresult) {
	
	var i;
	var html_output = '';
	var background_class;
	
	var referenceNode = ajaxresult.ajaxResponse[0].ref;
	
	// Daten nur verarbeiten, wenn auch welche vorhanden sind
	if (typeof referenceNode !== 'undefined') {
		
		html_output += '<div class="sedcard_referenz">&nbsp;'+sedcard_translation_referenzen_name+'</div>';
		html_output += '<div class="sedcard_referenz centered">'+sedcard_translation_referenzen_sortieren+'</div>';
		html_output += '<div class="sedcard_referenz">'+sedcard_translation_referenzen_delete2+'</div>';
		
		for (i=0; i < referenceNode.length; i++) {
			
			var userid		= referenceNode[i].userid[0].data;
			var username	= referenceNode[i].name[0].data;
			var position	= referenceNode[i].pos[0].data;
			
			// Hintergrundfarbe bestimmen
			if (i % 2 == 0) {
				background_class = 'sedcard_referenz_background1';
			}
			else {
				background_class = 'sedcard_referenz_background2';
			}
			
			html_output += '<div class="sedcard_referenz '+background_class+'">&nbsp;<a href="'+programmurl+'/pc/pc/mypics/'+userid+'" class="form_link">'+username+'</a></div>';
			html_output += '<div class="sedcard_referenz centered '+background_class+'">';
			html_output += '<img src="/gfx/sedcard/arrow_up.gif" class="sedcard_position_arrow" width="11" height="10" onmousedown="sedcard_change_position ('+userid+', 1);" />';
			html_output += '&nbsp; &nbsp; &nbsp; &nbsp;';
			html_output += '<img src="/gfx/sedcard/arrow_down.gif" class="sedcard_position_arrow" width="11" height="10" onmousedown="sedcard_change_position ('+userid+', 2);"/>';
			html_output += '</div>';
			html_output += '<div class="sedcard_referenz '+background_class+'"><input type="button" class="sedcard_referenz_delete" value="'+sedcard_translation_referenzen_delete+'" onClick="sedcard_delete_reference('+userid+')"/></div>';
		}
		
		html_output += '<div style="clear:both;"></div>';
		
		document.getElementById('referenzen_liste').innerHTML = html_output;
	}
}


function sedcard_delete_reference (userid) {
	
	cp.call ('/pc/inc/ajax_sedcard.inc.php', 'sedcard_delete_reference', sedcard_get_referencelist, userid);
}


// Action: 1 = hoch, 2 = runter
function sedcard_change_position (userid, action) {
	
	cp.call ('/pc/inc/ajax_sedcard.inc.php', 'sedcard_change_position', sedcard_get_referencelist, userid, action);
}


// Wenn ein User in der Sedcard-Suche die Option "Per Email Informieren"
// anwaehlt, soll ebenfalls die Option "Suchprofil speichern" aktiviert werden.
function sedcard_search_notification_change() {
	
	// Status der Checkbox "Email-Benachrichtigung" ermitteln
	var status_notification = document.getElementById('email_notification').checked;
	
	// Email-Benachrichtigung wurde aktiviert. Option "Suchprofil speichern"
	// ebenfalls aktivieren.
	if (status_notification === true) {
		
		document.getElementById('save_search').checked = true;
	}
}


function sedcard_search_showprofile (id) {
	if(id>0) {
		window.location.href = "/pc/pc/extra/sedcard/search/"+id;
	}
}

function sedcard_search_loadprofile (id) {
	if(id>0) {
		window.location.href = "/pc/sedcard/search/id/"+id;		
	} else {
		window.location.href = "/pc/sedcard/search/profile";		
	}
}

function sedcard_search_saveprofile (id, name) {
	
	if (id > 0) {
		window.location.href = "/pc/sedcard/search/save/"+id+"/name/"+name;
	}
}

function sedcard_search_deleteprofile (id) {
	
	if (id > 0) {
		window.location.href = "/pc/sedcard/search/"+id+"delete";
	}
}

function sedcard_change_image (img_id) {
	
}


var Fotocommunity_Sedcard = {

    deleteImage: function (element)
    {
        imageNumber = jQuery(element).attr('image_number');

        // Foto durch den entsprechenden Platzhalter austauschen
        jQuery('#thumb_' + imageNumber).attr('src', '/gfx/sedcard/sedcard_default_'+imageNumber+'.jpg');

        // Verlinkung entfernen
        jQuery('#thumb_link_' + imageNumber).remove();

        // Das Bild auf dem Server entfernen
        jQuery.post('/pc/inc/ajax_sedcard_deleteimage.inc.php', { 'imageNumber': imageNumber });
    }
}


// ===== UPLOAD-Overlay ===========================================

// Pruefung, ob Fotos im Sedcard-Formular hochgeladen werden sollen.
// Wenn ja, entsprechenden Hinweis einblenden.
function sedcard_check_fileupload () {
	
	var upload_1 = document.getElementById ('upload_1').value;
	var upload_2 = document.getElementById ('upload_2').value;
	var upload_3 = document.getElementById ('upload_3').value;
	var upload_4 = document.getElementById ('upload_4').value;
	var upload_5 = document.getElementById ('upload_5').value;
	
	if (upload_1 || upload_2 || upload_3 || upload_4 || upload_5) {
		
		showUploadOverlay();	
	}
}


// Pruefung, ob Fotos im Upload-Formular hochgeladen werden sollen.
// Wenn ja, entsprechenden Hinweis einblenden.
function upload_check_fileupload (userid,usertyp,formularchen) {
	
	var upload = document.getElementById ('photo').value;
	var upload2 = document.getElementById ('optimized_photo').value;
	
	if (upload || upload2) {
		
		showUploadOverlay();
		cp.call ('/pc/inc/log_upload.php', 'log_upload', do_nothing, userid);	
	}
	if (usertyp == 'free'){
		setTimeout("submitChristophUpload()", 25000);	
	}
	else{
		document.forms[1].submit();
	}
}

function submitChristophUpload(){
	document.forms[1].submit();
}

function do_nothing() {

}

// Pruefung, ob Fotos im Edit-Formular hochgeladen werden sollen.
// Wenn ja, entsprechenden Hinweis einblenden.
function edit_check_fileupload () {
	
	var upload = document.getElementById ('photo').value;
	
	if (upload ) {
		
		showUploadOverlay();
	}
}


// Pruefung, ob Fotos im Profil-Formular hochgeladen werden sollen.
// Wenn ja, entsprechenden Hinweis einblenden.
function profile_check_fileupload () {
	
	var upload = document.getElementById ('photo').value;
	
	if (upload) {
		
		showUploadOverlay();	
	}
}

function showUploadOverlay() {
	
	var objOverlay 				= document.getElementById("overlay");
	var objLightbox				= document.getElementById("lightbox");
	
	var arrayPageSize 			= getPageSize();
	var arrayPageScroll 		= getPageScroll();
	
	objOverlay.style.display 	= 'block';
	objOverlay.style.height 	= (arrayPageSize[1] + 'px');
	
	if(objLightbox.style.height == '500px'){
		//var lightboxTop = arrayPageScroll[1] + ((arrayPageSize[3] - 600) / 2);
		var lightboxTop = 250;
		var lightboxLeft = ((arrayPageSize[0] - 400) / 2);
	}
	else if (objLightbox.style.height == '700px'){
		//werbefilmchen im upload...
		var lightboxTop = 100;
		var lightboxLeft = 450;
	}
	else {
		var lightboxTop = arrayPageScroll[1] + ((arrayPageSize[3] - 35) / 2);
		var lightboxLeft = ((arrayPageSize[0] - 400) / 2);
	}
	
	
	objLightbox.style.top = (lightboxTop < 0) ? "0px" : lightboxTop + "px";
	objLightbox.style.left = (lightboxLeft < 0) ? "0px" : lightboxLeft + "px";
}


function showLimitboxOverlay(headlineNo,itemNo) {
	
	var objOverlay 				= document.getElementById("overlay_container");
	var objLightbox				= document.getElementById("limitbox");
	
	var tempName				= "limitBoxHeadline" + headlineNo;
	var objLightboxHeadline	= document.getElementById(tempName);
	
	var arrayPageSize 			= getPageSize();
	var arrayPageScroll 		= getPageScroll();
	
	objOverlay.style.display 					= 'block';
	objLightboxHeadline.style.display 	= 'block';
	objOverlay.style.height 	= (arrayPageSize[1] + 'px');
	
	var lightboxTop = arrayPageScroll[1] + ((arrayPageSize[3] - 605) / 2);
	var lightboxLeft = ((arrayPageSize[0] - 400) / 2);
	
	objLightbox.style.top = (lightboxTop < 0) ? "0px" : lightboxTop + "px";
	objLightbox.style.left = (lightboxLeft < 0) ? "0px" : lightboxLeft + "px";
	
	var limitLinkHref = document.getElementById("limit_link_anchor").href;
	if(headlineNo==1){
		limitLinkHref += "/image/"+itemNo;
	}
	else if(headlineNo==2){
		limitLinkHref += "/forum/"+itemNo;
	}
	else if(headlineNo==3){
		limitLinkHref += "/sell";
		document.getElementById('limitBoxFeature3').style.display = 'block';
	}
	else if(headlineNo==4){
		limitLinkHref += "/fotohome";
		document.getElementById('limitBoxFeature4').style.display = 'block';
	}
	else if(headlineNo==5){
		limitLinkHref += "/favorites";
		document.getElementById('limitBoxFeature5').style.display = 'block';
	}
	else if(headlineNo==6){
		limitLinkHref += "/friends";
		document.getElementById('limitBoxFeature5').style.display = 'block';
	}
	else if(headlineNo==7){
		limitLinkHref += "/storage";
		document.getElementById('limitBoxFeature7').style.display = 'block';
	}
	else if(headlineNo==8){
		//limitLinkHref += "/voting"; //voting ist noch nicht umgesetzt
	}
	else if(headlineNo==9){
		limitLinkHref += "/visitors";
		document.getElementById('limitBoxFeature9').style.display = 'block';
	}
	else if(headlineNo==10){
		limitLinkHref += "/upload";
		document.getElementById('limitBoxFeature10').style.display = 'block';
	}
	else if(headlineNo==11){
		document.getElementById('limitBoxFeature11').style.display = 'block';
	}
	else if(headlineNo==12){
		document.getElementById('limitBoxFeature12').style.display = 'block';
	}
	else{
	}
	document.getElementById("limit_link_anchor").href = limitLinkHref;
}

function showLimitboxPayOverlay(headlineNo) {
	
	var objOverlay 				= document.getElementById("overlay_container");
	var objLightbox				= document.getElementById("limitbox");
	
	var tempName				= "limitBoxHeadline" + headlineNo;
	var objLightboxHeadline	= document.getElementById(tempName);
	
	var arrayPageSize 			= getPageSize();
	var arrayPageScroll 		= getPageScroll();
	
	objOverlay.style.display 					= 'block';
	objLightboxHeadline.style.display 	= 'block';
	objOverlay.style.height 	= (arrayPageSize[1] + 'px');
	
	var lightboxTop = arrayPageScroll[1] + ((arrayPageSize[3] - 605) / 2);
	var lightboxLeft = ((arrayPageSize[0] - 400) / 2);
	
	objLightbox.style.top = (lightboxTop < 0) ? "0px" : lightboxTop + "px";
	objLightbox.style.left = (lightboxLeft < 0) ? "0px" : lightboxLeft + "px";
	var limitLinkHref = document.getElementById("limit_link_anchor").href;
	
	if(headlineNo==4){
		limitLinkHref += "/fotohome";
		document.getElementById('limit_text4').style.display = 'block';
		if(document.getElementById('limitBoxFeature7')){document.getElementById('limitBoxFeature7').style.display = 'block';}
		if(document.getElementById('limitBoxFeature10')){document.getElementById('limitBoxFeature10').style.display = 'block';}
		if(document.getElementById('limitBoxFeature11')){document.getElementById('limitBoxFeature11').style.display = 'block';}
	}
	else if(headlineNo==7){
		limitLinkHref += "/storage";
		document.getElementById('limit_text7').style.display = 'block';
		if(document.getElementById('limitBoxFeature4')){document.getElementById('limitBoxFeature4').style.display = 'block';}
		if(document.getElementById('limitBoxFeature10')){document.getElementById('limitBoxFeature10').style.display = 'block';}
		if(document.getElementById('limitBoxFeature11')){document.getElementById('limitBoxFeature11').style.display = 'block';}
	}
	else if(headlineNo==10){
		limitLinkHref += "/uploads";
		document.getElementById('limit_text10').style.display = 'block';
		if(document.getElementById('limitBoxFeature4')){document.getElementById('limitBoxFeature4').style.display = 'block';}
		if(document.getElementById('limitBoxFeature7')){document.getElementById('limitBoxFeature7').style.display = 'block';}
		if(document.getElementById('limitBoxFeature11')){document.getElementById('limitBoxFeature11').style.display = 'block';}
	}
	else if(headlineNo==11){
		document.getElementById('limit_text11').style.display = 'block';
		if(document.getElementById('limitBoxFeature4')){document.getElementById('limitBoxFeature4').style.display = 'block';}
		if(document.getElementById('limitBoxFeature7')){document.getElementById('limitBoxFeature7').style.display = 'block';}
		if(document.getElementById('limitBoxFeature10')){document.getElementById('limitBoxFeature10').style.display = 'block';}
	}
	else{
	}
	document.getElementById("limit_link_anchor").href = limitLinkHref;
}



function hideLimitboxOverlay() {

	var objOverlay 				= document.getElementById("overlay_container");
	var objLightbox				= document.getElementById("limitbox");

	var tmpLink = document.getElementById("limit_link_anchor").href;
	var Woerter = tmpLink.split("/");
	var newLink = Woerter[0] + "/" + Woerter[1] + "/" + Woerter[2] + "/" + Woerter[3] + "/" + Woerter[4];
	document.getElementById("limit_link_anchor").href = newLink;
	
	document.getElementById('limitBoxHeadline1').style.display = 'none';
	document.getElementById('limitBoxHeadline2').style.display = 'none';
	document.getElementById('limitBoxHeadline3').style.display = 'none';
	document.getElementById('limitBoxHeadline4').style.display = 'none';
	document.getElementById('limitBoxHeadline5').style.display = 'none';
	document.getElementById('limitBoxHeadline6').style.display = 'none';
	document.getElementById('limitBoxHeadline7').style.display = 'none';
	document.getElementById('limitBoxHeadline8').style.display = 'none';
	document.getElementById('limitBoxHeadline9').style.display = 'none';
	document.getElementById('limitBoxHeadline10').style.display = 'none';
	document.getElementById('limitBoxHeadline11').style.display = 'none';
	
	document.getElementById('limitBoxFeature3').style.display = 'none';
	document.getElementById('limitBoxFeature4').style.display = 'none';
	document.getElementById('limitBoxFeature9').style.display = 'none';
	document.getElementById('limitBoxFeature5').style.display = 'none';
	document.getElementById('limitBoxFeature7').style.display = 'none';
	document.getElementById('limitBoxFeature10').style.display = 'none';
	document.getElementById('limitBoxFeature11').style.display = 'none';
	
	
	objOverlay.style.display = 'none';
}

function hideLimitboxPayOverlay() {

	var objOverlay 				= document.getElementById("overlay_container");
	var objLightbox				= document.getElementById("limitbox");

	document.getElementById('limitBoxHeadline4').style.display = 'none';
	document.getElementById('limitBoxHeadline7').style.display = 'none';
	document.getElementById('limitBoxHeadline10').style.display = 'none';
	document.getElementById('limitBoxHeadline11').style.display = 'none';
	
	document.getElementById('limit_text4').style.display = 'none';
	document.getElementById('limit_text7').style.display = 'none';
	document.getElementById('limit_text10').style.display = 'none';
	document.getElementById('limit_text11').style.display = 'none';
	
	if(document.getElementById('limitBoxFeature4')){document.getElementById('limitBoxFeature4').style.display = 'none';}
	if(document.getElementById('limitBoxFeature7')){document.getElementById('limitBoxFeature7').style.display = 'none';}
	if(document.getElementById('limitBoxFeature10')){document.getElementById('limitBoxFeature10').style.display = 'none';}
	if(document.getElementById('limitBoxFeature11')){document.getElementById('limitBoxFeature11').style.display = 'none';}
	
	
	objOverlay.style.display = 'none';
}


function showSpecialOfferOverlay() {
	
	var objOverlay 				= document.getElementById("overlay2");
	var objLightbox				= document.getElementById("outer_lightbox2");
	
	var arrayPageSize 			= getPageSize();
	var arrayPageScroll 		= getPageScroll();

	objOverlay.style.display 	= 'block';
	objOverlay.style.height 	= (arrayPageSize[1] + 'px');
	
	var lightboxTop = arrayPageScroll[1] + ((arrayPageSize[3] - 345) / 2);
	var lightboxLeft = ((arrayPageSize[0] - 511) / 2);

	objLightbox.style.top = (lightboxTop < 0) ? "0px" : lightboxTop + "px";
	objLightbox.style.left = (lightboxLeft < 0) ? "0px" : lightboxLeft + "px";
}


function hideSpecialOfferOverlay(cookieVal, cookieLifetime, redirectURL) {
	
	var objOverlay 				= document.getElementById("overlay2");
	var objLightbox				= document.getElementById("lightbox2");

	objOverlay.style.visibility = 'hidden';

	var date = new Date();
	date.setTime(date.getTime()+cookieLifetime);
	var expires = "; expires="+date.toGMTString();
	document.cookie = "pay_special_offer="+cookieVal+expires+"; path=/";

	document.forms['form_pso'].elements['pso_choice'].value=cookieVal;

	if(redirectURL) {
		window.location.href = redirectURL;
	}
}


//
// getPageScroll()
// Returns array with x,y page scroll values.
// Core code from - quirksmode.org
//
function getPageScroll(){

	var yScroll;

	if (self.pageYOffset) {
		yScroll = self.pageYOffset;
	} else if (document.documentElement && document.documentElement.scrollTop){	 // Explorer 6 Strict
		yScroll = document.documentElement.scrollTop;
	} else if (document.body) {// all other Explorers
		yScroll = document.body.scrollTop;
	}

	arrayPageScroll = new Array('',yScroll); 
	return arrayPageScroll;
}



//
// getPageSize()
// Returns array with page width, height and window width, height
// Core code from - quirksmode.org
// Edit for Firefox by pHaez
//
function getPageSize(){
	
	var xScroll, yScroll;
	
	if (window.innerHeight && window.scrollMaxY) {	
		xScroll = document.body.scrollWidth;
		yScroll = window.innerHeight + window.scrollMaxY;
	} else if (document.body.scrollHeight > document.body.offsetHeight){ // all but Explorer Mac
		xScroll = document.body.scrollWidth;
		yScroll = document.body.scrollHeight;
	} else { // Explorer Mac...would also work in Explorer 6 Strict, Mozilla and Safari
		xScroll = document.body.offsetWidth;
		yScroll = document.body.offsetHeight;
	}
	
	var windowWidth, windowHeight;
	if (self.innerHeight) {	// all except Explorer
		windowWidth = self.innerWidth;
		windowHeight = self.innerHeight;
	} else if (document.documentElement && document.documentElement.clientHeight) { // Explorer 6 Strict Mode
		windowWidth = document.documentElement.clientWidth;
		windowHeight = document.documentElement.clientHeight;
	} else if (document.body) { // other Explorers
		windowWidth = document.body.clientWidth;
		windowHeight = document.body.clientHeight;
	}	
	
	// for small pages with total height less then height of the viewport
	if(yScroll < windowHeight){
		pageHeight = windowHeight;
	} else { 
		pageHeight = yScroll;
	}

	// for small pages with total width less then width of the viewport
	if(xScroll < windowWidth){	
		pageWidth = windowWidth;
	} else {
		pageWidth = xScroll;
	}


	arrayPageSize = new Array(pageWidth,pageHeight,windowWidth,windowHeight); 
	return arrayPageSize;
}

// ===== BANNERSTEUERUNG ======================================

	function div_ref (id) {
    	if      (document.layers)         return document.layers[id];         // NC 4
    	else if (document.all)            return document.all[id];            // IE 4
    	else if (document.getElementById) return document.getElementById(id); // DOM
    	else                              return null;        
  	}
	
	function div_ref_style (id) {
    	if      (document.layers)         return document.layers[id];              
    	else if (document.all)            return document.all[id].style;           
    	else if (document.getElementById) return document.getElementById(id).style;
    	else                              return null;        
  	}

  	

  	function footer_print_banner (farbe) {
  		
		//supersizebanner
		var myString1 = div_ref('temp_super').innerHTML;
		var laenge1 = myString1.length;
		if (laenge1 > 1200) {
			//Banner gefunden. Bannertag einfuegen
			div_ref('super').innerHTML = "";
			div_ref('super').innerHTML = myString1;
			div_ref_style("super").width =  728+ (document.documentElement? "px" : "");
			div_ref_style("super").height =  90 + (document.documentElement? "px" : "");
			div_ref_style("super").visibility =  "visible";
			//temporaeren Tag loeschen
			div_ref('temp_super').innerHTML = ""; //leeren fuer Safari
			div_ref_style("temp_super").width =  0 + (document.documentElement? "px" : "");
			div_ref_style("temp_super").height =  0 + (document.documentElement? "px" : "");
		}
		
		//fullsizebanner
		var myString2 = div_ref('temp_full').innerHTML;
		var laenge2 = myString2.length;
		if (laenge2 > 1200) {
			//Banner gefunden. Bannertag einfuegen
			div_ref('full').innerHTML = "";
			div_ref('full').innerHTML = myString2;
			div_ref_style("full").width =  468 + (document.documentElement? "px" : "");
			div_ref_style("full").height =  60 + (document.documentElement? "px" : "");
			div_ref_style("full").visibility =  "visible";
			//temporaeren Tag loeschen
			div_ref('temp_full').innerHTML = "";
			div_ref_style("temp_full").width =  0 + (document.documentElement? "px" : "");
			div_ref_style("temp_full").height =  0 + (document.documentElement? "px" : "");
		}
			
		//rectanglebanner
		var myString3 = div_ref('temp_rect').innerHTML;	
		var laenge3 = myString3.length;
		if (laenge3 > 1200) {
			//Banner gefunden. Bannertag einfuegen
			div_ref('rect').innerHTML = "";
			div_ref('rect').innerHTML = myString3;
			div_ref_style("rect").width =  300 + (document.documentElement? "px" : "");
			div_ref_style("rect").height =  250 + (document.documentElement? "px" : "");
			div_ref_style("rect").visibility =  "visible";
			//temporaeren Tag loeschen
			div_ref('temp_rect').innerHTML = "";
			div_ref_style("temp_rect").width =  0 + (document.documentElement? "px" : "");
			div_ref_style("temp_rect").height =  0 + (document.documentElement? "px" : "");
		
			//wenn ein aussendiv drum rum ist, einbinden in channelfarbe
				if(farbe.length > 1){
						div_ref_style("aussendiv").width =  320 + (document.documentElement? "px" : "");
						div_ref_style("aussendiv").height =  270 + (document.documentElement? "px" : "");
						div_ref_style("aussendiv").visibility =  "visible";
						var bgC                       =  document.layers? 'bgColor' : 'backgroundColor';
	  					div_ref_style("aussendiv")[bgC] = farbe;
				}
		}
  	}
  	
// ===== FAVORITEN BUTTON VIDEOCOMMUNITY ======================================
 
var toggleFavorite_vc = {
	
	
};


// ===== FUNKTIONEN DES PAGELOGGER ======================================

function PageLogger_expand () {
	
	var layername 	= 'PageLogger_Details';
	var layer		= document.getElementById(layername);
	
	if (layer.style.display == 'none') {
		
		layer.style.display = 'block';
	}
	else {
		
		layer.style.display = 'none';
	}
}

function PageLogger_expandDetails (group, info_number) {
	
	var layername 	= 'PageLogger_Details_'+group+'_'+info_number;
	var layer		= document.getElementById(layername);
	
	if (layer.style.display == 'none') {
		
		layer.style.display = 'block';
	}
	else {
		
		layer.style.display = 'none';
	}
}

// ===== FUNKTIONEN ZUR AKTUALISIERUNG DER BUGLISTE IM SUPPORT =====================

var support_bugfilter = {
	
	reload : function () {

		var buglist 	= document.getElementById('bugid');
		var issue_type 	= document.getElementById ('filter').value;
		
		// Dropdown-Liste mit Bug-Tickets leeren
		buglist.options.length = 0;
		buglist.selectedIndex  = 0;
		
		buglist.options[0] = new Option('loading bug data ...', 0);
		
		cp.call ('/pc/inc/ajax_support.inc.php', 'loadIssueList', this.callback, issue_type);
	},
	
	callback : function (responseObject) {
		
		var i, optionName, optionID;
		var buglist = document.getElementById('bugid');
		
		if (typeof responseObject !== 'undefined') {
			
			var dataObject 		= responseObject.ajaxResponse[0].ref;
			var numDataObjects 	= dataObject.length;
		}
		
		if (numDataObjects > 0) {
			
			// Dropdown-Liste mit Bug-Tickets leeren
			buglist.options.length = 0;
			buglist.selectedIndex  = 0;
			
			for (i=0; i < numDataObjects; i++) {
				
				optionID		= responseObject.ajaxResponse[0].ref[i].id[0].data;
				optionStatus	= responseObject.ajaxResponse[0].ref[i].status[0].data;
				optionName 		= '#' + optionID + ' ' + responseObject.ajaxResponse[0].ref[i].desc[0].data + ' (' + optionStatus + ')';
				
				buglist.options[i] = new Option(optionName, optionID);
			}
			
		}
	}
};


/* Funktionen der Kontaktliste */

var ContactList = {
	
	contactid: 		false,
	rowHeight:		false,
	userTags: 		[],
	tagList:		[],
	systemConfig:	[],
	
	
	init: function () {
		
		// Benoetigte Variablen vom Server holen
		ContactList.getSystemConfig();
	},
	
	
	// Benoetigte Variablen vom Server holen
	getSystemConfig: function () {
		
		// Userid des aktuell eingeloggten Users
		ContactList.systemConfig['userid'] 		= YDom.get ('userid').value;
			
		// Aktuelle URL mit Optionen
		ContactList.systemConfig['baseurl'] 	= unescape (YDom.get ('baseurl').value);
		
		//Programmurl der fc
		ContactList.systemConfig['programurl'] 	= unescape (YDom.get ('programurl').value);
		
		// In welcher Ansicht befindet sich der Nutzer
		ContactList.systemConfig['contacttype'] = YDom.get ('contactlisttype').value;
		
		// Sortierung nach Schlagwort. Das zu filternde Schlagwort
		ContactList.systemConfig['bytag'] 		= YDom.get ('bytag').value;
		
		// Sortier-Reihenfolge der TagListe
		ContactList.systemConfig['sorttagsby'] 	= YDom.get ('sorttagsby').value;
		
		// Uebersetzung fuer "Keine Schlagworte"
		ContactList.systemConfig['t_noTags'] 	= YDom.get ('t_noTags').value;

		// Uebersetzung fuer "Keine Schlagworte"
		ContactList.systemConfig['t_tagHelp'] 	= YDom.get ('t_tagHelp').value;
		
		// Anzahl der angezeigten Kontakte
		ContactList.systemConfig['numContacts'] = YDom.get ('numContacts').value;
		
		// Tagliste fuer den User aufrufen
		ContactList.getTagList();
	},

	
	// Liste aller vom  Nutzer verwendeten Tags vom Server holen
	getTagList: function () {

		// Tag Liste nun dann auslesen, wenn auch Kontakte angezeigt werden
		if (ContactList.systemConfig['numContacts'] > 0) {
		
			cp.call ('/pc/inc/ajax_contacts.inc.php', 'getTagListByUserId', ContactList.processTagList, ContactList.systemConfig['userid'], ContactList.systemConfig['sorttagsby'], ContactList.systemConfig['contacttype']);
		}
	},
	
	
	// Verarbeiten der Tagliste
	 processTagList: function (resultObj) {
	 	
	 	if (typeof resultObj !== 'undefined') {

		 	var referenceNode = resultObj.ajaxResponse[0].tags; 
		 	
		 	if (typeof referenceNode !== 'undefined') {
		 		
		 		for (i=0; i < referenceNode.length; i++) {
		 			
		 			var id 		= referenceNode[i].id[0].data;
		 			var tag 	= referenceNode[i].tag[0].data;
		 			var count 	= referenceNode[i].count[0].data;
		 			
					// Einfache Tagliste fuer das Autocomplete
		 			ContactList.userTags[id] = tag;
		 			
		 			// Erweiterte Tagliste mit Information
		 			// ueber die Haufigkeit eines Tags
		 			ContactList.tagList[i] = new Array (id, tag, count);
		 		}
		 		
				// Aufbau der Liste aller Tags des Nutzers
				YEvent.onAvailable ('tagListViewContainer', ContactList.buildTagListView);
		 	}
	 	}
	 },
	
	
	// Einblenden des Eingabefeldes beim hinzufuegen
	// eines Schlagwortes
	addTag: function (contactid) {
		
		// Die ID des Kontaktes in die Objekt-Variable uebernehmen
		ContactList.contactid = contactid;
		
		// Ausblenden des Links zum hinzufuegen eines Tags
		YDom.get ('addtag_'+ContactList.contactid).style.display = 'none';
		
		// Aktuelle Hoehe der Zeile ermitteln
		var currentHeight = YDom.getStyle ('row_'+ContactList.contactid, 'height');
		
		var currentHeightLength 	= currentHeight.length;
		var currentHeightNumeric 	= currentHeight.slice (0, currentHeightLength - 2);
		var newHeight				= Number (currentHeightNumeric) + Number (33);
		
		// Die "alte" hoehe der Zeile merken wir uns, damit
		// dessen Zustand spaeter wieder hergestellt werden kann.
		ContactList.rowHeight = currentHeight;
		
		// Vergroessern der Zeile, damit Platz fuer das Eingabefeld
		// vorhanden ist
		YDom.get ('row_'+ContactList.contactid).style.Height = newHeight + 'px';
		
		/* === Container mit einem clear:both === */
		
			/* Natuerlich ist das wieder so eine IE6 Kacke. */
		
			var clearContainer = document.createElement ('div');
			YDom.addClass (clearContainer, 'cb');
			YDom.insertAfter (clearContainer, 'addtag_'+ContactList.contactid);
		
		/* === Container fuer die Eingabebox erstellen === */
		
			// Neuen DIV-Container erstellen, um das Eingabefeld aufzunehmen
			var inputContainer = document.createElement ('div');
	
			// Der Container bekommt eine eindeutige ID
			inputContainer.setAttribute ('id', 'inputContainer_'+ContactList.contactid);
			
			// Klassen zur Formatierung auf den Container anwenden
			YDom.addClass (inputContainer, 'fl cb');
			YDom.addClass (inputContainer, 'yui-ac');
			YDom.setStyle (inputContainer, 'padding-top', '5px');
			
			// Container in den DOM einfuegen
			YDom.insertAfter (inputContainer, clearContainer);
		
		/* === Eingabefeld im Container erstellen */
		
			var inputField = document.createElement ('input');
			
			// Dem Eingabefeld eine ID und einen Type zuweisen
			inputField.setAttribute ('id', 'inputField_'+ContactList.contactid);
			inputField.setAttribute ('type', 'text');
			
			// Das neue Element dem Container hinzufuegen
			inputContainer.appendChild (inputField);
			
		/* === Container fuer die Auto-Vervollstaendigung === */
		
			autocompleteContainer = document.createElement ('div');
			
			// Dem Container eine ID geben
			autocompleteContainer.setAttribute ('id', 'autocompleteContainer_'+ContactList.contactid);
			autocompleteContainer.setAttribute ('z-index', '99');
			
			// Das neue Element dem Container hinzufuegen
			inputContainer.appendChild (autocompleteContainer);
			
		/* === Container fuer die Buttons erstellen === */
		
			buttonContainer = document.createElement ('div');
			
			// ID zuweisen
			buttonContainer.setAttribute ('id', 'buttonContainer_'+ContactList.contactid);
			
			// Klassen zur Formatierung auf den Container anwenden
			YDom.addClass (buttonContainer, 'buttonContainer');
			YDom.addClass (buttonContainer, 'fl');
			
			// Container in den DOM einfuegen
			YDom.insertAfter (buttonContainer, 'inputContainer_'+ContactList.contactid);
			
		/* === OK Button === */
		
			var button_ok = document.createElement ('a');
			
			// Dem Button eine ID und ein href zuweisen
			button_ok.setAttribute ('id', 'button_ok_'+ContactList.contactid);
			button_ok.style.cursor = 'pointer';
			YEvent.addListener (button_ok, 'click', ContactList.saveTags);
			
			// Formatierung mit Klasse
			YDom.addClass (button_ok, 'button');
			
			// Das neue Element dem Container hinzufuegen
			buttonContainer.appendChild (button_ok);
			
			// SPAN fuer den Beschreibungstext
			button_ok_desc = document.createElement ('span');
			button_ok_desc.innerHTML = "OK";
			button_ok.appendChild (button_ok_desc);
			
		/* === Abbrechen Button === */
		
			var button_cancel = document.createElement ('a');
			
			// Dem Button eine ID und ein href zuweisen
			button_cancel.setAttribute ('id', 'button_cancel_'+ContactList.contactid);
			button_cancel.style.cursor = 'pointer';
			YEvent.addListener (button_cancel, 'click', ContactList.normalizeRow);
			
			// Formatierung mit Klasse
			YDom.addClass (button_cancel, 'button');
			
			// Das neue Element dem Container hinzufuegen
			buttonContainer.appendChild (button_cancel);
			
			// SPAN fuer den Beschreibungstext
			button_cancel_desc = document.createElement ('span');
			button_cancel_desc.innerHTML = "Abbrechen";
			button_cancel.appendChild (button_cancel_desc);
			
		/* === Autocomplete erstellen === */
		
			// Datenquelle
			this.autoCompleteDataSource = new YAHOO.widget.DS_JSArray(ContactList.userTags);
			
			// Autocomplete Objekt
			this.autoComplete =  new YAHOO.widget.AutoComplete(	'inputField_'+ContactList.contactid, 
																'autocompleteContainer_'+ContactList.contactid, 
																this.autoCompleteDataSource);
			
			// Optionen fuer das Autocomplete
			this.autoComplete.typeAhead 	 			= false;
			this.autoComplete.useIFrame 				= true;
			this.autoComplete.queryMatchCase 			= true;
			this.autoComplete.allowBrowserAutocomplete 	= false; 
			this.autoComplete.minQueryLength 			= 0;
			this.autoComplete.delimChar 				= [","," "];
			
			this.autoComplete.setFooter('<div class="yui-ac-ft">' + ContactList.systemConfig['t_tagHelp'] + '</div>');
			
			// Fokus auf das Eingabefeld setzen
			YDom.get ('inputField_' + ContactList.contactid).focus();
		
	},
	
	
	// Die aktuell bearbeitete Zeile wieder in ihren 
	// Normalzustand versetzen.
	normalizeRow: function () {
		
		// Eingabe-Container entfernen
		var inputContainer = YDom.get ('inputContainer_'+ContactList.contactid);
		inputContainer.parentNode.removeChild(inputContainer);
		
		// Button-Container entfernen
		var buttonContainer = YDom.get ('buttonContainer_'+ContactList.contactid);
		buttonContainer.parentNode.removeChild(buttonContainer);
		
		// Hoehe der Zeile wieder verringern
		YDom.get ('row_'+ContactList.contactid).style.Height =  ContactList.rowHeight;
		
		// Einblenden des Links zum hinzufuegen eines Tags
		YDom.get ('addtag_'+ContactList.contactid).style.display = 'block';
	},
	
	
	// Senden der Eingabe an den Server und normalisieren der Zeile
	saveTags: function () {
		
		var autoCompleteInput = YDom.get ('inputField_'+ContactList.contactid).value;
		
		// Die Zeile wieder in ihren Normalzustand versetzen.
		ContactList.normalizeRow();
		
		cp.call ('/pc/inc/ajax_contacts.inc.php', 'saveTags', ContactList.getTagListByRefId, ContactList.systemConfig['userid'], ContactList.contactid, autoCompleteInput);
	},
	
	
	// Tagliste fuer einen bestimmten Kontakt auslesen
	getTagListByRefId: function () {
		
		cp.call ('/pc/inc/ajax_contacts.inc.php', 'getTagListByRefId', ContactList.rebuildContactTags, ContactList.contactid);
	},
	
	
	// Neu Aufbauen der Tagliste fuer einen bestimmten Kontakt
	rebuildContactTags: function (resultObj) {
		
		if (typeof resultObj !== 'undefined') {
		
			// Alte Tagliste des Kontaktes entfernen
			var taglist_old = YDom.get ('taglist_'+ContactList.contactid);
			var parentToTaglist = taglist_old.parentNode;
			
			// Neuen Container fuer die Tagliste erstellen
			taglist = document.createElement ('div');
			
			// Dem Element eine ID geben
			taglist.setAttribute ('id', 'taglist_'+ContactList.contactid);
				
			// Klassen zur Formatierung auf den Container anwenden
			YDom.addClass (taglist, 'fl');
			
			// Tagliste neu befuellen
		 	var referenceNode = resultObj.ajaxResponse[0].tags; 
		 	
		 	if (typeof referenceNode !== 'undefined') {
		 		
		 		if (referenceNode.length > 0) {
		 		
			 		for (i=0; i < referenceNode.length; i++) {
			 			
			 			var id 	= referenceNode[i].id[0].data;
			 			var tag = referenceNode[i].tag[0].data;
			 			
			 			/* === Container fuer den Tagnamen */
			 			var tagContainer = document.createElement ('span');
			 			tagContainer.setAttribute ('id', 'tag_'+ContactList.contactid+'_'+id);
			 			
			 			/* === Tagname === */
			 			if (i > 0) {
			 				
			 				var tagNode = document.createTextNode (', ' + tag);
			 				tagContainer.appendChild (tagNode);
			 			}
			 			else {
			 				
			 				var tagNode = document.createTextNode (tag);
			 				tagContainer.appendChild (tagNode);
			 			}
	
			 			
			 			/* === Funktion zum entfernen des Tags */
			 			var tagDeleteContainer = document.createElement ('span');
			 			tagDeleteContainer.setAttribute ('id', 'removeTag_'+ContactList.contactid+'_'+id);
			 			YDom.addClass (tagDeleteContainer, 'fg_999');
			 			YDom.addClass (tagDeleteContainer, 'size10px');
			 			
			 			// In den DOM einfuegen
			 			taglist.appendChild (tagContainer);
			 			taglist.appendChild (tagDeleteContainer);
			 			
			 			// InnerHTML wegen IE6
			 			tagDeleteContainer.innerHTML = '<a href="#" onClick="ContactList.removeTag(' + ContactList.contactid + ',' + id + ');" class="cancellink"> [x] </a>';
			 		}
		 		}
		 		else {
		 			
		 			// Es gibt keine Schlagworte mehr fuer diesen Kontakt
		 			var noTags = document.createElement ('i');
		 			
		 			var noTagsText = document.createTextNode (ContactList.systemConfig['t_noTags']);
		 			noTags.appendChild (noTagsText);
		 			
		 			taglist.appendChild (noTags);
		 		}
		 	}
		 	
		 	// Alte Tagliste entfernen
		 	taglist_old.parentNode.removeChild(taglist_old);

		 	// Das Element in das DOM einfuegen
			YDom.insertBefore (taglist, 'addtag_'+ContactList.contactid);
			
			// Tagliste fuer den User neu aufbauen
			ContactList.getTagList();

		}
	},
	
	
	// Entfernen eines Tags von einem gegebenen Kontakt
	removeTag: function (contactid, tagid) {
		
		// Entfernen des Tags aus dem Dom
		var tagContainer = YDom.get ('tag_'+contactid+'_'+tagid);
		
		tagParentNode = tagContainer.parentNode;
		
		tagContainer.parentNode.removeChild(tagContainer);
		
		// Entfernen des Loesch-Links aus dem Dom
		var removeTagContainer = YDom.get ('removeTag_'+contactid+'_'+tagid);
		removeTagContainer.parentNode.removeChild(removeTagContainer);
		
		// Hinweis ausgeben, wenn keine Tags mehr vorhanden sind
		if (tagParentNode.childNodes.length < 3) {
			
 			// Es gibt keine Schlagworte mehr fuer diesen Kontakt
 			var noTags = document.createElement ('i');
 			
 			var noTagsText = document.createTextNode (ContactList.systemConfig['t_noTags']);
 			noTags.appendChild (noTagsText);
 			
 			tagParentNode.appendChild (noTags);
		}
		
		// Server-seitige Tag-Entfernung
		cp.call ('/pc/inc/ajax_contacts.inc.php', 'deleteTagFromContact', ContactList.removeTagCallback, ContactList.systemConfig['userid'], contactid, tagid);
	},
	
	
	// Callback Funktion von "removeTag".
	// Hier muss nichts spezielles gemacht werden
	removeTagCallback: function () {
		
		// Neu Aufbauen der Tagliste
		ContactList.getTagList();
	},
	
	
	buildTagListView: function () {
		
		var tagListViewContainer = YDom.get ('tagListViewContainer');
		
		// Pruefen, ob sich bereits Elemente im Container befinden.
		// In diesem Fall wird die Liste bereinigt und neu angelegt.
		if (tagListViewContainer.innerHTML != '') {
			
			/* Wir muessen hier innerHTML verwenden, da sonst
			   der IE6 das nicht kapiert !!! */
			tagListViewContainer.innerHTML = '';
		}
		
		if (typeof ContactList.tagList !== 'undefined' && ContactList.tagList.length > 0) {
			
			for (i=0; i < ContactList.tagList.length; i++) {
				
				var insertArrow = false;
				
				if (typeof ContactList.tagList[i] !== 'undefined') {
				
					var tagid 	= ContactList.tagList[i][0];
					var tag 	= ContactList.tagList[i][1];
					var count 	= ContactList.tagList[i][2];
					
					/* == Element mit der Information ueber die Haeufigkeit erstellen === */
					
						var countContainer = document.createElement ('div');
						
						// Eigenschaften zuweisen
						YDom.addClass (countContainer, 'count');
						YDom.addClass (countContainer, 'fl');
						YDom.addClass (countContainer, 'cb');
						YDom.addClass (countContainer, 'alignr');
						YDom.addClass (countContainer, 'fg_000');
						
						var countText = document.createTextNode (count);
						
						countContainer.appendChild (countText);
						tagListViewContainer.appendChild (countContainer);
					
					/* === Tag-Name mit Verlinkung === */
					
						var tagContainer = document.createElement ('div');
						
						// Eigenschaften zuweisen
						YDom.addClass (tagContainer, 'tag');
						YDom.addClass (tagContainer, 'fl');
	
						var tagLink = document.createElement ('a');
						tagLink.setAttribute ('href', ContactList.systemConfig['baseurl'] + '/bytag/' + escape (tagid) );
						YDom.addClass (tagLink, 'orange');
						
						if (ContactList.systemConfig['bytag'].length > 0 &&
							ContactList.systemConfig['bytag'] == tagid) {
							
							YDom.addClass (tagLink, 'bold');
							
							arrowActive = document.createElement ('img');
							arrowActive.setAttribute ( 'height', '11' );
							arrowActive.setAttribute ( 'width',  '6' );
							arrowActive.setAttribute ( 'src',    '/gfx/contacts_active_arrow.gif' );
							YDom.addClass (arrowActive, 'arrowActive');
							
							insertArrow = true; 
						}
						
						var tagText = document.createTextNode (tag);
						tagLink.appendChild (tagText);
						
						tagContainer.appendChild (tagLink);
						
						if (insertArrow == true) {
							
							tagContainer.appendChild (arrowActive);
						}
						
						tagListViewContainer.appendChild (tagContainer);
				}
			}
		}
	},
	
	// Weiterleitung an die Adresse, die im Dropdown angegeben wurde
	dropDownJump: function () {
		
		selectedElement = YDom.get('dropdown').value;
		
		if (selectedElement != '0' && selectedElement != '1' && selectedElement != '2'  && selectedElement != '3') {
			
			var url = ContactList.systemConfig['programurl'] + '/pc/pc/contacts/' + selectedElement;
			window.location.href = url;
		}
		else {
			
			return (false);
		}
	},
	
	setRequestResult: function (result, userid) {
		
		// Angegebene Zeile komplett aus dem DOM entfernen
		var removeRowFromDOM = function () {
			
			contactRow.parentNode.removeChild(contactRow);
		};
		
		// Animation zum "verstecken" einer Zeile
		var rowHeightAnimation = function () {
			
			var animationAttributes = {
			   height: 		{to: 0, unit: 'px'},
			   minHeight: 	{to: 0, unit: 'px'}
			};
			
			var rowAnimation = new YAHOO.util.Anim ( contactRow, animationAttributes, 0.35 );
			
			// Nach Beendigung der Animation das Element
			// komplett aus dem DOM entfernen.
			rowAnimation.onComplete.subscribe(removeRowFromDOM);
			rowAnimation.animate();
		};
		
		// Animation zum kolorieren einer Zeile
		var rowColorAnimation = function (fromAnimationColor) {
			
			// Hintergrundfarbe des aktuellen Kontaktes ermitteln
			var toAnimationColor = YDom.getStyle (contactRow, 'background-color');
			
			// Animation zurueck zur originalen Hintergrundfarbe
			var rowAnimation = new YAHOO.util.ColorAnim(contactRow, {backgroundColor: {from: fromAnimationColor, to: toAnimationColor}}, 1.5);
			
			rowAnimation.onComplete.subscribe(rowHeightAnimation);
			rowAnimation.animate();
		};
		
		// Daten an den Server senden
		var sendRequestResult = function () {
			
			cp.call ('/pc/inc/ajax_contacts.inc.php', 'publicBuddyRequest', sendRequestResultCallback, result, userid);
		};
		
		// Verarbeitung nach Ajax-Anfrage
		var sendRequestResultCallback = function (ajaxResult) {
			
		};
		
		
		// Container der Zeile ermitteln, in welcher sich der Kontakt
		// befindet. Ausserdem ermitteln, welche Kontakt-Ansicht aktuell
		// verwendet wird.
		var contactRow = YDom.get ('row_' + userid);
		
		if (userid > 0 && (result == 1 || result == 0)) {
		
			switch (result) {
				
				// Anfrage wurde angenommen
				case "1":
				
					rowColorAnimation('#41A62A');
					
				break;
				
				// Anfrage wurde abgelehnt
				case "0":
				
					rowColorAnimation('#CC0000');
				
				break;
			}
			
			// Daten an den Server senden
			sendRequestResult();
		}
	}
};


var ContactDropDown = {
	
	contactid: 			false,
	ContactOverlay: 	false,
	externalView:		0,
	use_button:			0,
	
	open: function (contactid, use_button) {
		
		// Soll der Container am Icon oder am Button
		// positioniert werden ? Diesen Status aufnehmen.
		ContactDropDown.use_button = use_button;
		
		// Notwendige Daten abrufen, und dann zur Funktion "render" wechseln.
		cp.call ('/pc/inc/ajax_contacts.inc.php', 'getOverlayData', ContactDropDown.render, contactid);
	},
	
	
	close: function () {
		
		ContactDropDown.ContactOverlay.destroy();
	},
	
	
	render: function (resultObj) {
		
		// Variablen vordefinieren
		contactListType = 'profile';
		
		if ( YDom.get ('contactlisttype') !== null) {
			
			var contactListType = YDom.get ('contactlisttype').value;
		}
		
		if (typeof resultObj.ajaxResponse[0].user[0] !== 'undefined') {
			
			var userdata = resultObj.ajaxResponse[0].user[0];
			
			/* ===== Notwendige Daten auslesen ===== */
			
				ContactDropDown.contactid = userdata.id[0].data;
				var contactName = userdata.name[0].data;
				var imgurl		= userdata.url[0].data;
				var can_ignore	= userdata.can_ignore[0].data;
				var can_buddy	= userdata.can_buddy[0].data;
				var can_public	= userdata.can_public[0].data;
				var status		= userdata.status[0].data;
				
			/* ===== Notwendige Uebersetzungen auslesen ===== */
							
				var t_contacts_makebuddy 		=  userdata.t_contacts_makebuddy[0].data;
				var t_contacts_makepublicbuddy 	=  userdata.t_contacts_makepublicbuddy[0].data;
				var t_contacts_nofriend 		=  userdata.t_contacts_nofriend[0].data;
				var t_contacts_ignore 			=  userdata.t_contacts_ignore[0].data;
				var t_contacts_close			= userdata.t_contacts_close[0].data;

			/* ===== Container fuer das Overlay ===== */
			
				var overlayContainer = document.createElement ('div');
				
				overlayContainer.setAttribute ('id', 'overlayContainer_' + ContactDropDown.contactid);
				
				YDom.addClass (overlayContainer, 'bg_ccc');
				YDom.addClass (overlayContainer, 'ContactsOverlayContainer');
				
			/* ===== Hinzufuegen des Usernamen ===== */
			
				var overlayUsernameElement 	= document.createElement ('h3');
				YDom.addClass (overlayUsernameElement, 'fg_000');
				
				overlayUsernameText 	= document.createTextNode (contactName);
				overlayUsernameElement.appendChild (overlayUsernameText);
				
				overlayContainer.appendChild (overlayUsernameElement);
			
			/* ===== Container fuer das Profilfoto ===== */
			
				var overlayFotoContainer = document.createElement ('div');
				
				YDom.addClass (overlayFotoContainer, 'fl');
				YDom.setStyle (overlayFotoContainer, 'width',  '120px');
				YDom.setStyle (overlayFotoContainer, 'height', '110px');
				
				overlayContainer.appendChild (overlayFotoContainer);
				
			/* ===== Profilfoto ===== */
			
				var overlayFoto = document.createElement ('img');
				
				overlayFoto.setAttribute ('border', '0');
				overlayFoto.setAttribute ('src', imgurl);
				YDom.addClass (overlayFoto, 'overlayFoto');
				
				overlayFotoContainer.appendChild (overlayFoto);
			
			/* ===== Container fuer die Funktionslinks ===== */
			
				var overlayFunctionContainer = document.createElement ('div');
				overlayFunctionContainer.setAttribute ('id', 'overlayLinks');
				YDom.addClass (overlayFunctionContainer, 'overlayLinks');
				YDom.addClass (overlayFunctionContainer, 'fg_000');
				YDom.addClass (overlayFunctionContainer, 'fl');
				YDom.setStyle (overlayFunctionContainer, 'width',  '180px');
				YDom.setStyle (overlayFunctionContainer, 'height', '110px');
			
				overlayContainer.appendChild (overlayFunctionContainer);
				
			/* ===== Funktionslinks einfuegen: Als Freund merken ===== */
			
				if (status != 'b' && can_buddy == 1) {
					
					/* === Container fuer das Icon === */
					
					var iconContainerBuddy = document.createElement ('div');
					YDom.addClass (iconContainerBuddy, 'iconContainer');
					YDom.addClass (iconContainerBuddy, 'fl cb');
					overlayFunctionContainer.appendChild (iconContainerBuddy);
					
					/* === Status-Icon === */
					
					var icon_buddy = document.createElement ('img');
					icon_buddy.setAttribute ('src', '/gfx/contacticons/is_buddy.gif');
					icon_buddy.setAttribute ('border', '0');
					icon_buddy.setAttribute ('width', '19');
					icon_buddy.setAttribute ('height', '15');
					
					iconContainerBuddy.appendChild (icon_buddy);
				
					/* === Container fuer den Link === */
					
					var linkBuddyContainer = document.createElement ('div');
					YDom.addClass (linkBuddyContainer, 'fl');
					overlayFunctionContainer.appendChild (linkBuddyContainer);
					
					/* === Link === */
					
					/* Wir muessen hier mit innerHTML arbeiten, weil der IE6 das sonst nicht richtig kann */
					linkBuddyContainer.innerHTML = '<a href="#" onClick="ContactDropDown.action (\'buddy\'); return (false);" class="black functionLink">' + t_contacts_makebuddy + '</a>';
				}
				
			/* ===== Funktionslinks einfuegen: oeffentlicher Freund ===== */
			
				if (status != 'p' && can_public == 1) {
					
					/* === Container fuer das Icon === */
					
					var iconContainerPublic = document.createElement ('div');
					YDom.addClass (iconContainerPublic, 'iconContainer');
					YDom.addClass (iconContainerPublic, 'fl cb');
					overlayFunctionContainer.appendChild (iconContainerPublic);
					
					/* === Status-Icon === */
					
					var icon_public = document.createElement ('img');
					icon_public.setAttribute ('src', '/gfx/contacticons/is_public.gif');
					icon_public.setAttribute ('border', '0');
					icon_public.setAttribute ('width', '19');
					icon_public.setAttribute ('height', '15');
					
					iconContainerPublic.appendChild (icon_public);
					
					/* === Container fuer den Link === */
					
					var linkpublicBuddyContainer = document.createElement ('div');
					YDom.addClass (linkpublicBuddyContainer, 'fl');
					YDom.addClass (linkpublicBuddyContainer, 'textContainer');
					overlayFunctionContainer.appendChild (linkpublicBuddyContainer);

					/* === Link === */
					
					/* Wir muessen hier mit innerHTML arbeiten, weil der IE6 das sonst nicht richtig kann */
					linkpublicBuddyContainer.innerHTML = '<a href="#" onClick="ContactDropDown.action (\'public\'); return (false);" class="black functionLink">' + t_contacts_makepublicbuddy + '</a>';
				}	
			
			/* ===== Funktionslinks einfuegen: Als Freund merken mit weiterleitung auf pay ===== */
				
				if (status != 'b' && can_buddy == 'x') {
					
					/* === Container fuer das Icon === */
					
					var iconContainerBuddy = document.createElement ('div');
					YDom.addClass (iconContainerBuddy, 'iconContainer');
					YDom.addClass (iconContainerBuddy, 'fl cb');
					overlayFunctionContainer.appendChild (iconContainerBuddy);
					
					/* === Status-Icon === */
					
					var icon_buddy = document.createElement ('img');
					icon_buddy.setAttribute ('src', 'http://gfx.fotocommunity.com/ram/gfx/contacticons/is_buddy.gif');
					icon_buddy.setAttribute ('border', '0');
					icon_buddy.setAttribute ('width', '19');
					icon_buddy.setAttribute ('height', '15');
					
					iconContainerBuddy.appendChild (icon_buddy);
				
					/* === Container fuer den Link === */
					
					var linkBuddyContainer = document.createElement ('div');
					YDom.addClass (linkBuddyContainer, 'fl');
					overlayFunctionContainer.appendChild (linkBuddyContainer);
					
					/* === Link === */
					
					/* Wir muessen hier mit innerHTML arbeiten, weil der IE6 das sonst nicht richtig kann */
					linkBuddyContainer.innerHTML = '<a href="#" onClick="javascript:ContactDropDown.close();showLimitboxOverlay(6,0);" class="black functionLink">' + t_contacts_makebuddy + '</a>';
					//linkBuddyContainer.innerHTML = '<a href="https://' + window.location.hostname + '/membership/upgrade/friends" class="black functionLink">' + t_contacts_makebuddy + '</a>';
				}
			
			/* ===== Funktionslinks einfuegen: oeffentlicher Freund, weiterleitung auf pay ===== */
			
				if (status != 'p' && can_public == 'x') {
					
					/* === Container fuer das Icon === */
					
					var iconContainerPublic = document.createElement ('div');
					YDom.addClass (iconContainerPublic, 'iconContainer');
					YDom.addClass (iconContainerPublic, 'fl cb');
					overlayFunctionContainer.appendChild (iconContainerPublic);
					
					/* === Status-Icon === */
					
					var icon_public = document.createElement ('img');
					icon_public.setAttribute ('src', 'http://gfx.fotocommunity.com/ram/gfx/contacticons/is_public.gif');
					icon_public.setAttribute ('border', '0');
					icon_public.setAttribute ('width', '19');
					icon_public.setAttribute ('height', '15');
					
					iconContainerPublic.appendChild (icon_public);
					
					/* === Container fuer den Link === */
					
					var linkpublicBuddyContainer = document.createElement ('div');
					YDom.addClass (linkpublicBuddyContainer, 'fl');
					YDom.addClass (linkpublicBuddyContainer, 'textContainer');
					overlayFunctionContainer.appendChild (linkpublicBuddyContainer);

					/* === Link === */
					
					/* Wir muessen hier mit innerHTML arbeiten, weil der IE6 das sonst nicht richtig kann */
					linkpublicBuddyContainer.innerHTML = '<a href="#" onClick="javascript:ContactDropDown.close();showLimitboxOverlay(6,0);" class="black functionLink">' + t_contacts_makepublicbuddy + '</a>';
					//linkpublicBuddyContainer.innerHTML = '<a href="https://' + window.location.hostname + '/membership/upgrade/friends" class="black functionLink">' + t_contacts_makepublicbuddy + '</a>';
				}	
			
			/* ===== Funktionslinks einfuegen: kein Freund mehr ===== */
			
				if ( status.length > 0 ) {
			
					/* === Container fuer das Icon === */
					
					var iconContainerNeutral = document.createElement ('div');
					YDom.addClass (iconContainerNeutral, 'iconContainer');
					YDom.addClass (iconContainerNeutral, 'fl cb');
					overlayFunctionContainer.appendChild (iconContainerNeutral);
					
					/* === Status-Icon === */
					
					var icon_neutral = document.createElement ('img');
					icon_neutral.setAttribute ('src', '/gfx/contacticons/is_neutral.gif');
					icon_neutral.setAttribute ('border', '0');
					icon_neutral.setAttribute ('width', '19');
					icon_neutral.setAttribute ('height', '15');
					
					iconContainerNeutral.appendChild (icon_neutral);
				
					/* === Container fuer den Link === */
					
					var linkNoFriendContainer = document.createElement ('div');
					YDom.addClass (linkNoFriendContainer, 'fl');
					YDom.addClass (linkNoFriendContainer, 'textContainer');
					overlayFunctionContainer.appendChild (linkNoFriendContainer);
				
					/* === Link === */
					
					/* Wir muessen hier mit innerHTML arbeiten, weil der IE6 das sonst nicht richtig kann */
					linkNoFriendContainer.innerHTML = '<a href="#" onClick="ContactDropDown.action (\'nobuddy\'); return (false);" class="black functionLink">' + t_contacts_nofriend + '</a>';
				}
				
			/* ===== Funktionslinks einfuegen: Ignorieren ===== */
			
				if ( status != 'i' && can_ignore == 1 ) {
			
					/* === Container fuer das Icon === */
					
					var iconContainerIgnore = document.createElement ('div');
					YDom.addClass (iconContainerIgnore, 'iconContainer');
					YDom.addClass (iconContainerIgnore, 'fl cb');
					overlayFunctionContainer.appendChild (iconContainerIgnore);
					
					/* === Status-Icon === */
					
					var icon_ignore = document.createElement ('img');
					icon_ignore.setAttribute ('src', '/gfx/contacticons/is_ignore.gif');
					icon_ignore.setAttribute ('border', '0');
					icon_ignore.setAttribute ('width', '19');
					icon_ignore.setAttribute ('height', '15');
					
					iconContainerIgnore.appendChild (icon_ignore);
			
					/* === Container fuer den Link === */
					
					var linkIgnoreContainer = document.createElement ('div');
					YDom.addClass (linkIgnoreContainer, 'fl');
					YDom.addClass (linkIgnoreContainer, 'textContainer');
					overlayFunctionContainer.appendChild (linkIgnoreContainer);
				
					/* === Link === */
					
					/* Wir muessen hier mit innerHTML arbeiten, weil der IE6 das sonst nicht richtig kann */
					linkIgnoreContainer.innerHTML = '<a href="#" onClick="ContactDropDown.action (\'ignore\'); return (false);" class="black functionLink">' + t_contacts_ignore + '</a>';
				}
				
			/* ===== Container fuer den Schlieen-Button ===== */
			
				var overlayCloseContainer = document.createElement ('div');
				YDom.addClass (overlayCloseContainer, 'fl');
				YDom.addClass (overlayCloseContainer, 'alignr');
				YDom.setStyle (overlayCloseContainer, 'width', '290px');

				overlayContainer.appendChild (overlayCloseContainer);				
				
			/* ===== Link zum schliessen des Overlays ===== */
			
				/* Wir muessen hier mit innerHTML arbeiten, weil der IE6 das sonst nicht richtig kann */
				overlayCloseContainer.innerHTML = '<a href="#" onClick="ContactDropDown.close(); return(false);" class="black size10px">' + t_contacts_close +' [x]</a>';
				
			/* ===== Overlay zusammenbauen und ausgeben ===== */
			
				var row_icon =  YDom.get ('row_icon_' + ContactDropDown.contactid);
				var YOverlay = YAHOO.widget.Overlay;
			
				if (row_icon !== null) {
			
					ContactDropDown.ContactOverlay = new YOverlay(overlayContainer, {
					
						width: 	'300px',
						height: '155px',
						context: [ row_icon, "tr", "br" ]
						
					} );
				}
				else if (ContactDropDown.use_button == 1) {
					
					ContactDropDown.ContactOverlay = new YOverlay(overlayContainer, {
					
						width: 	'300px',
						height: '155px',
						context: [ 'button_buddy', "tl", "bl" ]
						
					} );
				}
				else {
					
					ContactDropDown.ContactOverlay = new YOverlay(overlayContainer, {
					
						width: 	'300px',
						height: '155px',
						context: [ 'BuddyIcon_' + ContactDropDown.contactid, "tl", "bl" ]
						
					} );
				}
				
				ContactDropDown.ContactOverlay.render(document.body);
		}
	},
	
	
	action: function (actionType) {
		
		// Variablen vordefinieren
		contactListType = 'profile';
		
		// Angegebene Zeile komplett aus dem DOM entfernen
		var removeRowFromDOM = function () {
			
			contactRow.parentNode.removeChild(contactRow);
		};
		
		// Animation zum "verstecken" einer Zeile
		var rowHeightAnimation = function () {
			
			var animationAttributes = {
			   height: 		{to: 0, unit: 'px'},
			   minHeight: 	{to: 0, unit: 'px'}
			};
			
			var rowAnimation = new YAHOO.util.Anim ( contactRow, animationAttributes, 0.35 );
			
			// Nach Beendigung der Animation das Element
			// komplett aus dem DOM entfernen.
			rowAnimation.onComplete.subscribe(removeRowFromDOM);
			rowAnimation.animate();
		};
		
		// Animation zum kolorieren einer Zeile
		var rowColorAnimation = function (fromAnimationColor, runRemoveAnimation) {
			
			// Hintergrundfarbe des aktuellen Kontaktes ermitteln
			var toAnimationColor = YDom.getStyle (contactRow, 'background-color');
			
			// Animation zurueck zur originalen Hintergrundfarbe
			var rowAnimation = new YAHOO.util.ColorAnim('row_' + ContactDropDown.contactid, {backgroundColor: {from: fromAnimationColor, to: toAnimationColor}}, 1.5);
			
			if (runRemoveAnimation == true && ContactDropDown.externalView == 0) {
				
				rowAnimation.onComplete.subscribe(rowHeightAnimation);
			}
			
			rowAnimation.animate();
		};
		
		
		// Die Aenderung an den Server senden.
		var changeContactStatusOnServer = function () {
			
			cp.call ('/pc/inc/ajax_contacts.inc.php', 'changeContactStatus', changeContactStatusCallback, ContactDropDown.contactid, actionType);
		};
		
		var changeContactStatusCallback = function (resultObj) {
		
			// Variablen vordefinieren
			var changeIconTo = false;
			
			// Die Aktion und deren Status an Google Analytics uebergeben
			_gaq.push(['_trackEvent', 'Interaction', 'Buddy', actionType]);
			
			if (actionType == 'nobuddy') {
			
				// Pruefen, ob der Tag-Container im DOM vorhanden ist.
				// Wenn ja, dann neu aufbauen, da eventuell Schlagworte
				// entfernt wurden.
				var tagListViewContainer = YDom.get ('tagListViewContainer');
				if ( typeof tagListViewContainer !== 'undefined' ) {
					
					ContactList.getTagList();
				}
			}
			
			if (actionType == 'public') {
				
				if (typeof resultObj.ajaxResponse[0].data !== 'undefined') {
					
					var resultArray = resultObj.ajaxResponse[0].data.split ("||");
					
					// Hinweis im Overlay ausgeben.
					YDom.get ('overlayLinks').innerHTML = resultArray[1];
					
					if (Number (resultArray[0]) > 0) {
					
						if ( Number(resultArray[0]) == 2) {
						
							changeIconTo = 'public_accepted';
						}
						
						if (typeof contactRow !== 'undefined') {
							
							// Wenn der Nutzer in der Ansicht "alle Freunde" ist,
							// dann die Zeile nicht entfernen, und das Buddy-Icon
							// einfaerben.
							if (contactListType == 'buddies') {
								
								var fromAnimationColor = '#41A62A';
								rowColorAnimation(fromAnimationColor, false);
								
								// Icon anpassen
								changeIcon(changeIconTo);
								
							}
							else if (contactListType == 'profile') {
								
								// Icon anpassen
								changeIcon(changeIconTo);
							}
							else {
								
								if (ContactDropDown.externalView == 0) {
									
									var fromAnimationColor = '#FF9900';
									rowColorAnimation(fromAnimationColor, true);
								}
								else {
									
									// Icon anpassen
									changeIcon(changeIconTo);
									
									var fromAnimationColor = '#FF9900';
									rowColorAnimation(fromAnimationColor, true);
								}							
							}
						}
						else {
					
							// Icon anpassen
							changeIcon(changeIconTo);
						}
					}
				}
			}
		};
		
		var changeIcon = function (changeIconTo) {
			
			// Variablen vordefinieren
			var icon_image;
			var icon_buddy_button;
			
			if (typeof (changeIconTo) == 'undefined' || changeIconTo == false) {changeIconTo = actionType;}
			
			// Ermitteln, welches Icon gesetzt werden soll.
			switch (changeIconTo) {
				
				case "buddy":
				
					icon_image			= '/gfx/contacticons/is_buddy.gif';
					icon_buddy_button 	= '/gfx/buttons/button_icon_buddy.gif';
				
				break;
				
				case "public":
				
					icon_image	 		= '/gfx/contacticons/is_pending.gif';
					icon_buddy_button 	= '/gfx/buttons/button_icon_pending.gif';
				
				break;
				
				case "public_accepted":
				
					icon_image	 		= '/gfx/contacticons/is_public.gif';
					icon_buddy_button 	= '/gfx/buttons/button_icon_public.gif';
				
				break;
				
				case "nobuddy":
				
					icon_image	 		= '/gfx/contacticons/is_neutral.gif';
					icon_buddy_button 	= '/gfx/buttons/button_icon_neutral.gif';
				
				break;
				
				case "ignore":
				
					icon_image	 		= '/gfx/contacticons/is_ignore.gif';
					icon_buddy_button 	= '/gfx/buttons/button_icon_ignore.gif';
				
				break;
			}
			
			// Anpassen des Buddy-Icons, falls vorhanden
			if ( YDom.get ('BuddyIcon_' + ContactDropDown.contactid) !== null ) {
				
				 YDom.get ('BuddyIcon_' + ContactDropDown.contactid).src = icon_image;	
			}
			
			
			// Icon des Buddy-Buttons aendern, falls vorhanden
			if ( YDom.get ('icon_buddy_button') !== null ) {
				
				 YDom.get ('icon_buddy_button').src = icon_buddy_button;	
			}
		};
		
		// Container der Zeile ermitteln, in welcher sich der Kontakt
		// befindet. Ausserdem ermitteln, welche Kontakt-Ansicht aktuell
		// verwendet wird.
		var contactRow = YDom.get ('row_' + ContactDropDown.contactid);
		
		if ( YDom.get ('contactlisttype') !== null) {
			
			var contactListType 			= YDom.get ('contactlisttype').value;
			ContactDropDown.externalView	= YDom.get ('external').value;
			
			switch (actionType) {
				
				case "buddy":
				
					// Das Overlay "zerstoeren"
					ContactDropDown.ContactOverlay.destroy();
				
					// Wenn der Nutzer in der Ansicht "alle Freunde" ist,
					// dann die Zeile nicht entfernen, und das Buddy-Icon
					// einfaerben.
					if (contactListType == 'buddies') {
					
						var fromAnimationColor = '#FF9900';
						rowColorAnimation(fromAnimationColor, false);
						
						// Icon anpassen
						changeIcon();
					}
					else if (contactListType == 'fotografen') {
						
						// Icon anpassen
						changeIcon();
					}
					else {
						
						if (ContactDropDown.externalView == 0) {
							
							var fromAnimationColor = '#FF9900';
							rowColorAnimation(fromAnimationColor, true);
						}
						else {
							
							// Icon anpassen
							changeIcon();
							
							var fromAnimationColor = '#FF9900';
							rowColorAnimation(fromAnimationColor, true);
						}
					}
				
				break;
				
				case "public":
				
					// Wird in der Funktion "changeContactStatusCallback"
					// verarbeitet, da eine Rckmeldung vom Server
					// erforderlich ist.
				
				break;
				
				case "nobuddy":
				
					// Das Overlay "zerstoeren"
					ContactDropDown.ContactOverlay.destroy();
					
					// Icon anpassen
					changeIcon();
					
					var fromAnimationColor = '#4A4A4A';
					rowColorAnimation(fromAnimationColor, true);
				
				break;
				
				case "ignore":
				
					// Das Overlay "zerstoeren"
					ContactDropDown.ContactOverlay.destroy();
					
					// Icon anpassen
					changeIcon();
				
					var fromAnimationColor = '#CC0000';
					rowColorAnimation(fromAnimationColor, true);
				
				break;
			}
		}
		else {
		
			if (actionType != 'public') {

				// Das Overlay "zerstoeren"
				ContactDropDown.ContactOverlay.destroy();
				
				// Icon anpassen
				changeIcon();
			}
			
		}
		
		// Die Status-Aenderung an den Server
		// weitergeben.
		changeContactStatusOnServer();
	}
};

var publish_foto = {
	
	slider:			false,
	margevalue:		false,
	
	// Slider initialisieren
	initSliderMarge: function () {
		
		// Slider initialisieren.
		publish_foto.slider = YAHOO.widget.Slider.getHorizSlider("slider_marge-bg", "slider-thumb", 0, 346);
		
		YDom.get('slider-thumb').style.left = '0px';

		publish_foto.margevalue = YDom.get('default_marge').value;

		// Sobald der Slider bewegt wird, wird die Funktion "sliderValueChangeMarge" aufgerufen.
		publish_foto.slider.subscribe("change", publish_foto.sliderValueChangeMarge);
		
		// Wenn bereits eine Stimme abgegeben wurde, den Slider
		// auf den entsprechenden Wert setzen.
		if (publish_foto.margevalue > 0) {
			
			// Umrechnung der Punkte auf den Slider
			sliderValue = Number (publish_foto.margevalue *34.6 / 30);
			sliderValue = Math.round(sliderValue);

			// Den Slider auf den gedrueckten Wert bewegen
			publish_foto.slider.setValue(sliderValue,true,true);
			
		}		
	},
	
	
	// Die Funktion reagiert auf Aenderungen des Sliders der Quick-Start-Seite
	sliderValueChangeMarge: function (sliderValue) {
		
		margePoints = Number (sliderValue * 30 / 34.6);
		
		// Sicherstellen, dass nicht mehr als 300 Prozent vergeben werden koennen.
		if ( margePoints > 300 ) {
		
			margePoints = 300;
		}

		YDom.get('margevalue').innerHTML = margePoints.toFixed(0)+' %';
		YDom.get('default_marge').value = margePoints.toFixed(0);		

		var margevalue_abs = Math.round((margePoints.toFixed(0)/100*1.18)*100)/100;
		if(YDom.get('margevalue_abs')) {
			YDom.get('margevalue_abs').innerHTML = margevalue_abs.replace(/./, ",")+' EUR';
		}
	}
};

var publish_fotolist = {
	
	// Mouseover Funktionalitaet fuer die Icons initialisieren
	initMouseOver: function () {
		
		// Elemente fuer das Mouseover
		var mouseOverElements =  YDom.getElementsByClassName('publish_thumbs', 'img');

		YEvent.addListener (mouseOverElements, 'mouseover', publish_fotolist.mouseOverHandler, YEvent);
		YEvent.addListener (mouseOverElements, 'mouseout',  publish_fotolist.mouseOutHandler, YEvent);
	},
	
	mouseOverHandler: function (e) {

		var img = YDom.get(this);

		var xPos = YEvent.getPageX(e);
		var yPos = YEvent.getPageY(e);
		
		YDom.get('bigger_img_'+img.id).style.top = (yPos-100)+'px';
		YDom.get('bigger_img_'+img.id).style.display = 'block';
	},
	
	mouseOutHandler: function (e) {

		var img = YDom.get(this);
		
		YDom.get('bigger_img_'+img.id).style.display = 'none';
	},
	
	// Empfang des Ergebnisses und Anzeige der richtigen Darstellung Hkchen / Kreuz 
	setPublishAllowance: function (result) {

		// Pruefen, ob ein AJAX-Result vorliegt.
		if (typeof(result) !== 'undefined') {
		
			if(result.ajaxResponse[0].descrid[0].data>0) {
				if(result.ajaxResponse[0].allowance[0].data==1) {
					document.getElementById('cb_'+result.ajaxResponse[0].descrid[0].data+'_1').className = 'cb_small_yes';
					document.getElementById('cb_'+result.ajaxResponse[0].descrid[0].data+'_2').className = 'cb_small_neutral';
					document.getElementById('publish_allowed_'+result.ajaxResponse[0].descrid[0].data).value = 'y';
	
					
				} else {
					document.getElementById('cb_'+result.ajaxResponse[0].descrid[0].data+'_1').className = 'cb_small_neutral';
					document.getElementById('cb_'+result.ajaxResponse[0].descrid[0].data+'_2').className = 'cb_small_no';
					document.getElementById('publish_allowed_'+result.ajaxResponse[0].descrid[0].data).value = 'n';
				}
			}	
		}
		
	},
	
	changeMarge: function (result) {
		// Pruefen, ob ein AJAX-Result vorliegt.
		if (typeof(result) !== 'undefined') {

			if(result.ajaxResponse[0].descrid[0].data>0) {
				
				if(result.ajaxResponse[0].marge[0].data==15) {
					document.getElementById('cb_'+result.ajaxResponse[0].descrid[0].data+'_15').className = 'cb_xsmall_yes';
					document.getElementById('cb_'+result.ajaxResponse[0].descrid[0].data+'_30').className = 'cb_xsmall_neutral';
					document.getElementById('marge_'+result.ajaxResponse[0].descrid[0].data+'_text15').className = 'fl bold';
					document.getElementById('marge_'+result.ajaxResponse[0].descrid[0].data+'_text30').className = 'fl';
					document.getElementById('marge_'+result.ajaxResponse[0].descrid[0].data).value = 15;
					
				} else {
					document.getElementById('cb_'+result.ajaxResponse[0].descrid[0].data+'_15').className = 'cb_xsmall_neutral';
					document.getElementById('cb_'+result.ajaxResponse[0].descrid[0].data+'_30').className = 'cb_xsmall_yes';
					document.getElementById('marge_'+result.ajaxResponse[0].descrid[0].data+'_text15').className = 'fl';
					document.getElementById('marge_'+result.ajaxResponse[0].descrid[0].data+'_text30').className = 'fl bold';
					document.getElementById('marge_'+result.ajaxResponse[0].descrid[0].data).value = 30;
				}
			}
		}		
	},
	
	// Funktionsaufruf nach dem ndern der Freigabe	
	click_change_marge: function (user_id, descr_id, marge) {
		cp.call ('/pc/inc/ajax_publish.inc.php', 'changeMarge', publish_fotolist.changeMarge, user_id, descr_id, marge);
	},

	// Funktionsaufruf nach dem ndern der Freigabe	
	click_publish_allowance: function (user_id, descr_id, allowance) {
		cp.call ('/pc/inc/ajax_publish.inc.php', 'setPublishAllowance', publish_fotolist.setPublishAllowance, user_id, descr_id, allowance);
	}
};

var display_foto = {
	
	is_privateFavourite: 	false,
	is_publicFavourite:  	false,
	current_photo:		 	false,
	nvotenow:		 		false,
	slider:				 	false,
	keyboardBuffer:		 	false,
	keyboardBufferActive:	false,
	fotoWidth:				false,
	resizeListener:			false,
	origMouseOverImg:		false,
	keyboardBufferTimeout:	2000,
	shareDialog:			false,
	
	// Sprachvariablen initialisieren
	txt_Yes:			 	false,
	txt_No:			 	 	false,
	txt_DeleteTitle: 	 	false,
	txt_DeleteText: 	 	false,
	txt_HomepageTitle: 	 	false,
	txt_HomepageText: 	 	false,
	
	
	// Beim Aufruf der Display-Seite fuer Fotos wird diese Funktion
	// aufgerufen. Diese fuehrt eine Reihe von Standard-Events durch.
	initPage: function () {

		// Den HTML-Body auf die volle Breite setzen.
		// Der Platzhalter fuer das Menue wird dadurch
		// mit fuer die Anzeige des Fotos verwendet.
		YDom.setStyle('fc_body', 'width', '801px'); 
		
		// Breite des Fotos ermitteln
		display_foto.fotoWidth = YDom.get ('xsize').value;
		
		// ggf. die Positionierung des Fotos anpassen, wenn
		// dies breiter als die Seitenbreite der fc ist.
		//display_foto.correctImagePosition();
		
		// Auslesen der aktuellen FotoID
		display_foto.current_photo = YDom.get ('current_photo').value;
		
		if ( ! YDom.get('orderPrints') ) {
/*		
			// Mit der Taste "links" gelangt der Nutzer zum vorherigen Foto
			ListenerKeyBack = new YUtil.KeyListener (document, {keys: 37}, {fn: display_foto.keypress_back});
			ListenerKeyBack.enable();
			
			// Mit der Taste "rechts" gelangt der Nutzer zum naechsten Foto
			ListenerKeyForward = new YUtil.KeyListener (document, {keys: 39}, {fn: display_foto.keypress_forward});
			ListenerKeyForward.enable();
*/			
		}
		
		// Mit dem Klick auf das Foto soll der Besucher zum naechsten Foto gelangen.
		// Hierfuer lesen wir erstmal aus, ob es sich bei dem Foto um ein Panorama
		// handelt welches im Java-Viewer dargestellt werden soll. Ist dies der Fall,
		// so wir der Klick auf Foto nicht aktiviert.
		var isPanorama = YDom.get ('smp').value;
		
		if ( ! isPanorama || isPanorama == 0 || isPanorama == 10 ) {
		
			YEvent.addListener ('fc_image', 'click', display_foto.keypress_forward);
		}
		
		// Nachdem das Foto klickbar gemacht wurde, soll nun noch der Cursor
		// angepasst werden.
		YDom.setStyle('fc_image', 'cursor', 'pointer'); 
		
		// Tooltip fuer die Sektion initialisieren
		YEvent.onAvailable ('sectionname', display_foto.initSectionToolTip);
		
		// Tooltip fuer den fotohome-Namen initialisieren
		YEvent.onAvailable ('psectionname', display_foto.initfotohomeToolTip);		
		
		// Tooltip fuer den Galerie-Namen initialisieren
		YEvent.onAvailable ('gallerysection', display_foto.initGalleryToolTip);

		// Tooltip fuers Sharing initialisieren
		YEvent.onAvailable ('sharing', display_foto.initSharingToolTip);

		// Favoriten-Buttons generieren, sobald der Contaniner verfuergar ist.
		YEvent.onAvailable('div_public_fav', display_foto.getFavouriteStatus);
		
		// Groesse der Infoboxen anpassen
		YEvent.onAvailable('container_right', display_foto.resizeInfoBoxes);
	},
	
	
	// Groe der Infoboxen anpassen
	resizeInfoBoxes: function () {
		
		// aktuelle Groesse der linken und rechten Infobox ermitteln
		var heightLeft 	= YDom.get('container_left').offsetHeight;
		var heightRight	= YDom.get('container_right').offsetHeight;
		
		// Schauen, welches der Elemente hoeher ist. Im Anschluss
		// die Hoehe beider Elemente aneinander angleichen
		if (heightLeft > heightRight) {
			
			var differenz = heightLeft - heightRight;
			
			// Padding/Hoehe der rechten Infobox anpassen
 			YDom.get('container_right').style.paddingTop 	= Number (differenz / 2) + 'px';
			YDom.get('container_right').style.paddingBottom = Number (differenz / 2) + 'px';

		}
		else if (heightRight > heightLeft) {
			
			var differenz = heightRight - heightLeft;
			
			// Padding/Hoehe der linken Infobox anpassen
			YDom.get('container_left').style.paddingTop 	= Number (differenz / 2) + 'px';
			YDom.get('container_left').style.paddingBottom 	= Number (differenz / 2) + 'px';
		}
	},
	
	// Tooltips fuer die Funktionsicons initialisieren
	initToolTips: function () {
		
		// Die Tooltips werden fuer jedes Element seperat initialisiert, da sonst die CSS-Angabe
		// width:auto nicht korrekt arbeitet.
		var tooltipQuickMessage = new YAHOO.widget.Tooltip("tooltipQuickMessage", 	{context:"icon_qm"});
		var tooltipFotomail 	= new YAHOO.widget.Tooltip("tooltipFotomail", 		{context:"icon_fm"});
		var tooltipPrivateFav 	= new YAHOO.widget.Tooltip("tooltipPrivateFav",		{context:"icon_private_fav"});
		var tooltipPublicFav 	= new YAHOO.widget.Tooltip("tooltipPublicFav",		{context:"icon_public_fav"});
		var tooltipGallery 		= new YAHOO.widget.Tooltip("tooltipGallery",		{context:"icon_galerie"});
		var tooltipSharing 		= new YAHOO.widget.Tooltip("tooltipSharing",		{context:"icon_sharing"});
	},
	
	
	// Tooltip fuer die Sektion
	initSectionToolTip: function () {
		
		var tooltipSection		= new YAHOO.widget.Tooltip("tooltipSection", 	{context:"sectionname"});
	},
	
	// Tooltip fuer den fotohome-Ordner
	initfotohomeToolTip: function () {
		
		var tooltipFotohome		= new YAHOO.widget.Tooltip("tooltipFotohome", 	{context:"psectionname"});
	},
	
	// Tooltip fuer die Galerie-Sektion
	initGalleryToolTip: function () {
		
		var tooltipGallery		= new YAHOO.widget.Tooltip("tooltipGallery", 	{context:"gallerysection"});
	},
	
	// Tooltip fuers Sharing
	initSharingToolTip: function () {
		
		var tooltipSharing		= new YAHOO.widget.Tooltip("tooltipSharing", 	{context:"sharing"});
	},
	
	// Mouseover Funktionalitaet fuer die Icons initialisieren
	initMouseOver: function () {
		
		// Elemente fuer das Mouseover
		var mouseOverElements = ['icon_qm', 'icon_fm', 'icon_private_fav', 'icon_public_fav', 'icon_galerie','icon_sharing'];
		
		YEvent.addListener (mouseOverElements, 'mouseover', display_foto.mouseOverHandler);
		YEvent.addListener (mouseOverElements, 'mouseout',  display_foto.mouseOutHandler);
	},
	
	mouseOverHandler: function () {
		
		// Original-Icon merken
                if(this.id.indexOf('_hover') > 0) {
                    var newId = this.id.split('_hover');
                    var replaceId = newId[0];
                } else {
                    replaceId = this.id;
                }
                display_foto.origMouseOverId = replaceId;
		
		
		YDom.get(this.id).id = replaceId +'_hover';
	},
	
	mouseOutHandler: function () {
		
		// Original Icon wiederherstellen
		YDom.get (this.id).id = display_foto.origMouseOverId;
	},
	
	// ggf. die Positionierung des Fotos anpassen, wenn
	// dies breiter als die Seitenbreite der fc ist.
	correctImagePosition: function () {
		
		var fcPageSize 		= 800;
		var browserWidth 	= YDom.getViewportWidth();
		
		// Browser-Typ und Version ermitteln
		var ua = window.navigator.userAgent.toLowerCase();
		
		// Pruefen, ob das Foto breiter ist als die fc-Seite
		if (display_foto.fotoWidth > fcPageSize) {
		
			// Default-Wert setzen
			var correctImagePosition = true;
			
			if (display_foto.fotoWidth > browserWidth) {
				
				// Positionierung fuer Fotos, die breiter sind
				// als das aktuelle Browser-Fenster. Wichtig ist
				// hier, dass das Panorama nicht ueber die Breite
				// des Browser-Fensters hinweg positioniert wird,
				// da es sonst links "abgeschnitten" wird.
				var positionCorrection = Math.ceil ((browserWidth - fcPageSize) / 2);
				
				// Ein paar Pixel "Platz" lassen, damit die Leute nicht immer meinen,
				// dass das Foto abgeschnitten wre.
				positionCorrection = Number (positionCorrection - 5);
				
				// Im IE5 und IE6 keine weitere Korrektur vornehmen, wenn es
				// sich um ein uebergroes Foto handelt (Panorama)
				if (ua.indexOf("msie 5") > -1 || ua.indexOf("msie 6") > -1) {
					correctImagePosition = false;
				}
			}
			else {
				
				// Positionierung fuer Fotos, die NICHT breiter 
				// sind als das aktuelle Browser-Fenster
				var positionCorrection = Math.ceil ((display_foto.fotoWidth - fcPageSize) / 2);
			}
			
			// Pruefen, ob die Positions-Korrektur vorgenommen
			// werden soll.
			if (correctImagePosition == true) {
			
				// Positionskorrektur vornehmen
				YDom.setStyle ('fc_image', 'left', '-' + positionCorrection + 'px');
				
				// Listener hinzufuefen, der aktiv wird, wenn die Breite des Browser-Fensters
				// geaendert wird. Im Anschluss wird diese Funktion erneut aufgerufen, um das
				// Foto nachzupositionieren.
				if (display_foto.resizeListener == false) {
					
						YEvent.addListener (window, "resize", display_foto.correctImagePosition);
					
					display_foto.resizeListener = true;
				}
			}
		}
	},
	
	
	// Laden der Information, welcher Typ von Favorit das Foto ist
	getFavouriteStatus: function () {
		
		cp.call('/pc/inc/ajax_favorite.inc.php', 'getFavouriteStatus', display_foto.setFavouriteStatus, display_foto.current_photo);
	},
	
	
	// Empfangen des Ergebnisses, ob und welcher Typ von
	// Favorit das Foto ist. Dem entsprechend werden im
	// Anschluss die Buttons generiert.
	setFavouriteStatus: function (result) {
		
		// Default-Werte setzen
		display_foto.is_privateFavourite = false;
		display_foto.is_publicFavourite  = false;
		
		// Pruefen, ob ein AJAX-Result vorliegt.
		if (typeof(result) !== 'undefined') {
			
			 switch (result.ajaxResponse[0].data) {
			 	
			 	case 1:
			 		display_foto.is_privateFavourite = true;
			 	break;
			 	
			 	case 2:
			 		display_foto.is_publicFavourite  = true;
			 	break;
			 	
			 	case "error:favlimit":
			 		//location.href = "https://" + window.location.hostname + "/membership/upgrade/favorites";
			 		showLimitboxOverlay(5,0);
			 	break;
			 }
		}
		
		// Den Button fuer privater Favorit rendern,
		display_foto.render_privateFavourite();
		
		// Den Button fuer oeffentlicher Favorit rendern, sobald der Contaniner verfuergar ist.
		display_foto.render_publicFavourite();
		
		// Mouseover initialisieren
		YEvent.onAvailable ('icon_public_fav', display_foto.initMouseOver);
		
		// Tooltips initialisieren
		YEvent.onAvailable ('icon_public_fav', display_foto.initToolTips);
	},
	
	// Rendern des Buttons "privater Favorit"
	render_privateFavourite: function () {
		
		var ButtonHTML;
		
		// Container-Element fuer den Button
		var container = YDom.get ('div_private_fav');
		
		// Button nur dann rendern, wenn der Container 
		// fuer den Button auch existiert.	
		if (container !== null) {

			// User muss eingeloggt sein. Ansonsten wird das Icon
			// ausgegraut dargestellt.
			if (YDom.get ('a_userid').value > 0) {
			
				if (display_foto.is_privateFavourite == true) {
					// Die Uebersetzung fuer den Button aus dem HTML-Dokument auslesen.
					var buttonText = YDom.get ('text_private_fav_no').value;
					ButtonHTML = '<a href="#" onClick="this.blur(); display_foto.click_private_favorite(); return (false);"><img src="/gfx/spacer.gif" class="fl" id="icon_private_fav_active" title="' + buttonText + '"/></a>';
				}
				else {
					// Die Uebersetzung fuer den Button aus dem HTML-Dokument auslesen.
					var buttonText = YDom.get ('text_private_fav').value;
					ButtonHTML = '<a href="#" onClick="this.blur(); display_foto.click_private_favorite(); return (false);"><img src="/gfx/spacer.gif" class="fl" height="18" width="33" id="icon_private_fav" title="' + buttonText + '"/></a>';
				}

			}
			else {
				// Die Uebersetzung fuer den Button aus dem HTML-Dokument auslesen.
				var buttonText = YDom.get ('text_private_fav').value;
				ButtonHTML = '<img src="/gfx/spacer.gif" class="fl" height="18" width="33" id="icon_private_fav_grey" title="' + buttonText + '"/>';
			}
			
			// Inhalt in die Seite uebertragen
			container.innerHTML = ButtonHTML;
		}
	},
	
	
	// Rendern des Buttons "oeffentlicher Favorit"
	render_publicFavourite: function () {
		
		var ButtonHTML;
		
		// Container-Element fuer den Button
		var container = YDom.get ('div_public_fav');
		
		// Button nur dann rendern, wenn der Container 
		// fuer den Button auch existiert.	
		if (container !== null) {
			
			// User muss eingeloggt sein. Ansonsten wird das Icon
			// ausgegraut dargestellt.
			if (YDom.get ('a_userid').value > 0) {
		
				if (display_foto.is_publicFavourite == true) {
					// Die Uebersetzung fuer den Button aus dem HTML-Dokument auslesen.
					var buttonText = YDom.get ('text_public_fav_no').value;
		
					ButtonHTML = '<a href="#" onClick="this.blur(); display_foto.click_public_favorite(); return (false);"><img src="/gfx/spacer.gif" class="fl" height="18" width="33" id="icon_public_fav_active" title="' + buttonText + '"/></a>';
				}
				else {
					// Die Uebersetzung fuer den Button aus dem HTML-Dokument auslesen.
					var buttonText = YDom.get ('text_public_fav').value;
		
					ButtonHTML = '<a href="#" onClick="this.blur(); display_foto.click_public_favorite(); return (false);"><img src="/gfx/spacer.gif" class="fl" height="18" width="33" id="icon_public_fav" title="' + buttonText + '"/></a>';
				}
			}
			else {
				// Die Uebersetzung fuer den Button aus dem HTML-Dokument auslesen.
				var buttonText = YDom.get ('text_public_fav').value;
		
				ButtonHTML = '<img src="/gfx/spacer.gif" class="fl" width="33" id="icon_private_fav_grey" title="' + buttonText + '"/>';
			}
			
			// Inhalt in die Seite uebertragen
			container.innerHTML = ButtonHTML;
		}
	},
	
	
	// Funktionsaufruf nach dem Klick auf "privater Favorit"	
	click_private_favorite: function () {
		
		var is_public = 'n';
		
		cp.call ('/pc/inc/ajax_favorite.inc.php', 'setFavouriteStatus', display_foto.setFavouriteStatus, display_foto.current_photo, is_public);
	},
	
	
	// Funktionsaufruf nach dem Klick auf "privater Favorit"	
	click_public_favorite: function () {
		
		var is_public = 'y';
		
		cp.call ('/pc/inc/ajax_favorite.inc.php', 'setFavouriteStatus', display_foto.setFavouriteStatus, display_foto.current_photo, is_public);
	},
	
	
	// Die Funktion wird aufgerufen, sobald ein Nutzer die
	// linke Pfeiltaste drueckt. Die Funktion springt dann
	// zum vorherigen Foto.
	keypress_back: function () {
		
		// URL auslesen und dekodieren
		var url = YDom.get ('prev_photo').value;
		url 	= unescape (url);
		
		// Aufruf der URL		
		window.location.href = url;
	},
	
	
	// Die Funktion wird aufgerufen, sobald ein Nutzer die
	// rechte Pfeiltaste drueckt. Die Funktion springt dann
	// zum naechsten Foto.
	keypress_forward: function () {
		
		// URL auslesen und dekodieren
		var url = YDom.get ('next_photo').value;
		url 	= unescape (url);
		
		// Aufruf der URL		
		window.location.href = url;
	},
	
	
	// Dialog zum loeschen eines Fotos
	initDeleteDialog: function () {
		
		// Sprachvariablen aus der Seite entgegennehmen
		display_foto.txt_Yes			= YDom.get ('txt_Yes').value;
		display_foto.txt_No				= YDom.get ('txt_No').value;
		display_foto.txt_DeleteTitle	= YDom.get ('txt_DeleteTitle').value;
		display_foto.txt_DeleteText		= YDom.get ('txt_DeleteText').value;
		
		// Event-Handler fuer die Buttons
		var handleYes = function() { 
			
			var url = unescape (YDom.get('dlink').value);
			
			// Aufruf der URL		
			window.location.href = url;
		};
		
		var handleNo = function() { 

		 	this.hide(); 
		};
		
		// Buttons definieren
		var ButtonsYesNo = [	
		
			{text:display_foto.txt_Yes, 	handler:handleYes}, 
			{text:display_foto.txt_No, 	handler:handleNo, isDefault:true} 
		];
				
		// Dialog initialisieren und Optionen setzen
		deleteDialog = new YAHOO.widget.SimpleDialog("deleteDialog", {  
		    width: 			"300px",
		    height: 		"120px",  
		    fixedcenter:	true,
		    close:			false,
		    modal:			true, 
		    visible:		true, 
		    draggable:		false,
		    iframe:			true,
		    underlay:		'matte'
		}); 
	    
		deleteDialog.setHeader(display_foto.txt_DeleteTitle); 
		deleteDialog.setBody(display_foto.txt_DeleteText); 
		deleteDialog.cfg.setProperty("icon",YAHOO.widget.SimpleDialog.ICON_INFO);
		
		deleteDialog.cfg.queueProperty("buttons", ButtonsYesNo); 
		
		// Rendern und anzeigen
		deleteDialog.render(document.body);
	},
	
	// Dialog zum facebook share
	initShareDialog: function () {
		
		//Sprachvariablen aus der Seite entgegennehmen
		var temp = YDom.get ('txt_ShareTitle').value;
		var temp2 = temp.replace("%%","<font size=\"1\" color=\"#DDD\" style=\"position:absolute;right:3px;\">");
		display_foto.txt_ShareTitle = temp2.replace("$$","</font>");
		
		display_foto.txt_ShareText		= YDom.get ('txt_ShareText').value+'<br><br>';
		
		//bild-url und titel:
		display_foto.bild_shorturl 		=  YDom.get ('bild_shorturl').value;
		display_foto.bild_longurl 		=  YDom.get ('bild_longurl').value;
		
		display_foto.bild_titel 		=  YDom.get ('bild_titel').value;
		
		var twitterUrl 		= 'http://twitter.com/home?status='+encodeURIComponent(display_foto.bild_titel)+'%20'+encodeURIComponent(display_foto.bild_shorturl);
		var facebookUrl 	= 'http://www.facebook.com/sharer.php?u='+encodeURIComponent(display_foto.bild_longurl)+'&t='+encodeURIComponent(display_foto.bild_titel);
		var misterwongUrl 	= 'http://www.mister-wong.com/index.php?action=addurl&bm_url='+encodeURIComponent(display_foto.bild_shorturl)+'&bm_description='+encodeURIComponent(display_foto.bild_titel);
		var digUrl 			= 'http://digg.com/submit?phase=2&url='+encodeURIComponent(display_foto.bild_shorturl)+'&title='+encodeURIComponent(display_foto.bild_titel);
		var redditUrl 		= 'http://www.reddit.com/submit?title='+encodeURIComponent(display_foto.bild_titel)+'&url='+encodeURIComponent(display_foto.bild_shorturl);
		var stumbleuponUrl 	= 'http://www.stumbleupon.com/submit.php?url='+encodeURIComponent(display_foto.bild_shorturl);
		var studivzUrl		= 'http://www.studivz.net/Suggest/Selection/?u='+encodeURIComponent(display_foto.bild_longurl)+'&desc='+encodeURIComponent(display_foto.bild_titel)+'&prov=fotocommunity.de';
			
		var gfxPath 		= '/gfx/buttons/ShareIcons/';
		var shortUrlToEmbed = YDom.get ('txt_shortUrlToEmbed').value;
		var copyText 		= YDom.get ('txt_copyText').value;
		
		// Dialog initialisieren und Optionen setzen
		this.shareDialog = new YAHOO.widget.SimpleDialog("shareDialog", {  
		    width: 			"400px",
		    height: 		"170px",  
		    fixedcenter:	true,
		    close:			true,
		    modal:			true, 
		    visible:		true, 
		    draggable:		true,
		    iframe:			true,
		    underlay:		'none'
		}); 
	    
		display_foto.txt_ShareTable = '<table border="0" width="90%" cellpadding="0" cellspacing="0" align="center"><tr>'
									+ '<td width="15%"><a href="'+twitterUrl+'" onclick="_gaq.push([\'_trackEvent\', \'Interaction\', \'Share Photo\', \'Twitter\']);" style="text-decoration:none;font-size:9px;color:black;" target="_blank"><img src="'+gfxPath+'Twitter_32x32.png" border="0" alt="twitter" title="twitter"></a></td>'
									+ '<td width="15%"><a href="'+facebookUrl+'" onclick="_gaq.push([\'_trackEvent\', \'Interaction\', \'Share Photo\', \'Facebook\']); display_foto.shareDialog.hide();" style="text-decoration:none;font-size:9px;color:black;" target="_blank"><img src="'+gfxPath+'FaceBook_32x32.png" border="0" alt="facebook" title="facebook"></a></td>'
									+ '<td width="15%"><a href="'+misterwongUrl+'" onclick="_gaq.push([\'_trackEvent\', \'Interaction\', \'Share Photo\', \'Mister Wong\']);" style="text-decoration:none;font-size:9px;color:black;" target="_blank"><img src="'+gfxPath+'Misterwong_32x32.png" border="0" alt="misterwong" title="misterwong"></a></td>'
									+ '<td width="15%"><a href="'+digUrl+'" onclick="_gaq.push([\'_trackEvent\', \'Interaction\', \'Share Photo\', \'Digg\']);" style="text-decoration:none;font-size:9px;color:black;" target="_blank"><img src="'+gfxPath+'digg_32x32.png" border="0" alt="digg" title="digg"></a></td>'
									+ '<td width="15%"><a href="'+redditUrl+'" onclick="_gaq.push([\'_trackEvent\', \'Interaction\', \'Share Photo\', \'Reddit\']);" style="text-decoration:none;font-size:9px;color:black;" target="_blank"><img src="'+gfxPath+'Reddit_32x32.png" border="0" alt="reddit" title="reddit"></a></td>'
									+ '<td width="15%"><a href="'+studivzUrl+'" onclick="_gaq.push([\'_trackEvent\', \'Interaction\', \'Share Photo\', \'StudiVZ\']);" style="text-decoration:none;font-size:9px;color:black;" target="_blank"><img src="'+gfxPath+'Studivz_32x32.png" border="0" alt="studivz" title="studivz"></a></td></tr></table>'
									+ '<br>'
									+ '<div style="font-size:11px;padding-left:20px;padding-bottom:5px;">'+shortUrlToEmbed+'</div>'
									+ '<div style="float:left;clear:both;height:20px;line-height:20px;padding-left:20px;"><input type="text" name="copy" id="copy" size="25" readonly="" style="color:#777;background:#FFF none repeat scroll 0 0;border:medium none;font-size:11px;height:18px;line-height:18px;vertical-align:top;" value="'+display_foto.bild_shorturl+'" onClick="getElementById(\'copy\').focus(); getElementById(\'copy\').select();"></div>';
									
									
		display_foto.txt_ShareBody = display_foto.txt_ShareText + display_foto.txt_ShareTable;
		
		this.shareDialog.setHeader(display_foto.txt_ShareTitle); 
		this.shareDialog.setBody(display_foto.txt_ShareBody); 
		this.shareDialog.cfg.setProperty("icon",YAHOO.widget.SimpleDialog.ICON_INFO);
		
		// Rendern und anzeigen
		this.shareDialog.render(document.body);
	},
	
	// Dialog der "Homepage"-Funktion
	initHomepageDialog: function () {
		
		// Sprachvariablen aus der Seite entgegennehmen
		display_foto.txt_Yes			= YDom.get ('txt_Yes').value;
		display_foto.txt_No				= YDom.get ('txt_No').value;
		display_foto.txt_HomepageTitle	= YDom.get ('txt_HomepageTitle').value;
		display_foto.txt_HomepageText	= YDom.get ('txt_HomepageText').value;
		
		// Event-Handler fuer die Buttons
		var handleYes = function() { 
			
			var url = unescape (YDom.get('hplink').value);
			
			// Aufruf der URL		
			window.location.href = url;
		};
		
		var handleNo = function() { 

		 	this.hide(); 
		};
		
		// Buttons definieren
		var ButtonsYesNo = [	
		
			{text:display_foto.txt_Yes, 	handler:handleYes}, 
			{text:display_foto.txt_No, 	handler:handleNo, isDefault:true} 
		];
				
		// Dialog initialisieren und Optionen setzen
		homepageDialog = new YAHOO.widget.SimpleDialog("homepageDialog", {  
		    width: 			"300px",
		    height: 		"120px",  
		    fixedcenter:	true,
		    close:			false,
		    modal:			true, 
		    visible:		true, 
		    draggable:		false,
		    underlay:		'matte'
		}); 
	    
		homepageDialog.setHeader(display_foto.txt_HomepageTitle); 
		homepageDialog.setBody(display_foto.txt_HomepageText); 
		homepageDialog.cfg.setProperty("icon",YAHOO.widget.SimpleDialog.ICON_INFO);
		
		homepageDialog.cfg.queueProperty("buttons", ButtonsYesNo); 
		
		// Rendern und anzeigen
		homepageDialog.render(document.body);
	},
	
	// Bei aktivem Contest-Voting den Slider initialisieren
	initSlider: function () {
		
		// Slider initialisieren.
		display_foto.slider = YAHOO.widget.Slider.getHorizSlider("slider-bg", "slider-thumb", 0, 480);
		
		YDom.get('slider-thumb').style.left = '15px';
		
		// Sobald der Slider bewegt wird, wird die Funktion "sliderValueChange" aufgerufen.
		display_foto.slider.subscribe("change", display_foto.sliderValueChange);
		
		// Pruefen, ob in der Vergangenheit bereits eine Stimme abgegeben wurde
		display_foto.nvotenow = YDom.get('nvotenow').value;
		
		// Wenn bereits eine Stimme abgegeben wurde, den Slider
		// auf den entsprechenden Wert setzen.
		if (display_foto.nvotenow > 0) {
			
			// Umrechnung der Punkte auf den Slider
			sliderValue = Number (display_foto.nvotenow - 1);
			sliderValue = Number (sliderValue * 53.5);
			sliderValue = Math.round(sliderValue);

			// Den Slider auf den gedrueckten Wert bewegen
			display_foto.slider.setValue (sliderValue,true,true);
			
		}
		
		// Auf die Tasten "1" bis "0" lauschen. Hier werden sowohl die 
		// normalen als auch die Nummernblock-Zahlen beruecksichtigt.
		ListenerContest = new YUtil.KeyListener  (
			document, 
			{keys: [49, 97, 50, 98, 51, 99, 52, 100, 53, 101, 54, 102, 55, 103, 56, 104, 57, 105, 48, 96]} , 
			{fn: display_foto.sliderKeyListener}
		);
		
		// Auf die ENTER/RETURN Taste lauschen. Wird diese gedrueckt, wird das Ergebnis des
		// Contest-Votings abgesendet.
		contestSendKey = new YUtil.KeyListener  ( document, {keys: 13} , {fn: display_foto.sendContestVote}
		);
		
		ListenerContest.enable();
		contestSendKey.enable();
		
		// Wenn ein Doppelklick auf den Knopf des Sliders gemacht wird,
		// dann sollen die abgegebenen Punkte abgesendet werden.
		YEvent.addListener('slider-thumb', 'dblclick', display_foto.sendContestVote);
	},
	
	
	// Die Funktion reagiert auf Aenderungen des Sliders
	// des Contest-Votings.
	sliderValueChange: function (sliderValue) {
		
		contestPoints = Number (sliderValue / 53.5);
		contestPoints = Number (contestPoints + 1);
		
		// Sicherstellen, dass nicht mehr als 10 Punkte vergeben werden koennen.
		if ( contestPoints > 10 ) {
		
			contestPoints = 10;
		}
		
		YDom.get('contestvalue').innerHTML = contestPoints.toFixed(1);
	},
	
	
	sliderKeyListener: function (event, keyCode) {
		
		var realKeyCode = keyCode[0];
		var contestPoints;
		var silderValue;
		
		switch (realKeyCode) {
			
			case 49:
			case 97:
				contestPoints = '1';
				break;
			case 50:
			case 98:
				contestPoints = '2';
				break;
			case 51:
			case 99:
				contestPoints = '3';
				break;
			case 52:
			case 100:
				contestPoints = '4';
				break;
			case 53:
			case 101:
				contestPoints = '5';
				break;
			case 54:
			case 102:
				contestPoints = '6';
				break;
			case 55:
			case 103:
				contestPoints = '7';
				break;
			case 56:
			case 104:
				contestPoints = '8';
				break;
			case 57:
			case 105:
				contestPoints = '9';
				break;
			case 48:
			case 96:
				contestPoints = '10';
				break;
		}
		
		// Wenn der Keyboard-Buffer nicht gesetzt ist, oder bereits 
		// zwei Zeichen enthaelt, wird die Eingabe explusiv uebernommen.
		// Ansonsten wird die Eingabe kaskadiert.
		if (display_foto.keyboardBuffer === false || 
			display_foto.keyboardBuffer.length >= 2 || 
			typeof (display_foto.keyboardBuffer.length) == 'undefined') {
			
			// Keyboard-Buffer exklusiv befuellen
			display_foto.keyboardBuffer = contestPoints;
		}
		else {
			
			// Eingabe kaskadieren
			display_foto.keyboardBuffer += contestPoints;
			
			// Wenn die Eingabe zwei Zeichen enthaelt, wird dieser Wert
			// durch 10 geteilt, um einen Komma-Wert zu erhalten.
			display_foto.keyboardBuffer = Number (display_foto.keyboardBuffer) / 10;
		}
		
		// Umrechnung der Punkte auf den Slider
		sliderValue = Number (display_foto.keyboardBuffer - 1);
		sliderValue = Number (sliderValue * 53.5);
		
		// Den Slider auf den gedrueckten Wert bewegen
		display_foto.slider.setValue (sliderValue);
		
		// Timer starten. Nach x Sekunden wird der
		// Keyboard-Buffer automatisch geleert.
		display_foto.keyboardBufferActive = window.setTimeout ("display_foto.flushKeyboardBuffer()", display_foto.keyboardBufferTimeout);
	},
	
	
	// Die Funktion leert den KeyboardBuffer. Sie wird
	// mittels setTimeout nach der Eingabe einer Ziffer
	// in der Funktion "sliderKeyListener" aufgerufen.
	flushKeyboardBuffer: function () {
		
		display_foto.keyboardBuffer = false;
		
		// Eventuell anderweitig laufende Timeouts abbrechen
		window.clearTimeout (display_foto.keyboardBufferActive);
	},
	
	
	// Absenden der Punkte fuer das Contest-Voting
	sendContestVote: function () {
		
		// Notwendige Informationen zusammentragen
		var url = unescape (YDom.get('next_photo').value);
		
		var nuserid  = YDom.get('a_userid').value;
		var nvoteid	 = YDom.get('current_photo').value;
		var nvotenow = YDom.get('contestvalue').innerHTML;
		
		// URL zusammenbauen
		url = url + '/nvoteid/' + nvoteid + '/nvotenow/' + nvotenow + '/nuserid/' + nuserid;
		
		// Aufruf der URL		
		window.location.href = url;
	}
};

var addComment = {
	
	commentData: 	false,
	buttonid:		false,
	
	// Konstruktor-Funktion
	init: function (commentData, buttonid) {
		
		addComment.commentData 	= YAHOO.lang.JSON.parse (unescape(commentData));
		addComment.buttonid		= buttonid;
		
		// Eingabebox aufbauen
		addComment.renderInputBox();
	},
	
	
	// Eingabebox aufbauen
	renderInputBox: function () {
		
		// Container fuer die Eingabebox erstellen
		var addCommentContainer = document.createElement ('div');
		addCommentContainer.setAttribute ('id', addComment.buttonid + '_container');
		YDom.addClass (addCommentContainer, 'flcb');
		
		// Die Eingabebox erstellen
		var inputContainer =  document.createElement ('textarea');
		inputContainer.setAttribute ('id',  addComment.buttonid + '_input');
		inputContainer.setAttribute ('wrap',  'virtual');
		YDom.addClass (inputContainer, 'addCommentInput');
		
		// Buttons fuer Absenden und Abbrechen
		var buttonContainer = document.createElement ('div');
		YDom.addClass (buttonContainer, 'flcb');
		YDom.setStyle (buttonContainer, 'padding-top', '3px');
		buttonContainer.innerHTML = '<a href="#" onClick="addComment.insertComment(); return (false);" class="button"><span>' + addComment.commentData['textOK'] + '</span></a> <a href="#" onClick="addComment.cancel(); return (false);" class="button"><span>' + addComment.commentData['textCancel'] + '</span></a>';
		
		
		// Die Eingabebox in den Container setzen
		addCommentContainer.appendChild (inputContainer);
		
		// Die Buttons in den Container setzen
		addCommentContainer.appendChild (buttonContainer);
		
		// Den Button "Anmerkung schreiben" ausblenden
		YDom.get (addComment.buttonid).style.display = 'none';
		
		// Den Container fuer die Eingabebox in den DOM einfuegen
		YDom.insertAfter (addCommentContainer, addComment.buttonid);
	},
	
	
	insertComment: function () {
		
		// Den Text extrahieren
		var commentText = YDom.get (addComment.buttonid + '_input').value;
		
		// Datum ermitteln und in Datums-String schreiben
		var datum = new Date();
		var datumstring = addComment.commentData['textToday'] + ' ' + datum.getHours() + ':' + datum.getMinutes() + ' ' +  addComment.commentData['textoClock'];
		
		// Die Eingabebox entfernen
		var addCommentContainer = YDom.get (addComment.buttonid + '_container');
		addCommentContainer.parentNode.removeChild(addCommentContainer);
		
		// Den Button "Anmerkung schreiben" einblenden
		YDom.get (addComment.buttonid).style.display = 'block';
		
		// HTML-Element fuer den Nutzernamen
		var userElement = document.createElement ('h4');
		YDom.addClass (userElement, 'c_submitter');
		userElement.innerHTML = '<a href="/pc/account?myprofile=' + addComment.commentData['userid'] + '">' + addComment.commentData['username'] + '</a>, ' + datumstring;
		
		// HTML-Element fuer den Kommentar-Text
		var textElement = document.createElement ('p');
		YDom.addClass (textElement, 'c_text');
		
		// Den Kommentar-Text aufnehmen
		var textElementTxt = document.createTextNode (commentText);
		textElement.appendChild (textElementTxt);
		
		// Den Autor sowie den Kommentar-Text in den DOM einfuegen
		YDom.insertAfter (userElement, addComment.buttonid);
		YDom.insertAfter (textElement, userElement);
		
		// Daten an den Server senden
		addComment.send (commentText);
	},
	
	
	// Die Eingabe an den Server senden
	send: function (commentText) {
		
		//cp.call ('/pc/inc/ajax_favorite.inc.php', 'setFavouriteStatus', display_foto.setFavouriteStatus, display_foto.current_photo, is_public);
	},
	
	
	// Die Eingabe abbrechen
	cancel: function () {
		
		// Die Eingabebox entfernen
		var addCommentContainer = YDom.get (addComment.buttonid + '_container');
		addCommentContainer.parentNode.removeChild(addCommentContainer);
		
		// Den Button "Anmerkung schreiben" einblenden
		YDom.get (addComment.buttonid).style.display = 'block';
	}
};


var membership_selector = {
	
	show_free: function () {
		
		// Tabs wechseln
		YDom.get ('tab_free').style.display = 'block';
		YDom.get ('tab_basic').style.display = 'none';
		YDom.get ('tab_pro').style.display = 'none';
		YDom.get ('tab_world').style.display = 'none';
		
		// Mitgliedschaft in HIDDEN-Field schreiben
		YDom.get ('selected_membership').value = 'free';
		
		// Infotext zur gewaehlten Mitgliedschaft aktualisieren
		if ( YDom.get ('selected_membership_text') !== null) {
			
			YDom.get ('selected_membership_text').innerHTML = YDom.get ('click_free').title;
		}
	},

	show_basic: function () {
		
		// Tabs wechseln
		YDom.get ('tab_free').style.display = 'none';
		YDom.get ('tab_basic').style.display = 'block';
		YDom.get ('tab_pro').style.display = 'none';
		YDom.get ('tab_world').style.display = 'none';
		
		// Mitgliedschaft in HIDDEN-Field schreiben
		YDom.get ('selected_membership').value = 'basic';
		
		// Infotext zur gewaehlten Mitgliedschaft aktualisieren
		if ( YDom.get ('selected_membership_text') !== null) {
			
			YDom.get ('selected_membership_text').innerHTML = YDom.get ('click_basic').title;
		}
	},
	
	
	show_pro: function () {
		
		// Tabs wechseln
		YDom.get ('tab_free').style.display = 'none';
		YDom.get ('tab_basic').style.display = 'none';
		YDom.get ('tab_pro').style.display = 'block';
		YDom.get ('tab_world').style.display = 'none';
		
		// Mitgliedschaft in HIDDEN-Field schreiben
		YDom.get ('selected_membership').value = 'pro';
		
		// Infotext zur gewaehlten Mitgliedschaft aktualisieren
		if ( YDom.get ('selected_membership_text') !== null) {
			
			YDom.get ('selected_membership_text').innerHTML = YDom.get ('click_pro').title;
		}
	},
	
	show_world: function () {
		
		// Tabs wechseln
		YDom.get ('tab_free').style.display = 'none';
		YDom.get ('tab_basic').style.display = 'none';
		YDom.get ('tab_pro').style.display = 'none';
		YDom.get ('tab_world').style.display = 'block';
		
		// Mitgliedschaft in HIDDEN-Field schreiben
		YDom.get ('selected_membership').value = 'world';
		
		// Infotext zur gewaehlten Mitgliedschaft aktualisieren
		if ( YDom.get ('selected_membership_text') !== null) {
			
			YDom.get ('selected_membership_text').innerHTML = YDom.get ('click_world').title;
		}
	}	
};

var SlideShowPage = {
	
	feed:  false,
	size:  "normal",
	speed: "normal",
	
	init: function () {
		
		SlideShowPage.feed =YDom.get('feed_url').value;
		
		// Embed-Objekt zusammenbauen
		SlideShowPage.buildEmbedObject();
	},
	
	sizeMouseOver: function (element) {
		
		element.style.background="#FFFEDC";
	},
	
	sizeMouseOut: function (element) {
		
		if (element.id == SlideShowPage.size) {
			
			// Das aktive Element wird verlassen
			element.style.background="#D5FCBD";
		}
		else {
			
			element.style.background="#FFFFFF";	
		}
	},
	
	sizeClick: function (element) {
		
		// Das vorherig aktive Element deselektieren
		YDom.get(SlideShowPage.size).style.background = '#FFFFFF';
		
		// Neues Element setzen und umfaerben
		SlideShowPage.size = element.id;
		element.style.background="#D5FCBD";
		
		// Embed-Objekt zusammenbauen
		SlideShowPage.buildEmbedObject();
	},
	
	speedClick: function (element) {
		
		SlideShowPage.speed = element.value;
		
		// Embed-Objekt zusammenbauen
		SlideShowPage.buildEmbedObject();
	},
	
	buildEmbedObject: function () {
		
		// Groesse bestimmen
		switch (SlideShowPage.size) {
			
			case "small":
			
				var sizeX = '324';
				var sizeY = '243';
			
			break;
			
			case "big":
			
				var sizeX = '450';
				var sizeY = '338';
			
			break;
			
			// Default-Angabe ist "normal"
			default:
			
				var sizeX = '426';
				var sizeY = '321';
			
			break;
		}
		
		// Geschwindigkeit bestimmen
		switch (SlideShowPage.speed) {
			
			case "slow":
			
				var speed = 8;			
				
			break;
			
			case "fast":
			
				var speed = 2;
				
			break;
			
			// Default-Angabe ist "normal"
			default:
			
				var speed = '4';
			
			break;
		}	
		
		// String zusammenbauen
		var EmbedObject = '<object width="' + sizeX + '" height="' + sizeY + '"><param name="movie" value="http://www.fotocommunity.de/widgets/FCSlideshowWidget.swf?feed=' + SlideShowPage.feed + '&intervall=' + speed + '"></param><param name="allowFullScreen" value="true"></param><embed src="http://www.fotocommunity.de/widgets/FCSlideshowWidget.swf?feed=' + SlideShowPage.feed + '&intervall=' + speed + '" type="application/x-shockwave-flash" allowfullscreen="true" width="' + sizeX + '" height="' + sizeY + '"></embed></object>';
		
		// String in Textarea schreiben
		YDom.get ('EmbedObject').value = EmbedObject;
		
		// Das Embed-Objekt in abgeaenderter Form fuer die Anzeige im Formular.
		// Im Gegensatz zum obigen Tag gibt es hier feste Angaben zur Groesse.
		var EmbedObjectForPreview = '';
			EmbedObjectForPreview += '<h4 style="margin:2px;">' + YDom.get ('SlideShowPreviewTitle').value + '</h4>';		
			EmbedObjectForPreview += '<object width="290" height="218"><param name="movie" value="http://www.fotocommunity.de/widgets/FCSlideshowWidget.swf?feed=' + SlideShowPage.feed + '&intervall=' + speed + '"></param><param name="allowFullScreen" value="true"></param><embed src="http://www.fotocommunity.de/widgets/FCSlideshowWidget.swf?feed=' + SlideShowPage.feed + '&intervall=' + speed + '" type="application/x-shockwave-flash" allowfullscreen="true" width="290" height="218"></embed></object>';
			EmbedObjectForPreview += '<p style="font-weight:normal;">' + YDom.get ('SlideShowPreviewNote').value + '</p>';
		
		// Preview generieren
		YDom.get ('SlideShowPreview').innerHTML = EmbedObjectForPreview;
		
	},
	
	embedTextClick: function (element) {
		
		element.select();
	}
};


/**
 * Oeffnen eines Kommentar-Fensters
 * 
 * Diese Funktion oeffnet ein Kommentar-Fenster.
 * Dabei werden bei der Fenstergroesse die Unterschiede
 * der verschiedenen Browser beruecksichtigt.
 */
function openCommentWindow (url, height, width) {

	// Browser-Typ und Version ermitteln
	var ua = window.navigator.userAgent.toLowerCase();
	
	if (ua.indexOf("firefox/3") > -1) {
	
		var height = Number(height) + 17;
	}
//	else if(ua.indexOf("chrome") > -1)
//	{
//		var height = Number(height) + 17;
//	}
	
	var windowOptions = 'height=' + height + ', width='+width+', top=300,left=500, resizable=yes, scrollbars=no, location=no, menubar=no, status=no, toolbar=no';
	commentWindow = window.open (url, "commentWindow", windowOptions);
}

/**
 * Oeffnen eines Kommentar-Fensters
 * 
 * Diese Funktion oeffnet ein Kommentar-Fenster.
 * Dabei werden bei der Fenstergroesse die Unterschiede
 * der verschiedenen Browser beruecksichtigt.
 */
function openQuickMessageWindow (toUserId) {

	var width 		= 415;
	var height 		= 245;
	var windowUrl	= '/pc/qmail.pop.php';
	
	// Es soll eine neue QM verfasst werden
	// In diesem Fall wurde an die Funktion
	// die UserId des Empfaengers uebergeben.
	// Diese nun pruefen, und als Parameter
	// an die aufzurufende Url anhaengen.
	if ( Number(toUserId) > 0) {
	
		windowUrl = windowUrl + '/newqm/' + toUserId;
	}

	// Browser-Typ und Version ermitteln
	var ua = window.navigator.userAgent.toLowerCase();
	
	if (ua.indexOf("firefox/3") > -1) {
	
		var height = Number(height) + 22;
	}
	
	//driss opera 11.10. oeffnet leeres fenster.
	var operaBugfix = 0;
	if (ua.indexOf("opera") > -1) {
	
		if(ua.indexOf("11.") > -1){
			
			var operaBugfix = 1;
		}
	}
	
	// Falls im DOM vorhanden, den Menue-Eintrag zum oeffnen der Quickmessage ausblenden
	window.setTimeout('menu_hide_quickmessage()', 2000);
	
	var windowOptions  = 'height=' + height + ', width='+width+', top=100,left=500, resizable=yes, scrollbars=yes, location=no, menubar=no, status=no, toolbar=no';
	windowQuickMessage = window.open ('', "windowQuickMessage", windowOptions);

	if(null != windowQuickMessage) // wenn null dann per popupblocker geblockt
	{	
		if ( windowQuickMessage.document.title == "" || typeof windowQuickMessage.document.title === 'undefined' || operaBugfix==1)
		{
			windowQuickMessage.location.href = windowUrl;
		}	
	}
}

function markAllImages() {

	// Alle Checkbboxen ermitteln
	checkBoxesOnPage = YDom.getElementsByClassName('thumbnail_checkbox', 'input');
	
	var numberOfCheckedImages = 0;
	
	if (checkBoxesOnPage.length > 0) {
	
		// Im ersten Durchlauf der Schleife wird geprueft,
		// wie viele der Checkboxen aktiv sind. Wenn alle
		// Checkboxen bereits aktiv sind, dann werden diese
		// im Anschluss wieder deaktiviert.
		for (var indexInArray in checkBoxesOnPage) {
			
			if ( checkBoxesOnPage[indexInArray].checked == true ) {
			
				numberOfCheckedImages++;
			}
		}
	
		// Alle Checkboxen markieren.
		for (var indexInArray in checkBoxesOnPage) {
			
			// Wenn bereits alle Checkboxen ausgewaehlt sind, dann
			// wird die Markierung umgekehrt.
			if (numberOfCheckedImages == checkBoxesOnPage.length) {
			
				checkBoxesOnPage[indexInArray].checked = false;
			}
			else {
			
				checkBoxesOnPage[indexInArray].checked = true;
			}
		}
	}
}

//funktionen zum anzeigen der profil-besuche
function show_next_visits(result){
	var ergebnis_array = result.ajaxResponse[0].ergebnisse[0].zeile;	
	var anzahl_gesamt = result.ajaxResponse[0].gesamt[0].data;	
	var start_with 		= result.ajaxResponse[0].start[0].data;	
	
	//nur, wenn ergebnisse vorhanden sind
	if (ergebnis_array.length > 0){
		var tmp_name = 0;
		var j = 0;
		var i = 0;
		document.getElementById("profilevisits").style.display = "block";
		
		for (i=0; i < ergebnis_array.length; i++) {
			j = i + 1;
			var my_html_name = "line2_" + j; 	
			var my_line = unescape(ergebnis_array[i].data);	
			document.getElementById(my_html_name).innerHTML = my_line;
			document.getElementById(my_html_name).style.display = "block";
		}
		//ueberfluessige zeilen leeren und verstecken
		if(j < 5){
			for(b = j; b < 5; b++){
				var c = b + 1;
				var my_html_name = "line2_" + c;
				document.getElementById(my_html_name).innerHTML = "";
				document.getElementById(my_html_name).style.display = "none";
			}
		}		
		//navigation anzeigen?
		var show_navi = 0;
		if(anzahl_gesamt > 5){
			show_navi = 1;
			if(start_with > 1){
				//zurueck anzeigen
				var newstart = start_with - 5;
				var backlink = "<img src=\"/gfx/d1w2.gif\" align=\"middle\" height=\"10\" hspace=\"6\" vspace=\"7\" width=\"8\" style=\"cursor:pointer;\" onClick=\"javascript:get_next_visits(" + newstart + ");\">";
				document.getElementById("navi_back").innerHTML = backlink;
				document.getElementById("navi_back").style.display = "block";
			}
			else{
				document.getElementById("navi_back").innerHTML = "";
				document.getElementById("navi_back").style.display = "none";
			}
			var last_shown = start_with + 4;
			if(anzahl_gesamt > last_shown){
				//vor anzeigen
				var newstart2 = start_with + 5;
				var forelink = "<img src=\"/gfx/d1w.gif\" align=\"middle\" height=\"10\" hspace=\"6\" vspace=\"7\" width=\"8\" style=\"cursor:pointer;\" onClick=\"javascript:get_next_visits(" + newstart2 + ");\">";
				document.getElementById("navi_fore").innerHTML = forelink;
				document.getElementById("navi_fore").style.display = "block";
			}
			else{
				document.getElementById("navi_fore").innerHTML = "";
				document.getElementById("navi_fore").style.display = "none";
			}
		}
		//wenn navigation notwendig:
		if(show_navi == 1){
			//document.getElementById("naviline").style.display = "block";
		}
		else{
			//document.getElementById("naviline").style.display = "none";
		}
	}
}


function changeVisibility(was,bild_id){

	var ablauf = new Date();
	var ineinemJahr = ablauf.getTime() + (365 * 24 * 60 * 60 * 1000);
	ablauf.setTime(ineinemJahr);


	if(document.getElementById(was).style.display == 'none'){
		document.getElementById(was).style.display = 'block';
		document.getElementById(bild_id).src = '/gfx/buttons/visits_down.gif';
		document.cookie = "show_profilevisits=1; path=/; expires=" + ablauf.toGMTString();
	}
	else{
		document.getElementById(was).style.display = 'none';
		document.getElementById(bild_id).src = '/gfx/buttons/visits_left.gif';
		document.cookie = "show_profilevisits=0; path=/; expires=" + ablauf.toGMTString();
	}
}

function changeVisibilitySectionBox(was,bild_id,span_id,readmore,readless){

	if(document.getElementById(was).className == 'collapsed'){
		document.getElementById(was).className = 'visible';
		document.getElementById(span_id).innerHTML = readless;
		document.getElementById(bild_id).src = '/gfx/mini_arrow_up.gif';
	}
	else{
		document.getElementById(was).className = 'collapsed';
		document.getElementById(span_id).innerHTML = readmore;
		document.getElementById(bild_id).src = '/gfx/mini_arrow_down.gif';
	}
}

function changeVisibilityCarouselBox(boxName,arrowId){

	if(document.getElementById(boxName).className == 'collapsed'){
		document.getElementById(boxName).className = 'visible';
		document.getElementById(arrowId).src = '/gfx/display2011/einklappen-inhalt.jpg';
	}
	else{
		document.getElementById(boxName).className = 'collapsed';
		document.getElementById(arrowId).src = '/gfx/display2011/ausklappen-inhalt.jpg';
	}
}

function changeVisibilityTagBox(boxName,arrowId,textAusklappen,textEinklappen){

	if(document.getElementById(boxName).className == 'collapsed'){
		document.getElementById(boxName).className = 'visible';
		document.getElementById(boxName).style.padding = '0px';
		document.getElementById('myTagBox').style.height = '100%';
		document.getElementById('tagBoxText').innerText = textEinklappen;
		document.getElementById(arrowId).src = '/gfx/display2011/einklappen-inhalt.jpg';
	}
	else{
		document.getElementById(boxName).className = 'collapsed';
		document.getElementById('myTagBox').style.height = '0px';
		document.getElementById('tagBoxText').innerText = textAusklappen;
		document.getElementById(arrowId).src = '/gfx/display2011/ausklappen-inhalt.jpg';
	}
}

var SlideShowPage = {
		
		userid: false,
		feed:  	false,
		size:  	"normal",
		speed: 	"normal",
		popup: 	null,
		
		init: function () {
			
			SlideShowPage.feed 		= YDom.get('feed_url').value;
			SlideShowPage.userid 	= YDom.get('userid').value;
			
			// Embed-Objekt zusammenbauen
			SlideShowPage.buildEmbedObject();
		},
		
		sizeMouseOver: function (element) {
			
			element.style.background="#FFFEDC";
		},
		
		sizeMouseOut: function (element) {
			
			if (element.id == SlideShowPage.size) {
				
				// Das aktive Element wird verlassen
				element.style.background="#D5FCBD";
			}
			else {
				
				element.style.background="#FFFFFF";	
			}
		},
		
		sizeClick: function (element) {
			
			// Das vorherig aktive Element deselektieren
			YDom.get(SlideShowPage.size).style.background = '#FFFFFF';
			
			// Neues Element setzen und umfaerben
			SlideShowPage.size = element.id;
			element.style.background="#D5FCBD";
			
			// Embed-Objekt zusammenbauen
			SlideShowPage.buildEmbedObject();
		},
		
		speedClick: function (element) {
			
			// Sicherstellen, dass sich der Wert auch geaendert hat.
			// Wir muessen hier leider mit onClick arbeiten anstatt
			// mit onChange, da der IE das wohl nicht richtig kann.
			if (element.value != SlideShowPage.speed) {
			
				SlideShowPage.speed = element.value;
				
				// Embed-Objekt zusammenbauen
				SlideShowPage.buildEmbedObject();
			}
		},
		
		embedTextClick: function (element) {
			
			element.select();
		},
		
		changeMyPicsOption: function (element) {
			
			SlideShowPage.feed = element.value;
			
			// Embed-Objekt zusammenbauen
			SlideShowPage.buildEmbedObject();
		},

		buildEmbedObject: function () {
		
			// Die Textarea mit dem Embed-Code ausblenden
			SlideShowPage.hideCode();
			
			// Groesse bestimmen
			switch (SlideShowPage.size) {
				
				case "small":
				
					var sizeX = '324';
					var sizeY = '243';
				
				break;
				
				case "big":
				
					var sizeX = '450';
					var sizeY = '338';
				
				break;
				
				// Default-Angabe ist "normal"
				default:
				
					var sizeX = '426';
					var sizeY = '321';
				
				break;
			}
			
			// Geschwindigkeit bestimmen
			switch (SlideShowPage.speed) {
				
				case "slow":
				
					var speed = 8;			
					
				break;
				
				case "fast":
				
					var speed = 2;
					
				break;
				
				// Default-Angabe ist "normal"
				default:
				
					var speed = 4;
				
				break;
			}	
			
			// String zusammenbauen
			var EmbedObject = '<div id="FCSlideshowWidget" style="width:' + sizeX + 'px; text-align:right; font-size:10px; font-family:Arial;"><object width="' + sizeX + '" height="' + sizeY + '"><param name="movie" value="http://www.fotocommunity.de/widgets/FCSlideshowWidget.swf?feed=' + SlideShowPage.feed + '&intervall=' + speed + '"></param><param name="allowFullScreen" value="true"></param><embed src="http://www.fotocommunity.de/widgets/FCSlideshowWidget.swf?feed=' + SlideShowPage.feed + '&intervall=' + speed + '" type="application/x-shockwave-flash" allowfullscreen="true" width="' + sizeX + '" height="' + sizeY + '"></embed></object><br><a href="http://www.fotocommunity.de?slideshow=' + SlideShowPage.userid + '" style="color:#000;" target="_blank">fotocommunity</a></div>';
			
			// String in Textarea schreiben
			YDom.get ('EmbedObject').value = EmbedObject;
			
			// Das Embed-Objekt in abgeaenderter Form fuer die Anzeige im Formular.
			// Im Gegensatz zum obigen Tag gibt es hier feste Angaben zur Groesse.
			var EmbedObjectForPreview = '';
				EmbedObjectForPreview += '<h4 style="margin:2px;">' + YDom.get ('SlideShowPreviewTitle').value + '</h4>';		
				EmbedObjectForPreview += '<object width="290" height="218"><param name="movie" value="http://www.fotocommunity.de/widgets/FCSlideshowWidget.swf?feed=' + SlideShowPage.feed + '&intervall=' + speed + '"></param><param name="allowFullScreen" value="true"></param><embed src="http://www.fotocommunity.de/widgets/FCSlideshowWidget.swf?feed=' + SlideShowPage.feed + '&intervall=' + speed + '" type="application/x-shockwave-flash" allowfullscreen="true" width="290" height="218"></embed></object>';
				EmbedObjectForPreview += '<p style="font-weight:normal;"><a href="#" onClick="SlideShowPage.openPopup(' + sizeX + ',' + sizeY + ',' + speed + '); return (false);" class="form_link">' + YDom.get ('SlideShowPreviewPopup').value + '</a></p>';
			
				
			// Preview generieren
			YDom.get ('SlideShowPreview').innerHTML = EmbedObjectForPreview;
			
			// Sollte das Popup-Fenster offen sein, so soll dieses nun auch
			// aktualisiert werden.
			if (SlideShowPage.popup !== null && !SlideShowPage.popup.closed) {
				
				SlideShowPage.openPopup(sizeX, sizeY, speed);
			}
		},
		
		activateSlideShow: function () {
		
			// Die Eingabebox mit dem HTML-Code anzeigen
			SlideShowPage.showCode();
			
			// Die Slideshow entgueltig in der Datenbank speichern
			cp.call('/pc/inc/ajax_slideshow.inc.php', 'activate_slideshow',SlideShowPage.activateSlideShowCallback, SlideShowPage.feed);
		},
		
		activateSlideShowCallback: function () {
		
			// nix
		},
		
		showCode: function () {
		
			YDom.get ('headline_html').style.display 			= 'block';
			YDom.get ('EmbedObject').style.display 				= 'block';
			YDom.get ('EmbedObject_description').style.display 	= 'block';
			
			YDom.get ('button_generate').style.display 			= 'none';
		},
		
		hideCode: function () {
		
			YDom.get ('headline_html').style.display 			= 'none';
			YDom.get ('EmbedObject').style.display 				= 'none';
			YDom.get ('EmbedObject_description').style.display 	= 'none';
			
			YDom.get ('button_generate').style.display 			= 'block';	
		},
		
		
		openPopup: function (sizeX, sizeY, speed) {
			
			if (YAHOO.env.ua.gecko != 0) {
				
				// Firefox & Co
				var sizeCorrectionX = 15;
				var sizeCorrectionY = 75;
			}
			else if (YAHOO.env.ua.opera != 0) {
				
				// Opera
				var sizeCorrectionX = 15;
				var sizeCorrectionY = 55;
			}
			else if (YAHOO.env.ua.ie == 6) {
				
				// Internet Explorer 6
				var sizeCorrectionX = 30;
				var sizeCorrectionY = 80;
			}
			else if (YAHOO.env.ua.ie == 7) {
				
				// Internet Explorer 7
				var sizeCorrectionX = 30;
				var sizeCorrectionY = 100;
			}
			else {
				
				// Sonstige ... Safari, etc.
				var sizeCorrectionX = 15;
				var sizeCorrectionY = 40;
			}
			
			var windowWidth  = Number (sizeX) + Number (sizeCorrectionX);
			var windowHeight = Number (sizeY) + Number (sizeCorrectionY);
			
			// Noch kein Fenster offen. Jetzt oeffnen
			SlideShowPage.popup = window.open('/pc/slideshowpreview.php?feed=' + SlideShowPage.feed + '&speed=' + speed + '&sizeX=' + sizeX + '&sizeY=' + sizeY, "slideshowPopupWindow", "width=" + windowWidth + ",height=" + windowHeight + ",location=no,status=no");
			
			// Mittels JavaScript "nachtraeglich" nochmal die groesse anpassen.
			// Dies ist notwendig, um ein bereits geoeffnetes Fenster in der
			// groesse anzupassen.
			SlideShowPage.popup.resizeTo ( windowWidth, windowHeight );
			SlideShowPage.popup.focus();
		}
};


Market = {
		
	// Oeffnen eines Popup mit Produkt-Informationen
	openPopup: function (element) 
	{
		var windowWidth  = 618;
		var windowHeight = 600;
		
		// Popup-Fenster oeffnen
		marketPopup = window.open(element.href, 
								  "marketPopupWindow", 
								  "width=" + windowWidth + 
								  ",height=" + windowHeight + 
								  ",location=no,status=no,scrollbars=yes");
		
		return false;
	},
	
	// Hinzufuegen/aendern eines Schlagworts fuer ein Foto
	changeKeyword: function (element) 
	{
		// Id des Fotos ermitteln
		var photoId = element.id.substr(8);

		// Informationen an den Server senden
		cp.call('/pc/inc/ajax_market.inc.php', 'changeKeyword',null, photoId, element.value);
		
		// Den Hintergrund des aktuellen Thumbnail einfaerben, damit dieses
		// als verschlagwortet markiert hervorgehoben ist.
		document.getElementById('thumb-' + photoId).style.background = '#416b4a';
		document.getElementById('thumb-' + photoId).style.border = '2px #FFF';
	}
};

function PicLensLink (link) {

	BrowserDetect.init();
	
	if (PicLensLite.hasClient() === true) {
	
		PicLensLite.start();
	}
	else {
	
		window.location.href = link;
	}
}

function openCommentsAtTestReport () {
	
	document.getElementById('commentlink').style.display 	= 'none';
	document.getElementById('comments').style.display 		= 'block';
}

function showInteractRow() {
	document.getElementById('interact_row1').style.visibility = '';
	document.getElementById('interact_row1').style.fontSize = '1px';
	document.getElementById('interact_row1').style.lineHeight = '1px';
	document.getElementById('interact_row1').style.height = '1px';
	document.getElementById('interact_row2').style.visibility = '';
	document.getElementById('interact_row2').style.fontSize = '12px';
	document.getElementById('interact_row2').style.lineHeight = '26px';
	document.getElementById('interact_row2').style.height = '26px';	
}

function hideInteractRow() {
	document.getElementById('interact_row1').style.visibility = 'hidden';
	document.getElementById('interact_row1').style.fontSize = '0px';
	document.getElementById('interact_row1').style.lineHeight = '0px';
	document.getElementById('interact_row1').style.height = '0px';
	document.getElementById('interact_row2').style.visibility = 'hidden';
	document.getElementById('interact_row2').style.fontSize = '0px';
	document.getElementById('interact_row2').style.lineHeight = '0px';
	document.getElementById('interact_row2').style.height = '0px';	
}


/**
 * Objekt zur Handhabe der Banner-Seite
 * 
 * @package		fotocommunity
 * @package		videocommunity
 * @subpackage	Affiliate
 * 
 * @author		Stephan Tijink
 * @since		10/2009
 */
var Banner = {
		
	bannerTabs: ['static-banner', 'animated-banner', 'logos-banner'],
		
	changeTabTo: function (nameOfActiveTab) 
	{
		// Alle Tabs erstmal ausblenden
		for (indexOfCurrentTab in this.bannerTabs) {
		
			if ( ! isNaN(indexOfCurrentTab) ) {
			
				currentTab = document.getElementById( this.bannerTabs[indexOfCurrentTab] );
				
				if ( typeof('currentTab') != null ) {
					
					currentTab.style.display = 'none';
				}
			}
		}
	
		// Der Tab, der angezeigt werden soll, wird eingeblendet.
		var activeTab = document.getElementById(nameOfActiveTab);
		activeTab.style.display = 'block';
	},
		
	changeVisibilityOfCodeTabs: function (tab, bannerId) 
	{
		// Die beiden Tabs selektieren
		var tabBBCode = document.getElementById('tab-bbcode-' + bannerId);
		var tabHTML   = document.getElementById('tab-html-' + bannerId);
		
		// Die beiden Textarea-Elemente selektieren
		var textareaBBCode = document.getElementById('bbcode-' + bannerId);
		var textareaHTML   = document.getElementById('html-' + bannerId);
		
		switch (tab) {

			// Der Tab "HTML" soll aktiv sein
			case 'html':

				tabHTML.style.backgroundImage 	= "url(/gfx/affiliate/banner-tab-aktiv.png)";
				tabBBCode.style.backgroundImage = "url(/gfx/affiliate/banner-tab-inaktiv.png)";
				
				tabHTML.style.color 			= '#5d5e60';
				tabBBCode.style.color 			= '#FFF';
				
				textareaHTML.style.display 		= 'block';
				textareaBBCode.style.display 	= 'none';
				
			break;
			
			// Der Tab "BBCode" soll aktiv sein
			case 'bbcode':
				
				tabHTML.style.backgroundImage 	= "url(/gfx/affiliate/banner-tab-inaktiv.png)";
				tabBBCode.style.backgroundImage = "url(/gfx/affiliate/banner-tab-aktiv.png)";
				
				tabHTML.style.color 			= '#FFF';
				tabBBCode.style.color 			= '#5d5e60';
			
				textareaHTML.style.display 		= 'none';
				textareaBBCode.style.display 	= 'block';
				
			break;
		}
	}
}


function switchCheckbox2(wert) {
	
	if(wert==15) {
		document.getElementById('cb_15').className = 'cb_yes';
		document.getElementById('cb_30').className = 'cb_neutral';
		document.getElementById('marge_text1').className = 'fl bold';
		document.getElementById('marge_text2').className = 'fl';
		document.getElementById('default_marge').value = 15;
		
	} else if(wert==30) {
		document.getElementById('cb_15').className = 'cb_neutral';
		document.getElementById('cb_30').className = 'cb_yes';
		document.getElementById('marge_text1').className = 'fl';
		document.getElementById('marge_text2').className = 'fl bold';
		document.getElementById('default_marge').value = 30;
	}

}


var myPrintOrder = {
	// Funktion bei Bestellung einer Ausbelichtung (dient zum Einblenden der abweichenden Lieferadresse)
	showOptionalAdress : function() {
		if (document.getElementById('other_adress').style.display == 'none') {
			document.getElementById('other_adress').style.display = 'block';
			document.getElementById('diff').value = '1';
		} else {
			document.getElementById('other_adress').style.display = 'none';
			document.getElementById('diff').value = '0';
		}
		
	},
	
	calculatePrice : function () {
		var product 				= YDom.get('product').value;
		var formatSelect 		= document.orderPrints.format;
		var surfaceSelect 	= document.orderPrints.surface;
		var numSelect 			= document.orderPrints.num;
		var fotoId					= YDom.get('current_photo').value;
		
		for (var i=0; i<formatSelect.length; i++) {
			if(formatSelect.options[i].selected==true) {
				
				var format = formatSelect.options[i].value;
			}	
		}
		
		for (var i=0; i<surfaceSelect.length; i++) {
			if(surfaceSelect.options[i].selected==true) {
				
				var surface = surfaceSelect.options[i].value;
			}	
		}
		
		for (var i=0; i<numSelect.length; i++) {
			if(numSelect.options[i].selected==true) {
				
				var num = numSelect.options[i].value;
			}	
		}
		
		cp.call('/pc/inc/ajax_orderprint.inc.php', 'getPrice', changePrice, product, format, surface, num, fotoId);
		//YDom.get('preis_gfx').innerHTML ='<br>fu';
	}
	
	
};

var fcPrints = {
		
		productList: false,
		productObject : false,
		fotoid: false,
		marge: false,
		fotoOwner: false,

		init: function(id, marge){
			fcPrints.fotoid = id; 
			fcPrints.marge = marge;
			fcPrints.fotoOwner = YDom.get('owner').value;
			
			var productID = YDom.get('product').value;
			
			cp.call ('/pc/inc/ajax.getPrintsProducts.inc.php', 'getInfos',fcPrints.storeList,fcPrints.fotoid, productID );
		},
		
		inArray: function(haystack,needle){
			for(var i=0; i < haystack.length; i++) if(haystack[i] === needle) return true;
			return false;
		},
		
		storeList: function (result) {
			fcPrints.productList = result.ajaxResponse[0].products[0].data;
			 fcPrints.productObject = eval('('+fcPrints.productList+')');
		},

		calculateShippingCosts : function(length) {
			var returnValue;
			if(length <= 60) {
				returnValue = 9;
			} else if(length >60 && length <=90) {
				returnValue = 18;
			} else {
				returnValue= 28;
			}
			return returnValue;
		},

		onChangeAction: function(typ,value){
			
			/*
			es gibt zwei typen: format, oberflaeche
			on change muss folgendes passieren:
			1) *beide* dropdowns werden neu aufgebaut und bekommen als ersten 
				eintrag den default "bitte waehlen"
			2)	das dropdown, was geaendert wurde, muss die komplette 
				moeglichkeitenliste bekommen
			3) das value, was ausgewaehlt wurde, muss natuerlich das selected 
				behalten
			4)	das andere dropdown muss die moeglichkeiten
				bekommen, die mit dieser auswahl moeglich sind
			5)	sind dort bereits welche ausgewaehlt gewesen, diese als selected
			 	markieren. sind die vorausgewaehlten mit dem neuen eintrag
			 	nicht moeglich, muss der "bitte waehlen" eintrag selected
			 	werden
			*/
			var changedTyp = typ;
			var selectedValue = value;
			
			var myForm = document.getElementById('orderPrints');
			var alleProdukte = fcPrints.productObject.produkte;
			
			switch(changedTyp){
				case "format":
					
					//eigene liste updaten:
					myForm.format.length=0;
					//NeuerEintrag = new Option('Bitte whlen', '0', true, true);
					//myForm.format.options[myForm.format.length] = NeuerEintrag;
					var myElements = fcPrints.productObject.formate;
					
					for(var i in myElements){
						if (i == '______array') {
							continue;
						}
						if( myElements[i] == selectedValue){
							NeuerEintrag = new Option(myElements[i], myElements[i], false, true);//selected
						}
						else{
							NeuerEintrag = new Option(myElements[i], myElements[i], false, false);
						}
						myForm.format.options[myForm.format.length] = NeuerEintrag;
					}
					
					//andere liste updaten:
					//eingestellte werte sichern
					var l3Value = myForm.surface.options[myForm.surface.selectedIndex].value;
					
					//liste leeren
					myForm.surface.length=0;
					
					//neue eintraege zusammenstellen
					var neueEintraegeL3 = new Array();
					var run2 = 0;
					for (var i in alleProdukte){
						var tempname = alleProdukte[i]['print_hoehe'] + "x" + alleProdukte[i]['print_breite'];
						if ( (tempname == selectedValue || selectedValue == "0") && tempname != "undefinedxundefined" ){
							if(fcPrints.inArray(neueEintraegeL3,alleProdukte[i]['oberflaeche']) === false){
								neueEintraegeL3[run2] = alleProdukte[i]['oberflaeche'];
								run2++;
							}
						}
					}
					if(neueEintraegeL3.length > 1){
						//NeuerEintrag = new Option('Bitte whlen', '0', true, true);
						//myForm.surface.options[myForm.surface.length] = NeuerEintrag;
					}
					for(var y=0; y < neueEintraegeL3.length; y++){
						if( neueEintraegeL3[y] == l3Value){
							NeuerEintrag = new Option(neueEintraegeL3[y], neueEintraegeL3[y], false, true);//selected
						}
						else{
							NeuerEintrag = new Option(neueEintraegeL3[y], neueEintraegeL3[y], false, false);
						}
						myForm.surface.options[myForm.surface.length] = NeuerEintrag;
					}
					break;
				case "surface":
					
					// Anpassen der Vorschaugrafik bei genderter Oberflche
					var selectedProduct 	= YDom.get('product').value;
					var previewThumb  = YDom.get('preview_surface');
					
					if (selectedProduct != 3 && selectedProduct != 4) {
						previewThumb.src = '/gfx/fotomarkt/'+selectedValue+'.jpg';
					}
					
					//eigene liste updaten:
					myForm.surface.length=0;
					//NeuerEintrag = new Option('Bitte whlen', '0', true, true);
					//myForm.surface.options[myForm.surface.length] = NeuerEintrag;
					var myElements = fcPrints.productObject.oberflaechen;
					for(var i in myElements){
						if (i == '______array') {
							continue;
						}
						if( myElements[i] == selectedValue){
							NeuerEintrag = new Option(myElements[i], myElements[i], false, true);//selected
						}
						else{
							NeuerEintrag = new Option(myElements[i], myElements[i], false, false);
						}
						myForm.surface.options[myForm.surface.length] = NeuerEintrag;
					}
					
					//andere liste updaten:
					//eingestellte werte sichern
					var l3Value = myForm.format.options[myForm.format.selectedIndex].value;
					
					//liste leeren
					myForm.format.length=0;
					
					//neue eintraege zusammenstellen
					var neueEintraegeL3 = new Array();
					var run2 = 0;
					for (var i in alleProdukte){
						var tempname = alleProdukte[i]['oberflaeche'];
						var format = alleProdukte[i]['print_hoehe'] + "x" + alleProdukte[i]['print_breite'];
						
						if ( (tempname == selectedValue || selectedValue == "0") && tempname != "undefined" ){
							if(fcPrints.inArray(neueEintraegeL3,format) === false){
								neueEintraegeL3[run2] = format;
								run2++;
							}
						}
					}
					if(neueEintraegeL3.length > 1){
						//NeuerEintrag = new Option('Bitte whlen', '0', true, true);
						//myForm.format.options[myForm.format.length] = NeuerEintrag;
					}
					for(var y=0; y < neueEintraegeL3.length; y++){
						if( neueEintraegeL3[y] == l3Value){
							NeuerEintrag = new Option(neueEintraegeL3[y], neueEintraegeL3[y], false, true);//selected
						}
						else{
							NeuerEintrag = new Option(neueEintraegeL3[y], neueEintraegeL3[y], false, false);
						}
						myForm.format.options[myForm.format.length] = NeuerEintrag;
					}
					break;
				default:
					break;
			}
			
			// Preis bestimmen
			var selectedFormat = myForm.format.options[myForm.format.selectedIndex].value;
			var selectedSurface = myForm.surface.options[myForm.surface.selectedIndex].value;
			var selectedNum		 = myForm.num.options[myForm.num.selectedIndex].value;
		
			if( selectedFormat !=0 && selectedSurface != 0) {
				var temp = selectedFormat.split('x');
				var hoehe = temp[0];
				var breite = temp[1];
			
				for( var n in alleProdukte) {
					
					if( alleProdukte[n]['oberflaeche'] == selectedSurface 
						&& alleProdukte[n]['print_hoehe']	== hoehe
						&& alleProdukte[n]['print_breite'] == breite) {

						var price15 = alleProdukte[n]['bruttoEndpreis_15'];
						var price30 = alleProdukte[n]['bruttoEndpreis_30'];
						break;
					}
				}
				
				var price = 0;
				
				if(fcPrints.fotoOwner == 1) {
					price = (parseFloat(price15)*0.85) * selectedNum;
				} else {
					if(fcPrints.marge == 15) {
						price = price15 * selectedNum;
					} else {
						price = price30 * selectedNum;
					}
				}

				price = Math.round((price*100))/100;
				var maxLength = breite;
				if(hoehe > breite) {
					maxLength = hohe;
				}
				
				var shipping = fcPrints.calculateShippingCosts(maxLength);
				price = price + shipping;
				YDom.get('preis_span').innerHTML= price.toFixed(2)+'&euro;';
				
				
				
			}
			
		},

		acceptPrintsAgb : function() {
			
			if(YDom.get('prints_agb').checked){
				YDom.get('submit_order').disabled=false;
			} else {
				YDom.get('submit_order').disabled=true;
			}
		}
		
};


function changePrice(resultObject) {
	var ajaxdata 		= resultObject.ajaxResponse[0];
	var price = ajaxdata.price[0].data;
	
	YDom.get('preis_span').innerHTML= price;
	
}


	/**
	*
	*  Base64 encode / decode
	*  http://www.webtoolkit.info/
	*
	**/
 
var Base64 = {
 
	// private property
	_keyStr : "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",
 
	// public method for encoding
	encode : function (input) {
		var output = "";
		var chr1, chr2, chr3, enc1, enc2, enc3, enc4;
		var i = 0;
 
		input = Base64._utf8_encode(input);
 
		while (i < input.length) {
 
			chr1 = input.charCodeAt(i++);
			chr2 = input.charCodeAt(i++);
			chr3 = input.charCodeAt(i++);
 
			enc1 = chr1 >> 2;
			enc2 = ((chr1 & 3) << 4) | (chr2 >> 4);
			enc3 = ((chr2 & 15) << 2) | (chr3 >> 6);
			enc4 = chr3 & 63;
 
			if (isNaN(chr2)) {
				enc3 = enc4 = 64;
			} else if (isNaN(chr3)) {
				enc4 = 64;
			}
 
			output = output +
			this._keyStr.charAt(enc1) + this._keyStr.charAt(enc2) +
			this._keyStr.charAt(enc3) + this._keyStr.charAt(enc4);
 
		}
 
		return output;
	},
 
	// public method for decoding
	decode : function (input) {
		var output = "";
		var chr1, chr2, chr3;
		var enc1, enc2, enc3, enc4;
		var i = 0;
 
		input = input.replace(/[^A-Za-z0-9\+\/\=]/g, "");
 
		while (i < input.length) {
 
			enc1 = this._keyStr.indexOf(input.charAt(i++));
			enc2 = this._keyStr.indexOf(input.charAt(i++));
			enc3 = this._keyStr.indexOf(input.charAt(i++));
			enc4 = this._keyStr.indexOf(input.charAt(i++));
 
			chr1 = (enc1 << 2) | (enc2 >> 4);
			chr2 = ((enc2 & 15) << 4) | (enc3 >> 2);
			chr3 = ((enc3 & 3) << 6) | enc4;
 
			output = output + String.fromCharCode(chr1);
 
			if (enc3 != 64) {
				output = output + String.fromCharCode(chr2);
			}
			if (enc4 != 64) {
				output = output + String.fromCharCode(chr3);
			}
 
		}
 
		output = Base64._utf8_decode(output);
 
		return output;
 
	},
 
	// private method for UTF-8 encoding
	_utf8_encode : function (string) {
		string = string.replace(/\r\n/g,"\n");
		var utftext = "";
 
		for (var n = 0; n < string.length; n++) {
 
			var c = string.charCodeAt(n);
 
			if (c < 128) {
				utftext += String.fromCharCode(c);
			}
			else if((c > 127) && (c < 2048)) {
				utftext += String.fromCharCode((c >> 6) | 192);
				utftext += String.fromCharCode((c & 63) | 128);
			}
			else {
				utftext += String.fromCharCode((c >> 12) | 224);
				utftext += String.fromCharCode(((c >> 6) & 63) | 128);
				utftext += String.fromCharCode((c & 63) | 128);
			}
 
		}
 
		return utftext;
	},
 
	// private method for UTF-8 decoding
	_utf8_decode : function (utftext) {
		var string = "";
		var i = 0;
		var c = c1 = c2 = 0;
 
		while ( i < utftext.length ) {
 
			c = utftext.charCodeAt(i);
 
			if (c < 128) {
				string += String.fromCharCode(c);
				i++;
			}
			else if((c > 191) && (c < 224)) {
				c2 = utftext.charCodeAt(i+1);
				string += String.fromCharCode(((c & 31) << 6) | (c2 & 63));
				i += 2;
			}
			else {
				c2 = utftext.charCodeAt(i+1);
				c3 = utftext.charCodeAt(i+2);
				string += String.fromCharCode(((c & 15) << 12) | ((c2 & 63) << 6) | (c3 & 63));
				i += 3;
			}
 
		}
 
		return string;
	}
 
}


function cnFindPos(obj) {
	var curleft = curtop = 0;
	if (obj.offsetParent) {
		do {
			curleft += obj.offsetLeft;
			curtop += obj.offsetTop;
			} 
		while (obj = obj.offsetParent);
		return [curleft,curtop];
	}
}

function hideHiddenHeaderLayer(func) {
	
	if (func == 1) {
		var layer = document.getElementById('hidden_language_layer');
		layer.style.display = 'none';
		
	} else {
		var profileLayer = document.getElementById('hidden_profile_layer');
		var menuLayer = document.getElementById('hidden_quickmenu_layer');
		
		profileLayer.style.display = 'none';
		menuLayer.style.display = 'none';
	}
}

function showHiddenHeaderLayer(func) {
	
	if(document.getElementById('welcome_message')) {
		var welcomeLength = document.getElementById('welcome_message').offsetWidth;
	} else {
		var welcomeLength = document.getElementById('header_registration').offsetWidth;
	}
	
	var optionsLength = document.getElementById('log_in_out').offsetWidth;
	var spacer = 15;
	var styleRight = parseInt(welcomeLength) + parseInt(optionsLength) +parseInt(spacer) - 2;
	
	if(document.getElementById('container_header_right_space')) {
		styleRight = parseInt(styleRight) +80;
	}
	
	if (func == 1) {
		var layer = document.getElementById('hidden_language_layer');
		layer.style.right = styleRight+'px';
		
		layer.style.display = 'block';
		
	} else {
		var profileLayer = document.getElementById('hidden_profile_layer');
		var menuLayer = document.getElementById('hidden_quickmenu_layer');
		
		if(document.getElementById('container_header_right_space')) {
			profileLayer.style.right = '80px';
			menuLayer.style.right = '80px';
		}
		
		document.getElementById('profile_spacer').style.width = document.getElementById('profile_link').offsetWidth+'px';
		profileLayer.style.display = 'block';
		menuLayer.style.display = 'block';
	}
	
}

var Uservoice = {
	
		openNoticeWindow: function ()
		{
			// Event-Handler fuer die Buttons
			var handleYes = function() { 
				
				// Mitteilung an Google Analytics, dass die Bestimmungen akzeptivert wurden
				_gaq.push(['_trackEvent', 'Interaction', 'Uservoice', 'redirectToForum']);
				
				// Aufruf	
				window.location.href = 'http://www.fotocommunity.de/uservoice/redirectToUservoiceForum.php';
			};
			
			var handleNo = function() { 
		
			 	this.hide(); 
			};
					
			// Dialog initialisieren und Optionen setzen
			uservoiceWindow = new YAHOO.widget.SimpleDialog("uservoiceWindow", {  
			    width: 			"450px",
			    height: 		"170px",  
			    fixedcenter:	true,
			    close:			false,
			    modal:			true, 
			    visible:		true, 
			    draggable:		false,
			    iframe:			true,
			    zIndex:			500,
			    underlay:		'matte'
			}); 
		    
			uservoiceWindow.setHeader('Hilf uns, die fotocommunity besser zu machen'); 
			uservoiceWindow.setBody('Diese Funktion basiert auf einer Zusammenarbeit mit UserVoice. Beim Start der Feedback-Funktion werden Dein Benutzername und Deine E-Mail-Adresse an UserVoice &uuml;bermittelt. Stimmst Du dem zu?'); 
			
			uservoiceWindow.cfg.queueProperty("buttons", [	
   				{text:'Ich stimme zu', handler:handleYes}, 
   				{text:'Nein danke', 	 handler:handleNo, isDefault:true} 
			 ]); 
			
			// Rendern und anzeigen
			uservoiceWindow.render(document.body);
			
			// Mitteilung an Google Analytics, dass der Tab geklickt wurde
			_gaq.push(['_trackEvent', 'Interaction', 'Uservoice', 'widgetClick']);
		}
};

var galleryComments = {

    changeVotingComments: function(id) {
        
        if(id > 0 ) {
            $.ajax({
                type: 'GET',
                url: '/pc/inc/ajax_voting.php?changeSettings=vc&id='+id,
                async: false,
                success: function(msg) {
                                        if (msg.length > 0) {
                                                var response = msg.split('_');
                                                var action = response[0];
                                                var txt = response[1];

                                                if(action == 'hide') {
                                                    $('.voting_comment').hide();
                                                } else {
                                                    $('.voting_comment').show();
                                                }

                                                $('#show_votingcomments').text(txt);
                                        }
                }

            });
        }
    },
    
    changeAfterVotingComments: function(id) {

        if(id > 0 ) {
            $.ajax({
                type: 'GET',
                url: '/pc/inc/ajax_voting.php?changeSettings=av&id='+id,
                async: false,
                success: function(msg) {
                                        if (msg.length > 0) {
                                                var response = msg.split('_');
                                                var action = response[0];
                                                var txt = response[1];

                                                if(action == 'hide') {
                                                    $('.submitterbig').find('.button').hide();
                                                } else {
                                                    $('.submitterbig').find('.button').show();
                                                    
                                                }

                                                $('#new_comments').text(txt);
                                        }
                }

            });
        }
    }
};

var wallpaperDiv = {

	doChange: function () {
		
		//Farbe holen:
		var myDiv = document.getElementById('changeColorTo');
		var newColor = myDiv.getAttribute('bgcolor');
		
		//Farbe setzen:
		var zielDiv = document.getElementById('big_container');
		zielDiv.style.backgroundColor=newColor;
		
		//Link aendern auf funktion:
		var myFunctionCall = "wallpaperDiv.getMousePosition(event);";
		zielDiv.setAttribute('onclick',myFunctionCall,0);
		zielDiv.setAttribute('onmouseover','wallpaperDiv.showHand(event)',0);
		
	},
	
	getMousePosition: function(e) {
		
		//Fensterbreite suchen, weil in dem skyscraper-div nur rechts geklickt werden soll
		if(navigator.userAgent.indexOf('MSIE') > -1){
			
			var fensterBreite = document.documentElement.clientWidth;
		}
		if(navigator.userAgent.indexOf('Gecko') > -1){
			
			var fensterBreite = window.innerWidth;
		}
		
		var startAt = (((fensterBreite - 961) / 2) + 801);
		
		if(((window.Event) ? e.pageX : event.clientX) > startAt){
			
			//Link holen:
			var myDiv = document.getElementById('changeColorTo');
			var newLink = myDiv.getAttribute('onclick');
			var temp1 = newLink.split("('");
			var temp2 = temp1[1].split("')");
			var strippedLink=temp2[0];
			window.open(strippedLink);
			
		}
		return false;
		
	},
	
	showHand: function(e) {
		
		//Fensterbreite suchen, weil in dem skyscraper-div nur rechts geklickt werden soll
		if(navigator.userAgent.indexOf('MSIE') > -1){
			
			var fensterBreite = document.documentElement.clientWidth;
		}
		if(navigator.userAgent.indexOf('Gecko') > -1){
			
			var fensterBreite = window.innerWidth;
		}
		
		var startAt = (((fensterBreite - 961) / 2) + 801);
		
		if(((window.Event) ? e.pageX : event.clientX) > startAt){
			
			document.getElementById('big_container').style.cursor='pointer';
		}
		
		else {
		
			document.getElementById('big_container').style.cursor='default';
		}
	}

};

function stroeerMakeWallpaper(e){
	
	//grundsaetzlich erst mal den body wieder normal faerben:
	//document.body.style.backgroundColor = "#222";
	//document.body.style.backgroundImage="";
	
	if(document.getElementById('sky_space')){
		
		var mySky = document.getElementById('sky_space');
		//mySky.style.width="";
		var ssBreite = mySky.offsetWidth;
		
		if(ssBreite > 0 && ssBreite < 180) {
			ssBreite = 160;
		}
		else{
			ssBreite=200;
		}
        
        
        //fuer den IE7: sky absolute positionieren!
        if(navigator.userAgent.indexOf('MSIE') > -1){
        	mySky.style.position = 'absolute';
			var fcBody = document.getElementById('fc_body');
			var bodyPos = findPos(fcBody);
			mySky.style.top = bodyPos[1];
			mySky.style.left = bodyPos[0] + 800;
		}
        
        document.getElementById('first_spacer_with_extra_space').style.backgroundColor = 'transparent';
        //$('#first_spacer_with_extra_space').css('background-color', 'transparent');
        if(document.getElementById('supersize_cont_design')){
			
			var myLB = document.getElementById('supersize_cont_design');
			var lbHoehe = myLB.offsetHeight;
			if(lbHoehe < 120){
				lbHoehe = 90;
			}
			else{
				lbHoehe = 180;
			}
            if(typeof(adtype) == 'undefined' || adtype != 'wallpaper') {
            	//mySky.style.paddingTop = $('#supersize_cont_design').height() + "px";
            }
		}
	
		var hoch = (self.innerHeight || (document.documentElement.clientHeight || document.body.clientHeight));
		var fensterBreite = (self.innerWidth || (document.documentElement.clientWidth || document.body.clientWidth));
		var fensterHoehe = document.getElementById('big_container').offsetHeight;
	
		if (hoch < (fensterHoehe + 118)){
			//scrollbar vorhanden!
			var addScrollOffset = 0;
			if(navigator.userAgent.indexOf('MSIE') > -1){
				addScrollOffset = 8;
			}
		}
		else{
			var addScrollOffset = 8;
		}
		
		if(navigator.userAgent.indexOf('MSIE 9.0') > -1){
				addScrollOffset = addScrollOffset - 8;
		}
		
		if (typeof(adtype) != 'undefined') { 
			
			if (adtype == 'wallpaper') {
				// Schiebe Leaderboard rechtsbuendig an Skyscraper
				document.getElementById('supersize_cont_design').style.textAlign = 'right';
                                                                mySky.style.paddingTop = "0px";
			} 
			if (adtype == 'expwallpaper') {
				// Schiebe Skyscraper unter Leaderboard und dieses nach rechts
				//der content ist 800px breit. das leaderboard ist 728px breit.
				//wir muessen also das leaderboard um 72px + sky-breite nach rechts schieben:
				var newLb = 72 + ssBreite;
				myLB.style.paddingLeft = newLb + "px";
				//und den skyscraper um die hoehe des leaderboard nach unten:
				mySky.style.paddingTop = lbHoehe + "px";
			
			} 
		}
		
	}
	if (typeof(bgcolor) != 'undefined' && bgcolor != null) {
			
			// Faerbe moegliche Bereiche ein
			var zielDiv = document.getElementById('big_container');
			zielDiv.style.backgroundColor=bgcolor;
			var zielDiv2 = document.getElementById('supersize_cont_design');
			zielDiv2.style.backgroundColor=bgcolor;
			if(navigator.userAgent.indexOf('MSIE') > -1){
			}
			else{
				//var zielDiv3 = document.getElementById('first_spacer_with_extra_space');
				//zielDiv3.style.backgroundColor=bgcolor;
			}
		}
	
		if (typeof(bgimage) != 'undefined' && bgimage != null) {
			// Setze Hintergrund Bild
			var zielDiv = document.getElementById('big_container');
			zielDiv.style.backgroundImage="url(\"" + bgimage + "\")";
			zielDiv.style.backgroundRepeat='repeat';
			var zielDiv2 = document.getElementById('supersize_cont_design');
			zielDiv2.style.backgroundImage="url(\"" + bgimage + "\")";
			zielDiv2.style.backgroundRepeat='repeat';
			if(navigator.userAgent.indexOf('MSIE') > -1){
			}
			else{
				//var zielDiv3 = document.getElementById('first_spacer_with_extra_space');
				//zielDiv3.style.backgroundImage="url(\"" + bgimage + "\")";
				//zielDiv3.style.backgroundRepeat='repeat';
			}
		}
	
		if (typeof(adclick) != 'undefined' && adclick != null) {
	
			//link setzen:
			var myClickPart = document.getElementById('stroeer_ad_clickurl');
			var myClickPart1 = document.getElementById('stroeer_ad_clickurl1');
			var myClickPart2 = document.getElementById('stroeer_ad_clickurl2');
			
			myClickPart.href = adclick;
			myClickPart1.href = adclick;
			myClickPart2.href = adclick;
		
			var startHoriz = (((fensterBreite - 960) / 2) + 800);
			var adClickWidth = fensterBreite - startHoriz - 20; //die 20 pixel muessen runter, damit keine horiz. scrollbar angezeigt wird
			var startVert = 118;
			var adClickHeight = fensterHoehe;
		
			myClickPart.style.left = startHoriz + "px";
			myClickPart.style.width = adClickWidth + "px";
			myClickPart.style.top = startVert + "px";
			myClickPart.style.height = adClickHeight + "px";
			myClickPart.style.position = "absolute";
		
			var firstClickBereichVon = 0
			var firstClickBereichBis = (fensterBreite - 960) / 2;
		
			myClickPart1.style.left =  firstClickBereichVon + "px";
			myClickPart1.style.width = firstClickBereichBis + "px";
			myClickPart1.style.top = startVert + "px";
			myClickPart1.style.height = adClickHeight + "px";
			myClickPart1.style.position = "absolute";
		
			var secondClickBereichVon = (fensterBreite - 960) / 2;
		
		
			myClickPart2.style.left =  secondClickBereichVon + "px";
			myClickPart2.style.width = "800px";
			myClickPart2.style.top = startVert + "px";
			myClickPart2.style.height = "90px";
			myClickPart2.style.position = "absolute";
			myClickPart2.style.zIndex = "2";
		
			document.getElementById('supersize_cont_design').style.cursor='pointer';
		
			//show cursor:
			if(((window.Event) ? e.pageX : event.clientX) > startAt || ((window.Event) ? e.pageX : event.clientX) < firstClickBereichBis){
				document.getElementById('big_container').style.cursor='pointer';
			}
			else {
				document.getElementById('big_container').style.cursor='default';
			}
			
		}
}


function findPos(obj) {
	var curleft = curtop = 0;
	if (obj.offsetParent) {
		do {
			curleft += obj.offsetLeft;
			curtop += obj.offsetTop;
   	   	} 
   	   	while (obj = obj.offsetParent);
   	   	return [curleft,curtop];
	}
}


//EVENT-HANDLER verarbeiten. Das YAHOO-Objekt muss
//dafuer existieren. Dies vorher pruefen.
if (typeof (YAHOO) !== 'undefined') {
	// Kuerzel fuer die YAHOO-Objekte erstellen
	var YEvent 	= YAHOO.util.Event;
	var YDom	= YAHOO.util.Dom;
	var YUtil	= YAHOO.util;
	
	// Referenz auf das Overlay-Objekt, wenn vorhanden
	if ( typeof (YAHOO.widget.Overlay) !== 'undefined' ) {
		
		YOverlay = YAHOO.widget.Overlay;
	}
	
	// Kontaktliste initialieren, sobald diese Verfuegbar ist
	YEvent.onContentReady ('contacts', ContactList.init);
	
	// Foto-Seite initialisieren, sobald diese verfuegbar ist
	YEvent.onContentReady('display_foto', display_foto.initPage);

	// Bei Bedarf das Foto neu positionieren, sobald geladen.
	YEvent.onContentReady('fc_image', display_foto.correctImagePosition);
	
	// Bei aktivem Contest-Voting den Slider initialisieren
	YEvent.onContentReady('contestvalue', display_foto.initSlider);

	// Bei Quick-Start-Seite fr Foto-Publish den Slider initialisieren
//	YEvent.onContentReady('margevalue', publish_foto.initSliderMarge);

	// Bei Quick-Start-Seite fr Foto-Publish den Slider initialisieren
//	YEvent.onContentReady('publish_list_cont', publish_fotolist.initMouseOver);

	// Aufruf der Slideshow-Seite
	YEvent.onContentReady('slideshow_size', SlideShowPage.init);
	
	//eventuell Hintergrund einfaerben bei Werbung
	//YEvent.onContentReady('changeColorTo', wallpaperDiv.doChange);
	
	//stroeer wallpaper check
	YEvent.onDOMReady(stroeerMakeWallpaper);
}
