/**
* JavaScript functions for cookiehandling
*
* @package    StWD
* @access	  public
* @author	  Dominique Stender <dstender@st-webdevelopment.de?>
* @copyright  2004 (Dominique Stender); All rights reserved
* @version    1.0.0
*/

  /**
  * Sets a cookie
  *
  * @param string name Name of the cookie
  * @param string value Value of the cookie
  * @param string expired Time when the cookie will expire
  * @param string path path for which the cookie is valid
  * @param string domain domain for which the cookie is valid
  * @param string secure flag weather the cookie is SSL enabled or not
  * @return void
  */
  function cookie_set(name, value, expires, path, domain, secure) {
    var cur_cookie = name + "=" + escape(value) +
        ((expires) ? "; expires=" + expires.toGMTString() : "") +
        ((path) ? "; path=" + path : "") +
        ((domain) ? "; domain=" + domain : "") +
        ((secure) ? "; secure" : "");
    document.cookie = cur_cookie;
  } // end: function  cookie_set()



  /**
  * retrieves the contents of a cookie
  *
  * @param string name Name of the cookie
  * @return mixed string containing the cookies value, NULL if the cookie does not exist
  */
  function cookie_get(name) {
    var dc      = document.cookie;
    var prefix  = name + "=";
    var begin   = dc.indexOf("; " + prefix);

    if (begin == -1) {
      begin = dc.indexOf(prefix);

      if (begin != 0) {
        return null;
      } // end: if
    } else {
      begin += 2;
    } // end: if
    var end = document.cookie.indexOf(";", begin);

    if (end == -1) {
      end = dc.length;
    } // end: if

    return unescape(dc.substring(begin + prefix.length, end));
  } // end: function cookie_get()


  /**
  * removes a cookie
  *
  * @param string name Name of the cookie
  * @param path path for which the cookie is valid
  * @param string domain domain for which the cookie is valid
  * @return void
  */
  function cookie_delete(name, path, domain) {
    if (get_cookie(name)) {
      document.cookie = name + "=" +
      ((path) ? "; path=" + path : "") +
      ((domain) ? "; domain=" + domain : "") +
      "; expires=Thu, 01-Jan-70 00:00:01 GMT";
    } // end: if
  } // end: function cookie_delete()



  /**
  * Minor fixes for dates
  *
  * @param date an instance of the Date object
  * @return void
  */
  function fix_date(date) {
    var base = new Date(0);
    var skew = base.getTime();

    if (skew > 0) {
      date.setTime(date.getTime() - skew);
    } // end: if
  } // end: function fix_date()

/*
 * function.js
 *
 * The content of this file is (c) 2003 - 2007 dmc
 * digital media center GmbH
 * All rights reserved
 *
 * This software is the confidential and proprietary
 * information of dmc digital media center GmbH.
 *
 */


/**
 * global functions used by many extensions
 *
 * $Id: functions.js 8952 2008-11-03 10:42:29Z in-sms $
 */

	/**
	* flag to prevent double submits by doubleclicks on buttons
	*/
	var doubleclickFormSubmitFlag = false;

	/**
	* performs a form submit of the form defined by ctype and uid
	* and prevents a double click form submit
	*
	* @access public
	* @param  ctype    the name of the extension
	* @param  uid      the uid of the pageelement
	* @return void
	*/
	function doubleclickCheckFormSubmit(ctype, uid) {
		var form			= document.getElementById(ctype + '[' + uid + ']' + '[form]');

		if (doubleclickFormSubmitFlag == false) {
			if (form) {
				doubleclickFormSubmitFlag = true;
				form.submit();
			} // end: if
		} // end: if
	} // end: function

	/**
	* Change the value of the object with the given id
	*
	* @access	public
	* @param  	id    		the id of the form element to get changed
	* @param  	newValue    the new value for the form element to get changed
	* @return	boolean		result of the change
	*/
	function changeFormElementvalue(id, newValue) {
		var returnValue		= false;
		var formElement		= document.getElementById(id);

		if (formElement) {
			formElement.value = newValue;
			returnValue = true;
		} // end: if

		return returnValue;
	} // end: if

	/**
	* Trigger "needs cookie" warning in layer.
	*
	* @access public
	* @return void
	*/
	function cookieWarning(cookieName, getName, warnText) {
		var cookieSessionId = cookie_get(cookieName);
		var myDiv 			= false;

		if (typeof document.getElementById('mb3HeaderWarnings') == 'object') {
			myDiv = document.getElementById('mb3HeaderWarnings');

			if (!cookieSessionId
				&& document.location.href.indexOf(getName + '=') == -1) {

				myDiv.innerHTML 			= warnText;
				myDiv.style['visibility']	= 'visible';
				myDiv.style['display']		= 'block';
			} // end: if
		}
	} // end: function

	/**
	* Redirects the user if no session cookie is set and URL-based sessionIds are
	* allowed within the system.
	*
	* @access public
	* @return void
	*/
	function noCookieRedirect(cookieName, getName, sessionId) {
		var cookieSessionId = cookie_get(cookieName);
		var paramAppend		= '&';
		var redirectString	= getName + '=' + sessionId;

		if (cookieSessionId == null) {
			// no cookie set in browser

			// fix appender-char if no params exist
			if (document.location.href.indexOf('?') == -1) {
				// appended & because typo3 has a small bug
				// if there is no 'id=' in the query typo3 thinks that ftu=... is the id
				paramAppend = '?&';
			}

			// redirect to self with url-param
			document.location.href = document.location.href + paramAppend + redirectString;
		} // end: if
	} // end: function

	var dmcOnloadFuncs = new Array();
	/**
	* calls specified functions for the body onLoad Event
	* the function which wants to be called, adds itself to an array and than it gets called
	* current function calls:
	* __utmSetTrans() - send the Google Analytics Form @ the basket checkout (wk step6) - according global variable: utmTrans
	* __initZoom() - initiate the zoom-layer-script - according global variable: initZoom
	* __foofoo() - sample for further function calls  - according global variable: foofoo
	*
	* @access	public
	* @return	void
	*/
	function dmcOnLoad() {

		for(var i=0; i<dmcOnloadFuncs.length; i++) {

			if (typeof dmcOnloadFuncs[i] == 'function') {
				dmcOnloadFuncs[i]();
			}
		}
	} // end: function

	/**
	*
	* @access public
	* @param  func
	* @return void
	*/
	function addOnloadFunction(func) {
		if (typeof func == 'function') {
			dmcOnloadFuncs.push(func);
		}
	} // end: function

	/**
	*
	* @access public
	* @param  url
	* @param  name
	* @param  parameter
	* @return popuphandler
	*/
	function openWindow(url, name, parameter) {
		// Wenn ein Parameter uebergeben wird --> diesen uebernehmen
		if (parameter) {
			size = parameter;
		}

		var popuphandler = window.open(url,name,size);
		popuphandler.window.focus();

		return popuphandler;
	} // end: function

	/**
	*
	* @access public
	* @param  url
	* @param  name
	* @param  parameter
	*/
	function openJQueryPopupWindow(url, name, parameter) {
				
		name	 = '<span style="font-size:17px;font-weight:bold">'+name+'</span>';
		popupurl = url+"?TB_iframe=true&";
		
		// Wenn ein Parameter uebergeben wird --> diesen uebernehmen
		if (parameter) {
			size = parameter.replace(/\,/g, "&");
			popupurl = url+"?TB_iframe=true&"+size;
		}

		tb_show(name, popupurl, false);

	} // end: function


	/*
	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.
	*/

	var JSON = {
		org: 'http://www.JSON.org',
		copyright: '(c)2005 JSON.org',
		license: 'http://www.crockford.com/JSON/license.html',

		stringify: function (arg) {
	    	var c, i, l, s = '', v;
	    	var numeric = true;

	    	switch (typeof arg) {
	    		case 'object':
	      			if (arg) {
	        			if(Array.prototype.isPrototypeOf(arg)){
	          			// do a test whether all array keys are numeric
	          				for (i in arg) {
	            				if (isNaN(i) || !isFinite(i)) {
	              					numeric = false;
	              					break;
	            				} // end: if
	          				} // end: for

	          				if (numeric == true) {
	            				for (i = 0; i < arg.length; ++i) {
	              					if (typeof arg[i] != 'undefined') {
	                					v = this.stringify(arg[i]);
	                					if (s) {
	                  						s += ',';
	                					} // end: if
	                					s += v;
	              					} else {
	                					s += ',null';
	              					} // end: if
	            				} // end: for
	            				return '[' + s + ']';
	          				} else {
	            				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;
	                				} // end: if
	            				} // end: for
	            				// return as object
	            				return '{' + s + '}';
	          				} // end: if
	        			} 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 += ',';
	              					} // end: if
	              					s += this.stringify(i) + ':' + v;
	            				} // end: if
	          				} // end: for
	          				return '{' + s + '}';
	        			} // end: if
	      			} // end: if
	      			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 += '\\';
	          				} // end: if
	          				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);
	          				} // end: if
	        			} // end: if
	      			} // end: for
	      			return s + '"';

				case 'boolean':
	      			return String(arg);

	   			default:
	      			return 'null';
	    	} // end: switch
	  	},

		parse: function (text) {
	    	var at = 0;
	    	var ch = ' ';

	    	function error(m) {
	      		throw {
	        		name: 'JSONError',
	        		message: m,
	        		at: at - 1,
	        		text: text
	      		};
	    	} // end: function

	    	function next() {
	      		ch = text.charAt(at);
	      		at += 1;
	      		return ch;
	    	} // end: function

	    	function white() {
	      		while (ch != '' && ch <= ' ') {
	        		next();
	      		} // end: while
	    	} // end: function

	    	function str() {
	      		var i, s = '', t, u;

	      		if (ch == '"') {
					outer:      while (next()) {
	          			if (ch == '"') {
	            			next();
	            			return s;
	          			} else if (ch == '\\') {
	            			switch (next()) {
	            				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;
	            				case 'u':
	              					u = 0;
	              					for (i = 0; i < 4; i += 1) {
	                					t = parseInt(next(), 16);
	                					if (!isFinite(t)) {
	                  						break outer;
	                					} // end: if
	                					u = u * 16 + t;
	              					} // end: for
	              					s += String.fromCharCode(u);
	              					break;
	            				default:
	              					s += ch;
	            			} // end: switch
	          			} else {
	            			s += ch;
	          			} // end: if
	        		} // end: while
	      		} // end: if
	      		error("Bad string");
	    	} // end: function

	    	function arr() {
	      		var a = [];

	      		if (ch == '[') {
	        		next();
	        		white();
	        		if (ch == ']') {
	          			next();
	          			return a;
	        		} // end: if
	        		while (ch) {
	          			a.push(val());
	          			white();
	          			if (ch == ']') {
	            			next();
	            			return a;
	          			} else if (ch != ',') {
	            			break;
	          			} // end: if
	          			next();
	          			white();
	        		} // end: while
	      		} // end: if
	      		error("Bad array");
	    	} // end: function

	    	function obj() {
	      		var k, o = {};

	      		if (ch == '{') {
	        		next();
	        		white();
	        		if (ch == '}') {
	          			next();
	          			return o;
	        		} // end: if
	        		while (ch) {
	          			k = str();
	          			white();
	          			if (ch != ':') {
	            			break;
	          			}
	          			next();
	          			o[k] = val();
	          			white();
	          			if (ch == '}') {
	            			next();
	            			return o;
	          			} else if (ch != ',') {
	            			break;
	          			} // end: if
	          			next();
	          			white();
	        		} // end: while
	      		} // end: if
	      		error("Bad object");
	    	} // end: function

	    	function assoc() {
	      		var k, a = [];

	      		if (ch == '<') {
	        		next();
	        		white();
	        		if (ch == '>') {
	          			next();
	          			return a;
	        		}
	        		while (ch) {
	          			k = str();
	          			white();
	          			if (ch != ':') {
	            			break;
	          			} // end: if
	          			next();
	          			a[k] = val();
	          			white();
	          			if (ch == '>') {
	            			next();
	            			return a;
	          			} else if (ch != ',') {
	            			break;
	          			} // end: if
	          			next();
	          			white();
	        		} // end: while
	      		} // end: if
	      		error("Bad associative array");
	    	} // end: function

	    	function num() {
	      		var n = '', v;

		  		if (ch == '-') {
	        		n = '-';
	        		next();
	      		} // end: if
	      		while (ch >= '0' && ch <= '9') {
	        		n += ch;
	        		next();
	      		} // end: while
	      		if (ch == '.') {
	        		n += '.';
	        		while (next() && ch >= '0' && ch <= '9') {
	          			n += ch;
	        		} // end: while
	      		} // end: if
	      		if (ch == 'e' || ch == 'E') {
	        		n += 'e';
	        		next();
	        		if (ch == '-' || ch == '+') {
	          			n += ch;
	          			next();
	        		} // end: if
	        		while (ch >= '0' && ch <= '9') {
	          			n += ch;
	          			next();
	        		} // end: while
	      		} // end: if
	      		v = +n;
	      		if (!isFinite(v)) {
	        		error("Bad number");
	      		} else {
	        		return v;
	      		} // end: if
	    	} // end: function

	    	function word() {

			  	switch (ch) {
	        		case 't':
	          			if (next() == 'r' && next() == 'u' && next() == 'e') {
	            			next();
	            			return true;
	          			} // end: if
	          			break;
	        		case 'f':
	          			if (next() == 'a' && next() == 'l' && next() == 's' &&
	              			next() == 'e') {
	            			next();
	            			return false;
	          			} // end: if
	          			break;
	        		case 'n':
	          			if (next() == 'u' && next() == 'l' && next() == 'l') {
	            			next();
	            			return null;
	          			} // end: if
	          			break;
	      		} // end: switch
	      		error("Syntax error");
	    	} // end: function

	    	function val() {

		  		white();
	      		switch (ch) {
	        		case '{':
	          			return obj();
	        		case '[':
	          			return arr();
	        		case '<':
	          			return assoc();
	        		case '"':
	          			return str();
	        		case '-':
	          			return num();
	        		default:
	          			return ch >= '0' && ch <= '9' ? num() : word();
	      		} // end: switch
	    	} // end: function

	    	return val();
	  	}
	};




  // focusses the next lottery input field  
function lottery_nextField(e, source, nextNumber) {
 	if (!e) var e = window.event;
 	// no controlchars
 			//console.log(e);
 	if (e.keyCode > 32)
 	{	
 		if(document.getElementById('lottery_solution_' + nextNumber)){
 			// fixes firefox bug 
 			document.getElementById('lottery_solution_' + nextNumber).setAttribute('autocomplete','off');
 			//focus the next field
 			document.getElementById('lottery_solution_' + nextNumber).focus();
 		}
 	}
} //function

// focusses the previous lottery input field 
function lottery_previousField(e, source, nextNumber){
	if (!e) var e = window.event;
	// fixes firefox bug 
 	document.getElementById('lottery_solution_' + (nextNumber-1)).setAttribute('autocomplete','off');
	// if the user presses backspace
	if(e.keyCode == 8 && source.value== ''){
	 		if((nextNumber-2) >= 0){
		 		//focus the last field
		 		document.getElementById('lottery_solution_' + (nextNumber-2)).focus();
		 		document.getElementById('lottery_solution_' + (nextNumber-2)).value="";
			}
	 	}
}
//cheks if the user tries to input a space character and blocks it
function lottery_checkSpace(e){
	if (!e) var e = window.event;
	if (e.charCode == 32){
		return false;
	}
	return true;
}

// General purpose event constructor.
function CustomEvent() {
	// list of registered event handlers
	this._handlers = [];
} // end: function Event

/**
 * Register a callback function for the event (function name is also allowed).
 * Optionally an object can be passed which will be the object the function
 * is applied on.
 * If the callback function returns `false` (means 'interrupt') then the
 * remaining callback functions will not be called.
 *
 * @param   function|string  function   The event handling callback function.
 * @param   obj              object     The object the callback function shall
 *                                      be applied on.
 * @return  void
 */
CustomEvent.prototype.addHandler = function(func, obj) {
	if (typeof func == 'string') {
		func = window[func];
	} // end: if

	if (obj == undefined) {
		obj = null;
	} // end: if

	if (typeof func == 'function') {
		this._handlers.push([func, obj]);
	} // end: if
};

/**
 * Trigger the event. Pass any arguments you like. Will passed to the
 * event handlers.
 *
 * @param   *                *          Variable list of arguments.
 *                                      be applied on.
 * @return  null|false                  Returns `false` if any event handler
 *                                      has interrupted the process, otherwise `null`.
 */
CustomEvent.prototype.trigger = function(_someArgs_) {
	var retVal = null;

	for (var i = 0; i < this._handlers.length;  ++i) {
	  var handler = this._handlers[i];
	  var func = handler[0];
	  var obj = handler[1];

	  if (func.apply(obj, arguments) === false) {
	    retVal = false;
	    break;
	  } // end: if
	} // end: if

	return retVal;
};


	var dmc_mb3_product_pi1mediaActive	= '';
	var dmc_mb3_product_pi1mediaIndex	= 0;
	// definiert die angezeigten Links  f?r die Bildervorschau,
	// +1 dazurechnen wegen handling in forscheife
	var imgMax = 3;
	var addToBasketPopup;

	var popupFocus;

	var selectedArticle = null;

	// Custom event that will be triggered if article has been changed on
	// product content element.
	window.onArticleChanged = new CustomEvent();

	function productToggle(uid, id, imageNum, state) {
		dmc_mb3_product_pi1mediaIndex = imageNum;

		/* gather necessary objects */
		var mainImage	= document.getElementById('dmc_mb3_product_pi1' + uid + 'MainImage');
		var toggleImage	= document.getElementById('dmc_mb3_product_pi1' + uid + 'Product' + id + 'Opener');
		var productBody	= document.getElementById('dmc_mb3_product_pi1' + uid + 'Product' + id + 'Body');

		/* if state is 1 or 0, transform it to the other
			(user supplies target state, switch statement checks for current state */
		if (state == 1 || state == 0) {
			state = (state + 1) % 2;

		} else if (productConf[uid][id]) {
			state = productConf[uid][id]['state'];
		} /* end: if */


		if (mainImage) {
			switch (state) {
				case 0:

					if (productConf[uid][id]['large'][imageNum]) {
						mainImage.src					= productConf[uid][id]['large'][imageNum];

						/* handle grey activity indicator below thumbnails */
						var oldActive	= false;
						var newActive	= document.getElementById('dmc_mb3_product_pi1' + uid + id + imageNum + 'mediaActive');

						if (dmc_mb3_product_pi1mediaActive != '') {
							oldActive	= document.getElementById(dmc_mb3_product_pi1mediaActive);
						} /* end: if */

						if (oldActive) {
							gfxToggle(oldActive, 'clear.gif', 'but_detail_thumb_on.gif');
						} /* end: if */

						if (newActive) {
							gfxToggle(newActive, 'clear.gif', 'but_detail_thumb_on.gif');
							dmc_mb3_product_pi1mediaActive = 'dmc_mb3_product_pi1' + uid + id + imageNum + 'mediaActive';
						} /* end: if */

					} else if (productConf[uid][id]['large']['default']) {
						mainImage.src	= productConf[uid][id]['large']['default'];
					} /* end: if */

					if (toggleImage) {
						toggleImage.src					= dmc_mb3_product_pi1ToggleImageOff;
					} /* end: if */

					if (productBody) {
						productBody.className			= 'productBodyVisible';
					} /* end: if */

					if (typeof productConf[uid][id]['state'] != undefined) {
						productConf[uid][id]['state']	= 1;
					} /* end: if */
					break;

				case 1:
					if (toggleImage) {
						toggleImage.src				 		= dmc_mb3_product_pi1ToggleImageOn;
					} /* end: if */

					if (productBody) {
						productBody.className				= 'productBodyInvisible';
					} /* end: if */

					if (typeof productConf[uid][id]['state'] != undefined) {
						productConf[uid][id]['state']	= 0;
					} /* end: if */
					break;

				default:
			} /* end: switch */
		} /* end: if */
	}

	function initProduct(uid, id) {

		if(typeof productConf[uid][id] == 'undefined') return;

		/* gather necessary objects */
		var variation		= '';
		var size			= '';
		var color			= '';
		var productBody		= document.getElementById('dmc_mb3_product_pi1' + uid + 'Product' + id + 'Body');
		var toggleImage		= document.getElementById('dmc_mb3_product_pi1' + uid + 'Product' + id + 'Opener');
		var state			= productConf[uid][id]['state'];
		var masterArticleNumber = 0;

		/* check whether a single article is Masterarticle */
		for (var tmpVariation in productConf[uid][id]['articles']) {

			for (var tmpSize in productConf[uid][id]['articles'][tmpVariation]) {

				for (var tmpColor in productConf[uid][id]['articles'][tmpVariation][tmpSize]) {

					if (productConf[uid][id]['articles'][tmpVariation][tmpSize][tmpColor]['selected'] == '1'
					) {
						variation	= tmpVariation;
						size		= tmpSize;
						color		= tmpColor;
					} /* end: if */
				} /* end: for */
			} /* end: for */
		} /* end: for */

		/* check whether a single article is preselected */
		for (var tmpVariation in productConf[uid][id]['articles']) {

			for (var tmpSize in productConf[uid][id]['articles'][tmpVariation]) {

				for (var tmpColor in productConf[uid][id]['articles'][tmpVariation][tmpSize]) {

					if ( productConf[uid][id]['articles'][tmpVariation][tmpSize][tmpColor]['articlePk'] == selectedArticle
					) {
						variation	= tmpVariation;
						size		= tmpSize;
						color		= tmpColor;
					} /* end: if */
				} /* end: for */
			} /* end: for */
		} /* end: for */


		fillVariationForm(uid, id, variation, color, size);
		variation	= currentVariation(uid, id);
		size		= currentSize(uid, id, variation);
		color		= currentColor(uid, id, variation, size);
		displayArtNumber(uid, id, variation, size, color);
		displayPrice(uid, id, variation, size, color);
		displayAvailability(uid, id, variation, size, color);
		displayYardWareNotice(uid, id, variation, size, color);
		displayAdditionalFeeNotice(uid, id, variation, size, color);
		displayCrossselling(uid, id, variation, size, color);
		displayDeliveryServiceIcon(uid, id, variation, size, color);

		checkSubmitButton(uid, id, variation, size, color);

		imageToggleInit(uid, id, variation, size, color);
		displayBulkyDeliveryNote(uid, id, variation, size, color);
	}

	function changeProduct(uid, id, startFrom) {
		/* gather necessary objects */
		var variationForm	= document.getElementById('productVariationForm_' 	+ uid + '_' + id);
		var sizeForm		= document.getElementById('productSizeForm_' 		+ uid + '_' + id);
		var colorForm		= document.getElementById('productColorForm_' 		+ uid + '_' + id);
		var variation		= currentVariation(uid, id);
		var size			= currentSize(uid, id, variation);
		var color			= currentColor(uid, id, variation, size);

		// if isze is not available for a certain color, we have to reset the product
		if( typeof productConf[uid][id]['articles'][variation][size][color] == 'undefined' ){
			initProduct(uid,id);
			return;
		}

		var artNumber 		= productConf[uid][id]['articles'][variation][size][color]['artNumber'];


		switch (startFrom) {
			case 'variation':
				fillSizeForm(uid, id, variation);
				break;

			case 'size':
				fillColorForm(uid, id, variation, size);
				break;

			case 'color':
				setGravure(uid, id, variation, size, color);
				break;

			default:
		} /* end: switch */

		variation		= currentVariation(uid, id);
		size			= currentSize(uid, id, variation);
		color			= currentColor(uid, id, variation, size);

		selectedArticle = productConf[uid][id]['articles'][variation][size][color]['articlePk'];

		displayArtNumber(uid, id, variation, size, color);
		displayPrice(uid, id, variation, size, color);
		displayAvailability(uid, id, variation, size, color);
		displayYardWareNotice(uid, id, variation, size, color);
		displayAdditionalFeeNotice(uid, id, variation, size, color);
		displayCrossselling(uid, id, variation, size, color);
		displayDeliveryServiceIcon(uid, id, variation, size, color);
		checkSubmitButton(uid, id, variation, size, color);
		imageToggleInit(uid, id, variation, size, color);
		displayBulkyDeliveryNote(uid, id, variation, size, color);
		onArticleChanged.trigger(uid, id, artNumber, variation, color, size);
	}


	/*	(1)This function is called by clicking on the add to basket button
		if the product is from the manufacurer Stokke tge function "openStokke" is called*/
	function tryAddToBasket(isStokkeProduct, languageId, returnUrl, uid, id, target, popup, url, popupParams)
	{
	  add_uid = uid;
	  add_id = id;
	  add_target = target;
	  add_popup = popup;
	  add_url = url;
	  add_popupParams = popupParams;

	  if (isStokkeProduct)
	    return openStokke(languageId, returnUrl);
	  else
	   return addToBasketSubmit(add_uid, add_id, add_target, add_popup, add_url, add_popupParams);
	}

	/*	(2)This function opens the stokke questions, which must be answerd correctly to add the product in the basket
		When the answers are correct the page "stokke_recipient" is opened where the returnStokkeSuccess-Method is called */
	function openStokke(languageId, returnUrl)
	{

		window.open(languageId+'&RETURNSUCCESS='+ returnUrl +'' ,null,"height=625,width=670,status=no,toolbar=no,menubar=no,location=no,scrollbars=no");
		return false;
	}

	/*	(3)This function is called when the user has answered the stokke questions correctly.
		Called from the page "stokke_recipient", this method adds the product finally to the basket. */
	function returnStokkeSuccess()
	{

	   tryAddToBasket(0,0,0,add_uid, add_id, add_target, add_popup, add_url, add_popupParams);
	}

	function addToBasketSubmit(uid, id, target, popup, url, popupParams) {

		var variation		= currentVariation(uid, id);
		var size			= currentSize(uid, id, variation);
		var color			= currentColor(uid, id, variation, size);

		// check certain fields
		if(!checkFields(uid, id,variation, size, color)) {
		return (false);
		};

		// article is not available
		if (productConf[uid][id]['articles'][variation][size][color]['stockType'] == 3 ||
			productConf[uid][id]['articles'][variation][size][color]['stockType'] == 4
		){
			return (false);
		}

		if (popup) {
			var form			= document.getElementById('productForm_' + uid);
			form.action 		= url;

			// do NOT load page from 'url' variable here! race condition w/ 2 Apache threads!
			POPUP = window.open('/clear.gif', target, popupParams);
			POPUP.focus();
		}

		return addToBasket(uid, id);
	}


	function addToBasket(uid, id) {
		var form			= document.getElementById('productForm_' + uid);
		var amountForm		= document.getElementById('productAmountForm_' + uid + '_' + id);
		var pkForm			= document.getElementById('productBasketPk_' + uid);
		var productPkForm	= document.getElementById('productBasketProductPk_' + uid);
		var variation		= currentVariation(uid, id);
		var size			= currentSize(uid, id, variation);
		var color			= currentColor(uid, id, variation, size);
		var amount			= 0;

		if (amountForm) {
			if(amountForm.nodeName == 'SELECT') {
				amount = amountForm.options[amountForm.selectedIndex].value;
			} else if (amountForm.nodeName == 'INPUT'
				&& (amountForm.type == 'text'
					|| amountForm.type == 'hidden')) {
				amount = amountForm.value;
				if(amount <1){
					amount = 1;
				}
			}
		}

		if (form && pkForm && productPkForm && amount > 0) {
			pkForm.value		= productConf[uid][id]['articles'][variation][size][color]['articlePk'];
			productPkForm.value = id;
			form.submit();
		}

		return false;
	}

	/**
	* Functions to regain the focus after a click on the add to basket button in IE
	* startFocusTimer ist called by the onload event of the popup. It starts the function "regainFocusRecursive",
	* that sets the focus to the popup every 100 millisconds.
	* After seven seconds the recursive iteration is stopped.
	*/
	function startFocusTimer(){
		regainFocusRecursive();
		setTimeout('stopFocusTimer()', 5000);
	}

	function regainFocusRecursive(){
		self.focus();
		popupFocus = setTimeout('regainFocusRecursive()', 100);
	}

	function stopFocusTimer(){
		window.onblur = '';
		window.clearTimeout(popupFocus);
	}


	function changeItemInBasket(uid, id, doSubmit) {
		var returnValue		= false;
		var form			= document.getElementById('productForm_' + uid);
		var amountForm		= document.getElementById('productAmountForm_' + uid + '_' + id);
		var pkForm			= document.getElementById('productBasketPk_' + uid);
		var productPkForm	= document.getElementById('productBasketProductPk_' + uid);
		var adcodeForm		= document.getElementById('productBasketAdcode_' + uid);
		var artnumberForm	= document.getElementById('productBasketArtnumber_' + uid);
		var variation		= currentVariation(uid, id);
		var size			= currentSize(uid, id, variation);
		var color			= currentColor(uid, id, variation, size);
		var amount			= 0;

		// check certain fields
		if(checkFields(uid, id,variation, size, color)) {
			if (amountForm) {
				if(amountForm.nodeName == 'SELECT') {
					amount = amountForm.options[amountForm.selectedIndex].value;
				} else if (amountForm.nodeName == 'INPUT'
					&& (amountForm.type == 'text'
						|| amountForm.type == 'hidden')) {
					amount = amountForm.value;
				}
			}

			if (form && pkForm && productPkForm && amount > 0) {
				returnValue = true;
				pkForm.value		= productConf[uid][id]['articles'][variation][size][color]['articlePk'];

				// use the override adcode only if the articlenumber hasn't changed
				// if it has changed, reset the adcode
				if (artnumberForm.value != productConf[uid][id]['articles'][variation][size][color]['artNumber']) {
					adcodeForm.value = '';
				}

				productPkForm.value = id;

				if (doSubmit) {
					form.submit();
				} // end: if

				window.close();
			}
		}

		return returnValue;
	}

	function displayArtNumber(uid, id, variation, size, color) {
		var artNumberDiv			= document.getElementById('productArtNumber_' 			+ uid + '_' + id);
		var articleOrderNumberDiv	= document.getElementById('productArticleOrderNumber_' + uid + '_' + id);

		if (artNumberDiv) {
			artNumberDiv.innerHTML	= productConf[uid][id]['articles'][variation][size][color]['artNumber'];
		} // end: if

		if (articleOrderNumberDiv) {
			if (window.config.brandId == 7) {
				// special display pattern for order number in brand 7
				articleOrderNumberDiv.innerHTML =
						'EY0'
						+ productConf[uid][id]['articles'][variation][size][color]['artNumber']
						+ productConf[uid][id]['articles'][variation][size][color]['adCode']
						+ '10';
			} else {
				articleOrderNumberDiv.innerHTML = productConf[uid][id]['articles'][variation][size][color]['articleOrderNumber'];
			} // end: if
		} // end: function displayArtNumber


		changeCopytext(uid, id, variation, size, color);
	} // end: function displayArtNumber

	function changeCopytext(uid, id, variation, size, color) {
		// set Copytext according to selected article
		var productCopytext	= document.getElementById('productCopytext' + uid + '_' + id);

		if (productCopytext) {

			var articleOrderNumber = productConf[uid][id]['articles'][variation][size][color]['articleOrderNumber'].replace(/\./g,'');
			var copyText = productConf[uid][id]['crossCopyText'][articleOrderNumber];
			var retText =  productConf[uid][id]['copyText'];

			if(copyText){
				retText = copyText;
			}
			productCopytext.innerHTML = retText;
		}
	}

function displayPrice(uid, id, variation, size, color) {
		var priceDiv		= document.getElementById('productPrice_' 		+ uid + '_' + id);
		var oldPriceDiv		= document.getElementById('productOldPrice_'	+ uid + '_' + id);
		var currency		= ' &euro;';

		if(this['config']['clientPk'].substring(2, 3)=='3') {
			currency = ' CHF';
		}

		if (priceDiv) {
			priceDiv.innerHTML	= productConf[uid][id]['articles'][variation][size][color]['price'];
		} /* end: if */

		var oldPriceWrap				= document.getElementById('productOldPrice_'	+ uid + '_' + id + '_wrap');
		var currentPriceWrap			= document.getElementById('productCurrentPrice_'	+ uid + '_' + id + '_wrap');
		var recommendedRetailPriceWrap	= document.getElementById('productRecommendedRetailPrice_'	+ uid + '_' + id + '_wrap');

		var currentPrice			= parseFloat(productConf[uid][id]['articles'][variation][size][color]['pricePlain']);
		var recommendedRetailPrice	= parseFloat(productConf[uid][id]['articles'][variation][size][color]['recommendedRetailPricePlain']);
		var oldPrice				= parseFloat(productConf[uid][id]['articles'][variation][size][color]['oldPricePlain']);

		var currentPriceFormated	= productConf[uid][id]['articles'][variation][size][color]['price'];

		var displayRecommendedRetailPriceWrap 	= 'none';
		var displayOldPriceWrap					= 'none';
		var displayCurrentPriceWrap				= 'block';

        var diffPercentThreshold                = (config.brandId == 7 ? 5 : 10);

		if  (recommendedRetailPrice > 0 && recommendedRetailPrice > currentPrice ){

			if (recommendedRetailPriceWrap) {
				var recommendedRetailPriceFormatted 	= productConf[uid][id]['articles'][variation][size][color]['recommendedRetailPrice'];
				var recommendedRetailPriceSpan 			= document.getElementById('productRecommendedRetailPrice_span');
				var currentPriceSpan3					= document.getElementById('productCurrentPrice3_span');
				var savingsSpan3						= document.getElementById('productSavings3_span');

				if (currentPriceSpan3) {
					currentPriceSpan3.innerHTML 		= currentPriceFormated;
				}
				recommendedRetailPriceSpan.innerHTML 	= recommendedRetailPriceFormatted;

				if (config.brandId != 7) {
					var diffPercent = 100 - Math.round((currentPrice*100)/recommendedRetailPrice);

					if(diffPercent >= 10){

						var diffTotal = calculateSavingTotal(recommendedRetailPrice, currentPrice, recommendedRetailPriceFormatted);
						var savings = diffTotal;
						if (recommendedRetailPrice<100){
							savings 	= diffPercent + '%';
						}
						savingsSpan3.innerHTML 	= savings;
						displayRecommendedRetailPriceWrap	= 'block';
						displayCurrentPriceWrap				= 'none';

					} else {
						savingsSpan3.innerHTML 				= '';
					}

				} else {
					// find out price difference of current price to old price,
					// format it in the same way like oldPriceFormatted
					// and show it on web page.
					var delta = calculateSavingTotal(recommendedRetailPrice, currentPrice, recommendedRetailPriceFormatted)

					displayRecommendedRetailPriceWrap		= 'block';
					savingsSpan3.innerHTML 	= delta;
				} // end: if
			}

		} else if (oldPrice > 0 && oldPrice > currentPrice) {

			if (oldPriceWrap) {
				var oldPriceFormatted 					= productConf[uid][id]['articles'][variation][size][color]['oldPrice'];
				var currentPriceSpan2					= document.getElementById('productCurrentPrice2_span');
				var oldPriceSpan						= document.getElementById('productOldPrice_span');
				var savingsSpan							= document.getElementById('productSavings_span');
				if (currentPriceSpan2) {
					currentPriceSpan2.innerHTML			= currentPriceFormated;
				}
				oldPriceSpan.innerHTML					= oldPriceFormatted;

				if (config.brandId != 7) {
					var diffPercent = 100 - Math.round((currentPrice*100)/oldPrice);

					if(diffPercent >= 10){
						var diffTotal = calculateSavingTotal(oldPrice, currentPrice, oldPriceFormatted);
						var savings = diffTotal;
						if (oldPrice<100){
							savings	= diffPercent + '%';
						}
						savingsSpan.innerHTML 	= savings;
						displayOldPriceWrap		= 'block';
						displayCurrentPriceWrap	= 'none';
					} else {
						savingsSpan.innerHTML	= '';
					} // end: if
				} else {
					// find out price difference of current price to old price,
					// format it in the same way like oldPriceFormatted
					// and show it on web page.
					var delta = calculateSavingTotal(oldPrice, currentPrice, oldPriceFormatted)

					displayOldPriceWrap		= 'block';
					savingsSpan.innerHTML 	= delta;
				} // end: if
			} // end: if
		} // end: if

		if (recommendedRetailPriceWrap) {
			recommendedRetailPriceWrap.style.display = displayRecommendedRetailPriceWrap;
		}
		if (oldPriceWrap) {
			oldPriceWrap.style.display = displayOldPriceWrap;
		}
		if (currentPriceWrap) {
			currentPriceWrap.style.display 	= displayCurrentPriceWrap;
		} // end: if

		var currentPriceSpan1			= document.getElementById('productCurrentPrice1_span');
		if (currentPriceSpan1) {
			currentPriceSpan1.innerHTML	= currentPriceFormated;
		}

		// Show article's base unit price if available.
		var baseUnitPriceContainer = document.getElementById('baseUnitPriceInfo_' + uid);

		if (baseUnitPriceContainer) {
			var baseUnitPriceInfo = productConf[uid][id]['articles'][variation][size][color]['baseUnitPriceInfo'];

			if (typeof baseUnitPriceInfo == 'string') {
				baseUnitPriceContainer.innerHTML = baseUnitPriceInfo;
			} // end: if
		} // end: if


		var infoBlockPrice1		= document.getElementById('infoBlockPrice1');
		var articleBlockPrice1	= document.getElementById('articleBlockPrice1');
		var articleBlockAmount1	= document.getElementById('articleBlockAmount1');
		var infoBlockPrice2		= document.getElementById('infoBlockPrice2');
		var articleBlockPrice2	= document.getElementById('articleBlockPrice2');
		var articleBlockAmount2	= document.getElementById('articleBlockAmount2');
		var infoPriceGroup		= document.getElementById('infoPriceGroup');

		if (infoBlockPrice1 && articleBlockPrice1 && articleBlockAmount1) {

			if (productConf[uid][id]['articles'][variation][size][color]['blockAmount1'] > 0) {
				infoBlockPrice1.style.display = '';
				articleBlockPrice1.innerHTML = productConf[uid][id]['articles'][variation][size][color]['blockPrice1']
				articleBlockAmount1.innerHTML = blockPriceAmountText.replace('###BLOCKAMOUNT###', productConf[uid][id]['articles'][variation][size][color]['blockAmount1']);

			} else {
				infoBlockPrice1.style.display = 'none';
			}
		}

		if (infoBlockPrice2 && articleBlockPrice2 && articleBlockAmount2) {

			if (productConf[uid][id]['articles'][variation][size][color]['blockAmount2'] > 0) {
				infoBlockPrice2.style.display = '';
				articleBlockPrice2.innerHTML = productConf[uid][id]['articles'][variation][size][color]['blockPrice2']
				articleBlockAmount2.innerHTML = blockPriceAmountText.replace('###BLOCKAMOUNT###', productConf[uid][id]['articles'][variation][size][color]['blockAmount2']);
			} else {
				infoBlockPrice2.style.display = 'none';
			}
		}

		if (infoPriceGroup) {
			if (productConf[uid][id]['articles'][variation][size][color]['pricegroupId'] != '000'
				&& productConf[uid][id]['articles'][variation][size][color]['blockAmount1'] > 0) {
				infoPriceGroup.style.display = '';
			} else {
				infoPriceGroup.style.display = 'none';
			}
		}

	} // end: function displayPrice

	function calculateSavingTotal(oldPrice, currentPrice, oldPriceFormatted){
		// find out price difference of current price to old price,
		// format it in the same way like oldPriceFormatted
		// and show it on web page.
		var delta = oldPrice - currentPrice;
		var matches = oldPriceFormatted.match(/([^0-9.,]*)([0-9.,]*(,|\.)[0-9]*)([^0-9.,]*)/);

		if (matches) {
			var currencyPrefix = matches[1];
			var decimalChar = matches[3];
			var currencySuffix = matches[4];
			delta = Math.round(delta * 100);
			var decimals = (delta % 100);


			if (decimals < 10) {
				decimals = '0' + decimals;
			} // end: if

			delta = currencyPrefix + Math.floor(delta / 100) + decimalChar + decimals + currencySuffix;
		} // end: if
		return delta;
	}


	function displayAvailability(uid, id, variation, size, color) {
		var availDiv	= document.getElementById('productAvail_' 		+ uid + '_' + id);
		if (availDiv) {

			availDiv.innerHTML	= productConf[uid][id]['articles'][variation][size][color]['stockTypeText'];
			availDiv.className	= productConf[uid][id]['articles'][variation][size][color]['stockTypeClass'];

			var stockType = productConf[uid][id]['articles'][variation][size][color]['stockType'];
			var weeksToDel = productConf[uid][id]['articles'][variation][size][color]['weeksToDelivery'];
			if (stockType==2 && weeksToDel>0){
				var infoText = weeksToDeliveryInfo.replace('{ORDERLINE_weeksToDelivery}', weeksToDel);
				availDiv.innerHTML = infoText;
			}
		} /* end: if */

	}

	function setVariation(uid, id, variation) {
		var variationForm	= document.getElementById('productVariationForm_' 	+ uid + '_' + id);
		var index			= 0;

		if (variationForm) {
			if(variationForm.nodeName == 'SELECT') {
				for (var tmpVariation in productConf[uid][id]['articles']) {

					if (tmpVariation == variation) {
						variationForm.selectedIndex = index;
					} /* end: if */

					index++;
				} /* end: for */
			} else if (variationForm.nodeName == 'INPUT'
				&& (variationForm.type == 'text'
					|| variationForm.type == 'hidden')
				) {

				variationForm.value = variation;
			}/* end: if*/
		} /* end: if */
	}

	function firstVariation(uid, id) {
		/* find first variation */
		for (var returnValue in productConf[uid][id]['articles']) {
			break;
		} /* end: for */

		return returnValue;
	}

	function currentVariation(uid, id) {
		var returnValue		= '';
		var variationForm	= document.getElementById('productVariationForm_' 	+ uid + '_' + id);

		if (variationForm) {
			if(variationForm.nodeName == 'SELECT' && variationForm.selectedIndex != -1) {
				returnValue = variationForm.options[variationForm.selectedIndex].value;
			} else if (variationForm.nodeName == 'INPUT'
				&& (variationForm.type == 'text'
					|| variationForm.type == 'hidden')
				) {

				returnValue = variationForm.value;
			}/* end: if*/
		} else {
			returnValue = firstVariation(uid, id);
		} /* end: if */

		return returnValue;
	}

	function fillVariationForm(uid, id, variation, color, size) {
		var variationForm	= document.getElementById('productVariationForm_' 	+ uid + '_' + id);
		var tmpVariation	= false;
		var index			= 0;

		if (variationForm) {
			if(variationForm.nodeName == 'SELECT') {
				/* clear all options */
				for (var j = variationForm.length; j >= 0; j--) {
					variationForm.options[j] = null;
				} /* end: for */

			/* fill with new variations */
			for (tmpVariation in productConf[uid][id]['articles']) {

				if (tmpVariation == variation) {
					variationForm.options[variationForm.length]	= new Option(tmpVariation, tmpVariation, false, true);
					variationForm.selectedIndex					= index;

				} else {
					variationForm.options[variationForm.length]	= new Option(tmpVariation, tmpVariation, false, false);
				} /* end: if */

					index++;
				} /* end: for */

				/* set selected */
				if (variationForm.selectedIndex == -1) {
					variationForm.selectedIndex = 0;
				} /* end: if */
			} else if (variationForm.nodeName == 'INPUT'
				&& (variationForm.type == 'text'
					|| variationForm.type == 'hidden')
				) {

				variationForm.value = variation;
			}/* end: if*/
		} /* end: if */

		/* fill size form */
		fillSizeForm(uid, id, currentVariation(uid, id), size, color);
	}

	function setSize(uid, id, variation, size) {
		var sizeForm	= document.getElementById('productSizeForm_' 	+ uid + '_' + id);
		var index		= 0;

		if (sizeForm) {
			if(sizeForm.nodeName == 'SELECT') {
				for (var tmpSize in productConf[uid][id]['articles'][variation]) {

					if (tmpSize == size) {
						sizeForm.selectedIndex = index;
					} /* end: if */

					index++;
				} /* end: for */
			} else if (sizeForm.nodeName == 'INPUT'
				&& (sizeForm.type == 'text'
					|| sizeForm.type == 'hidden')
				) {

				sizeForm.value = size;
			}/* end: if*/
		} /* end: if */
	}

	function firstSize(uid, id, variation) {
		/* find first size */
		for (var returnValue in productConf[uid][id]['articles'][variation]) {
			break;
		} /* end: for */

		return returnValue;
	}

	function currentSize(uid, id, variation) {
		var returnValue		= '';
		var sizeForm		= document.getElementById('productSizeForm_' 	+ uid + '_' + id);

		if (sizeForm) {
			if (sizeForm.nodeName == 'SELECT' && sizeForm.selectedIndex != -1) {
				returnValue = sizeForm.options[sizeForm.selectedIndex].value;
			} else if (sizeForm.nodeName == 'INPUT'
				&& (sizeForm.type == 'text'
					|| sizeForm.type == 'hidden')
				) {

				returnValue = sizeForm.value;
			}/* end: if*/
		} else {
			returnValue = firstSize(uid, id, variation);
		} /* end: if */

		return returnValue;
	}

	function fillSizeForm(uid, id, variation, size, color) {
		var sizeForm	= document.getElementById('productSizeForm_' 	+ uid + '_' + id);
		var tmpSize		= false;
		var sizeOld		= false;
		var sizeOldName	= false;
		var index		= 0;

		if (sizeForm) {
			if(sizeForm.nodeName == 'SELECT') {
				/* remember old state */
				sizeOld = sizeForm.selectedIndex;

			if (sizeOld != -1) {
				sizeOldName = sizeForm.options[sizeOld].value;
			} /* end: if */

			/* clear all options */
			for (var j = sizeForm.length; j >= 0; j--) {
				sizeForm.options[j] = null;
			} /* end: for */

			/* fill with new sizes */
			for (tmpSize in productConf[uid][id]['articles'][variation]) {

				if (tmpSize == size
					|| tmpSize == sizeOldName) {

					sizeForm.options[sizeForm.length]	= new Option(tmpSize, tmpSize, false, true);
					sizeForm.selectedIndex				= index;

				} else {
					sizeForm.options[sizeForm.length]	= new Option(tmpSize, tmpSize, false, false);
				} /* end: if */

					index++;
				} /* end: for */
			} else if (sizeForm.nodeName == 'INPUT'
				&& (sizeForm.type == 'text'
					|| sizeForm.type == 'hidden')
				) {

				sizeForm.value = size;
			}/* end: if*/
		} /* end: if */

		/* fill color form */
		fillColorForm(uid, id, variation, currentSize(uid, id, variation), color);
	}

	function setColor(uid, id, variation, size, color) {
		var colorForm	= document.getElementById('productColorForm_' 	+ uid + '_' + id);
		var index		= 0;

		if (colorForm) {
			if(colorForm.nodeName == 'SELECT') {
				for (var tmpColor in productConf[uid][id]['articles'][variation][size]) {

					if (tmpColor == color) {
						colorForm.selectedIndex = index;
					} /* end: if */

					index++;
				} /* end: for */
			} else if (colorForm.nodeName == 'INPUT'
				&& (colorForm.type == 'text'
					|| colorForm.type == 'hidden')
				) {

				colorForm.value = color;
			}/* end: if*/
		} /* end: if */
	}

	function firstColor(uid, id, variation, size) {
		/* find first color */
		for (var returnValue in productConf[uid][id]['articles'][variation][size]) {
			break;
		} /* end: for */

		return returnValue;
	}

	function currentColor(uid, id, variation, size) {
		var returnValue		= '';
		var colorForm		= document.getElementById('productColorForm_' 	+ uid + '_' + id);

		if (colorForm) {
			if (colorForm.nodeName == 'SELECT' && colorForm.selectedIndex != -1) {
				returnValue = colorForm.options[colorForm.selectedIndex].value;
			} else if (colorForm.nodeName == 'INPUT'
				&& (colorForm.type == 'text'
					|| colorForm.type == 'hidden')
				) {
				returnValue = firstColor(uid, id, variation, size);//colorForm.value;
				if (selectedArticle){
					returnValue = colorForm.value;
				}
			}/* end: if*/
		} else {
			returnValue = firstColor(uid, id, variation, size);
		} /* end: if */

		return returnValue;
	}

	function fillColorForm(uid, id, variation, size, color) {
		var colorForm		= document.getElementById('productColorForm_' 	+ uid + '_' + id);
		var tmpColor		= false;
		var colorOld		= false;
		var colorOldName	= false;
		var index			= 0;

		if (colorForm) {
			if(colorForm.nodeName == 'SELECT') {
				/* remember old state */
				colorOld = colorForm.selectedIndex;

				if (colorOld != -1) {
					colorOldName = colorForm.options[colorOld].value;
				} /* end: if */

				/* clear all options */
				for (var j = colorForm.length; j >= 0; j--) {
					colorForm.options[j] = null;
				} /* end: for */

				/* fill with new colors */
				for (tmpColor in productConf[uid][id]['articles'][variation][size]) {

					if (tmpColor == color
						|| (colorOldName != false && tmpColor == colorOldName)) {

						colorForm.options[colorForm.length]	= new Option(tmpColor, tmpColor, false, true);
						colorForm.selectedIndex = index;

					} else {
						colorForm.options[colorForm.length]	= new Option(tmpColor, tmpColor, false, false);
					} /* end: if */

					index++;
				} /* end: for */
			} else if (colorForm.nodeName == 'INPUT'
				&& (colorForm.type == 'text'
					|| colorForm.type == 'hidden')
				) {

				colorForm.value = color;
			}/* end: if*/
		} /* end: if */

		/* set gravure */
		setGravure(uid, id, variation, size, currentColor(uid, id, variation, size));
	}

	function setGravure(uid, id, variation, size, color) {

		var gravureFieldCount	= parseInt(productConf[uid][id]['articles'][variation][size][color]['gravureText']);
		var gravureFieldLength	= parseInt(productConf[uid][id]['articles'][variation][size][color]['gravureLength']);
		var gravureInput		= document.getElementById('productGravureInput_' + uid + '_' + id);
		var gravureMessageBefore = document.getElementById('productGravureMessageBefore_' + uid + '_' + id);
		var gravureMessageAfter = document.getElementById('productGravureMessageAfter_' + uid + '_' + id);
		var gravureForm			= document.getElementById('productGravureForm_' + uid + '_' + id);

		// if there is no input field do nothing
		if(!gravureInput){
			return;
		}


		// reset gravure info text
		if(gravureMessageBefore && gravureMessageAfter){
			gravureMessageBefore.innerHTML = '';
			gravureMessageAfter.innerHTML = '';
		}

		// do we have a gravure, handle/display info text
		if (gravureFieldCount>0 && gravureFieldLength>0){

			var textParts = infoGravureBefore.split('||');
			var newText = textParts[0] + gravureFieldLength + textParts[1];
			gravureMessageBefore.innerHTML = newText;
			gravureMessageAfter.innerHTML = infoGravureAfter;
		}

		// create Input Fields according to article values
		if (gravureFieldCount>0 && gravureFieldLength>0) {
				gravureInput.innerHTML = '';
				for (var i=0; i<gravureFieldCount; i++){
					var ipt = document.createElement('input');
          ipt.setAttribute('maxLength',gravureFieldLength);
					ipt.setAttribute('id', 'productGravureText_' + uid + '_' + id + '_'+i, true);
					ipt.value='';
					if (gravureForm.value){
					var metadata = gravureForm.value;
					var rows = metadata.split(textGravureSeparator);
						if(!rows[i]||rows[i]==undefined){
							ipt.value = '';
						}else{
							ipt.value = rows[i];
						}
					}

					ipt.name='productGravureText_' + uid + '_' + id + '['+i+']';
					ipt.className='gravure';
          ipt.style.margin='0px';
					gravureInput.appendChild(ipt);
				}
				gravureInput.style.visibility	= 'visible';
				gravureInput.style.display	= 'block';
		}else{
			if(gravureInput){
				gravureInput.style.visibility	= 'hidden';
				gravureInput.style.display	= 'none';
			}
		}
	}

	if (!productConf) {
		var productConf = new Array();
	}

	function checkFields(uid, id, variation, size, color){

		var boolReturn = true;

		var amountFieldId = 'productAmountForm_'+uid+'_'+id;
		var yardWareFieldId = null;

		var gravureFieldId = 'productGravureForm_'+uid+'_'+id;
		var gravureFieldTextId = 'productGravureText_'+uid+'_'+id;
		var gravureFieldCount = parseInt(productConf[uid][id]['articles'][variation][size][color]['gravureText']);
		var gravureFieldLength = parseInt(productConf[uid][id]['articles'][variation][size][color]['gravureLength']);
		var gravureObj = document.getElementById(gravureFieldId);


		var gravureText = '';
		gravureTextPlain = '';
		var gravureTextArr = new Array();
		// only check if article has gravure
		if (gravureObj && gravureFieldCount>0 && gravureFieldLength>0){

			for (var i=0; i<gravureFieldCount; i++){
				var iptValue = document.getElementById('productGravureText_' + uid + '_' + id + '_'+i).value;
				gravureTextArr[i] = trimString(iptValue);
			}

			gravureTextPlain = gravureTextArr.join('');
			gravureText = gravureTextArr.join(textGravureSeparator);
			// check valid characters

			strPattern = /[^\x20-\xFF]/;

			if (gravureTextPlain.search(strPattern) != -1 || gravureTextPlain.search(textGravureSeparator)!=-1)
			{
				alert(noticeGravureError);
				boolReturn = false;
			}else{
				document.getElementById(gravureFieldId).value = gravureText;
			}

			// Wenn Feld leer dann Abfrage
			if (gravureTextPlain == "")
			{
				if (confirm(noticeGravureNo))
				{

					document.getElementById(gravureFieldId).value = textGravureSeparator;
					// set separator if empty, otherwise we do not know if orderline has gravure

				}
				else
				{
					boolReturn = false;
				}
			}

		} // end: gravure

		// Anzahl
		var amountObj = document.getElementById(amountFieldId);
		var yardWare = productConf[uid][id]['articles'][variation][size][color]['stockUnit'];


		if (amountObj)
		{
			// Meterware ?
			if (yardWare && yardWare== "M")
			{
				var splitText= noticeYardWare.split('||');
				if (confirm (splitText[0] + (amountObj.value * 10) + splitText[1] + amountObj.value + splitText[2]) == false)
				{
					amountObj.value = 1;
					amountObj.focus();
					boolReturn = false;
				}
			}
			else if (amountObj.value >= 10)
			{
				var splitText= noticeAmount.split('||');
				if (confirm (splitText[0] + amountObj.value + splitText[1]) == false)
				{
					amountObj.value = 1;
					amountObj.focus();
					boolReturn = false;
				}
			}else{
				// do nothing
			}
		}

		return(boolReturn);
	}

	function displayYardWareNotice(uid, id, variation, size, color){
		var yardWare = productConf[uid][id]['articles'][variation][size][color]['stockUnit'];
		var noticeYardware = document.getElementById('productYardwareNotice');

		if(yardWare=='M'){
			noticeYardware.style.display = 'block';
		}
	}

	function displayAdditionalFeeNotice(uid, id, variation, size, color){
		var deliveryTypeCode = productConf[uid][id]['articles'][variation][size][color]['deliveryTypeCode'];
		var articleBulkyCosts = productConf[uid][id]['articles'][variation][size][color]['bulkycosts'];
		var noticeBulkyGood = document.getElementById('productBulkyFeeNotice');

		if(deliveryTypeCode==1){
			noticeBulkyGood.innerHTML = bulkyCostsInfo.replace('###bulkycosts###', articleBulkyCosts);
			noticeBulkyGood.style.display = 'block';
		}
	}

	function displayCrossselling(uid, id, variation, size, color){

		var targetContainer = document.getElementById('crosssellingTargetContainer');
		var crosssellingContainer = document.getElementById('crosssellings');
		var crossNotice = document.getElementById('productCrossSellingNotice');
		var articleOrderNumber = productConf[uid][id]['articles'][variation][size][color]['articleOrderNumber'].replace(/\./g,'');
		var masterarticleOrderNumber = productConf[uid][id]['masterarticleOrderNumber'].replace(/\./g,'');;
		var noCrossselling = productConf[uid][id]['crossNoCrossSelling'][articleOrderNumber];
		var sourceList = productConf[uid][id]['crossSellingList'][articleOrderNumber];
		var masterList = productConf[uid][id]['crossSellingList'][masterarticleOrderNumber];

		if(targetContainer){
			targetContainer.innerHTML='';
		}
		if(noCrossselling==1){
			if (crosssellingContainer) {
				crosssellingContainer.style.display = 'none';
			}
			if (crossNotice) {
				crossNotice.style.display = 'none';
			}
		}else{

			if (sourceList && sourceList.length>0) {
			//alert('if');
				renderProductlist(sourceList,targetContainer,crosssellingContainer,crossNotice);
			}else if(masterList && masterList.length>0) {
			//alert('else if');
				renderProductlist(masterList,targetContainer,crosssellingContainer,crossNotice);
			}else{
			//alert('else');
				if (crosssellingContainer){
					crosssellingContainer.style.display = 'none';
				}
				if (crossNotice) {
					crossNotice.style.display = 'none';
				}
			}
		}
	}

	function displayDeliveryServiceIcon(uid, id, variation, size, color){
		var deliveryServiceContainer = document.getElementById('deliveryServiceIcon');

		if(deliveryServiceContainer) {
			deliveryServiceContainer.style.display = 'none';

			if (productConf[uid][id]['articles'][variation][size][color]['status'] & 16) {
				deliveryServiceContainer.style.display = 'block';
			} else {
				deliveryServiceContainer.style.display = 'none';
			} // end: if
		} // end: if
	} // end: function displayDeliveryServiceIcon

	// Special behavior of the gui-elemets button (into basket), notepad and giftdesk link,
	// when an article is sold out
	function checkSubmitButton(uid, id, variation, size, color){
		// article is not available
		var stockType = productConf[uid][id]['articles'][variation][size][color]['stockType'];
		var butt = document.getElementById('textimage_add_to_basket_1');
		var buttSrc = '';

		var notepadLink 	= document.getElementById('notepadLink');
		var giftdeskLink 	= document.getElementById('giftdeskLink');

		//  Logic for button ('into basket')
		if (butt){
			if (stockType == 3 || stockType==0 || stockType==4){
				buttSrc = buttInactive;
				// set special alt and title Tag for button
				butt.alt = buttInactiveAltTag;
				butt.title = buttInactiveAltTag;
				butt.style.cursor = 'default';

				// if block exists and stocktype = 4 unhide
				if( $('#soldout2') && stockType==4 ){
					$('#soldout2').show();
				}
			} else {
				// if block exists hide it
				if( $('#soldout2') ){
					$('#soldout2').hide();
				}
				buttSrc = buttActive;
				// set special alt and title Tag for button
				butt.alt = buttActiveAltTag;
				butt.title = buttActiveAltTag;
				butt.style.cursor = 'pointer';
			}
			butt.src = buttSrc;
		}
		// Logic for link ('to notepad')
		if (notepadLink){
			if (stockType == 3 || stockType==0 || stockType==4){
				notepadLink.style.display = "none";
			}
			else{
				notepadLink.style.display = "";
			}
		}
		// Logic for link ('to giftdesk')
		if (giftdeskLink){
			if (stockType == 3 || stockType==0 || stockType==4){
				giftdeskLink.style.display = "none";
			}
			else{
				giftdeskLink.style.display = "";
			}
		}
	}

	function imageToggleInit(uid, id, variation, size, color){
		var alternateViews	= document.getElementById('dmc_mb3_product_pi1' + uid + 'AlternativeViews');
		var alternateViewsAsThumbnails	= document.getElementById('dmc_mb3_product_pi1' + uid + 'AlternativeViewsAsThumbnails');
		var mainImage	= document.getElementById('dmc_mb3_product_pi1' + uid + 'MainImage');
		var linkList = document.getElementById('dmc_mb3_product_pi1' + uid + 'ImageLinks');
		if(linkList) linkList.innerHTML = '';
		var artNum = productConf[uid][id]['articles'][variation][size][color]['artNumber'];
		var adCode = productConf[uid][id]['articles'][variation][size][color]['adCode'];
		var orderNum = artNum+adCode;

		var imageList = new Array();
		if(productConf[uid]['main']['large'][orderNum]){
			imageList = productConf[uid]['main']['large'][orderNum];
			var actItem   = productConf[uid]['main']['large'][orderNum][0]['url'];
			if(actItem==''){
				actItem = productConf[uid]['main']['large']['default'];
			}

			mainImage.src = actItem;
			dmc_mb3_product_pi1mediaIndex = productConf[uid]['main']['large'][orderNum][0]['zoomindex'];
		}else{
			mainImage.src = productConf[uid]['main']['large']['default'];
		}

		for (var k = 0; k < 2; k++) {
			var containerDiv = [alternateViews, alternateViewsAsThumbnails][k];

			if( containerDiv && imageList.length > 1 && linkList){
				if (k == 0) {
					// Set initial ... as first element
					if(imageList.length > imgMax+1 ){
						var moreStart = document.createElement('li');
						moreStart.appendChild(document.createTextNode('...'));
						//moreStart.setAttribute('id','li_moreStart');
                        //moreStart.setAttribute('style','display:none');
                        moreStart.id = 'li_moreStart';
                        moreStart.style.display = 'none';

						linkList.appendChild(moreStart);
					}//end: if
				} // end: if

				//Set numbers

				for (i=0; i<imageList.length; i++){
					var aTag  = document.createElement('a');

					if(i==0){
						aTag.className='aktiv';
					}//end: if
					var imgId = uid+'_'+id+'_'+orderNum+'_'+i;
					aTag.setAttribute('href','javascript:imageToggle(\''+uid+'\',\''+id+'\',\''+orderNum+'\','+i+')');
					aTag.setAttribute('id',imgId);
					aTag.setAttribute('onclick','javascript:imageToggle(\''+uid+'\',\''+id+'\',\''+orderNum+'\','+i+')');


					if (k == 0) {
						var liTag = document.createElement('li');
						var textNode = document.createTextNode(i+1);
						aTag.appendChild(textNode);
						liTag.appendChild(aTag);
						liTag.setAttribute('id','li_'+imgId);
						//don't show more than imgMax+1 images
						if(i>=imgMax+1){
							//liTag.setAttribute('style', 'display:none');
                            liTag.style.display = 'none';
						}//end: if
						//anppend li
						linkList.appendChild(liTag);
						//show ...
						containerDiv.style.display = 'block';
					} else {
						var imgTag  = document.createElement('img');
						imgTag.src = productConf[uid]['main']['thumb2'][artNum + adCode][i];
						imgTag.className = 'thumbs';
						aTag.appendChild(imgTag);
						linkList.appendChild(aTag);
					} // end: if
				}//end: for

				// Set  '...' as last element
				if(k == 0  && imageList.length > imgMax+1 ){
					var moreEnd = document.createElement('li');
					moreEnd.appendChild(document.createTextNode('...'));
					moreEnd.setAttribute('id','li_moreEnd');
					linkList.appendChild(moreEnd);
				} // end: if
			} else if (containerDiv) {
				containerDiv.style.display = 'none';
				// just for eltern.de
				$('.moreImages').hide();
			} // end: if


		} // end: for
	}//end: function

	function imageToggle(uid,id,orderNum,imgNum){

		var mainImage	= document.getElementById('dmc_mb3_product_pi1' + uid + 'MainImage');
		var newImage = productConf[uid]['main']['large'][orderNum][imgNum]['url'];
		if (newImage=='') {
			newImage = productConf[uid]['main']['large']['default'];
		}// end if
		mainImage.src = newImage;
		dmc_mb3_product_pi1mediaIndex = productConf[uid]['main']['large'][orderNum][imgNum]['zoomindex'];
		var actId = uid+'_'+id+'_'+orderNum+'_'+imgNum;
		var imageList = productConf[uid]['main']['large'][orderNum];
		moreEnd  = document.getElementById('li_moreEnd');
		moreStart  = document.getElementById('li_moreStart');
		// generate navi elements 1 - 3 or generate all elements
		// if they all can be displayed

		if(imgNum < 3 || moreEnd == null){
			for (i=0; i<imageList.length; i++){
				aTag = document.getElementById(uid+'_'+id+'_'+orderNum+'_'+i);
				liTag = document.getElementById('li_'+uid+'_'+id+'_'+orderNum+'_'+i);

				if (aTag && liTag) {
					aTag.className='';
					if (i < imgMax+1){
	                    liTag.style.display = 'inline';
					}//end: if
					else{
						liTag.style.display = 'none';
					}//end: else
					if(aTag.id==actId){
						aTag.className='aktiv';
						aTag.setAttribute('class','aktiv');
					}//end: if
				} // end: if
				// show list and select
			}//end: for
			if(moreStart!=null){
				moreStart.style.display = 'none';
			}//end: if
			if(moreEnd!=null){
				moreStart.style.display = 'none';
                moreEnd.style.display = 'inline';
			}//end: if
		}//end: if
		// generate navi elemets 'in the middle'
		// if we have many images show '...' in front of and after
		// the selected image
		else if(imgNum >= 3 && imgNum < imageList.length-2){
			for (i=0; i<imageList.length; i++){
				aTag = document.getElementById(uid+'_'+id+'_'+orderNum+'_'+i);
				liTag = document.getElementById('li_'+uid+'_'+id+'_'+orderNum+'_'+i);

				if (aTag && liTag) {
					aTag.className='';
					if (imgNum == i-1 || imgNum == i || imgNum == i+1){
						liTag.style.display = 'inline';
					}//end: if
					else{
						liTag.style.display = 'none';
					}//end: else
					if(aTag.id==actId){
						aTag.className='aktiv';
						aTag.setAttribute('class','aktiv');
					}//end: if
				} // end: if

				// show list and select
				moreStart.style.display = 'inline';
	            moreEnd.style.display = 'inline';
			}//end: for
		}//end: else if
		// here are the last elemetns build: special logic for hiding the '...'
		// and dsiplaying one additional navi element
		else {
			for (i=0; i<imageList.length; i++){
				aTag = document.getElementById(uid+'_'+id+'_'+orderNum+'_'+i);
				liTag = document.getElementById('li_'+uid+'_'+id+'_'+orderNum+'_'+i);

				if (aTag && liTag) {
					aTag.className='';
					if (imgNum == i-1 || imgNum == i || imgNum == i+1){
						liTag.style.display = 'inline';
					}//end: if
					else{
						liTag.style.display = 'none';
					}//end: else
					//special logic for last images
					if(imageList.length-1==imgNum && imgNum == i+2){
						liTag.style.display = 'inline';
					}//end: if
					if(aTag.id==actId){
						aTag.className='aktiv';
						aTag.setAttribute('class','aktiv');
					}//end: if
				} // end: if
			}//end: for
			moreStart.style.display = 'inline';
            moreEnd.style.display = 'none';
		}//end: else
	}//end: function

	/*
	* This function is used for popups like addto_notepad or addto_giftdesk combined with user login:
	* It refreshes some modules (basket/notepad/giftdesk) in the parent window and closes the popup.
	*/
	function closeAndParentReload(){
		opener.setUserDataFromCookie();
		close();
	}
	/**
	* Renderlogic for Crosselling Block on Productdetail
	*/
	function renderProductlist(itemList,targetContainer,crosssellingContainer,crossNotice){

		var targetList = new Array();
			for (var i=0; i<itemList.length; i++ ){
				var hiddenNode = document.getElementById('plist'+itemList[i]);
				if(hiddenNode){
					var newNode = hiddenNode.cloneNode(true);
					newNode.id = 'plist'+i;

					targetList[i] = newNode;
				}
			}

			var newRowDiv = null;
			var rowDiv = document.createElement('div');
			rowDiv.className = 'prodLine';

			for (var j=0; j<targetList.length; j++){

				productDiv = targetList[j]


				if(j%3==0){
					newRowDiv = rowDiv.cloneNode(true);
					targetContainer.appendChild(newRowDiv);
				}

				newRowDiv.appendChild(productDiv);
			}

			if(targetList.length >0 ){
				crosssellingContainer.style.display = 'block';
				crossNotice.style.display = 'block';
			}
	}

	function trimString(word) {
		word = word.replace(/^\s*(.*)/, "$1");
		word = word.replace(/(.*?)\s*$/, "$1");
		return word;
	}

	// A Function to toggle the displaying information on free delivery note based on the good type(Bulky good)
	function displayBulkyDeliveryNote(uid, id, variation, size, color){
		var deliveryTypeCode = productConf[uid][id]['articles'][variation][size][color]['deliveryTypeCode'];
		var articleBulkyCosts = productConf[uid][id]['articles'][variation][size][color]['bulkycosts'];
		var freeDeliveryNotice = document.getElementById('productDeliveryNotice');
		var pricePlain = productConf[uid][id]['articles'][variation][size][color]['pricePlain'];

		// check if minDeliveryCostFree is set and comapre it with price

		// Additional check for validating bulky good or not
		// Based on this check, the free delivery notice will be hidden/made visible
		if( (pricePlain/100 > minDeliveryCostFree/100)
			&& minDeliveryCostFree!=0
			&& (deliveryTypeCode & 1) == 0
			&& (articleBulkyCosts.search(/(.)*[1-9](.)*/)) == -1
		){
			freeDeliveryNotice.style.display = 'block';
		} // end: if
	} // end: function displayBulkyDeliveryNote

	// Cliplister Video
	function videoPopup(url,popupParams) {
			openWindow(url,
					   'popup_video',
					   popupParams);
		}
	function clHandleFrame(iframe)
	{
		if( iframe.id.substr(0,10)=="cliplister") {
			var test = new Image();
			test.onload = function() {
				if (test.width<2) {
					iframe.style.height="0";
					iframe.style.width="0";
					iframe.style.visibility="hidden";
				}
			}
			var s = iframe.src.replace(/\/ind/g,"");
			test.src = s.replace(/playBtn/g,"play")+"/cx";
		}
	}

	function cliplister()
	{
		var iframes = document.getElementsByTagName("iframe");
		var i;
		for(i=0;i<iframes.length;i++) {
			clHandleFrame(iframes[i]);
		}
	}




function factfinder_clicktracking(n, query, product_name, product_number, channel, artSimi, sessionId, pageSize, pageNum) {
    /**
     * note: substracting 0 forces javascript strings to integer type
     *       e.g.: "21" - 0 => 21
     */

    // find highest div for this entry (div with id attribute)
    while(n = n.parentNode) {
        if(/^plist\d+/i.test(n.id)) break;
    }
    n           = $(n); // jquery
    var num     = n.attr('id').replace(/\D+/g,'') - 0 + 1; // entry number within current page (e.g. 1-9)
    pageSize   -= 0; // convert page size to integer
    pageNum    -= 0; // convert page number to integer
    artSimi    -= 0; // convert similarity to integer
    var data = { // data for ajax request
            'query'         : query,
            'id'            : product_number,
            'pos'           : (pageNum * pageSize - pageSize) + num,
            'origPos'       : num,
            'page'          : pageNum,
            'simi'          : artSimi,
            'sid'           : sessionId,
            'title'         : product_name,
            'pageSize'      : $('.prodLine').find('[id^=plist]').length,
            'origPageSize'  : pageSize,
            'channel'       : channel,
            'event'         : 'click'
            };
        // console.log(data); // firebug console output
    // send data via ajax
    $.ajax({
            'type'          : 'POST',
            'url'           : '/typo3conf/ext/dmc_mb3_search_factfinderremote/libs/factfindertracker.php',
            'data'          : data,
            'contentType'   : 'application/x-www-form-urlencoded; charset=UTF-8',
            'cache'         : false,
            'async'         : false
    });
}


/******************************************************************************
Name:    Highslide JS
Version: 3.2.11 (November 19 2007)
Author:  Torstein Hĝnsi
Support: http://vikjavev.no/highslide/forum
Email:   See http://vikjavev.no/megsjol

Licence:
Highslide JS is licensed under a Creative Commons Attribution-NonCommercial 2.5
License (http://creativecommons.org/licenses/by-nc/2.5/).

You are free:
	* to copy, distribute, display, and perform the work
	* to make derivative works

Under the following conditions:
	* Attribution. You must attribute the work in the manner  specified by  the
	  author or licensor.
	* Noncommercial. You may not use this work for commercial purposes.

* For  any  reuse  or  distribution, you  must make clear to others the license
  terms of this work.
* Any  of  these  conditions  can  be  waived  if  you  get permission from the 
  copyright holder.

Your fair use and other rights are in no way affected by the above.
******************************************************************************/
eval(function(p,a,c,k,e,d){e=function(c){return(c<a?'':e(parseInt(c/a)))+((c=c%a)>35?String.fromCharCode(c+29):c.toString(36))};if(!''.replace(/^/,String)){while(c--){d[e(c)]=k[c]||e(c)}k=[function(e){return d[e]}];e=function(){return'\\w+'};c=1};while(c--){if(k[c]){p=p.replace(new RegExp('\\b'+e(c)+'\\b','g'),k[c])}}return p}('k c={3z:\'11/7r/\',56:"7q.5U",6P:10,6G:5t,6F:10,6Q:5t,5V:I,6l:I,58:1,2I:1a,57:3,45:10,6O:35,6E:10,2K:35,4i:5,2Y:7s,2H:\'7t.7w\',6Y:\'7v 2h 7u 7o\',5o:\'4X 2h 4R 1S, 7n 5J 7h 2h 3o. 7g 7f 7i Q 3l 5J 5S.\',6j:\'4X 2h 7j 2h 7m\',6L:\'7l...\',60:\'4X 2h 7k\',6K:0.75,4Z:I,6e:\'7x 2q <i>5E 5F</i>\',6r:\'7y://7L.7K/11/\',6q:\'7J 2h 7M 5E 5F 7N\',61:I,2J:\'2z\',4r:\'2z\',4k:K,4g:K,2R:K,3I:K,3D:K,3m:30,2B:5I,2V:5I,3U:I,1c:\'7Q-7P\',4l:K,3e:[],4B:I,4h:0,z:[],2M:[\'2J\',\'4r\',\'4k\',\'4g\',\'1c\',\'2I\',\'3m\',\'4l\',\'2B\',\'2V\',\'2R\',\'3I\',\'3U\',\'3D\'],1m:[],32:{},4E:{},46:[],1i:(V.7O&&!1F.5a),4c:4f.7I.7H("7B")!=-1,3b:1a,$:r(1o){u V.7e(1o)},4G:r(2c,5H){2c[2c.19]=5H},17:r(5A,2G,2b,55,5s){k m=V.17(5A);f(2G)c.5y(m,2G);f(5s)c.1C(m,{7z:0,7C:\'3M\',6h:0});f(2b)c.1C(m,2b);f(55)55.2y(m);u m},5y:r(m,2G){Q(k x 5x 2G){m[x]=2G[x]}},1C:r(m,2b){Q(k x 5x 2b){O{f(c.1i&&x==\'1g\'){m.q.5Y=2b[x]==1?\'3M\':\'7D(1g=\'+(2b[x]*2a)+\')\'}G m.q[x]=2b[x]}P(e){}}},2m:r(){2c=4f.7G.3G("7F");u 5N(2c[1])},6I:r(){k 3t=V.5e&&V.5e!="6y"?V.5Z:V.4t;b.R=c.1i?3t.7E:5w.7R;b.H=c.1i?3t.70:5w.7c;b.3H=c.1i?3t.3H:77;b.4b=c.1i?3t.4b:79},U:r(m){k p={x:m.5X,y:m.5W};41(m.5G){m=m.5G;p.x+=m.5X;p.y+=m.5W;f(m!=V.4t&&m!=V.5Z){p.x-=m.3H;p.y-=m.4b}}u p},5i:r(a,1P,3y){O{2Q M(a,1P,3y);u 1a}P(e){u I}},62:r(){k 51=0,3Q=-1;Q(i=0;i<c.z.19;i++){f(c.z[i]){f(c.z[i].D.q.1v&&c.z[i].D.q.1v>51){51=c.z[i].D.q.1v;3Q=i}}}f(3Q==-1)c.2W=-1;G c.z[3Q].2g()},74:r(1o){u c.4R(1o)},4R:r(m){O{c.3d(m).2C()}P(e){}u 1a},5h:r(C,1B){k 2O=V.49(\'A\'),4Q={},4H=-1,j=0;Q(i=0;i<2O.19;i++){f(c.3N(2O[i])&&((c.z[C].3D==c.4I(2O[i],\'3D\')))){4Q[j]=2O[i];f(c.z[C]&&2O[i]==c.z[C].a){4H=j}j++}}u 4Q[4H+1B]},4I:r(a,3a){O{k s=a.2X.5g().1z(/\\s/g,\' \').3G(\'{\')[2].3G(\'}\')[0];f(c.4c){Q(k i=0;i<c.2M.19;i++){s=s.1z(c.2M[i]+\':\',\',\'+c.2M[i]+\':\').1z(2Q 7d("^\\\\s*?,"),\'\')}}5m(\'k 2c = {\'+s+\'};\');f(2c[3a])u 2c[3a];G u c[3a]}P(e){u c[3a]}},2L:r(a){k 1l=c.4I(a,\'1l\');f(1l)u 1l;u a.78.1z(/7a/g,\'/\')||a.2r},3K:r(1o){k 3J=c.$(1o),2o=c.4E[1o],a={};f(!3J&&!2o)u K;f(!2o){2o=3J.5P(I);2o.1o=\'\';c.4E[1o]=2o;u 3J}G{u 2o.5P(I)}},2A:r(d){f(!c.1i)u;k a=d.72,i,l,n;f(a){l=a.19;Q(i=0;i<l;i+=1){n=a[i].2v;f(1M d[n]===\'r\'){d[n]=K}}}f(c.5T&&c.5T(d))u;a=d.1X;f(a){l=a.19;Q(i=0;i<l;i+=1){c.2A(d.1X[i])}}},3V:r(m,1B){k 1n=c.3d(m);O{c.5h(1n.C,1B).2X()}P(e){}O{1n.2C()}P(e){}u 1a},5S:r(m){u c.3V(m,-1)},3l:r(m){u c.3V(m,1)},42:r(e){f(!e)e=1F.1t;f(!e.1e)e.1e=e.5u;f(e.1e.5z)u;k 1B=K;7A(e.86){1Y 34:1Y 39:1Y 40:1B=1;5O;1Y 33:1Y 37:1Y 38:1B=-1;5O;1Y 27:1Y 13:1B=0}f(1B!==K){c.3u(V,\'4C\',c.42);O{f(!c.61)u I}P(e){}f(e.47)e.47();G e.8B=1a;f(1B==0){O{c.3d().2C()}P(e){}u 1a}G{u c.3V(c.2W,1B)}}G u I},8x:r(1s){c.4G(c.1m,1s)},5l:r(4L){k m,2x=/^11-D-([0-9]+)$/;m=4L;41(m.1x){m=m.1x;f(2x.8s(m.1o))u m.1o.1z(2x,"$1")}m=4L;41(m.1x){f(m.3j&&c.3N(m)){Q(C=0;C<c.z.19;C++){1n=c.z[C];f(1n&&1n.a==m)u C}}m=m.1x}},3d:r(m){O{f(1M m==\'3T\')u c.z[c.2W];f(1M m==\'36\')u c.z[m];f(1M m==\'4J\')m=c.$(m);u c.z[c.5l(m)]}P(e){}},6C:r(){Q(i=0;i<c.z.19;i++){f(c.z[i]&&c.z[i].6z)c.62()}},4W:r(e){f(!e)e=1F.1t;f(e.8v>1)u I;f(!e.1e)e.1e=e.5u;f(e.1e.5z)u;k 1h=e.1e;41(1h.1x&&!(1h.14&&1h.14.Z(/11-(1S|3o|3x)/))){1h=1h.1x}f(!1h.1x)u;c.W=c.3d(1h);f(1h.14.Z(/11-(1S|3o)/)){k 5d=I;k 2T=1f(c.W.D.q.Y);k 2U=1f(c.W.D.q.15)}f(e.5Q==\'6X\'){f(5d){f(1h.14.Z(\'11-1S\'))c.W.F.q.1H=\'3o\';c.2T=2T;c.2U=2U;c.64=e.5K;c.5q=e.5v;c.2s(V,\'5L\',c.59);f(e.47)e.47();f(c.W.F.14.Z(/11-(1S|3x)-31/)){c.W.2g();c.3b=I}u 1a}G f(1h.14.Z(/11-3x/)){c.W.2g();c.W.44();c.3b=1a}}G f(e.5Q==\'6V\'){c.3u(V,\'5L\',c.59);f(5d&&c.W){f(1h.14.Z(\'11-1S\')){1h.q.1H=c.3p}k 3C=2T!=c.2T||2U!=c.2U;f(!3C&&!c.3b&&!1h.14.Z(/11-3o/)){c.W.6f()}G f(3C||(!3C&&c.7Y)){c.W.44()}c.3b=1a}G f(1h.14.Z(\'11-1S-31\')){1h.q.1H=c.3p}}},59:r(e){f(!c.W||!c.W.D)u;f(!e)e=1F.1t;c.W.x.E=c.2T+e.5K-c.64;c.W.y.E=c.2U+e.5v-c.5q;k w=c.W.D;w.q.Y=c.W.x.E+\'N\';w.q.15=c.W.y.E+\'N\';f(c.W.X){k o=c.W.X;o.1k.q.Y=(c.W.x.E-o.1p)+\'N\';o.1k.q.15=(c.W.y.E-o.1p)+\'N\'}u 1a},2s:r(m,1t,1V){O{m.2s(1t,1V,1a)}P(e){O{m.5r(\'2Z\'+1t,1V);m.7V(\'2Z\'+1t,1V)}P(e){m[\'2Z\'+1t]=1V}}},3u:r(m,1t,1V){O{m.3u(1t,1V,1a)}P(e){O{m.5r(\'2Z\'+1t,1V)}P(e){m[\'2Z\'+1t]=K}}},3N:r(a){u(a.2X&&a.2X.5g().1z(/\\s/g,\' \').Z(/c.(84|e)8b/))},4z:r(i){f(c.4B&&c.3e[i]&&c.3e[i]!=\'3T\'){k 12=V.17(\'12\');12.4e=r(){c.4z(i+1)};12.1l=c.3e[i]}},6b:r(36){f(36&&1M 36!=\'8c\')c.4i=36;k a,2x,j=0;k 4O=V.49(\'A\');Q(i=0;i<4O.19;i++){a=4O[i];2x=c.3N(a);f(2x&&2x[0]==\'c.5i\'){f(j<c.4i){c.3e[j]=c.2L(a);j++}}}2Q 2t(c.1c,r(){c.4z(0)});k 5U=c.17(\'12\',{1l:c.3z+c.56})},4m:r(){f(!c.2u){c.2u=c.17(\'29\',K,{U:\'23\',Y:0,15:0,R:\'2a%\',1v:c.2Y},V.4t,I)}},3r:r(m,o,4s,2S,i){o=5N(o);m.q.S=(o<=0)?\'T\':\'1j\';f(o<0||(2S==1&&o>4s))u;f(i==K)i=c.46.19;f(1M(m.i)!=\'3T\'&&m.i!=i){7X(c.46[m.i]);o=m.5M}m.i=i;m.5M=o;m.q.S=(o<=0)?\'T\':\'1j\';c.1C(m,{1g:o});c.46[i]=2k(r(){c.3r(m,1y.1D((o+0.1*2S)*2a)/2a,4s,2S,i)},25)}};2t=r(1c,1K){b.1K=1K;b.1c=1c;k v=c.2m(),43;b.3i=c.1i&&v>=5.5&&v<7;b.5R=!c.1i||(c.1i&&v>=7);f(!1c||(!b.3i&&!b.5R)){f(1K)1K();u}c.4m();b.1k=c.17(\'1k\',{8i:0},{S:\'T\',U:\'23\',1v:c.2Y++,8p:\'81\'},c.2u,I);b.4q=c.17(\'4q\',K,K,b.1k,1);b.1d=[];Q(k i=0;i<=8;i++){f(i%3==0)43=c.17(\'43\',K,{H:\'2z\'},b.4q,I);b.1d[i]=c.17(\'1d\',K,K,43,I);k q=i!=4?{89:0,8a:0}:{U:\'4o\'};c.1C(b.1d[i],q)}b.1d[4].14=1c;b.5D()};2t.L.5D=r(){k 1l=c.3z+"7U/"+b.1c+".7T";k 5B=c.4c?c.2u:K;b.22=c.17(\'12\',K,{U:\'23\',Y:\'-5C\',15:\'-5C\'},5B,I);k 2E=b;b.22.4e=r(){2E.63()};b.22.1l=1l};2t.L.63=r(){k o=b.1p=b.22.R/4,1R=[[0,0],[0,-4],[-2,0],[0,-8],0,[-2,-8],[0,-2],[0,-6],[-2,-2]],3E={H:(2*o)+\'N\',R:(2*o)+\'N\'};Q(k i=0;i<=8;i++){f(1R[i]){f(b.3i){k w=(i==1||i==7)?\'2a%\':b.22.R+\'N\';k 29=c.17(\'29\',K,{R:\'2a%\',H:\'2a%\',U:\'4o\',6v:\'T\'},b.1d[i],I);c.17(\'29\',K,{5Y:"80:7Z.8w.8t(8z=8A, 1l=\'"+b.22.1l+"\')",U:\'23\',R:w,H:b.22.H+\'N\',Y:(1R[i][0]*o)+\'N\',15:(1R[i][1]*o)+\'N\'},29,I)}G{c.1C(b.1d[i],{6A:\'52(\'+b.22.1l+\') \'+(1R[i][0]*o)+\'N \'+(1R[i][1]*o)+\'N\'})}c.1C(b.1d[i],3E)}}c.32[b.1c]=b;f(b.1K)b.1K()};2t.L.4K=r(){c.2A(b.1k);O{b.1k.1x.3c(b.1k)}P(e){}};M=r(a,1P,3y,1E){c.4B=1a;b.3y=3y;Q(i=0;i<c.2M.19;i++){k 2v=c.2M[i];f(1P&&1M 1P[2v]!=\'3T\')b[2v]=1P[2v];G b[2v]=c[2v]}k m;f(1P&&1P.3X)m=c.$(1P.3X);G m=a.49(\'6k\')[0];f(!m)m=a;Q(i=0;i<c.z.19;i++){f(c.z[i]&&c.z[i].2p!=m&&!c.z[i].48){c.z[i].5j()}}Q(i=0;i<c.z.19;i++){f(c.z[i]&&c.z[i].a==a){c.z[i].2g();u 1a}}f(!c.5V){O{c.z[c.4h-1].2C()}P(e){}}k C=b.C=c.4h++;c.z[b.C]=b;f(1E==\'3x\'){b.3s=I;b.1E=\'3x\'}G{b.1W=I;b.1E=\'1S\'}b.a=a;b.3Y=m.1o||a.1o;b.2p=m;b.1m=[];k 1R=c.U(m);b.D=c.17(\'29\',{1o:\'11-D-\'+b.C,14:b.4l},{S:\'T\',U:\'23\',1v:c.2Y++},K,I);b.D.8l=r(e){O{c.z[C].6T(e)}P(e){}};b.D.8o=r(e){O{c.z[C].6Z(e)}P(e){}};b.1U=m.R?m.R:m.1T;b.1O=m.H?m.H:m.1u;b.2i=1R.x;b.2f=1R.y;b.2F=(b.2p.1T-b.1U)/2;b.3B=(b.2p.1u-b.1O)/2;c.4m();f(c.32[b.1c]){b.4j();b[b.1E+\'4d\']()}G f(!b.1c){b[b.1E+\'4d\']()}G{b.4n();k 2E=b;2Q 2t(b.1c,r(){2E.4j();2E[2E.1E+\'4d\']()})}};M.L.4j=r(x,y){k w=c.32[b.1c];b.X=w;c.32[b.1c]=K};M.L.4n=r(){f(b.48||b.1b)u;b.5k=b.a.q.1H;b.a.q.1H=\'8r\';f(!c.1b){c.1b=c.17(\'a\',{14:\'11-1b\',2N:c.60,1w:c.6L},{U:\'23\',1g:c.6K},c.2u)}b.1b=c.1b;b.1b.2r=\'6R:c.z[\'+b.C+\'].5j()\';b.1b.S=\'1j\';b.1b.q.Y=(b.2i+b.2F+(b.1U-b.1b.1T)/2)+\'N\';b.1b.q.15=(b.2f+(b.1O-b.1b.1u)/2)+\'N\';2k("f (c.z["+b.C+"] && c.z["+b.C+"].1b) "+"c.z["+b.C+"].1b.q.S = \'1j\';",2a)};M.L.8m=r(){k C=b.C;k 12=V.17(\'12\');b.F=12;12.4e=r(){O{c.z[C].1K()}P(e){}};12.14=\'11-1S\';12.q.S=\'T\';12.q.3A=\'3L\';12.q.U=\'23\';12.q.8n=\'3M\';12.q.1v=3;12.2N=c.5o;f(c.4c)c.2u.2y(12);12.1l=c.2L(b.a);b.4n()};M.L.1K=r(){O{f(!b.F)u;f(b.48)u;G b.48=I;f(b.1b){b.1b.q.S=\'T\';b.1b=K;b.a.q.1H=b.5k||\'\'}f(b.1W){b.2e=b.F.R;b.2n=b.F.H;b.3W=b.2e;b.6n=b.2n;b.F.R=b.1U;b.F.H=b.1O}G f(b.6N)b.6N();b.2K=c.2K;b.6o();b.D.2y(b.F);b.F.q.U=\'4o\';f(b.J)b.D.2y(b.J);b.D.q.Y=b.2i+\'N\';b.D.q.15=b.2f+\'N\';c.2u.2y(b.D);b.1N=(b.F.1T-b.1U)/2;b.1G=(b.F.1u-b.1O)/2;k 6D=c.6O+2*b.1N;b.2K+=2*b.1G;k 26=b.2e/b.2n;k 2B=b.3U?b.2B:b.2e;k 2V=b.3U?b.2V:b.2n;k 16={x:\'2z\',y:\'2z\'};f(b.4r==\'1Q\'){16.x=\'1Q\';16.y=\'1Q\'}G{f(b.2J.Z(/^15/))16.y=K;f(b.2J.Z(/54$/))16.x=\'4p\';f(b.2J.Z(/^53/))16.y=\'4p\';f(b.2J.Z(/Y$/))16.x=K}3q=2Q c.6I();b.x={E:1f(b.2i)-b.1N+b.2F,B:b.2e,1I:b.2e<2B?b.2e:2B,16:16.x,1e:b.4k,1A:c.45,21:6D,24:3q.3H,1Z:3q.R,3Z:b.1U};k 8k=b.x.E+1f(b.1U);b.x=b.16(b.x);b.y={E:1f(b.2f)-b.1G+b.3B,B:b.2n,1I:b.2n<2V?b.2n:2V,16:16.y,1e:b.4g,1A:c.6E,21:b.2K,24:3q.4b,1Z:3q.H,3Z:b.1O};k 8g=b.y.E+1f(b.1O);b.y=b.16(b.y);f(b.3s)b.8h();f(b.1W)b.6B(26);k x=b.x;k y=b.y;b.6H()}P(e){f(c.z[b.C]&&c.z[b.C].a)1F.4S.2r=c.2L(c.z[b.C].a)}};M.L.6H=r(){k 1r={x:b.x.E-20,y:b.y.E-20,w:b.x.B+40,h:b.y.B+40+b.3m};c.3O=(c.1i&&c.2m()<7);f(c.3O)b.2d(\'4U\',\'T\',1r);c.3P=(1F.5a||4f.8j==\'8q\'||(c.1i&&c.2m()<5.5));f(c.3P)b.2d(\'4V\',\'T\',1r);f(b.X&&!b.2I)b.3w(b.x.E,b.y.E,b.x.B,b.y.B);k 3F=b.X?b.X.1p:0;b.4N(1,b.2i+b.2F-b.1N,b.2f+b.3B-b.1G,b.1U,b.1O,b.x.E,b.y.E,b.x.B,b.y.B,c.6G,c.6P,c.57,3F)};M.L.16=r(p){k 2j,3E=p==b.x?\'x\':\'y\';f(p.1e&&p.1e.Z(/ /)){2j=p.1e.3G(\' \');p.1e=2j[0]}f(p.1e&&c.$(p.1e)){p.E=c.U(c.$(p.1e))[3E];f(2j&&2j[1]&&2j[1].Z(/^[-]?[0-9]+N$/))p.E+=1f(2j[1])}G f(p.16==\'2z\'||p.16==\'1Q\'){k 4A=1a;k 2D=I;f(p.16==\'1Q\')p.E=1y.1D(p.24+(p.1Z-p.B-p.21)/2);G p.E=1y.1D(p.E-((p.B-p.3Z)/2)); f(p.E<p.24+p.1A){p.E=p.24+p.1A;4A=I}f(p.B<p.1I){p.B=p.1I;2D=1a}f(p.E+p.B>p.24+p.1Z-p.21){f(4A&&2D)p.B=p.1Z-p.1A-p.21;G f(p.B<p.1Z-p.1A-p.21){p.E=p.24+p.1Z-p.B-p.1A-p.21}G{p.E=p.24+p.1A;f(2D)p.B=p.1Z-p.1A-p.21}}f(p.B<p.1I){p.B=p.1I;2D=1a}}G f(p.16==\'4p\'){p.E=1y.82(p.E-p.B+p.3Z)}f(p.E<p.1A){6W=p.E;p.E=p.1A;f(2D)p.B=p.B-(p.E-6W)}u p};M.L.6B=r(26){k x=b.x;k y=b.y;k 4a=1a;f(x.B/y.B>26){ k 85=x.B;x.B=y.B*26;f(x.B<x.1I){x.B=x.1I;y.B=x.B/26}4a=I}G f(x.B/y.B<26){ k 88=y.B;y.B=x.B/26;4a=I}f(4a){x.E=1f(b.2i)-b.1N+b.2F;x.1I=x.B;b.x=b.16(x);y.E=1f(b.2f)-b.1G+b.3B;y.1I=y.B;b.y=b.16(y)}};M.L.4N=r(2S,3f,3k,3h,3g,4u,4v,4y,4x,6a,1L,3n,4w){k 67=(4y-3h)/1L,66=(4x-3g)/1L,68=(4u-3f)/1L,69=(4v-3k)/1L,65=(4w-3n)/1L,t,1n="c.z["+b.C+"]";Q(i=1;i<=1L;i++){3h+=67;3g+=66;3f+=68;3k+=69;3n+=65;t=1y.1D(i*(6a/1L));k s="O {";f(i==1){s+=1n+".F.q.S = \'1j\';"+"f ("+1n+".2p.3j == \'6k\' && c.6l) "+1n+".2p.q.S = \'T\';"}f(i==1L){3h=4y;3g=4x;3f=4u;3k=4v;3n=4w}s+=1n+"."+b.1E+"8e("+1y.1D(3h)+", "+1y.1D(3g)+", "+1y.1D(3f)+", "+1y.1D(3k)+", "+1y.1D(3n);s+=");} P (e) {}";2k(s,t)}f(2S==1){2k(\'O { \'+1n+\'.X.1k.q.S = "1j"; } P (e){}\',t);2k(\'O { \'+1n+\'.6x(); } P(e){}\',t+50)}G 2k(\'O { \'+1n+\'.4P(); } P(e){}\',t)};M.L.87=r(w,h,x,y,1p){O{b.F.R=w;b.F.H=h;f(b.X&&b.2I){k o=b.X.1p-1p;b.3w(x+o,y+o,w-2*o,h-2*o,1)}c.1C(b.D,{\'S\':\'1j\',\'Y\':x+\'N\',\'15\':y+\'N\'})}P(e){1F.4S.2r=c.2L(b.a)}};M.L.3w=r(x,y,w,h,6w){f(!b.X)u;k o=b.X;f(6w)o.1k.q.S=\'1j\';o.1k.q.Y=(x-o.1p)+\'N\';o.1k.q.15=(y-o.1p)+\'N\';o.1k.q.R=(w+2*(b.1N+o.1p))+\'N\';w+=2*(b.1N-o.1p);h+=+2*(b.1G-o.1p);o.1d[4].q.R=w>=0?w+\'N\':0;o.1d[4].q.H=h>=0?h+\'N\':0;f(o.3i)o.1d[3].q.H=o.1d[5].q.H=o.1d[4].q.H};M.L.6x=r(){b.6z=I;b.2g();f(b.3s&&b.8d==\'83\')b.7W();b.4T();f(c.4Z)b.4Y();f(b.J)b.6s();f(b.3W>b.x.B)b.6S();f(!b.J)b.5c()};M.L.5c=r(){k C=b.C;k 1c=b.1c;2Q 2t(1c,r(){O{c.z[C].6p()}P(e){}})};M.L.6p=r(){k 3l=c.5h(b.C,1);f(3l.2X.5g().Z(/c\\.5i/))k 12=c.17(\'12\',{1l:c.2L(3l)})};M.L.5j=r(){b.a.q.1H=b.5k;f(b.1b)c.1b.q.S=\'T\';c.z[b.C]=K};M.L.4Y=r(){k 5f=c.17(\'a\',{2r:c.6r,14:\'11-5f\',1w:c.6e,2N:c.6q});b.3R(5f,\'15 Y\')};M.L.6o=r(){f(!b.2R&&b.3Y)b.2R=\'J-Q-\'+b.3Y;f(b.2R){b.J=c.3K(b.2R)}f(b.3I){k s=(b.J)?b.J.1w:\'\';b.J=c.3K(b.3I);f(b.J)b.J.1w=b.J.1w.1z(/\\s/g,\' \').1z(\'{J}\',s)}f(b.J)b.2K+=b.3m};M.L.6s=r(){O{b.D.q.R=b.D.1T+\'N\';b.J.q.S=\'T\';b.J.14+=\' 11-3A-3L\';k H;f(c.1i&&(c.2m()<6||V.5e==\'6y\')){H=b.J.1u}G{k 6u=c.17(\'29\',{1w:b.J.1w},K,K,I);b.J.1w=\'\';b.J.2y(6u);H=b.J.1X[0].1u;b.J.1w=b.J.1X[0].1w}c.1C(b.J,{6v:\'T\',H:0,1v:2});f(c.58){2l=1y.1D(H/50);f(2l==0)2l=1;2l=2l*c.58}G{b.5b(H,1);u}k t=0;Q(k h=H%2l;h<=H;h+=2l,t+=10){k 3S=(h==H)?1:0;k 5m="O { "+"c.z["+b.C+"].5b("+h+", "+3S+");"+"} P (e) {}";2k(5m,t)}}P(e){}};M.L.5b=r(H,3S){f(!b.J)u;b.J.q.H=H+\'N\';b.J.q.S=\'1j\';b.y.B=b.D.1u-2*b.1G;k o=b.X;f(o){o.1d[4].q.H=(b.D.1u-2*b.X.1p)+\'N\';f(o.3i)o.1d[3].q.H=o.1d[5].q.H=o.1d[4].q.H}f(3S)b.5c()};M.L.2d=r(3j,S,1r){k 18=V.49(3j);f(18){Q(i=0;i<18.19;i++){f(18[i].8f==3j){k 1q=18[i].3v(\'T-2q\');f(S==\'1j\'&&1q){1q=1q.1z(\'[\'+b.C+\']\',\'\');18[i].2w(\'T-2q\',1q);f(!1q)18[i].q.S=\'1j\'}G f(S==\'T\'){k 1J=c.U(18[i]);1J.w=18[i].1T;1J.h=18[i].1u;k 6d=(1J.x+1J.w<1r.x||1J.x>1r.x+1r.w);k 6i=(1J.y+1J.h<1r.y||1J.y>1r.y+1r.h);k 5n=c.5l(18[i]);f(!6d&&!6i&&5n!=b.C){f(!18[i].5p||(18[i].5p&&18[i].5p[\'S\']!=\'T\')){f(!1q){18[i].2w(\'T-2q\',\'[\'+b.C+\']\')}G f(!1q.Z(\'[\'+b.C+\']\')){18[i].2w(\'T-2q\',1q+\'[\'+b.C+\']\')}18[i].q.S=\'T\'}}G f(1q==\'[\'+b.C+\']\'||c.2W==5n){18[i].2w(\'T-2q\',\'\');18[i].q.S=\'1j\'}G f(1q&&1q.Z(\'[\'+b.C+\']\')){18[i].2w(\'T-2q\',1q.1z(\'[\'+b.C+\']\',\'\'))}}}}}};M.L.2g=r(){Q(i=0;i<c.z.19;i++){f(c.z[i]&&i==c.2W){k 28=c.z[i];28.F.14+=\' 11-\'+28.1E+\'-31\';f(28.J){28.J.14+=\' 11-J-31\'}f(28.1W){28.F.q.1H=c.1i?\'6g\':\'4M\';28.F.2N=c.6j}}}b.D.q.1v=c.2Y++;f(b.X)b.X.1k.q.1v=b.D.q.1v;b.F.14=\'11-\'+b.1E;f(b.J){b.J.14=b.J.14.1z(\' 11-J-31\',\'\')}f(b.1W){b.F.2N=c.5o;c.3p=1F.5a?\'4M\':\'52(\'+c.3z+c.56+\'), 4M\';f(c.1i&&c.2m()<6)c.3p=\'6g\';b.F.q.1H=c.3p}c.2W=b.C;c.2s(V,\'4C\',c.42)};M.L.6f=r(){b.2C()};M.L.2C=r(){c.3u(V,\'4C\',c.42);O{b.8u=I;k x=1f(b.D.q.Y);k y=1f(b.D.q.15);k w=(b.1W)?b.F.R:1f(b.F.q.R);k h=(b.1W)?b.F.H:1f(b.F.q.H);f(b.X){f(b.2I)b.3w(x,y,w,h);G f(b.6M)b.X.1k.q.S=\'T\';G b.X.4K()}k n=b.D.1X.19;Q(i=n-1;i>=0;i--){k 6U=b.D.1X[i];f(6U!=b.F){c.2A(b.D.1X[i]);b.D.3c(b.D.1X[i])}}f(b.3s)b.8y();b.D.q.R=\'2z\';b.F.q.1H=\'7S\';k 3F=b.X?b.X.1p:0;b.4N(-1,x,y,w,h,b.2i-b.1N+b.2F,b.2f-b.1G+b.3B,b.1U,b.1O,c.6Q,c.6F,3F,c.57)}P(e){b.4P()}};M.L.4P=r(){b.2p.q.S=\'1j\';f(c.3O)b.2d(\'4U\',\'1j\');f(c.3P)b.2d(\'4V\',\'1j\');f(b.3s&&b.6M)b.71();G{f(b.X&&b.2I)b.X.4K();c.2A(b.D);f(c.1i&&c.2m()<5.5)b.D.1w=\'\';G b.D.1x.3c(b.D)}f(c.6J)c.6J.q.3A=\'3M\';c.z[b.C]=K;c.6C()};M.L.3R=r(m,U,2P,1g){f(1M m==\'4J\')m=c.3K(m);f(!m||1M m==\'4J\'||!b.1W)u;k 1s=c.17(\'29\',K,{\'Y\':0,\'15\':0,\'U\':\'23\',\'1v\':3,\'S\':\'T\'},b.D,I);f(1g)c.1C(m,{\'1g\':1g});m.14+=\' 11-3A-3L\';1s.2y(m);k Y=b.1N;k 4F=b.F.R-1s.1T;k 15=b.1G;k 4D=b.F.H-1s.1u;f(!U)U=\'1Q 1Q\';f(U.Z(/^53/))15+=4D;f(U.Z(/^1Q/))15+=4D/2;f(U.Z(/54$/))Y+=4F;f(U.Z(/1Q$/))Y+=4F/2;1s.q.Y=Y+\'N\';1s.q.15=15+\'N\';f(2P)1s.2w(\'2P\',I);f(!1g)1g=1;1s.2w(\'1g\',1g);c.3r(1s,0,1g,1);c.4G(b.1m,1s)};M.L.4T=r(){Q(i=0;i<c.1m.19;i++){k o=c.1m[i];f(o.3X==K||o.3X==b.3Y){b.3R(o.76,o.U,o.2P,o.1g)}}};M.L.6T=r(){Q(i=0;i<b.1m.19;i++){k o=b.1m[i];f(o.3v(\'2P\'))c.3r(o,0,o.3v(\'1g\'),1)}};M.L.6Z=r(){Q(i=0;i<b.1m.19;i++){k o=b.1m[i];f(o.3v(\'2P\'))c.3r(o,o.3v(\'1g\'),0,-1)}};M.L.6S=r(){k a=c.17(\'a\',{2r:\'6R:c.z[\'+b.C+\'].6m();\',2N:c.6Y},{6A:\'52(\'+c.3z+c.2H+\')\',3A:\'3L\',6h:\'0 6c 6c 0\',R:\'73\',H:\'7b\'},K,I);b.3R(a,\'53 54\',I,0.75);b.2H=a};M.L.6m=r(){O{c.2A(b.2H);b.2H.1x.3c(b.2H);b.2g();b.x.E=1f(b.D.q.Y)-(b.3W-b.F.R)/2;f(b.x.E<c.45)b.x.E=c.45;b.D.q.Y=b.x.E+\'N\';k 6t=b.D.1T-b.F.R;b.F.R=b.3W;b.F.H=b.6n;b.x.B=b.F.R;b.D.q.R=(b.x.B+6t)+\'N\';b.y.B=b.D.1u-2*b.1G;b.3w(b.x.E,b.y.E,b.x.B,b.y.B);Q(k i=0;i<b.1m.19;i++){c.2A(b.1m[i]);b.1m[i].1x.3c(b.1m[i])}f(c.4Z)b.4Y();b.4T();b.44()}P(e){1F.4S.2r=b.F.1l}};M.L.44=r(){k 1r={x:1f(b.D.q.Y)-20,y:1f(b.D.q.15)-20,w:b.F.1T+40,h:b.F.1u+40+b.3m};f(c.3O)b.2d(\'4U\',\'T\',1r);f(c.3P)b.2d(\'4V\',\'T\',1r)};c.2s(V,\'6X\',c.4W);c.2s(V,\'6V\',c.4W);c.2s(1F,\'7p\',c.6b);',62,534,'|||||||||||this|hs|||if|||||var||el||||style|function|||return|||||expanders||span|key|wrapper|min|content|else|height|true|caption|null|prototype|HsExpander|px|try|catch|for|width|visibility|hidden|position|document|dragExp|objOutline|left|match||highslide|img||className|top|justify|createElement|els|length|false|loading|outlineType|td|target|parseInt|opacity|fobj|ie|visible|table|src|overlays|exp|id|offset|hiddenBy|imgPos|overlay|event|offsetHeight|zIndex|innerHTML|parentNode|Math|replace|marginMin|op|setStyles|round|contentType|window|offsetBorderH|cursor|minSpan|elPos|onLoad|steps|typeof|offsetBorderW|thumbHeight|params|center|pos|image|offsetWidth|thumbWidth|func|isImage|childNodes|case|clientSpan||marginMax|graphic|absolute|scroll||ratio||blurExp|div|100|styles|arr|showHideElements|newWidth|thumbTop|focus|to|thumbLeft|tgt|setTimeout|step|ieVersion|newHeight|clone|thumb|by|href|addEventListener|HsOutline|container|name|setAttribute|re|appendChild|auto|purge|minWidth|doClose|allowReduce|pThis|thumbOffsetBorderW|attribs|fullExpandIcon|outlineWhileAnimating|anchor|marginBottom|getSrc|overrides|title|aAr|hideOnMouseOut|new|captionId|dir|wLeft|wTop|minHeight|focusKey|onclick|zIndexCounter|on||blur|pendingOutlines||||number||||param|hasFocused|removeChild|getExpander|preloadTheseImages|x1|h1|w1|hasAlphaImageLoader|tagName|y1|next|spaceForCaption|oo1|move|styleRestoreCursor|client|fade|isHtml|iebody|removeEventListener|getAttribute|positionOutline|html|custom|graphicsDir|display|thumbOffsetBorderH|hasMoved|slideshowGroup|dim|o2|split|scrollLeft|captionTemplateId|node|getNode|block|none|isHsAnchor|hideSelects|hideIframes|topmostKey|createOverlay|end|undefined|allowSizeReduction|previousOrNext|fullExpandWidth|thumbnailId|thumbsUserSetId|thumbSpan||while|keyHandler|tr|redoShowHide|marginLeft|faders|preventDefault|onLoadStarted|getElementsByTagName|changed|scrollTop|safari|Create|onload|navigator|targetY|expandedImagesCounter|numberOfImagesToPreload|connectOutline|targetX|wrapperClassName|genContainer|displayLoading|relative|max|tbody|align|oFinal|body|x2|y2|oo2|h2|w2|preloadFullImage|hasMovedMin|continuePreloading|keydown|dTop|clones|dLeft|push|activeI|getParam|string|destroy|element|pointer|changeSize|aTags|onEndClose|hsAr|close|location|createCustomOverlays|SELECT|IFRAME|mouseClickHandler|Click|writeCredits|showCredits||topZ|url|bottom|right|parent|restoreCursor|outlineStartOffset|captionSlideSpeed|mouseMoveHandler|opera|placeCaption|onDisplayFinished|isDraggable|compatMode|credits|toString|getAdjacentAnchor|expand|cancelLoading|originalCursor|getWrapperKey|eval|wrapperKey|restoreTitle|currentStyle|dragY|detachEvent|nopad|250|srcElement|clientY|self|in|setAttribs|form|tag|appendTo|9999px|preloadGraphic|Highslide|JS|offsetParent|val|200|and|clientX|mousemove|tempOpacity|parseFloat|break|cloneNode|type|hasPngSupport|previous|geckoBug|cur|allowMultipleInstances|offsetTop|offsetLeft|filter|documentElement|loadingTitle|enableKeyListener|focusTopmost|onGraphicLoad|dragX|dOo|dH|dW|dX|dY|dur|preloadImages|10px|clearsX|creditsText|onClick|hand|margin|clearsY|focusTitle|IMG|hideThumbOnExpand|doFullExpand|fullExpandHeight|getCaption|preloadNext|creditsTitle|creditsHref|writeCaption|borderOffset|temp|overflow|vis|onExpanded|BackCompat|isExpanded|background|correctRatio|cleanUp|modMarginRight|marginTop|restoreSteps|expandDuration|show|clientInfo|mask|loadingOpacity|loadingText|preserveContent|htmlGetSize|marginRight|expandSteps|restoreDuration|javascript|createFullExpand|onMouseOver|child|mouseup|tmpMin|mousedown|fullExpandTitle|onMouseOut|clientHeight|sleep|attributes|45px|closeId||overlayId|pageXOffset|rel|pageYOffset|_slash_|44px|innerHeight|RegExp|getElementById|arrow|Use|drag|keys|bring|cancel|Loading|front|click|size|load|zoomout|graphics|1001|fullexpand|actual|Expand|gif|Powered|http|padding|switch|Safari|border|alpha|clientWidth|MSIE|appVersion|indexOf|userAgent|Go|no|vikjavev|the|homepage|all|shadow|drop|innerWidth|default|png|outlines|attachEvent|writeExtendedContent|clearTimeout|hasHtmlexpanders|DXImageTransform|progid|collapse|floor|after|htmlE|tmpWidth|keyCode|imageSetSize|tmpHeight|lineHeight|fontSize|xpand|object|objectLoadTime|SetSize|nodeName|oldBottom|htmlSizeOperations|cellSpacing|vendor|oldRight|onmouseover|imageCreate|maxWidth|onmouseout|borderCollapse|KDE|wait|test|AlphaImageLoader|isClosing|button|Microsoft|registerOverlay|htmlOnClose|sizingMethod|scale|returnValue'.split('|'),0,{}))


function deleteNpadOrderline( uid, name, orderlinePK ){
	var obj = document.getElementById('deleteNotepadOrderline');
	var tmp = uid.split('_');
	var parent_uid = tmp[0];
	var formObj = document.getElementById('dmc_mb3_notepad_pi1['+parent_uid+'][form]');
	obj.name = name;
	obj.value = orderlinePK;
	formObj.submit();
}

function deleteGiftdeskOrderlineWithConfirm( uid, deleteFieldName, orderlinePK, confirmationText ) {
	var check = confirm(confirmationText);
	if( check ) {
		// hidden field, which contains the information about what should be deleted
		var obj = document.getElementById('deleteGiftdeskOrderline');
		obj.name = deleteFieldName;
		obj.value = orderlinePK;
		var tmp = uid.split('_');
		var parent_uid = tmp[0];
		var formObj = document.getElementById('dmc_mb3_giftdesk_pi1['+parent_uid+'][form]');
		formObj.submit();
	} else {
		return false;
	}
}

function deleteBasketOrderline( uid, name, orderlinePK ){
	var obj = document.getElementById('deleteOrderline');
	var tmp = uid.split('_');
	var parent_uid = tmp[0];
	var formObj = document.getElementById('dmc_mb3_shoppingbasket_pi1['+parent_uid+'][form]');
	if (confirm (deleteOrderlineNotice) == true){
		obj.name = name;
		obj.value = orderlinePK;
		formObj.submit();
	}

}

function allIntoShoppingBasket( uid, name ) {
	var obj = document.getElementById('allIntoBasket');
	var formObj = document.getElementById('dmc_mb3_notepad_pi1['+uid+'][form]');
	obj.name = name;
	obj.value = 'moveAllOrderlines';
	formObj.submit();
}

function allIntoShoppingBasketFromGiftdesk( uid, name ) {
	var obj = document.getElementById('allIntoBasketFromGiftdesk');
	var formObj = document.getElementById('dmc_mb3_giftdesk_pi1['+uid+'][form]');
	obj.name = name;
	obj.value = 'moveAllOrderlinesFromGiftdesk';
	formObj.submit();
}

function changeOrderlineStatus( uid, changeFieldName, orderlinePK ) {
	// hidden field, which contains the information about which orderline should be changed
	var obj = document.getElementById('changeGiftdeskOrderline');
	obj.name = changeFieldName;
	obj.value = orderlinePK;
	var tmp = uid.split('_');
	var parent_uid = tmp[0];
	var formObj = document.getElementById('dmc_mb3_giftdesk_pi1['+parent_uid+'][form]');
	formObj.submit();
}

var shoppingbasketFormDoubleSubmit = false;

function shoppingbasketFormSubmit(ctype, uid, nextstepValue, formnum) {
	var formId = ''
	/* special configuration:
	*  with the additional parameter you can have more than one form on a page
	*  else-Part is done due to IE7 not recognizing the right hidden field (maybe parser Bug?)
	*/
	if (formnum){
		formId = '['+formnum+']';
	}else{
		var overidefieldnum = document.getElementById('overidefieldnum');

		if(overidefieldnum){
			newId = overidefieldnum.value
			formId = '['+newId+']';
		}
	}

	var form			= document.getElementById(ctype + '[' + uid + ']' + '[form]' + formId);
	var nextstep		= document.getElementById(ctype + '[' + uid + ']' + '[nextstep]' + formId);
	
	if (shoppingbasketFormDoubleSubmit == false) {
		if (form && nextstep && nextstepValue > 0) {
			shoppingbasketFormDoubleSubmit = true;
			nextstep.value 	= '' + nextstepValue;

			form.submit();
		}
	}
}

function shoppingbasketFormChangeAction(ctype, uid, oldAction, newAction) {

	var action			= document.getElementById(ctype + '[' + uid + ']' + '[action][' + oldAction + ']');

	if (action) {
		action.value = newAction;
	}
}

function shoppingbasketCheckPaymentType(ctype, uid, installment){
	var installmentCheckBox = document.getElementById(ctype + '[' + uid + ']' + '[installment][checkbox]');

	var mode	= installmentCheckBox.checked;
    if(installment == '1') {
		installmentCheckBox.disabled = false;
	} else {
		installmentCheckBox.checked	= false;
		installmentCheckBox.disabled = true;
	}
}

/**
* This is used for the extension specific functions
*
* @package		mb3p
* @subpackage	shoppingbasketcached
* @access		public
* @author	    Boris Azar
* @version		1.0.0
*/
var dmc_mb3_shoppingbasketcached = {

	// public method for url decoding
	decode : function (data) {
		var lsRegExp = /\+/g;
		// Return the decoded string
		return this.decodeUtf8(unescape(String(data).replace(lsRegExp, " ")));
	},

	/**
	* decodes a string in utf8
	*
	* @param string 	utftext							string to be decoded
	* @return void
	*/
	decodeUtf8: function (utftext) {
		var plaintext = "";
		var i=0;
		var c=0;
		var c1=0;
		var c2=0;

		// while-Schleife, weil einige Zeichen uebersprungen werden
		while(i<utftext.length) {
			c = utftext.charCodeAt(i);
			if (c<128) {
				plaintext += String.fromCharCode(c);
				i++;
			} else if((c>191) && (c<224)) {
				c2 = utftext.charCodeAt(i+1);
				plaintext += String.fromCharCode(((c&31)<<6) | (c2&63));
				i+=2;
			} else {
				c2 = utftext.charCodeAt(i+1); c3 = utftext.charCodeAt(i+2);
				plaintext += String.fromCharCode(((c&15)<<12) | ((c2&63)<<6) | (c3&63));
				i+=3;
			}
		}

		return plaintext;
	 } // end: function

}

/**
* Shoppingbasketcached function
*
* @package		mb3p
* @subpackage	shoppingbasketcached
* @access		public
* @author	    Boris Azar
* @version		1.0.0
*/

/**
* Sets a cookie
*
* @param string 	basketAmountContainerId			id of the basketAmountContainer
* @param string 	articlesAmountContainerId		id of the articlesAmountContainer
* @return void
*/
function fillShoppingBasketWithData(basketAmountContainerId, articlesAmountContainerId, tipText) {
	var articlesAmountContainer = document.getElementById(articlesAmountContainerId);
	var basketAmountContainer = document.getElementById(basketAmountContainerId);

	var cookieData = cookie_get('mb3pc');
	if (cookieData && typeof cookieData != 'undefined') {

		var data = JSON.parse(cookieData);
		if (data) {
			// get the articlesAmountContainer object and set data in it
			if (articlesAmountContainer
				&& typeof data.shoppingbasket.articlesAmount != 'undefined') {

				// do not forget to decode the data (+ signs are converted back to spaces)
				articlesAmountContainerValue = dmc_mb3_shoppingbasketcached.decode(data.shoppingbasket.articlesAmount);

				// get the articlesAmountContainer object and set data in it
				if (articlesAmountContainer) {
					// do not forget to decode the data (+ signs are converted back to spaces)
					articlesAmountContainer.innerHTML = articlesAmountContainerValue;
				} // end: if

			} // end: if

			// get the basketAmountContainer object and set data in it
			if (basketAmountContainer
				&& typeof data.shoppingbasket.basketAmount != 'undefined') {

				// do not forget to decode the data (+ signs are converted back to spaces)
				basketAmountContainerValue = dmc_mb3_shoppingbasketcached.decode(data.shoppingbasket.basketAmount);

				// get the basketAmountContainer object and set data in it
				if (basketAmountContainer) {
					// do not forget to decode the data (+ signs are converted back to spaces)
					basketAmountContainer.innerHTML = basketAmountContainerValue;
				} // end: if
			} // end: if

			if (typeof data.shoppingbasket.basketAmount != 'undefined'
				&& data.shoppingbasket.freeDelivery == 1) {
				var basketDisplayContentContainer = document.getElementById('basketDisplayContent');
				basketDisplayContentContainer.className = basketDisplayContentContainer.className + ' addText';
			}

			if(data.shoppingbasket.basketAddStatus == 1) {
				showToolTip(basketAmountContainerId,tipText);
			} // end: if

			resetCookie();
		} // end: if
	} // end: if
} // end: function

function resetCookie() {
	var cookieData = cookie_get('mb3pc');
	if (cookieData && typeof cookieData != 'undefined') {
		var data = JSON.parse(cookieData);

		if (data) {
			data.shoppingbasket.basketAddStatus = "0";
			cookieDataUpdated = JSON.stringify(data);
			cookie_set('mb3pc',cookieDataUpdated,'','/');
		}// end: if

	} // end: if
}// end: function

function isBasketEmpty(){
	var cookieData  = cookie_get('mb3pc');
	var retval 	    = true;

	if (cookieData && typeof cookieData != 'undefined') {

		var data = JSON.parse(cookieData);
		if (data) {
			if (typeof data.shoppingbasket != 'undefiend' && data.shoppingbasket.articlesAmount != 0) {
				retval = false;
			}
		}
	}
	return retval;
}

/**
* performs delivery address name change submit defined by ctype and uid
*
* @access public
* @param ctype the name of the extension
* @param uid the uid of the pageelement
* @return void
*/
function deliveryAddressChangeName(ctype, uid) {
	var form = document.getElementById(ctype + '[' + uid + ']' + '[form]');
	if (form) {
		document.getElementById(ctype + '[' + uid + ']' + '[action]' + '[changeDeliveryCustomer]').value = "loadDeliveryAddress";
		form.submit();
	} // end: if
} // end: function


// delete Orderline
function deleteOrderline( uid, name, orderlinePK ){
	var obj = document.getElementById('deleteOrderline');
	var tmp = uid.split('_');
	var parent_uid = tmp[0];
	var formObj = document.getElementById('dmc_mb3_shoppingbasket_pi1['+parent_uid+'][form]');
	if (confirm (deleteOrderlineNotice) == true){
		obj.name = name;
		obj.value = orderlinePK;
		formObj.submit();
	}

}

// this function triggers a move or copy action
function moveOrderline(uid, basicFieldName, actionType, orderlinePk, fromValue, toValue){

	// orderlinePk: assign a dummy hidden field with the correct name and value
	var obj 	= document.getElementById(fromValue+'ActionIdentifier');
	obj.name 	= basicFieldName+'[action]['+actionType+']['+orderlinePk+']';
	obj.value 	= orderlinePk;

	// to (OrderVO name): assign a dummy hidden field with the correct name and value
	var obj2 	= document.getElementById(fromValue+'OrderlineTo');
	obj2.name 	= basicFieldName+'[orderlineTo]';
	obj2.value 	= toValue;

	// from (OrderVO name): assign a dummy hidden field with the correct name (value is preset at the template!)
	var obj3 	= document.getElementById(fromValue+'OrderlineFrom');
	obj3.name 	= basicFieldName+'[orderlineFrom]';
	obj3.value 	= fromValue;

	var tmp 		= uid.split('_');
	var parentUid 	= tmp[0];

	// determine the extension name
	if( fromValue == 'shoppingcart' ) {
		var extensionName = 'dmc_mb3_shoppingbasket_pi1';
	} else if( fromValue == 'notepad' ) {
		var extensionName = 'dmc_mb3_notepad_pi1';
	} else if( fromValue == 'giftdesk' ) {
		var extensionName = 'dmc_mb3_giftdesk_pi1';
	}

	var formObj = document.getElementById(extensionName+'['+parentUid+'][form]');
	formObj.submit();
}

// Shows or hides payment, delivery and subdelivery radio buttons dependent
// on which options are allowed in the given context (for example 'prepayment'
// is not allowed in combination with '24h express' delivery.
function updatePaymentAndDeliveryTypeVisibility() {
	var $ = jQuery;

	// Find involved radio buttons and labels.
	var radioPrepayment = $('#payment_prepayment');
	var labelPrepayment = $('label[for=payment_prepayment]');
	var radio24hExpress = $('#input_deliverysubtype_24hexpress');
	var label24hExpress = $('label[for=input_deliverysubtype_24hexpress]');

	// Show or hide involveld radion buttons and labels dependent on the
	// current context.
	if (radioPrepayment.size()&& radio24hExpress.size()) {
	 	if (radioPrepayment.attr('checked')) {
			radio24hExpress.hide();
			label24hExpress.hide();
		} else {
			radio24hExpress.show();
			label24hExpress.show();
	 	} // end: if

	 	if (radio24hExpress.attr('checked')) {
			radioPrepayment.hide();
			labelPrepayment.hide();
		} else {
			radioPrepayment.show();
			labelPrepayment.show();
	 	} // end: if
	} // end: if
} // end: function updatePaymentAndDeliveryTypeVisibility

/**
 * toggles function fot the the delivery address/packstation address
 *
 * @access public
 * @parameters ctype				the ctype
 * @parameters uid					the uid
 * @parameters state				boolean
 * @parameters checkboxId			the checkboxid
 * @parameters containerId			the containerid , the div box
 * @parameters actionName			the actionname
 * @parameters actionSetValue		the actionsetvalue for the next step
 * @parameters actionUnsetValue		the actionunsetvalue for the next step
 * @parameters todos				pass the function
 * @return void
 */
(function() {
	function toggleBox(ctype, uid, state, checkboxId, containerId, actionName, actionSetValue, actionUnsetValue, todos) {
		var checkbox = $('#' +checkboxId);
		var container = $('#' +containerId);

		var visible = ((container.css('display') != 'none') && (container.css('visibility') != 'hidden'));

		if ((!state || !visible) && (state !== false || visible)) {

			if (typeof todos == 'function') {
				todos();
			}

			container.animate({height: 'toggle', opacity: 'toggle'}, 'normal');
			checkbox.attr('checked', !visible);

			if (visible) {
				shoppingbasketFormChangeAction(ctype, uid, actionSetValue, actionUnsetValue);

			} else {
				shoppingbasketFormChangeAction(ctype, uid, actionSetValue, actionSetValue);
			} // end: if
		} // end: if
	}  // end: function toggleDeliveryAddress

	window.toggleLoginCustomer = function(ctype, uid, state) {
		toggleBox(ctype, uid, state, 'loginCustomerCheckbox', 'loginCustomerForm',
			'loginCustomer', 'loginCustomer', 'unsetloginCustomer'
		);
	}  // end: function toggleLoginCustomer


	window.toggleDeliveryAddress = function(ctype, uid, state) {
		toggleBox(ctype, uid, state, 'deliveryAddressCheckBox', 'shippingAddress_deliverycustomer',
			'deliveryAddress', 'deliveryAddress', 'unsetDeliveryAddress',
			function() {
				var elem = document.getElementById(ctype + '[' + uid + '][shippingAddress]');
				togglePackstationAddress(ctype, uid, false)
				elem.value = (elem.value == 2) ? 1 : 2;
			}
		);
	}  // end: function toggleDeliveryAddress


	/**
	 * toggles the packstation address
	 *
	 * @access public
	 * @return void
	 **/
	window.togglePackstationAddress = function(ctype, uid, state) {
		toggleBox(ctype, uid, state, 'packstationAddressCheckBox', 'packstationAddressForm',
			'delivery', 'shippingAddress', 'unsetDelivery',
			function() {
				var elem = document.getElementById(ctype + '[' + uid + '][shippingAddress]');
				toggleDeliveryAddress(ctype, uid, false)
				elem.value = (elem.value == 3) ? 1 : 3;
			}
		);
	}  // end: function togglePackstationAddress

})();


/*
 * function.js
 *
 * The content of this file is (c) 2003 - 2007 dmc
 * digital media center GmbH
 * All rights reserved
 *
 * This software is the confidential and proprietary
 * information of dmc digital media center GmbH.
 *
 */


/**
 * tooltip methods for the newsletter extension
 *
 * $Id: functions.js 3266 2007-05-16 08:26:34Z toegerol $
 */

var mouseX 			= 0;
var mouseY 			= 0;
var tooltip 		= null;

/**
*
* @access public
* @param  e
* @return void
*/
function getMouseXY(e) {

	if (document.all) {
		mouseX = window.event.x + document.body.scrollLeft;
		mouseY = window.event.y + document.body.scrollTop;

	} else {
		var Element = e.target;

		var CalculatedTotalOffsetLeft 	= 0;
		var CalculatedTotalOffsetTop 	= 0;
		while (Element.offsetParent)
		{
			CalculatedTotalOffsetLeft = Element.offsetLeft;
			CalculatedTotalOffsetTop = Element.offsetTop;
			Element = Element.offsetParent;
		} ;

		mouseX = e.pageX - CalculatedTotalOffsetLeft;
		mouseY = e.pageY - CalculatedTotalOffsetTop;
	} // end: if
} // end: function

/**
*
* @access public
* @param  x
* @param  y
* @return void
*/
function updateTooltip(x, y) {

	if (tooltip != null) {
		tooltip.style.left	= (x + 10) + 'px';
		tooltip.style.top 	= (y + 10) + 'px';
	} // end: if
} // end: function

/**
*
* @access public
* @param  id
* @return void
*/
function showTooltip(id) {
	tooltip = document.getElementById(id);

	if (tooltip.innerHTML != '') {
		tooltip.style.display 		= 'block';
		tooltip.style.visibility	= 'visible';
	} // end: if
} // end: function

/**
*
* @access public
* @return void
*/
function hideTooltip() {
	tooltip.style.display 		= 'none';
	tooltip.style.visibility	= 'hidden';

	tooltip = null;
} // end: function

function orderFormChangeAction(ctype, uid, actionName, actionValue, additionalParam, lineNumberIn) {
	var form			= document.getElementById(ctype + '[' + uid + ']' + '[form]');
	var action			= document.getElementById(ctype + '[' + uid + ']' + '[action]');


	if(additionalParam != null) {
		additionalParam	= '[' + additionalParam + ']';
	}else{
		additionalParam = '';
	}

	if(lineNumberIn != null) {
		lineNumber	= lineNumberIn;
	}

	if (action) {
		action.name		= ctype + '[' + uid + '][action][' + actionName + ']' + additionalParam;
		action.value	= actionValue;
	}

	if( checkOrderlineFields(lineNumber) == true){
		form.submit();
	}
}

function setDivVisible(field) {
	if (document.getElementById('selectbox_' + field).length > 0) {
		document.getElementById('selectdiv_' +field).style.marginLeft = "0px";
    document.getElementById('cartBoxDirectHeight').style.minHeight  = "210px";
	}
}

function setDivInvisible(field){
  document.getElementById('selectdiv_' +field).style.marginLeft = "-1000px";
  document.getElementById('cartBoxDirectHeight').style.height = "auto";
}

function setupFields() {

	for (var lineNumber=0; lineNumber < numberOfOrderlines; lineNumber++) {
		updateSize(lineNumber);
	}
}

function updateSize(lineNumber) {
	// find size text field and clear it
	var inputSize = document.getElementById('text_size_' + lineNumber);
	var alreadyUpdated = inputSize.alreadyUpdated;
	var oldSize = '';
	var oldSizeStillAvailable = false;

	if (!alreadyUpdated) {
		inputSize.alreadyUpdated = true;
	} else {
		inputSize.className = inputSize.className.replace('error', 'noError');
		oldSize = inputSize.value;
		inputSize.value = '';
	}

	// removes all options from the selectbox
	var selectboxSize = document.getElementById('selectbox_size_'+lineNumber);

	for (var i=selectboxSize.length; i > 0; i--) {
    selectboxSize.options[i-1] = null;
	}


	// adds available options from the array to the selectbox
	var artnumber = document.getElementById('text_artnumber_'+lineNumber).value;
	if (artnumber) {
		if (articleData[artnumber]) {
			for (var size in articleData[artnumber]) {
				if (typeof(articleData[artnumber][size]) == 'object') {
					if (oldSize !== '' && size == oldSize) {
						oldSizeStillAvailable = true;
					}
					newoption = new Option(size);
          selectboxSize.options[selectboxSize.length] = newoption;
          //document.getElementById('selectbox_size_0').size = selectboxSize.length;
	 			}
			}
		}
	}

	if (oldSizeStillAvailable) {
		inputSize.value = oldSize;
	} else {
		//preset the first option if there is only one or invalid option
		if (selectboxSize.length == 1 ||
			(selectboxSize.length > 0 && (!inputSize.value))) {
			inputSize.value = selectboxSize.options[0].text;
		}
	}

	if(inputSize.value=='-'){
		document.getElementById('text_size_'+lineNumber).readOnly=true;
	}

	updateColor(lineNumber);
}


function updateColor(lineNumber) {
	// find color text field and clear it
	var inputColor = document.getElementById('text_color_' + lineNumber);
	var alreadyUpdated = inputColor.alreadyUpdated;
	var oldColor = '';
	var oldColorStillAvailable = false;

	if (!alreadyUpdated) {
		inputColor.alreadyUpdated = true;
	} else {
		inputColor.className = inputColor.className.replace('error', 'noError')
		oldColor = inputColor.value;
		inputColor.value = '';
	}

	// removes all options from the selectbox
	var selectboxColor = document.getElementById('selectbox_color_'+lineNumber);
	for (var i=selectboxColor.length; i > 0; i--) {
		selectboxColor.options[i-1] = null;
	}

	// adds available options from the array to the selectbox
	var artnumber = document.getElementById('text_artnumber_'+lineNumber).value;
	var size 	  = document.getElementById('text_size_'+lineNumber).value;

	if (artnumber && size) {
		if (articleData[artnumber]) {

			for (var color in articleData[artnumber][size]) {
				if (typeof(articleData[artnumber][size][color]) == 'object') {
					if (oldColor !== '' && color === oldColor) {
						oldColorStillAvailable = true;
					}

					newoption = new Option(color);
					selectboxColor.options[selectboxColor.length] = newoption;
				}
			}
		}
	}

	if (oldColorStillAvailable) {
		inputColor.value = oldColor;
	} else {
  	//preset the first option if there is only one or invalid option
		if (selectboxColor.length == 1 ||
  			(selectboxColor.length > 0 && (!inputColor.value))) {
			inputColor.value = selectboxColor.options[0].text;
		}
	}

	//updateStaticFields(lineNumber);
	updateGravure(lineNumber);
}



function updateStaticFields(lineNumber) {

	// sets static fields depending on the selection of the fields
	// 'artnumber', 'variation', 'size', 'color' and 'amount'
	var artnumber = document.getElementById('text_artnumber_'+lineNumber).value;
	var size 	  = document.getElementById('text_size_'+lineNumber).value;
	var color 	  = document.getElementById('text_color_'+lineNumber).value;
	var amountField = document.getElementById('text_amount_'+lineNumber);
	// default settings
	var amountNum = '';
	var description = '';
	var imageURL	= clearGif;
	var imageHeight = 1;
	var productlink = '#';
	var singlePrice = '';
	var	totalPrice 	= '';
	var	stocktype	= '';
	var	stocktypecode	= '';
	var	stockunit	= '';
	var stocktypeHTML 	= '';
	var weeksToDelivery = 0;

	// field that depend on articlenumber only
	if (artnumber && articleData[artnumber]) {

		// if set it could display the producttext even before size and color is chosen.
		//description = articleData[artnumber]['text'];
		imageURL	= articleData[artnumber]['imageURL'];
		imageHeight = 40;
		productlink = 'product/' + articleData[artnumber]['productPk'] + '/group/' + articleData[artnumber]['groupPk'] + productURL;
	}

	if (artnumber){
		// remap artnumber
		var artNum = artnumber;
		if(artnumber.length>9){
			artNum = artnumber.substring(1);
		}

		var artNb1 = document.getElementById('ordernb1');
		artNb1.value = artNum.substring(0,3);
		var artNb2 = document.getElementById('ordernb2');
		artNb2.value = artNum.substring(3,6);
		var artNb3 = document.getElementById('ordernb3');
		artNb3.value = artNum.substring(6,9);
	}

	// fields that depend on all attributes
	if (artnumber && articleData[artnumber]
		&& articleData[artnumber][size] && articleData[artnumber][size][color]) {

		if (articleData[artnumber][size][color]['variation'] > 0) {
			description = description+'<BR />'+articleData[artnumber][size][color]['variation'];
		}
		singlePriceNum 	= (parseFloat(articleData[artnumber][size][color]['price'])).toFixed(2);
		amountNum 		= parseInt(amountField.value);

		if (isNaN(amountNum) || amountNum <= 0) {
			amountNum = 1;
		} else if (amountNum > 100) {
			amountNum = 100;
		}

		amountField.className = amountField.className.replace('formError', 'noError');

		if (isNaN(singlePriceNum))  {
			singlePrice = '';
		} else {
			singlePrice = singlePriceNum+' '+currency;
		}
		if (isNaN(singlePriceNum))  {
			totalPrice = '';
		} else {
			totalPrice = (singlePriceNum * amountNum).toFixed(2)+' '+currency;
		}
		description = articleData[artnumber][size][color]['text'];
		stocktype	= stockTypeCodes[articleData[artnumber][size][color]['stocktype']];
		stocktypecode	= articleData[artnumber][size][color]['stocktype'];
		stockunit   = articleData[artnumber][size][color]['stockunit'];
		weeksToDelivery = articleData[artnumber][size][color]['weeksToDelivery'];

	}

	if(stocktypecode!='' && stocktype!=''){
		if (stocktypecode==2 && weeksToDeliveryInfo!='' && weeksToDelivery>0){
			stocktype = weeksToDeliveryInfo.replace('###weeksToDelivery###', weeksToDelivery);
		}
		stocktypeHTML = '<span class="stock_'+stocktypecode+'">'+stocktype+'</span>';
	}
	document.getElementById('text_amount_'+lineNumber).value = amountNum;
	document.getElementById('label_singleprice_'+lineNumber).innerHTML = singlePrice.replace('.',',');
	document.getElementById('label_totalprice_'+lineNumber).innerHTML = totalPrice.replace('.',',');
	document.getElementById('label_description_'+lineNumber).innerHTML = description;
	document.getElementById('label_stocktype_'+lineNumber).innerHTML = stocktypeHTML;
	document.getElementById('label_stockunit_'+lineNumber).innerHTML = stockunit;
	document.getElementById('label_image_'+lineNumber).src = imageURL;
	document.getElementById('label_image_'+lineNumber).width = imageHeight;
	document.getElementById('productlink_'+lineNumber).value = productlink;

	if (javaErrorcheck) {
		errorCheck(lineNumber);
	}

}


function errorCheck(lineNumber) {
	var error = false;
	var errorLabel = "";
	var artnumber  = document.getElementById('text_artnumber_'+lineNumber).value;
	var size 	   = document.getElementById('text_size_'+lineNumber).value;
	var color 	   = document.getElementById('text_color_'+lineNumber).value;
	var classname  = "";

	if (artnumber.length > 0) {

		if(articleData[artnumber]) {
			classname = document.getElementById('text_artnumber_' +lineNumber).className.replace("error", "noError");
			document.getElementById('text_artnumber_' +lineNumber).className = classname;
			document.getElementById('ordernb1').className = classname;
			document.getElementById('ordernb2').className = classname;
			document.getElementById('ordernb3').className = classname;
			if (size.length > 0) {
				if (articleData[artnumber][size]) {
					classname = document.getElementById('text_size_' +lineNumber).className.replace("error", "noError");
					document.getElementById('text_size_' +lineNumber).className = classname;
					if (color.length > 0) {
						if (articleData[artnumber][size][color]) {
							classname = document.getElementById('text_color_' +lineNumber).className.replace("error", "noError");
							document.getElementById('text_color_' +lineNumber).className = classname;
							if (articleData[artnumber][size][color]['stocktype'] == 3
							|| articleData[artnumber][size][color]['stocktype'] == 4
							) {
								errorLabel = 'soldout';
								document.getElementById('addToBasketEnabled_'+lineNumber).style.display = 'none';
								document.getElementById('addToBasketDisabled_'+lineNumber).style.display = 'block';

							} else {
								document.getElementById('addToBasketEnabled_'+lineNumber).style.display = 'block';
								document.getElementById('addToBasketDisabled_'+lineNumber).style.display = 'none';
							}
						} else {
							errorLabel = 'color';
						}
					}
				} else {
					errorLabel = 'size';
				}
			}
		} else {
			errorLabel = 'artnumber';
		}
	}

	if (errorLabel.length > 0) {

		var errorTextKey = errorLabel;

		if (errorLabel != 'soldout') {
			classname = document.getElementById('text_'+errorLabel+'_'+lineNumber).className.replace("noError", "error");
			document.getElementById('text_'+errorLabel+'_'+lineNumber).className = classname;
		}

		if(articleData['not_online']){
			errorTextKey = 'orderonline';
		}

		document.getElementById('error_'+lineNumber).innerHTML = errorTexts[errorTextKey];

		document.getElementById('errorbox_' +lineNumber).className = ' errorVisible';


		if(errorLabel == 'artnumber'){
			document.getElementById('ordernb1').className = classname;
			document.getElementById('ordernb2').className = classname;
			document.getElementById('ordernb3').className = classname;
		}
	} else {
		document.getElementById('errorbox_' +lineNumber).className = ' errorHidden';
	}
}

function fieldOnFocus(field, lineNumber) {

	var tmpValue = document.getElementById('text_'+field+'_'+lineNumber).value;
	if(tmpValue!='-'){
		document.getElementById('selectbox_'+field+'_'+lineNumber).selectedIndex = 0;
		setDivVisible(field+'_'+lineNumber);
		document.getElementById('selectbox_'+field+'_'+lineNumber).focus();
	}
}

function fieldOnBlur(field, lineNumber) {

	setDivInvisible(field+'_'+lineNumber);
}

function fieldOnChange(field, self, lineNumber) {
	var index = self.selectedIndex;
	if(index >= 0) {
		document.getElementById('text_'+field+'_'+lineNumber).value = self.options[index].text;
	};
}

function fieldOnClick(field, lineNumber, nextFocus) {
	fieldOnBlur(field, lineNumber);
	var nextField = document.getElementById(nextFocus);
	if (nextField) {
		nextField.focus();
	}
}

function addOrderline(lineNumber) {

	var numberOfOrderlines = parseInt(document.getElementById('numberOfOrderlines').value);
	/*/ if actual lineNumer is the last line of the orderform
	if ((numberOfOrderlines-1) == parseInt(lineNumber)) {
		template = document.getElementById('orderlineTemplate').innerHTML;
		template = template.replace(/JSMARKERNUM/g, numberOfOrderlines);
		template = template.replace(/JSMARKERPLUS/g, (numberOfOrderlines + 1));
		template = template.replace(/JSMARKERMOD2/g, (numberOfOrderlines % 2));
		document.getElementById('addOrderline_'+numberOfOrderlines).innerHTML = template;
		document.getElementById('numberOfOrderlines').value = numberOfOrderlines + 1;
	}*/
}

function retrieveArticleData(lineNumber) {

	var artnumber = document.getElementById('text_artnumber_'+lineNumber).value;
	ajaxCall = false;

	if (artnumber.length > 0) {
		if (typeof(articleData[artnumber]) == 'object') {
			//article data already exists
		} else {
			ajaxCall = useAjax;
		}
	}

	if (ajaxCall) {

		cp.call('/typo3conf/ext/dmc_mb3_orderform/ajaxGetArticleData.php',
						'getArticleData',
						response,
						artnumber,
						clientPk,
						languagePk,
						lineNumber);

	} else {

		updateSize(lineNumber);
	}
}

function response(result) {

	var artnumber = result['data']['artnumber'];
	var lineNumber = result['data']['lineNumber'];

	articleData['not_online'] = false;
	if (result['data']['status'] == 'found') {
		articleData[artnumber] = result['data']['properties'];
	}else if (result['data']['status'] == 'not_online') {
		articleData['not_online'] = true;
	}

	document.getElementById('text_artnumber_'+lineNumber).value = artnumber;
	updateSize(lineNumber);
	document.getElementById('text_size_'+lineNumber).focus();
	fieldOnFocus('size',lineNumber);
}

function productInfoPopup(productlinkId,titleId) {

	var popupurl = document.getElementById(productlinkId).value;
	var title = document.getElementById(titleId);
	if (title) {
		title = title.textContent;
	} else {
		title = '';
	}
	openJQueryPopupWindow(popupurl,title,'width=705,height=510,scrollbars=yes,resizable=no,toolbar=no,status=no,directories=no,menubar=no,location=no')

}

function nextField(e, source, dest, fieldlen) {
 	if (!e) var e = window.event;

 	// Keine Controlchars
 	if (e.keyCode > 32)
 	{
 		if (source.value.length == fieldlen)
 		{
 			dest.value='';
 			dest.focus();
 		}
 	}
} //function

function checkArtNumberField (e, artNumberFieldId, lineNumber) {
	var artNb1 = document.getElementById('ordernb1');
	var artNb2 = document.getElementById('ordernb2');
	var artNb3 = document.getElementById('ordernb3');
	var artNb = artNb1.value+artNb2.value+artNb3.value;

	var artNumberField = document.getElementById(artNumberFieldId);

	if (!e) var e = window.event;
 	// Keine Controlchars
 	if (e.keyCode > 32)
 	{
	 	if (artNumberField && artNb.length == 9) {
	 		artNumberField.value = artNb;
	 		addOrderline(lineNumber)
	 		retrieveArticleData(lineNumber)
	 	}//if
	 }
}//function

function checkOrderlineFields(orderlineNum){

		if( !articleData || articleData['not_online'] ){
			return false;
		}

		var boolReturn = true;

		var amountFieldId = 'text_amount_'+orderlineNum;
		var yardWareFieldId = 'label_stockunit_'+orderlineNum;

		// Anzahl
		var amountObj = document.getElementById(amountFieldId);
		var yardWare  = document.getElementById(yardWareFieldId).innerHTML;

		onb1 = document.getElementById('ordernb1');
		onb2 = document.getElementById('ordernb2');
		onb3 = document.getElementById('ordernb3');

		// prevent form from being sent if article number fields are not filled correctly
		if(onb1.value.length==3 && onb2.value.length==3 && onb3.value.length==3){
			artnumber=onb1+onb2+onb3;
		}else{
			onb1.className = 'error';
			onb2.className = 'error';
			onb3.className = 'error';
			document.getElementById('error_'+orderlineNum).innerHTML = errorTexts['artnumber'];
			document.getElementById('errorbox_' +orderlineNum).className = ' errorVisible';

			return false;
		}


		var gravureFieldId 		= 'orderlineGravureForm_'+orderlineNum;
		var gravureFieldTextId	= 'orderlineGravureText_'+orderlineNum;
		var gravureFieldCount	= 0;
		var gravureFieldLength	= 0;

		if(	document.getElementById('orderlineGravureHeadline_'+orderlineNum).value > 0
				&& document.getElementById('orderlineGravureLength_'+orderlineNum).value > 0 ){

			gravureFieldCount	= parseInt(document.getElementById('orderlineGravureHeadline_'+orderlineNum).value);
			gravureFieldLength	= parseInt(document.getElementById('orderlineGravureLength_'+orderlineNum).value);
		}
		var gravureObj			= document.getElementById(gravureFieldId)

		var gravureText = '';
		var gravureTextPlain = '';
		var gravureTextArr = new Array();

		if (gravureObj && gravureFieldCount>0 && gravureFieldLength>0){

			for (var i=0; i<gravureFieldCount; i++){
				var iptValue = document.getElementById('orderlineGravureText_' + orderlineNum + '_'+i).value;
				gravureTextArr[i] = iptValue;
			}

			gravureTextPlain = gravureTextArr.join('');
			gravureText = gravureTextArr.join(textGravureSeparator);

			// Gültige Zeichen prüfen
			strPattern = /[^\x20-\xFF]/;

			if (gravureTextPlain.search(strPattern) != -1 || gravureTextPlain.search(textGravureSeparator)!=-1)
			{
				alert(noticeGravureError);
				boolReturn = false;
			}else{
				document.getElementById(gravureFieldId).value = gravureText;
			}

			// Wenn Feld leer dann Abfrage
			if (gravureTextPlain == "")
			{
				if (confirm(noticeGravureNo))
				{
					document.getElementById(gravureFieldId).value = textGravureSeparator;
				}
				else
				{
					boolReturn = false;
				}
			}

		} // end: gravure

		if (amountObj)
		{
			// Meterware ?
			if (yardWare && yardWare== "M")
			{
				var splitText= noticeYardWare.split('||');
				if (confirm (splitText[0] + (amountObj.value * 10) + splitText[1] + amountObj.value + splitText[2]) == false)
				{
					amountObj.value = 1;
					amountObj.focus();
					boolReturn = false;
				}
			}
			else if (amountObj.value >= 10)
			{
				var splitText= noticeAmount.split('||');
				if (confirm (splitText[0] + amountObj.value + splitText[1]) == false)
				{
					amountObj.value = 1;
					amountObj.focus();
					boolReturn = false;
				}
			}else{
				// do nothing
			}
		}
		return(boolReturn);
	}

function updateGravure(lineNumber) {

		var artnumber  = document.getElementById('text_artnumber_'+lineNumber).value;
		var size 	   = document.getElementById('text_size_'+lineNumber).value;
		var color 	   = document.getElementById('text_color_'+lineNumber).value;
		var gravureInput		= document.getElementById('orderlineGravureInput_' + lineNumber);
		var gravureMessage		= document.getElementById('orderlineGravureMessage_' + lineNumber);
		var gravureForm			= document.getElementById('orderlineGravureForm_' + lineNumber);
		var gravureInfo			= document.getElementById('orderlineGravureInfo_' + lineNumber);


		var gravureLength		= document.getElementById('orderlineGravureLength_' + lineNumber);
		var gravureHeadline		= document.getElementById('orderlineGravureHeadline_' + lineNumber);


		var gravureFieldCount = 0;
		var gravureFieldLength = 0;


		if (articleData[artnumber] && articleData[artnumber][size] && articleData[artnumber][size][color]) {
			gravureFieldLength	= parseInt(articleData[artnumber][size][color]['gravurelength']);
			gravureFieldCount	= parseInt(articleData[artnumber][size][color]['gravureheadline']);
		}

		gravureLength.value		= gravureFieldLength;
		gravureHeadline.value	= gravureFieldCount;

		actualFieldCount = gravureInput.getElementsByTagName('input').length;

		if(gravureFieldCount != actualFieldCount || articleData['status'] != 'found'){

			gravureInput.innerHTML = '';
			gravureMessage.innerHTML = '';
			gravureInput.style.visibility	= 'hidden';
			gravureInput.style.display	= 'none';
			gravureInfo.style.visibility	= 'hidden';
			gravureInfo.style.display	= 'none';


			if (gravureMessage && gravureFieldLength>0 && gravureFieldCount>0){
				var mParts = gravureMessageBefore.split('||');
				var newText = mParts[0] + gravureFieldLength + mParts[1];
				gravureMessage.innerHTML = newText;
			}

			// create Input Fields according to article values
			if (gravureFieldCount>0 && gravureFieldLength>0) {
					for (var i=0; i<gravureFieldCount; i++){
						var br = document.createElement('br');
						var ipt = document.createElement('input');
						ipt.setAttribute('maxLength',gravureFieldLength);
						ipt.setAttribute('id', 'orderlineGravureText_' + lineNumber + '_'+i, true);
						ipt.value='';
						if (gravureForm.value){
							var metadata = gravureForm.value;
							var rows = metadata.split(textGravureSeparator);
							if(!rows[i]||rows[i]==undefined){
								ipt.value = '';
							}else{
								ipt.value = rows[i];
							}
						}
						ipt.name='orderlineGravureText_' + lineNumber + '['+i+']';
						ipt.style.width='307px';

						gravureInput.appendChild(ipt);
						gravureInput.appendChild(br);
					}
					gravureInput.style.visibility	= 'visible';
					gravureInput.style.display	= '';

					gravureInfo.style.visibility	= 'visible';
					gravureInfo.style.display	= '';
			}
	}
	updateStaticFields(lineNumber);
}



	function addToNotepad(uid, id) {



		var form				= document.getElementById('notepadForm_' + uid);
		var notepadArticlePk	= document.getElementById('notepadArticlePk_' + uid);
		var notepadProductPk	= document.getElementById('notepadProductPk_' + uid);
		var notepadAmount		= document.getElementById('notepadAmount_' + uid);

		var amountForm		= document.getElementById('productAmountForm_' + uid + '_' + id);
		var variation		= currentVariation(uid, id);
		var size			= currentSize(uid, id, variation);
		var color			= currentColor(uid, id, variation, size);
		var amount			= 0;



		if (amountForm) {
			amount = amountForm.value;
		}

		if (form && notepadArticlePk && notepadProductPk && amount > 0) {
			notepadArticlePk.value 	= productConf[uid][id]['articles'][variation][size][color]['articlePk'];
			notepadProductPk.value 	= id;
			notepadAmount.value		= amount;
			form.submit();
		}
	}


	/**
	* This is used for the extension specific functions
	*
	* @package		mb3p
	* @subpackage	notepadcached
	* @access		public
	* @author	    Boris Azar
	* @version		1.0.0
	*/
	var dmc_mb3_notepadcached = {

		// public method for url decoding
		decode : function (data) {
			var lsRegExp = /\+/g;
			// Return the decoded string
			return this.decodeUtf8(unescape(String(data).replace(lsRegExp, " ")));
		},

		/**
		* decodes a string in utf8
		*
		* @param string 	utftext							string to be decoded
		* @return void
		*/
		decodeUtf8: function (utftext) {
			var plaintext = "";
			var i=0;
			var c=0;
			var c1=0;
			var c2=0;

			// while-Schleife, weil einige Zeichen uebersprungen werden
			while(i<utftext.length) {
				c = utftext.charCodeAt(i);
				if (c<128) {
					plaintext += String.fromCharCode(c);
					i++;
				} else if((c>191) && (c<224)) {
					c2 = utftext.charCodeAt(i+1);
					plaintext += String.fromCharCode(((c&31)<<6) | (c2&63));
					i+=2;
				} else {
					c2 = utftext.charCodeAt(i+1); c3 = utftext.charCodeAt(i+2);
					plaintext += String.fromCharCode(((c&15)<<12) | ((c2&63)<<6) | (c3&63));
					i+=3;
				}
			}

			return plaintext;
		 } // end: function

	}

	/**
	* Notepadcached function
	*
	* @package		mb3p
	* @subpackage	notepadcached
	* @access		public
	* @author	    Boris Azar
	* @version		1.0.0
	*/

	/**
	* Sets a cookie
	*
	* @param string 	notepadAmountContainerId			id of the notepadAmountContainer
	* @param string 	notepadArticleAmountContainerId		id of the notepadArticleAmountContainer
	* @return void
	*/
	function fillNotepadWithData(notepadAmountContainerId, notepadArticleAmountContainerId, tipText) {
		var notepadArticlesAmountContainer = document.getElementById(notepadArticleAmountContainerId);
		var notepadAmountContainer = document.getElementById(notepadAmountContainerId);

		var cookieData = cookie_get('mb3pc');
		if (cookieData && typeof cookieData != 'undefined') {

			var data = JSON.parse(cookieData);
			if (data && typeof data.notepad != 'undefined') {
				// get the notepadArticlesAmountContainer object and set data in it
				if (notepadArticlesAmountContainer
					&& typeof data.notepad.articlesAmount != 'undefined') {

					// do not forget to decode the data (+ signs are converted back to spaces)
					notepadArticlesAmountContainerValue = dmc_mb3_notepadcached.decode(data.notepad.articlesAmount);

					// get the notepadArticlesAmountContainer object and set data in it
					if (notepadArticlesAmountContainer) {
						// do not forget to decode the data (+ signs are converted back to spaces)
						notepadArticlesAmountContainer.innerHTML = notepadArticlesAmountContainerValue;
					} // end: if

				} // end: if

				// get the notepadAmountContainer object and set data in it
				if (notepadAmountContainer
					&& typeof data.notepad.notepadAmount != 'undefined') {

					// do not forget to decode the data (+ signs are converted back to spaces)
					notepadAmountContainerValue = dmc_mb3_notepadcached.decode(data.notepad.notepadAmount);

					// get the notepadAmountContainer object and set data in it
					if (notepadAmountContainer) {
						// do not forget to decode the data (+ signs are converted back to spaces)
						notepadAmountContainer.innerHTML = notepadAmountContainerValue;
					} // end: if
				} // end: if

				if(data.notepad.notepadAddStatus == 1) {
					showToolTip(notepadAmountContainerId,tipText);
				} // end: if

				resetNotepadCookie();
			} // end: if
		} // end: if
	} // end: function

	function resetNotepadCookie() {
		var cookieData = cookie_get('mb3pc');
		if (cookieData && typeof cookieData != 'undefined') {
			var data = JSON.parse(cookieData);

			if (data) {
				data.notepad.notepadAddStatus = "0";
				cookieDataUpdated = JSON.stringify(data);
				cookie_set('mb3pc',cookieDataUpdated,'','/');
			} // end: if

		} // end: if
	} // end: function

	function isNotepadEmpty(){
		var cookieData  = cookie_get('mb3pc');
		var retval 	    = true;

		if (cookieData && typeof cookieData != 'undefined') {

			var data = JSON.parse(cookieData);
			if (data) {
				if (typeof data.notepad != 'undefined' && data.notepad.articlesAmount != 0) {
					retval = false;
				}
			}
		}
		return retval;
	}



	function checkFieldsNotepad(uid, id, variation, size, color)
	{
		boolReturn = true;
		var amountFieldId = 'productAmountForm_'+uid+'_'+id;
		var yardWareFieldId = null;
		var gravureFieldId = 'notepadGravure_'+uid;
		var gravureFieldTextId = 'productGravureText_'+uid+'_'+id;
		var gravureFieldCount = parseInt(productConf[uid][id]['articles'][variation][size][color]['gravureText']);
		var gravureFieldLength = parseInt(productConf[uid][id]['articles'][variation][size][color]['gravureLength']);
		var gravureObj = document.getElementById('productGravureForm_'+uid+'_'+id);


		var gravureText = '';
		gravureTextPlain = '';
		var gravureTextArr = new Array();

		// only check if article has gravure
		if (gravureObj && gravureFieldCount>0 && gravureFieldLength>0) {

			for (var i=0; i<gravureFieldCount; i++) {
				var iptValue = document.getElementById('productGravureText_' + uid + '_' + id + '_'+i).value;
				gravureTextArr[i] = iptValue;
			}

			gravureTextPlain = gravureTextArr.join('');
			gravureText = gravureTextArr.join(textGravureSeparator);

			// check valid characters

			strPattern = '/[^\x20-\xFF]/';

			if (gravureTextPlain.search(strPattern) != -1 || gravureTextPlain.search(textGravureSeparator)!=-1) {
				alert(noticeGravureError);
				boolReturn = false;
			} else {
				document.getElementById(gravureFieldId).value = gravureText;
			}

			// Wenn Feld leer dann Abfrage
			if (gravureTextPlain == "") {
				if (confirm(noticeGravureNo)) {
					document.getElementById(gravureFieldId).value = textGravureSeparator;
					// set separator if empty, otherwise we do not know if orderline has gravure
				} else {
					boolReturn = false;
				}
			}
		} // end: gravure

		// Anzahl
		var amountObj = document.getElementById(amountFieldId);
		var yardWare = productConf[uid][id]['articles'][variation][size][color]['stockUnit'];

		if (amountObj)
		{
			// Meterware ?
			if (yardWare && yardWare== "M")
			{
				var splitText= noticeYardWare.split('||');
				if (confirm (splitText[0] + (amountObj.value * 10) + splitText[1] + amountObj.value + splitText[2]) == false)
				{
					amountObj.value = 1;
					amountObj.focus();
					boolReturn = false;
				}
			}
			else if (amountObj.value >= 10)
			{
				var splitText= noticeAmount.split('||');
				if (confirm (splitText[0] + amountObj.value + splitText[1]) == false)
				{
					amountObj.value = 1;
					amountObj.focus();
					boolReturn = false;
				}
			}else{
				// do nothing
			}
		}

		return boolReturn;
	}

	function addToNotepadSubmit(uid, id, target, popup, url, popupParams) {


		var variation		= currentVariation(uid, id);
		var size			= currentSize(uid, id, variation);
		var color			= currentColor(uid, id, variation, size);
		if (checkFieldsNotepad(uid, id, variation, size, color)){
			if (popup) {
				var form			= document.getElementById('notepadForm_' + uid);
				form.action 		= url;

				// do NOT load page from 'url' variable here! race condition w/ 2 Apache threads!
				var POPUP = window.open('/clear.gif', target, popupParams);
				POPUP.focus();
				
			}
			addToNotepad(uid, id);
		}
	}


/*
 * function.js
 *
 * The content of this file is (c) 2003 - 2007 dmc
 * digital media center GmbH
 * All rights reserved
 *
 * This software is the confidential and proprietary
 * information of dmc digital media center GmbH.
 *
 */

/**
 * function
 *
 * $Id: functions.js 3267 2007-05-16 08:33:45Z toegerol $
 */

/**
* this function works in combination with product extension
* it uses the productConf array created by the product extension
* so it may not work anywhere else than productdetail pages...
*
* @access public
* @param  uid
* @param  id
* @param  url
* @param  popupWidth
* @param  popupHeight
* @return void
*/
function articleFeedbackLink(uid, id, url, popupWidth, popupHeight) {
	var artNumber 		= '';
	var variation		= '';
	var size			= '';
	var color			= '';

	if (!popupWidth) {
		popupWidth = 560;
	}

	if (!popupHeight) {
		popupHeight = 750;
	}

	// find currently selected article number
	variation	= currentVariation(uid, id);
	size		= currentSize(uid, id, variation);
	color		= currentColor(uid, id, variation, size);

	artNumber	= productConf[uid][id]['articles'][variation][size][color]['artNumber'];

	//change/render document.location
	//document.location.href = url.replace('%s', artNumber);
	popupurl = url.replace('%s', artNumber);

	var popup_productFeedback = window.open(popupurl, 'popup_productFeedback', 'width=' + popupWidth + ',height=' + popupHeight + ',scrollbars=yes,resizable=yes,toolbar=no,status=no,directories=no,menubar=no,location=no');
	popup_productFeedback.focus();
}

function backToFormView(ctype, uid) {
	var preview			= document.getElementById('preview');
	var form			= document.getElementById(ctype + '[' + uid + ']' + '[form]');

	if (preview) {
		preview.value = -1;
	}
	if(form){
	form.submit();
	}
}


/**
* Show popup window for the cheaper product feedback form
*
* @access public
* @param  uid
* @param  id
* @param  url
* @param  popupWidth
* @param  popupHeight
* @return void
*/
function cheaperProductFeedbackLink(uid, id, url, popupParams) {
	var artNumber 		= '';
	var variation		= '';
	var size			= '';
	var color			= '';

	if (typeof popupParams != 'string' || popupParams == '') {
		popupParams = 'scrollbars=yes,resizable=yes,toolbar=no,status=no,directories=no,menubar=no,location=no';
	} // end: if

	// find currently selected article number
	variation	= currentVariation(uid, id);
	size		= currentSize(uid, id, variation);
	color		= currentColor(uid, id, variation, size);

	artNumber	= productConf[uid][id]['articles'][variation][size][color]['artNumber'];

	//change/render document.location
	//document.location.href = url.replace('%s', artNumber);
	popupurl = url.replace('%s', artNumber);

	var popup_cheaperProductFeedback = window.open(popupurl, 'popup_cheaperProductFeedback', popupParams);
	popup_cheaperProductFeedback.focus();
}
// this function works in combination with product extension
// it uses the productConf array created by the product extension
// so it may not work anywhere else than productdetail pages...
function articleRecommendLink(uid, id, url, popupParams) {
	var artNumber 		= '';
	var variation		= '';
	var size			= '';
	var color			= '';

	// find currently selected article number
	variation	= currentVariation(uid, id);
	size		= currentSize(uid, id, variation);
	color		= currentColor(uid, id, variation, size);

	artNumber	= productConf[uid][id]['articles'][variation][size][color]['artNumber'];

	//change/render document.location
	//document.location.href = url.replace('%s', artNumber);
	popupurl = url.replace('%s', artNumber);

	var popup_productRecommend = window.open(popupurl, 'popup_productRecommend', popupParams);
	popup_productRecommend.focus();
}

function backToFormView(ctype, uid) {
	var preview			= document.getElementById('preview');
	var form			= document.getElementById(ctype + '[' + uid + ']' + '[form]');

	if (preview) {
		preview.value = -1;
	}
	if(form){
	form.submit();
	}
}

/*
 * function.js
 *
 * The content of this file is (c) 2003 - 2007 dmc
 * digital media center GmbH
 * All rights reserved
 *
 * This software is the confidential and proprietary
 * information of dmc digital media center GmbH.
 *
 */


/**
 * functions to set pco actions
 *
 * $Id: functions.js 3272 2007-05-16 08:52:41Z toegerol $
 */


	/**
	* set a pco action to a defined action form field
	*
	* @access public
	* @param  ctype       the name of the extension
	* @param  uid         the uid of the pageelement
	* @param  newAction   the name of the pco action
	* @return void
	*/
	function pcoFormSetAction(ctype, uid, newAction) {

		var action			= document.getElementById(ctype + '[' + uid + ']' + '[pcoAction]');

		if (action) {
			action.value = newAction;
		} // end: if
	} // end: function


/**
* flag to prevent double submits by doubleclicks on buttons
*/
var loginFormSubmitFlag = false;
var logoutFormSubmitFlag = false;
var changePasswordSubmitFlag = false;
var autoLoginSubmitFlag = false;
var billingAddressSubmitFlag = false;
var deliveryAddressSubmitFlag = false;
var paymentTypeSubmitFlag = false;
var userProfileSubmitFlag = false;
var userNameSubmitFlag = false;

/**
* performs login form submit defined by ctype and uid
* and prevents a double click form submit
*
* @access public
* @param ctype the name of the extension
* @param uid the uid of the pageelement
* @return void
*/
function loginFormSubmit(ctype, uid) {
	var form = document.getElementById(ctype + '[' + uid + ']' + '[form]' + '[login]');
	if (loginFormSubmitFlag == false) {
		if (form) {
			loginFormSubmitFlag = true;
			form.submit();
		} // end: if
	} // end: if
} // end: function


/**
* performs change password form submit defined by ctype and uid
* and prevents a double click form submit
*
* @access public
* @param ctype the name of the extension
* @param uid the uid of the pageelement
* @return void
*/
function changePasswordFormSubmit(ctype, uid) {
	var form = document.getElementById(ctype + '[' + uid + ']' + '[form]' + '[changePassword]');
	if (changePasswordSubmitFlag == false) {
		if (form) {
			changePasswordSubmitFlag = true;
			form.submit();
		} // end: if
	} // end: if
} // end: function


/**
* performs auto login form submit defined by ctype and uid
* and prevents a double click form submit
*
* @access public
* @param ctype the name of the extension
* @param uid the uid of the pageelement
* @return void
*/
function autoLoginFormSubmit(ctype, uid) {
	var form = document.getElementById(ctype + '[' + uid + ']' + '[form]' + '[changeAutoLogin]');
	if (autoLoginSubmitFlag == false) {
		if (form) {
			autoLoginSubmitFlag = true;
			form.submit();
		} // end: if
	} // end: if
} // end: function

/**
* performs billing address form submit defined by ctype and uid
* and prevents a double click form submit
*
* @access public
* @param ctype the name of the extension
* @param uid the uid of the pageelement
* @return void
*/
function billingAddressFormSubmit(ctype, uid) {
	var form = document.getElementById(ctype + '[' + uid + ']' + '[form]' + '[billingcustomer]');
	if (billingAddressSubmitFlag == false) {
		if (form) {
			billingAddressSubmitFlag = true;
			form.submit();
		} // end: if
	} // end: if
} // end: function

/**
* performs delivery address form submit defined by ctype and uid
* and prevents a double click form submit
*
* @access public
* @param ctype the name of the extension
* @param uid the uid of the pageelement
* @return void
*/
function deliveryAddressFormSubmit(ctype, uid) {
	var form = document.getElementById(ctype + '[' + uid + ']' + '[form]' + '[deliverycustomer]');
	if (deliveryAddressSubmitFlag == false) {
		if (form) {
			deliveryAddressSubmitFlag = true;
			form.submit();
		} // end: if
	} // end: if
} // end: function


/**
* delete the existing delivery address defined by ctype and uid
*
* @access public
* @param ctype the name of the extension
* @param uid the uid of the pageelement
* @return void
*/
function deliveryAddressDelete(ctype, uid) {
	var form = document.getElementById(ctype + '[' + uid + ']' + '[form]' + '[deliverycustomer]');
	if (form) {
		document.getElementById(ctype + '[' + uid + ']' + '[action]' + '[changeDeliveryCustomer]').value = "deleteDeliveryCustomer";
		form.submit();
	} // end: if
} // end: function


/**
* performs delivery address name change submit defined by ctype and uid
*
* @access public
* @param ctype the name of the extension
* @param uid the uid of the pageelement
* @return void
*/
function deliveryAddressChangeName(ctype, uid) {
	var form = document.getElementById(ctype + '[' + uid + ']' + '[form]' + '[deliverycustomer]');
	if (form) {
		document.getElementById(ctype + '[' + uid + ']' + '[action]' + '[changeDeliveryCustomer]').value = "loadDeliveryAddress";
		form.submit();
	} // end: if
} // end: function


/**
* performs paymenttype form submit defined by ctype and uid
* and prevents a double click form submit
*
* @access public
* @param ctype the name of the extension
* @param uid the uid of the pageelement
* @return void
*/
function paymentTypeFormSubmit(ctype, uid) {
	var form = document.getElementById(ctype + '[' + uid + ']' + '[form]' + '[paymenttype]');
	if (paymentTypeSubmitFlag == false) {
		if (form) {
			paymentTypeSubmitFlag = true;
			form.submit();
		} // end: if
	} // end: if
} // end: function

/**
* performs userprofile form submit defined by ctype and uid
* and prevents a double click form submit
*
* @access public
* @param ctype the name of the extension
* @param uid the uid of the pageelement
* @return void
*/
function userProfileFormSubmit(ctype, uid) {
	var form = document.getElementById(ctype + '[' + uid + ']' + '[form]' + '[profile]');
	if (userProfileSubmitFlag == false) {
		if (form) {
			userProfileSubmitFlag = true;
			form.submit();
		} // end: if
	} // end: if
} // end: function

/**
* performs logout form submit defined by ctype and uid
* and prevents a double click form submit
*
* @access public
* @param ctype the name of the extension
* @param uid the uid of the pageelement
* @return void
*/
function logoutFormSubmit(ctype, uid) {
	var form = document.getElementById(ctype + '[' + uid + ']' + '[form]' + '[logout]');
	if (logoutFormSubmitFlag == false) {
		if (form) {
			logoutFormSubmitFlag = true;
			form.submit();
		} // end: if
	} // end: if
} // end: function

/**
* performs username change form submit defined by ctype and uid
* and prevents a double click form submit
*
* @access public
* @param ctype the name of the extension
* @param uid the uid of the pageelement
* @return void
*/
function changeUserNameSubmit(ctype, uid) {
	var form = document.getElementById(ctype + '[' + uid + ']' + '[form]' + '[changeUsername]');
	if (userNameSubmitFlag == false) {
		if (form) {
			userNameSubmitFlag = true;
			form.submit();
		} // end: if
	} // end: if
} // end: function

function getBike(formname,fieldname,boxnum,clientpk,isocode2) {
	var pickerBox = document.getElementById('pickerBox'+boxnum);
	var pickerBox1 = document.getElementById('pickerBox1');
	var pickerBox2 = document.getElementById('pickerBox2');
	if(pickerBox1 && pickerBox2 && pickerBox) {
		if(pickerBox1.style.display == 'none' && pickerBox1.id == pickerBox.id) {
			pickerBox1.innerHTML = poloPickerGenerateHTML(boxnum,formname,fieldname);
			pickerBox1.style.display = 'block';
			pickerBox2.style.display = 'none';
		}
		else if(pickerBox2.style.display == 'none' && pickerBox2.id == pickerBox.id) {
			pickerBox2.innerHTML = poloPickerGenerateHTML(boxnum,formname,fieldname);
			pickerBox2.style.display = 'block';
			pickerBox1.style.display = 'none';
		}
		else {
			pickerBox.style.display='none';
		} // end: if
	} // end: if
	else if((pickerBox1&&pickerBox)) {
		if(pickerBox1.style.display == 'none' && pickerBox1.id == pickerBox.id) {
			pickerBox1.innerHTML = poloPickerGenerateHTML(boxnum,formname,fieldname);
			pickerBox1.style.display = 'block';
		}
		else {
			pickerBox.style.display='none';
		} // end: if
	} // end: if
}// end: function

/**
* toggles order detail, close all other container concernig the boxPrefix and
* toggles the innHTML of the link concerning the linkPrefix
*
* @access	public
* @param	integer		num 		number identifing the row
* @param	string		offContent 	innerHTML of the link in off state
* @param	string		onContent 	innerHTML of the link in on state
* @param	string		boxPrefix 	prefix of the toggle container
* @param	string		linkPrefix 	prefix of the link that toggles
* @see		$('')
* @return	void
*/
function toggleDetail(num, offContent, onContent) {

	var boxPrefix 	= (arguments[3]) ? arguments[3] : 'detail-';
	var linkPrefix 	= (arguments[4]) ? arguments[4] : 'detaillink-';

	var pattern  = boxPrefix +'(.*)';

	var divs = document.getElementsByTagName('div');
	for (var i = 0; i < divs.length; i++) {

		var regex = '/'+ pattern +'/.exec(divs[i].id)';
		var match = eval(regex);

		if (match) {

			if (divs[i].id == boxPrefix + num) {

				divs[i].style.display = ( divs[i].style.display == 'none' ) ? "block" : "none";
				document.getElementById(linkPrefix + num).innerHTML = (document.getElementById(linkPrefix + num).innerHTML == offContent ) ? onContent : offContent;

			} else {

				divs[i].style.display = 'none';
				document.getElementById(linkPrefix + match[1]).innerHTML = offContent;
			}
		}
	}
}// end: function


/**
* This is used for the extension specific functions
*
* @package		mb3p
* @subpackage	shoppingbasketcached
* @access		public
* @author	    Boris Azar
* @version		1.0.0
*/
var dmc_mb3_usermanagementcached = {

	// public method for url decoding
	decode : function (data) {
		var lsRegExp = /\+/g;
		// Return the decoded string
		return this.decodeUtf8(unescape(String(data).replace(lsRegExp, " ")));
	},

	/**
	* decodes a string in utf8
	*
	* @param string 	utftext							string to be decoded
	* @return void
	*/
	decodeUtf8: function (utftext) {
		var plaintext = "";
		var i=0;
		var c=0;
		var c1=0;
		var c2=0;

		// while-Schleife, weil einige Zeichen uebersprungen werden
		while(i<utftext.length) {
			c = utftext.charCodeAt(i);
			if (c<128) {
				plaintext += String.fromCharCode(c);


				i++;

			} else if((c>191) && (c<224)) {
				c2 = utftext.charCodeAt(i+1);
				plaintext += String.fromCharCode(((c&31)<<6) | (c2&63));
				i+=2;
			} else {
				c2 = utftext.charCodeAt(i+1); c3 = utftext.charCodeAt(i+2);
				plaintext += String.fromCharCode(((c&15)<<12) | ((c2&63)<<6) | (c3&63));
				i+=3;
			}
		}

		return plaintext;
	 } // end: function

}

/**
* Sets a cookie
*
* @param string 	basketAmountContainerId			id of the basketAmountContainer
* @param string 	articlesAmountContainerId		id of the articlesAmountContainer
* @return void
*/
function setUserDataFromCookie() {

	var cookieData = cookie_get('mb3pc');

	if (cookieData && typeof cookieData != 'undefined') {

		var data = JSON.parse(cookieData);
		if (data) {

			var usermanagementSalutionContainer = document.getElementById('usermanagement_salution');
			var notepadInfoContainer 			= document.getElementById('notepad_info');
			var giftdeskInfoContainer 			= document.getElementById('giftdesk_info');

			// get the usermanagementSalutionContainer and set data in it
			if (usermanagementSalutionContainer
				&& typeof data.usermanagement.customersalutation != 'undefined'
				&& typeof data.usermanagement.customername != 'undefined') {

				if(data.usermanagement.customersalutation){
					// do not forget to decode the data (+ signs are converted back to spaces)
					usermanagementSalutionValue = salutation['intro'] + ' '
					+ salutation[data.usermanagement.customersalutation] + ' '
					+ dmc_mb3_usermanagementcached.decode(data.usermanagement.customername);
				}else{
					// do not forget to decode the data (+ signs are converted back to spaces)
					usermanagementSalutionValue = salutation['intro'] + ' '
					+ dmc_mb3_usermanagementcached.decode(data.usermanagement.customername);
				}


				usermanagementSalutionContainer.innerHTML = usermanagementSalutionValue;

			} // end: if

			if (notepadInfoContainer
				&& typeof data.notepad != 'undefined'
				&& typeof data.notepad.articlesAmount != 'undefined') {

				if (data.notepad.articlesAmount > 0) {
                    notepadInfoContainer.className = "mwNavHeadline";
                    notepadInfoContainer.innerHTML = notepadinfo.replace('###amount###', data.notepad.articlesAmount);
				}

			} // end: if

			if (giftdeskInfoContainer
				&& typeof data.giftdesk != 'undefined'
				&& typeof data.giftdesk.articlesAmount != 'undefined') {

				if (data.giftdesk.articlesAmount > 0) {
                    giftdeskInfoContainer.className = "mwNavHeadline";
					giftdeskInfoContainer.innerHTML = giftdeskinfo.replace('###amount###', data.giftdesk.articlesAmount);
				}

			} // end: if

		} // end: if
	} // end: if
} // end: function


/**
* These three function are used for the login pages of addto_notepad or addto_giftdesk.
* These pages could be popups.
* All requests work in the following way: If we are in a popup and the user falied to login
* or wants to read more abaout the services close the popup and redirect the parent window.
* If we are in the main window itself, not in a popup the main window should be redirected, and nothing should be closed.
*
* This opens an url in the parentwindow if we are in a popup, or else in the current window.
*/
function openURL(url){
	var errorURL=url;
	if (window.opener && window.opener.open && !window.opener.closed){
		opener.location.href=errorURL;
		close();
	}
	else{
		self.location.href=errorURL;
	}
}

/**
* These three function are used for the login pages of addto_notepad or addto_giftdesk.
* These pages could be popups.
* All requests work in the following way: If we are in a popup and the user falied to login
* or wants to read more abaout the services close the popup and redirect the parent window.
* If we are in the main window itself, not in a popup the main window should be redirected, and nothing should be closed.
*
* This opens an url in the parentwindow if we are in a popup, or else in the current window.
*/
function updateDoubletInput(originId, doubletId){

	originElement 	= document.getElementById(originId);
	doubletElement	= document.getElementById(doubletId);

	if (originElement && doubletElement) {
		doubletElement.value = originElement.value;
	}

}




	function addToGiftdesk(uid, id) {



		var form				= document.getElementById('giftdeskForm_' + uid);
		var giftdeskArticlePk	= document.getElementById('giftdeskArticlePk_' + uid);
		var giftdeskProductPk	= document.getElementById('giftdeskProductPk_' + uid);
		var giftdeskAmount		= document.getElementById('giftdeskAmount_' + uid);

		var amountForm		= document.getElementById('productAmountForm_' + uid + '_' + id);
		var variation		= currentVariation(uid, id);
		var size			= currentSize(uid, id, variation);
		var color			= currentColor(uid, id, variation, size);
		var amount			= 0;



		if (amountForm) {
			amount = amountForm.value;
		}

		if (form && giftdeskArticlePk && giftdeskProductPk && amount > 0) {
			giftdeskArticlePk.value 	= productConf[uid][id]['articles'][variation][size][color]['articlePk'];
			giftdeskProductPk.value 	= id;
			giftdeskAmount.value		= amount;
			form.submit();
		}
	}


	/**
	* This is used for the extension specific functions
	*
	* @package		mb3p
	* @subpackage	giftdeskcached
	* @access		public
	* @author	    Boris Azar
	* @version		1.0.0
	*/
	var dmc_mb3_giftdeskcached = {

		// public method for url decoding
		decode : function (data) {
			var lsRegExp = /\+/g;
			// Return the decoded string
			return this.decodeUtf8(unescape(String(data).replace(lsRegExp, " ")));
		},

		/**
		* decodes a string in utf8
		*
		* @param string 	utftext							string to be decoded
		* @return void
		*/
		decodeUtf8: function (utftext) {
			var plaintext = "";
			var i=0;
			var c=0;
			var c1=0;
			var c2=0;

			// while-Schleife, weil einige Zeichen uebersprungen werden
			while(i<utftext.length) {
				c = utftext.charCodeAt(i);
				if (c<128) {
					plaintext += String.fromCharCode(c);
					i++;
				} else if((c>191) && (c<224)) {
					c2 = utftext.charCodeAt(i+1);
					plaintext += String.fromCharCode(((c&31)<<6) | (c2&63));
					i+=2;
				} else {
					c2 = utftext.charCodeAt(i+1); c3 = utftext.charCodeAt(i+2);
					plaintext += String.fromCharCode(((c&15)<<12) | ((c2&63)<<6) | (c3&63));
					i+=3;
				}
			}

			return plaintext;
		 } // end: function

	}

	/**
	* Giftdeskcached function
	*
	* @package		mb3p
	* @subpackage	giftdeskcached
	* @access		public
	* @author	    Boris Azar
	* @version		1.0.0
	*/

	/**
	* Sets a cookie
	*
	* @param string 	giftdeskAmountContainerId			id of the giftdeskAmountContainer
	* @param string 	giftdeskArticleAmountContainerId		id of the giftdeskArticleAmountContainer
	* @return void
	*/
	function fillGiftdeskWithData(giftdeskAmountContainerId, giftdeskArticleAmountContainerId, tipText) {
		var giftdeskArticlesAmountContainer = document.getElementById(giftdeskArticleAmountContainerId);
		var giftdeskAmountContainer = document.getElementById(giftdeskAmountContainerId);

		var cookieData = cookie_get('mb3pc');
		if (cookieData && typeof cookieData != 'undefined') {

			var data = JSON.parse(cookieData);
			if (data && typeof data.giftdesk != 'undefined') {
				// get the giftdeskArticlesAmountContainer object and set data in it
				if (giftdeskArticlesAmountContainer
					&& typeof data.giftdesk.articlesAmount != 'undefined') {

					// do not forget to decode the data (+ signs are converted back to spaces)
					giftdeskArticlesAmountContainerValue = dmc_mb3_giftdeskcached.decode(data.giftdesk.articlesAmount);

					// get the giftdeskArticlesAmountContainer object and set data in it
					if (giftdeskArticlesAmountContainer) {
						// do not forget to decode the data (+ signs are converted back to spaces)
						giftdeskArticlesAmountContainer.innerHTML = giftdeskArticlesAmountContainerValue;
					} // end: if

				} // end: if

				// get the giftdeskAmountContainer object and set data in it
				if (giftdeskAmountContainer
					&& typeof data.giftdesk.giftdeskAmount != 'undefined') {

					// do not forget to decode the data (+ signs are converted back to spaces)
					giftdeskAmountContainerValue = dmc_mb3_giftdeskcached.decode(data.giftdesk.giftdeskAmount);

					// get the giftdeskAmountContainer object and set data in it
					if (giftdeskAmountContainer) {
						// do not forget to decode the data (+ signs are converted back to spaces)
						giftdeskAmountContainer.innerHTML = giftdeskAmountContainerValue;
					} // end: if
				} // end: if

				if(data.giftdesk.giftdeskAddStatus == 1) {
					showToolTip(giftdeskAmountContainerId,tipText);
				} // end: if

				resetGiftdeskCookie();
			} // end: if
		} // end: if
	} // end: function

	function resetGiftdeskCookie() {
		var cookieData = cookie_get('mb3pc');
		if (cookieData && typeof cookieData != 'undefined') {
			var data = JSON.parse(cookieData);

			if (data) {
				data.giftdesk.giftdeskAddStatus = "0";
				cookieDataUpdated = JSON.stringify(data);
				cookie_set('mb3pc',cookieDataUpdated,'','/');
			} // end: if

		} // end: if
	} // end: function

	function isGiftdeskEmpty(){
		var cookieData  = cookie_get('mb3pc');
		var retval 	    = true;

		if (cookieData && typeof cookieData != 'undefined') {

			var data = JSON.parse(cookieData);
			if (data) {
				if (typeof data.giftdesk != 'undefined' && data.giftdesk.articlesAmount != 0) {
					retval = false;
				}
			}
		}
		return retval;
	}



	function checkFieldsGiftdesk(uid, id, variation, size, color)
	{
		boolReturn = true;
		var amountFieldId = 'productAmountForm_'+uid+'_'+id;
		var yardWareFieldId = null;
		var gravureFieldId = 'giftdeskGravure_'+uid;
		var gravureFieldTextId = 'productGravureText_'+uid+'_'+id;
		var gravureFieldCount = parseInt(productConf[uid][id]['articles'][variation][size][color]['gravureText']);
		var gravureFieldLength = parseInt(productConf[uid][id]['articles'][variation][size][color]['gravureLength']);
		var gravureObj = document.getElementById('productGravureForm_'+uid+'_'+id);


		var gravureText = '';
		gravureTextPlain = '';
		var gravureTextArr = new Array();
		if (gravureObj && gravureFieldCount>0 && gravureFieldLength>0){

			for (var i=0; i<gravureFieldCount; i++)	{
				var iptValue = document.getElementById('productGravureText_' + uid + '_' + id + '_'+i).value;
				gravureTextArr[i] = iptValue;
			}

			gravureTextPlain = gravureTextArr.join('');
			gravureText = gravureTextArr.join(textGravureSeparator);

			// check valid characters

			strPattern = '/[^\x20-\xFF]/';

			if (gravureTextPlain.search(strPattern) != -1 || gravureTextPlain.search(textGravureSeparator)!=-1) {
				alert(noticeGravureError);
				boolReturn = false;
			} else {
				document.getElementById(gravureFieldId).value = gravureText;
			}

			// Wenn Feld leer dann Abfrage
			if (gravureTextPlain == "") {
				if (confirm(noticeGravureNo)) {
					document.getElementById(gravureFieldId).value = textGravureSeparator;
					// set separator if empty, otherwise we do not know if orderline has gravure;
				} else {
					boolReturn = false;
				}
			}
		} // end: gravure

		// Anzahl
		var amountObj = document.getElementById(amountFieldId);
		var yardWare = productConf[uid][id]['articles'][variation][size][color]['stockUnit'];

		if (amountObj)
		{
			// Meterware ?
			if (yardWare && yardWare== "M")
			{
				var splitText= noticeYardWare.split('||');
				if (confirm (splitText[0] + (amountObj.value * 10) + splitText[1] + amountObj.value + splitText[2]) == false)
				{
					amountObj.value = 1;
					amountObj.focus();
					boolReturn = false;
				}
			}
			else if (amountObj.value >= 10)
			{
				var splitText= noticeAmount.split('||');
				if (confirm (splitText[0] + amountObj.value + splitText[1]) == false)
				{
					amountObj.value = 1;
					amountObj.focus();
					boolReturn = false;
				}
			}else{
				// do nothing
			}
		}

		return boolReturn;
	}

	function addToGiftdeskSubmit(uid, id, target, popup, url, popupParams) {

		var variation		= currentVariation(uid, id);
		var size			= currentSize(uid, id, variation);
		var color			= currentColor(uid, id, variation, size);
		if (checkFieldsGiftdesk(uid, id, variation, size, color)){
			if (popup) {
				var form			= document.getElementById('giftdeskForm_' + uid);
				form.action 		= url;

				// do NOT load page from 'url' variable here! race condition w/ 2 Apache threads!
				var POPUP = window.open('/clear.gif', target, popupParams);
				POPUP.focus();
			}
			addToGiftdesk(uid, id);
		}
	}


	/**
	* This is used for the send2friend form to add new recipient rows on demand.
	* The variable 'myRowCounter' is located at the template 'TEMPLATE_08'.
	*
	* @package		mb3p
	* @subpackage	giftdesk
	* @access		public
	* @author	    Goran Zukolo <goran.zukolo@dmc.de>
	* @version		1.0.0
	*/
	function addRecipientRow() {

		// add article row
		if(myRowCounter > 0 && myRowCounter < 15) {

			// we need the old counter to identify the placeholder div
			var oldCounter = myRowCounter-1;
			// get the template code
			var tpl = $('#recipientRowTemplate').html();

			if( tpl != null ) {

				var rowHTML = '';

				// add 5 new rows
				for(var i=0; i<5; i++) {
					// replace the placeholder with the current counter
					tpl_tmp = tpl.replace(/PLACEHOLDER/g, myRowCounter);
					tpl_tmp = tpl_tmp.replace(/ROWCOUNTER/g, myRowCounter+1);

					rowHTML += tpl_tmp;
					// alter the counter by 1
					myRowCounter++;
				} // end: for

				// print the new article row
				$('#newRecipientRow_'+oldCounter).replaceWith(rowHTML);

			} // end: if
		} else {
			// we need the old counter to identify the placeholder div
			var oldCounter = myRowCounter-1;
			$('#newRecipientRow_'+oldCounter).replaceWith(noticeMaxRowsReached);
		}
	} // end: function addRecipientRow

// this function works in combination with product extension
// it uses the productConf array created by the product extension
// so it may not work anywhere else than productdetail pages...
function articleRankingLink(uid, id, url) {
	var artNumber 		= '';
	var variation		= '';
	var size			= '';
	var color			= '';

	// find currently selected article number
	variation	= currentVariation(uid, id);
	size		= currentSize(uid, id, variation);
	color		= currentColor(uid, id, variation, size);

	artNumber	= productConf[uid][id]['articles'][variation][size][color]['artNumber'];

	// change document.location
	document.location.href = url.replace('%s', artNumber);
}

// Callback function creation function.
// The callback function will be a handler for the 'onArticleChange" event
// on product details page.
// On article change the product ranking information will be adjusted dynamically
// and links regarding product ranking will be set properly.
// This is for 'template04'.
function createOnArticleChangedHandlerForRanking(uid, urlRatingsDummy, urlRankingDummy, popupParams) {
	var defaultRankingImage = $('#rankdetail_' + uid + '_image').attr('src');

	return	function(_, _, artNumber, variation, color, size) {
		var $ = jQuery;

		if (window.artRankingDetails) {
			var detail = artRankingDetails[artNumber];
			var image = $('#rankdetail_' + uid + '_image');
			var countSpan = $('#rankdetail_' + uid + '_count');
			var readRatingsLink = $('#rankdetail_' + uid + '_readRatings');
			var rankingLink = $('#rankdetail_' + uid + '_ranking');
			var imageLink =  $('#rankdetail_' + uid + '_imageLink');
			var urlRatings = urlRatingsDummy.replace('__ARTNUMBER__', artNumber);
			var urlRanking = urlRankingDummy.replace('__ARTNUMBER__', artNumber);

			// Set links.
			rankingLink.attr('href',
				"javascript:void(window.open('" + urlRanking + "', 'ratingPopup', '" + popupParams + "'))"
			);

			// Clear image link (may be set below).
			imageLink.attr('href', 'javascript:void(0)');

			// Update ranking division.
			if (detail && detail.commentCount > 0) {
				image.attr('src', detail.urlImage);
				countSpan.html('(' + detail.commentCount + ')');
				readRatingsLink.show();
				imageLink.css('cursor', 'pointer');
				imageLink.attr('href', '#productRankingComments');
			} else {
				imageLink.attr('href', 'javascript:void(0)');
				imageLink.css('cursor', 'default');
				image.attr('src', defaultRankingImage);
				countSpan.html('(0)');
				readRatingsLink.hide();
			} // end: if
		} // end: if
	}; // end: function
} // end: function createOnArticleChangedHandlerForRanking

// Callback function creation function.
// The callback function will be a handler for the 'onArticleChange" event
// on product details page.
// On article change the product ranking information will be adjusted dynamically
// and comment information and comment links will be set properly.
// This is for 'template03'.
function createOnArticleChangedHandlerForRankingComments(uid, urlRatingsDummy, urlRankingDummy, popupParams) {
	var $ = jQuery;

	// Some general parameters for the presentation of the comments.
	var numberOfInitialComments = 3;
	var maxCommentsPerPage = 10;
	var commentShrinkHeight = 45;

	// The general part of template03 should have the same behaviour as
	// template04 (see there).
	var rankingHandler = createOnArticleChangedHandlerForRanking(uid, urlRatingsDummy, urlRankingDummy, popupParams);

	return function(_, id, artNumber, variation, color, size) {
		rankingHandler(uid, id, artNumber, variation, color, size);
		var showAllCommentsLink = $('#showAllComments_' + uid);
		var allComments = $('.productranking_comment_' + uid);
		var pagination = $('#commentsPagination_' + uid).html('');

		// Show active comments.
		var comments = $('.productranking_comment_' + uid+ '_' + artNumber);
		var commentsCount = comments.size();

		var updateComments = function(pageIdx) {
			allComments.hide();
			var startIdx = 0;
			var endIdx = 0;

			if (isNaN(pageIdx)) {
				endIdx = Math.min(numberOfInitialComments, commentsCount);
			} else {
				startIdx = pageIdx * maxCommentsPerPage;
				endIdx = Math.min(startIdx + maxCommentsPerPage, commentsCount);
			} // end: if

			for (var i = startIdx; i < endIdx; ++i) {
				(function() {
					// Provide the possibility for long comments to show
					// only the first couple of lines. There shall be a link
					// to show the whole comment and another one to shrink
					// back.
					var comment = $(comments.get(i));
					var commentText = comment.find('.productranking_commenttext');
					var showMoreLink = comment.find('[name=commentShowMore]').hide();
					var showLessLink = comment.find('[name=commentShowLess]').hide();
					commentText.css('height', 'auto');
					commentText.css('overflow', 'hidden');
					showMoreLink.unbind('click');
					showLessLink.unbind('click');

					var showMoreCallback = function() {showMoreLink.hide(); showLessLink.show(); commentText.css('height', 'auto'); return false;};
					var showLessCallback = function() {showLessLink.hide(); showMoreLink.show(); commentText.css('height', commentShrinkHeight + 'px'); return false;}

					showMoreLink.click(showMoreCallback);
					showLessLink.click(showLessCallback);
					comment.show();

					if (commentText.height() > commentShrinkHeight) {
						showLessCallback();
					} // end: if
				})();
			} // end: for
		} // end: function update

		// Initialize comments elements.
		updateComments();

		// Show link 'showAllComments' only if necessary.
		showAllCommentsLink.hide()

		if (commentsCount > numberOfInitialComments) {
			showAllCommentsLink.unbind('click');

			showAllCommentsLink.click(function() {
				// Hide 'showAllCommentsLink' and show pagination if multiple
				// pages of comments are available.
				showAllCommentsLink.hide();
				updateComments(0);
				var pageCount = Math.ceil(commentsCount / maxCommentsPerPage);

				// Render pagination.
				if (pagination.size() > 0 && pageCount > 1) {
					pagination.html('');

					for (var i = 0; i < pageCount; ++i) {
						if (i > 0) {
							pagination.append(document.createTextNode(' | '));
						} // end: if

						var page = $(document.createElement('a'));
						page.attr('href', '#');
						page.addClass('shopColor');
						page.html(i + 1);

						if (i == 0) {
							page.addClass('PageHeadAktiv');
						} // end: if

						// Add behaviour to pagination items.
						page.click(function() {
							var pages = pagination.find('a');
							pages.removeClass('PageHeadAktiv');
							var pageIdx = $(this).html() - 1;
							var page = $(pages.get(pageIdx));
							page.addClass('PageHeadAktiv');
							updateComments(pageIdx);
							return false;
						});

						pagination.append(page);
					} // end: for
				} // end :if

				return false;
			});

			showAllCommentsLink.show();
		} // end: if
	} // end: function
} // end: function createOnArticleChangedHandlerForRankingComments
