/**
* 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();
	  	}
	};




/*
 * 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

	var dmc_mb3_product_pi1mediaActive	= '';
	var dmc_mb3_product_pi1mediaIndex	= 0;
	var takeItEasySmallImages = false;
	var switchToBiggestColorSetOnInit = false;

	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 rasterImage			= document.getElementById('dmc_mb3_product_pi1' + uid + 'RasterImage');
		var rasterImageMap00	= document.getElementById('dmc_mb3_product_pi1' + uid + 'Area00');
		var rasterImageMap01	= document.getElementById('dmc_mb3_product_pi1' + uid + 'Area01');
		var rasterImageMap10	= document.getElementById('dmc_mb3_product_pi1' + uid + 'Area10');
		var rasterImageMap11	= document.getElementById('dmc_mb3_product_pi1' + uid + 'Area11');
		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 */

		/* in Zoom-PopUp set state=0 */
		if(rasterImage){
			state = 0;
		}

		if (mainImage) {
			switch (state) {
				case 0:

					if (productConf[uid][id]['large'][imageNum]) {
						mainImage.src				= productConf[uid][id]['large'][imageNum];
						if(rasterImage){
							rasterImage.src			= productConf[uid][id]['thumb'][imageNum];
							rasterImageMap00.href 	= "javascript:changeMainFromRasterImage(" + uid + "," + id + ", " + imageNum + ", '00');";
							rasterImageMap01.href 	= "javascript:changeMainFromRasterImage(" + uid + "," + id + ", " + imageNum + ", '01');";
							rasterImageMap10.href 	= "javascript:changeMainFromRasterImage(" + uid + "," + id + ", " + imageNum + ", '10');";
							rasterImageMap11.href 	= "javascript:changeMainFromRasterImage(" + uid + "," + id + ", " + imageNum + ", '11');";
						}


						/* 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 changeMainFromRasterImage(uid, id, imageNum, area){
		var mainImage = document.getElementById('dmc_mb3_product_pi1' + uid + 'MainImage');
		mainImage.src = productConf[uid][id]['raster'][imageNum].replace(/gesamt$/, area);
	}

	function initProduct(uid, id, addSetProduct) {
		if(addSetProduct == null || addSetProduct == "undefined" || addSetProduct == '')var addSetProduct = false;

		/* 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'];

		/* 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]['selected'] == '1') {
						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);

		if(addSetProduct == true){
			showCurrentMainImage(uid, id, variation, size, color);
		}

		if (switchToBiggestColorSetOnInit == true) {
			changeProduct(uid, id, 'biggestColorSet');
		}

		if (toggleImage
			&& productBody) {
			switch (state) {
				case 1:
					productBody.className	= 'productBodyVisible';
					toggleImage.src			= dmc_mb3_product_pi1ToggleImageOff;
					break;

				case 0:
					productBody.className	= 'productBodyInvisible';
					toggleImage.src			= dmc_mb3_product_pi1ToggleImageOn;
					break;

				default:
			} /* end: switch */
		} /* end: if */
	}

	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);


		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;

			case 'biggestColorSet':
				fillSizeForm(uid, id, variation);
				fillColorForm(uid, id, variation, getSizeForBiggestColorSet(uid, id, variation));
				break;

			default:
		} /* end: switch */

		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);

		showCurrentMainImage(uid, id, variation, size, color);

	}

	function showCurrentMainImage(uid, id, variation, size, color){
		var artNumber	= getCurrentArtNumber(uid, id, variation, size, color);
		var mainImage	= document.getElementById('dmc_mb3_product_pi1' + uid + 'MainImage');
		var imageSize = 'large';
		if(takeItEasySmallImages && takeItEasySmallImages == true){ imageSize = 'medium';	}
		var imageArray	= productConf[uid]['main'][imageSize];

		/* set default */
		dmc_mb3_product_pi1mediaIndex = 'default';
		mainImage.src = productConf[uid]['main'][imageSize]['default'];
		/* serach right image */
		for (var i = 0; i < imageArray.length; ++i) {

			var matches = /([0-9]*)_?([0-9]*)\.jpg$/.exec(imageArray[i]);
			if (matches) {
				if(matches[1] == artNumber){
					mainImage.src = imageArray[i];
					dmc_mb3_product_pi1mediaIndex = i;
					break;
				} else if(matches[1] == artNumber.substr(0,8)){
					if(matches[2] == '' || imageArray.length == 1){
						mainImage.src = imageArray[i];
						dmc_mb3_product_pi1mediaIndex = i;
						break;
					}
				}
			} /* end: if */
		}

	} /* end: function */

	function addToBasket(uid, id, addSetProduct) {
		if(addSetProduct == null || addSetProduct == "undefined" || addSetProduct == '')var addSetProduct = false;

		var form			= document.getElementById('productForm_' + uid);
		var formAction 		= document.getElementById('action_' + 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 (form && pkForm && productPkForm && amount > 0) {
			pkForm.value		= productConf[uid][id]['articles'][variation][size][color]['articlePk'];

			if (addSetProduct == true){
				var setProductList = '';
				var setVariation, setSize, setColor, setProductId;

				for (var setProductId in productConf[uid]) {
					if(setProductId == 'main') {continue;}

					setVariation		= currentVariation(uid, setProductId);
					setSize				= currentSize(uid, setProductId, setVariation);
					setColor			= currentColor(uid, setProductId, setVariation, setSize);

					setProductList += productConf[uid][setProductId]['articles'][setVariation][setSize][setColor]['articlePk'] + ",";

				}
				formAction.value = 'addMulti';
				pkForm.value = setProductList.substring(0,(setProductList.length - 1));
			}

			productPkForm.value = id;
			form.submit();
		}
	}

	function addToBasketSubmit(uid, id, target, popup, url, popupParams, addSetProduct) {
		if(addSetProduct == null || addSetProduct == "undefined" || addSetProduct == '')var addSetProduct = false;

		if (popup) {

			if(!addSetProduct){
				var form			= document.getElementById('productForm_' + uid);
				form.action 		= url;
			}
			var variation		= currentVariation(uid, id);
			var size			= currentSize(uid, id, variation);
			var color			= currentColor(uid, id, variation, size);
			var articlePk		= productConf[uid][id]['articles'][variation][size][color]['articlePk'];

			if (url.search(new RegExp(window.location.host)) != -1) {
			    var pattern = new RegExp(window.location.host+'\/');
			    var replace = window.location.host+'/article/'+articlePk+'/';
			} else {
			    var pattern = new RegExp('\/');
			    var replace = '/article/'+articlePk+'/';
			}
			url = url.replace(pattern, replace);

			// do NOT load page from 'url' variable here! race condition w/ 2 Apache threads!
			var popuphandler = window.open('/clear.gif', target, popupParams);
			popuphandler.window.focus();
			popuphandler.window.location.href = url;
		}

		addToBasket(uid, id, addSetProduct);
	}

	function addToNotepad(uid, id, url) {

		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.options[amountForm.selectedIndex].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();
		}

		/*
		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);
			*/
	}

	function changeItemInBasket(uid, id, addSetProduct) {
		if(addSetProduct == null || addSetProduct == "undefined" || addSetProduct == '')var addSetProduct = false;

		var form			= document.getElementById('productForm_' + uid);
		var formAction 		= document.getElementById('action_' + 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 (form && pkForm && productPkForm && amount > 0) {
			pkForm.value		= productConf[uid][id]['articles'][variation][size][color]['articlePk'];

			if (addSetProduct == true){
				var setProductList = '';
				var setVariation, setSize, setColor, setProductId, setArticleId, setOrderlineId;

				var orderlineListElementName;
				var splitted;

				for (var i = 0; i < form.length; ++i) {
					if(form.elements[i].name.match(/orderlineList/)){
						splitted 		= form.elements[i].name.split("[");
						setProductId 	= splitted[4].replace(/\]/,"");

						// insert new articlePK into hidden-field for every given orderline
						setArticlePkForOrderlineList(uid, setProductId, form.elements[i]);

					}

				}
				formAction.value = 'changeMulti';

			}

			productPkForm.value = id;
			form.submit();
			window.close();
		}

		return false;
	}

	function setArticlePkForOrderlineList(uid, id, formElement) {
		var variation		= currentVariation(uid, id);
		var size			= currentSize(uid, id, variation);
		var color			= currentColor(uid, id, variation, size);

		formElement.value 	= productConf[uid][id]['articles'][variation][size][color]['articlePk'];
	}

	function displayArtNumber(uid, id, variation, size, color) {
		var artNumberDiv	= document.getElementById('productArtNumber_' 		+ uid + '_' + id);

		if (artNumberDiv) {
			artNumberDiv.innerHTML	= productConf[uid][id]['articles'][variation][size][color]['artNumber'];
// CCC [dst] 21.12.2005 - compatible to CH only!
//									+ ' '
//									+ productConf[uid][id]['articles'][variation][size][color]['adCode'];
		} /* end: if */
	}

	function getCurrentArtNumber(uid, id, variation, size, color) {
		return productConf[uid][id]['articles'][variation][size][color]['artNumber'];
	}

	function displayPrice(uid, id, variation, size, color) {
		var priceDiv		= document.getElementById('productPrice_' 		+ uid + '_' + id);
		var pricePrefix		= document.getElementById('productPrice_' 		+ uid + '_' + id + '_prefix');
		var oldPriceDiv		= document.getElementById('productOldPrice_'	+ uid + '_' + id);
		var oldPriceWrap	= document.getElementById('productOldPrice_'	+ uid + '_' + id + '_wrap');
		var savingsDiv		= document.getElementById('savings_' 			+ uid + '_' + id);
		var bonusdigitsDiv	= document.getElementById('bonusdigits_' 		+ uid + '_' + id);

		if (priceDiv) {
			priceDiv.innerHTML	= productConf[uid][id]['articles'][variation][size][color]['price'];
		} /* end: if */

		if (oldPriceDiv && oldPriceWrap) {
			var oldPrice 	= productConf[uid][id]['articles'][variation][size][color]['oldPrice'];
			oldPrice 		= parseFloat(oldPrice.replace(/,/g, '.'));

		if (savingsDiv) {
			savingsDiv.innerHTML	= productConf[uid][id]['articles'][variation][size][color]['savings'];
		} /* end: if */

			if (oldPrice > 0) {
				oldPriceDiv.innerHTML			= productConf[uid][id]['articles'][variation][size][color]['oldPrice'];
				oldPriceWrap.style.visibility	= 'visible';
				oldPriceWrap.style.display		= 'inline';

				if(pricePrefix) {
					pricePrefix.style.visibility	= 'visible';
					pricePrefix.style.display		= 'inline';
				}

			} else {
				oldPriceWrap.style.visibility	= 'hidden';
				oldPriceWrap.style.display		= 'none';

				pricePrefix.style.visibility	= 'hidden';
				pricePrefix.style.display		= 'none';
			}

			if (bonusdigitsDiv) {
				bonusdigitsDiv.innerHTML	= productConf[uid][id]['articles'][variation][size][color]['bonusdigits'];
			} /* end: if */

		}

	}

	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]['stockType'];
			availDiv.className	= productConf[uid][id]['articles'][variation][size][color]['stockTypeClass'];
		} /* 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']) {

					var optionLabel = tmpVariation;
					/*
					var matches = /\(.*\) (.*)/.exec(tmpVariation);
					if (matches) {
						optionLabel = matches[1];
					}
					*/

					if (tmpVariation == variation) {
						variationForm.options[variationForm.length]	= new Option(optionLabel, tmpVariation, false, true);
						variationForm.selectedIndex					= index;

					} else {
						variationForm.options[variationForm.length]	= new Option(optionLabel, 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 */
		if (switchToBiggestColorSetOnInit == true) {
			fillSizeForm(uid, id, currentVariation(uid, id), getSizeForBiggestColorSet(uid, id, variation), color);
		} else {
			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 getSizeForBiggestColorSet(uid, id, variation) {
		var returnValue	= '';
		var amount 		= 0;

		for (tmpSize in productConf[uid][id]['articles'][variation]) {

			tmpAmount = countObjects(productConf[uid][id]['articles'][variation][tmpSize]);
			if (returnValue == '') {
				returnValue = tmpSize;
			} else if (tmpAmount > amount) {
				returnValue = tmpSize;
				amount = tmpAmount;
			}
		}

		return returnValue;
	}

	function countObjects(object){
		var returnValue = 0;
		for (entry in object) {
			returnValue++;
		} /* 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]) {

					var optionLabel = tmpSize;
					var matches = /^\([^\s]*\) (.*)/.exec(tmpSize);
					if (matches) {
						optionLabel = matches[1];
					} /* end: if */

					if (tmpSize == size
						|| tmpSize == sizeOldName) {

						sizeForm.options[sizeForm.length]	= new Option(optionLabel, tmpSize, false, true);
						sizeForm.selectedIndex				= index;

					} else {
						sizeForm.options[sizeForm.length]	= new Option(optionLabel, 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;
			}/* 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]) {

					var optionLabel = tmpColor;
					var matches = /^\([^\s]*\) (.*)/.exec(tmpColor);
					if (matches) {
						optionLabel = matches[1];
					} /* end: if */

					if (tmpColor == color
						|| tmpColor == colorOldName) {

						colorForm.options[colorForm.length]	= new Option(optionLabel, tmpColor, false, true);
						colorForm.selectedIndex = index;

					} else {
						colorForm.options[colorForm.length]	= new Option(optionLabel, 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 gravureForm			= document.getElementById('productGravureForm_' + uid + '_' + id);
		var gravureFormField	= document.getElementById('productGravureFormField_' + uid + '_' + id);
		var gravureTitle		= document.getElementById('productGravureTitle_' + uid + '_' + id);
		var gravureText			= document.getElementById('productGravureText_' + uid + '_' + id);

		if (gravureForm && gravureTitle && gravureText) {
			gravureText.innerHTML = productConf[uid][id]['articles'][variation][size][color]['gravureText'];

			if (productConf[uid][id]['articles'][variation][size][color]['gravureLength'] == 0) {
				gravureForm.style.visibility	= 'hidden';
				gravureTitle.style.visibility	= 'hidden';
				gravureText.style.visibility	= 'hidden';
				gravureForm.style.display		= 'none';
				gravureTitle.style.display		= 'none';
				gravureText.style.display		= 'none';

			} else {
				gravureForm.style.visibility	= 'visible';
				gravureTitle.style.visibility	= 'visible';
				gravureText.style.visibility	= 'visible';
				gravureForm.style.display		= 'inline';
				gravureTitle.style.display		= 'block';
				gravureText.style.display		= 'block';
			} /* end: if */

			if(productConf[uid][id]['articles'][variation][size][color]['gravureText'] == 'DEPOSIT'){
				gravureFormField.value = productConf[uid][id]['articles'][variation][size][color]['gravureText'] + '_' + productConf[uid][id]['articles'][variation][size][color]['gravureLength'];
				gravureText.innerHTML = '';
				gravureFormField.style.visibility = 'hidden';
				gravureText.style.visibility	= 'hidden';
				gravureText.style.display		= 'none';
				gravureTitle.style.visibility	= 'hidden';
				gravureTitle.style.display		= 'none';
			}

		} /* end: if */
	}

	if (!productConf) {
		var productConf = new Array();
	}

	function openerUrl(url){
		if (opener == null || typeof(opener.name) == "unknown" || typeof(opener.name) == "undefined" ) {
			var handler = window.open(url,'','');
			handler.focus();
			self.close();
		} else {
			opener.location.href = url;
			opener.focus();
			self.close();
		}
	}



	function intoBasket(id) {
			
		var form = document.getElementById("orderlineForm_"+id); /* uid hinzufuegen */
		form.submit();
	}
	
function shoppingbasketFormSubmit(ctype, uid, nextstepValue) {
	var form			= document.getElementById(ctype + '[' + uid + ']' + '[form]');
	var nextstep		= document.getElementById(ctype + '[' + uid + ']' + '[nextstep]');
	if (form && nextstep && nextstepValue > 0) {
		nextstep.value 	= nextstepValue;
	}
}

function shoppingbasketFormChangeAction(ctype, uid, oldAction, newAction) {
	var form			= document.getElementById(ctype + '[' + uid + ']' + '[form]');
	var action			= document.getElementById(ctype + '[' + uid + ']' + '[action][' + oldAction + ']');

	if (action) {
		action.value = newAction;
	}
}

function changePaymentType(ctype, uid, currentstep, name) {

	var installmentBox = document.getElementById(ctype + '[' + uid + ']' + '[installment][checkbox]');

	switch(name){
		case 'installment':
			if (installmentBox) {
				installmentBox.value = 'true';
			}
			shoppingbasketFormSubmit(ctype, uid, currentstep);
			document.getElementById(ctype + '[' + uid + ']' + '[form]').submit();
			break;
		default:
			if (installmentBox) {
				installmentBox.value = '';
			}
			break;
	}
}



	function addToNotepad(uid, id, addSetProduct) {
		if(addSetProduct == null || addSetProduct == "undefined" || addSetProduct == '')var addSetProduct = false;

		var form				= document.getElementById('notepadForm_' + uid);
		var formAction 			= document.getElementById('notepadAction_' + uid);
		var notepadArticlePk	= document.getElementById('notepadArticlePk_' + uid);
		var notepadProductPk	= document.getElementById('notepadProductPk_' + uid);
		var notepadAmount		= document.getElementById('notepadAmount_' + uid);
		var notepadTooltip		= document.getElementById('notepadTooltip_' + 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.options[amountForm.selectedIndex].value;
		}

		if (form && notepadArticlePk && notepadProductPk && amount > 0) {
			notepadTooltip.style.display 	= 'block';
			notepadTooltip.style.visibility	= 'visible';

			notepadArticlePk.value 	= productConf[uid][id]['articles'][variation][size][color]['articlePk'];

			if (addSetProduct == true){
				var setProductList = '';
				var setVariation, setSize, setColor, setProductId;

				for (var setProductId in productConf[uid]) {
					if(setProductId == 'main') {continue;}

					setVariation		= currentVariation(uid, setProductId);
					setSize				= currentSize(uid, setProductId, setVariation);
					setColor			= currentColor(uid, setProductId, setVariation, setSize);

					setProductList += productConf[uid][setProductId]['articles'][setVariation][setSize][setColor]['articlePk'] + ",";

				}
				formAction.value = 'notepadAddMulti';
				notepadArticlePk.value = setProductList.substring(0,(setProductList.length - 1));
			}

			notepadProductPk.value 	= id;
			notepadAmount.value		= amount;
			form.submit();
		}
	}



// 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);
}

// 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) {
	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', 'width=704,height=634,resizable=no,toolbar=no,status=no,directories=no,menubar=no,location=no,scrollbars=yes');
	popup_productRecommend.focus();
}

/**
* 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

	/**
	* 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 toggleOrderDetail(num, offContent, onContent) {

		var boxPrefix 	= (arguments[3]) ? arguments[3] : 'orderdetail-';
		var linkPrefix 	= (arguments[4]) ? arguments[4] : 'orderdetaillink-';

		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";
					$(linkPrefix + num).innerHTML = ($(linkPrefix + num).innerHTML == offContent ) ? onContent : offContent;

				} else {

					divs[i].style.display = 'none';
					$(linkPrefix + match[1]).innerHTML = offContent;
				}
			}
		}
	}

//V2.01.A - http://www.openjs.com/scripts/jx/
jx = {
	http:false, //HTTP Object
	format:'text',
	callback:function(data){},
	handler:false,
	error: false,
	opt:new Object(),
	//Create a xmlHttpRequest object - this is the constructor. 
	getHTTPObject : function() {
		var http = false;
		//Use IE's ActiveX items to load the file.
		if(typeof ActiveXObject != 'undefined') {
			try {http = new ActiveXObject("Msxml2.XMLHTTP");}
			catch (e) {
				try {http = new ActiveXObject("Microsoft.XMLHTTP");}
				catch (E) {http = false;}
			}
		//If ActiveX is not available, use the XMLHttpRequest of Firefox/Mozilla etc. to load the document.
		} else if (XMLHttpRequest) {
			try {http = new XMLHttpRequest();}
			catch (e) {http = false;}
		}
		return http;
	},
	// This function is called from the user's script. 
	//Arguments - 
	//	url	- The url of the serverside script that is to be called. Append all the arguments to 
	//			this url - eg. 'get_data.php?id=5&car=benz'
	//	callback - Function that must be called once the data is ready.
	//	format - The return type for this function. Could be 'xml','json' or 'text'. If it is json, 
	//			the string will be 'eval'ed before returning it. Default:'text'
	//	method - GET or POST. Default 'GET'
	load : function (url,callback,format,method) {
		this.init(); //The XMLHttpRequest object is recreated at every call - to defeat Cache problem in IE
		if(!this.http||!url) return;
		//XML Format need this for some Mozilla Browsers
//		if (this.http.overrideMimeType) this.http.overrideMimeType('text/xml');

		this.callback=callback;
		if(!method) var method = "GET";//Default method is GET
		if(!format) var format = "text";//Default return type is 'text'
		this.format = format.toLowerCase();
		method = method.toUpperCase();
		var ths = this;//Closure
		
		//Kill the Cache problem in IE.
		var now = "cuid=" + new Date().getTime();
		url += (url.indexOf("?")+1) ? "&" : "?";
		url += now;

		var parameters = null;

		if(method=="POST") {
			var parts = url.split("\?");
			url = parts[0];
			parameters = parts[1];
		}
		this.http.open(method, url, true);

		if(method=="POST") {
			this.http.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
			this.http.setRequestHeader("Content-length", parameters.length);
			this.http.setRequestHeader("Connection", "close");
		}

		if(this.handler) { //If a custom handler is defined, use it
			this.http.onreadystatechange = this.handler;
		} else {
			this.http.onreadystatechange = function () {//Call a function when the state changes.
				if(!ths) return;
				var http = ths.http;
				if (http.readyState == 4) {//Ready State will be 4 when the document is loaded.
					if(http.status == 200) {
						var result = "";
						if(http.responseText) result = http.responseText;
						//If the return is in JSON format, eval the result before returning it.
						if(ths.format.charAt(0) == "j") {
							//\n's in JSON string, when evaluated will create errors in IE
							result = result.replace(/[\n\r]/g,"");
							result = eval('('+result+')');

						} else if(ths.format.charAt(0) == "x") { //XML Return
							result = http.responseXML;
						}

						//Give the data to the callback function.
						if(ths.callback) ths.callback(result);
					} else {
						if(ths.opt.loadingIndicator) document.getElementsByTagName("body")[0].removeChild(ths.opt.loadingIndicator); //Remove the loading indicator
						if(ths.opt.loading) document.getElementById(ths.opt.loading).style.display="none"; //Hide the given loading indicator.
						
						if(ths.error) ths.error(http.status);
					}
				}
			}
		}
		this.http.send(parameters);
	},
	bind : function(user_options) {
		var opt = {
			'url':'', 			//URL to be loaded
			'onSuccess':false,	//Function that should be called at success
			'onError':false,	//Function that should be called at error
			'format':"text",	//Return type - could be 'xml','json' or 'text'
			'method':"GET",		//GET or POST
			'update':"",		//The id of the element where the resulting data should be shown. 
			'loading':"",		//The id of the loading indicator. This will be set to display:block when the url is loading and to display:none when the data has finished loading.
			'loadingIndicator':"" //HTML that would be inserted into the document once the url starts loading and removed when the data has finished loading. This will be inserted into a div with class name 'loading-indicator' and will be placed at 'top:0px;left:0px;'
		}
		for(var key in opt) {
			if(user_options[key]) {//If the user given options contain any valid option, ...
				opt[key] = user_options[key];// ..that option will be put in the opt array.
			}
		}
		this.opt = opt;
		if(!opt.url) return; //Return if a url is not provided
		if(opt.onError) this.error = opt.onError;

		var div = false;
		if(opt.loadingIndicator) { //Show a loading indicator from the given HTML
			div = document.createElement("div");
			div.setAttribute("style","position:absolute;top:0px;left:0px;");
			div.setAttribute("class","loading-indicator");
			div.innerHTML = opt.loadingIndicator;
			document.getElementsByTagName("body")[0].appendChild(div);
			this.opt.loadingIndicator=div;
		}
		if(opt.loading) document.getElementById(opt.loading).style.display="block"; //Show the given loading indicator.
		
		this.load(opt.url,function(data){
			if(opt.onSuccess) opt.onSuccess(data);
			if(opt.update) document.getElementById(opt.update).innerHTML = data;
			
			if(div) document.getElementsByTagName("body")[0].removeChild(div); //Remove the loading indicator
			if(opt.loading) document.getElementById(opt.loading).style.display="none"; //Hide the given loading indicator.
		},opt.format,opt.method);
	},
	init : function() {this.http = this.getHTTPObject();}
}


// Merge Objects: @see http://www.prototypejs.org/api/object/extend
Object.extend = function(destination, source) {
	for (var property in source)
		destination[property] = source[property];
	return destination;
};

var BikeDBConnector = function () {

	this.conf = {
		pageId:'',
		uid:'',
		form:'',
		tmpl:'',
		ll:'',
		updateId:'',
		loading:'',
		ext:'dmc_mb3_bikedb',
		ctype:'dmc_mb3_bikedb_pi1'
	}
	
	this.formPrefix = '';
	this.formObj = {};
	this.savedParams = {};
	this.params = [];
	
	this.init = function () {

		this.formPrefix = this.conf.ctype+'['+this.conf.uid+']';
		this.formObj = document.getElementById(this.conf.form);
		this.setInitParams();
	}
	
	this.setConfig = function (conf) {
		Object.extend(this.conf, conf || { });
	}

	this.handleStep = function (obj, step, context, addargs) {
	
		switch (context) {
			case 'filterManufacturer':
				this.showAjaxLoader();
				this.resetFormFields([this.formPrefix+'[filter][manufacturer]']);
				this.setInitParams();
				this.setFormParams();
				this.getStep(step);
				
				break;

			case 'filterCylinderCapacity':
				this.showAjaxLoader();
				this.resetFormFields(
					[this.formPrefix+'[filter][manufacturer]',
					 this.formPrefix+'[filter][cylindercapacity]']
				);
				this.setInitParams();
				this.setFormParams();
				this.getStep(step);
				
				break;	
			case 'filterBikeModel':
				this.showAjaxLoader();
				this.resetFormFields(
					[this.formPrefix+'[filter][manufacturer]',
					 this.formPrefix+'[filter][cylindercapacity]',
					 this.formPrefix+'[filter][model]']
				);
				this.setInitParams();
				this.setFormParams();
				this.getStep(step);
				
				break;	

			case 'showResult':
				this.showAjaxLoader();
				this.resetFormFields(
					[this.formPrefix+'[filter][manufacturer]',
					 this.formPrefix+'[filter][cylindercapacity]',
					 this.formPrefix+'[filter][model]',
					 this.formPrefix+'[filter][yearofmanufacture]']
				);
				this.setInitParams();
				this.setFormParams();
				
				var myAction 		= this.formObj.action;
				var myGroup 		= (this.conf.ll == 'en') ? '7496' : '33';
				var myUrl 			= '/shop//group/' + myGroup + '/' + this.conf.ctype + '.' + this.conf.uid + '.step/5/';
				var myKey 			= '';
				var currentKey 		= '';
				var currentValue 	= '';
				
				for (var i=0; i < this.params.length; i++) {
					currentKey 		= this.params[i].key;
					currentValue 	= this.params[i].value;
					//console.debug(currentKey+'='+currentValue);
					if(
						(currentValue >= 0 || currentValue != '')
						&& currentKey != 'eID'
						&& currentKey != 'id'
						&& currentKey != 'uid'
						&& currentKey != 'ctype'
						&& currentKey != 'tmpl'
						&& currentKey != 'll'
						&& currentKey != this.conf.ctype + '[' + this.conf.uid + '][step]'
					){
						myKey = this.params[i].key;
						myKey = myKey.replace(/\[/g,".");
						myKey = myKey.replace(/\]/g,"");
				    	myUrl += '' + myKey +'/'+ currentValue + '/';
					}
			    }
				
				myAction = myAction.replace(/http:\/\/polo5\.dev\.intra\.dmc\.de\//,"");
				myAction = myAction.replace(/http:\/\/polo5-moto\.dev\.intra\.dmc\.de\//,"");
				myAction = myAction.replace(/http:\/\/polo5\.test\.dmc\.de\//,"");
				myAction = myAction.replace(/http:\/\/polo5-moto\.test\.dmc\.de\//,"");
				myAction = myAction.replace(/http:\/\/www.polo-motorrad.de\//,"");
				myAction = myAction.replace(/http:\/\/www.polo-moto.net\//,"");
				
				window.location.href = myUrl + myAction;
				
				break;

			default:
				this.showAjaxLoader();
				this.setInitParams();
				this.setFormParams();
				this.getStep(step);
				
				break;
		}
	}

	this.showAjaxLoader = function () {
		this.ajaxContainer = document.getElementById('ajaxLoader');
		this.ajaxContainer.style.visibility = 'visible';
	}
	
	this.setInitParams = function () {
		this.params = [];
		this.params.push({key:'eID', value:this.conf.ext});
		this.params.push({key:'id', value:this.conf.pageId});
		this.params.push({key:'uid', value:this.conf.uid});
		this.params.push({key:'ctype', value:this.conf.ctype});
		this.params.push({key:'tmpl', value:this.conf.tmpl});
		this.params.push({key:'ll', value:this.conf.ll});
	}

	this.setResultStep = function () {
		this.params.push({key:this.formPrefix+'[substep]', value:'result'});
		this.conf.updateId = 'subUpdateContainer';
	}

	this.setReloadContentAndResultStep = function () {
		this.params.push({key:this.formPrefix+'[substep]', value:'result'});
		this.params.push({key:this.formPrefix+'[reloadcontent]', value:'1'});
		this.conf.updateId = 'updateContainer';
	}

	this.resetFormFields = function (excludeFields) {

	    for (var i=0; i < this.formObj.elements.length; i++) {
			var element = this.formObj.elements[i];
	
			var isExcludeField = false;
			if (typeof excludeFields != 'undefined') {
				for (var j=0; j < excludeFields.length; j++) {
					if (element.name.indexOf(excludeFields[j]) == 0) {
						isExcludeField = true;
					}
			    }
				if (isExcludeField == false) {
					switch (element.type) {
					case 'select-one':
						element.selectedIndex = 0;
						break;
						
					case 'text':
						element.value = '';
						break;
					}
				}
			} else {
				switch (element.type) {
					case 'select-one':
						element.selectedIndex = 0;
						break;
						
					case 'text':
						element.value = '';
						break;
				}
			}
	    }
	}

	this.setFormParams = function (allowedFields) {

	    for (var i=0; i < this.formObj.elements.length; i++) {
			var element = this.formObj.elements[i];
	
			if (typeof allowedFields != 'undefined') {
			    for (var i=0; i < allowedFields.length; i++) {
					if (element.name.indexOf(allowedFields[i]) > 0) {
						this.params.push({key:element.name, value:element.value});					
					}
			    }
			} else {
			
				this.params.push({key:element.name, value:element.value});				
			}
	    }
	}
	
	this.getStep = function (step) {
	    var url = '/index.php?';
	
		this.params.push({key:this.formPrefix+'[step]', value:step});
		
	    for (var i=0; i < this.params.length; i++) {
	    	url += '&' + this.params[i].key +'='+ this.params[i].value;
	    }
		
		var JXConf = {
			'url':url,
			'update':this.conf.updateId,
			'method':'get'
		};
		
		if (this.conf.loading != '') {
			JXConf.loading = this.conf.loading;
		} 
		
		// bind data to jx ajax object    
		jx.bind(JXConf);
	}
	
	this.de = function () {
		console.dir(this);
	}
}
