
	var ModOrder = {    	
		
		i: [],
		aktiv: [],
		isMoving: [],
		activePage: 0,
		activeTmpl: 0,
		
		/*
		 * ModOrder.MenuActive
		 */
		MenuActive: function(img_id) {		
			if(this.activeTmpl != 7) {
				for(c = 1; c <= 5; c++) {
					if(!this.i[c] && this.activePage != c)
						this.i[c] = 0;
					if(!this.aktiv[c] && this.activePage != c)
						this.aktiv[c] = 0;
					if(!this.isMoving[c] && this.activePage != c)
						this.isMoving[c] = false;
				}
				
				if(!this.isMoving[img_id]  && this.activePage != img_id) {
					this.isMoving[img_id] = true;
					this.aktiv[img_id] = window.setInterval("ModOrder.SetImage('" + parseInt(img_id) + "')", 1);			
				} else {				
					return;
				}
			}
		},
		
		SetImage: function(img_id) {			
			if(this.i[img_id] > 106) {
				window.clearInterval(this.aktiv[img_id]);
				return;
			}
			this.i[img_id]++;
			this.i[img_id]++;
			this.i[img_id]++;
			
			$('menu' + img_id + '_img').style.marginTop = (107 - this.i[img_id]) + 'px';
			$('menu' + img_id + '_decker').style.height = this.i[img_id] + 'px';
			return;
		},			
		
		/*
		 * ModOrder.InitMenuInActive
		 */
		InitMenuActive: function(img_id, activeTmpl) {
			this.activeTmpl = activeTmpl;
			this.MenuActive(img_id);
			this.activePage = img_id;			
		},
		
		/*
		 * ModOrder.MenuInActive
		 */
		MenuInActive: function(img_id) {			
			if(this.activeTmpl != 7) {
				for(c = 1; c <= 5; c++) {
					if(c != this.activePage) {
						window.clearInterval(this.aktiv[c]);
						this.i[c] = 0;
						this.aktiv[c] = '';
						this.isMoving[c] = false;
						$('menu' + c + '_img').style.marginTop = '107px';
						$('menu' + c + '_decker').style.height = '0px';
					}
				}
			}
		},
		
		/*
		 * ModOrder.AddToCart
		 */
		AddToCart: function(article_cn_id) {
  		
			if($('article_amount').value == "" || isNaN($('article_amount').value)) {
				
				alert($('alert_amount').innerHTML);
				$('article_amount').focus();
				
			} else {
			
				$('do').value = "addToCart";
				$('article_cn_id').value = article_cn_id;
				$('amount').value = $('article_amount').value;
				$('Search').action = "../stage_content_ajax.php";
				$('Search').request(
					{
						asynchronous: true,
						encoding: 'UTF-8',
						onComplete: function(transport) {					
							alert("Artikel wurde in den Warenkorb gelegt.");						
							if($('CartBox'))
								$('CartBox').innerHTML = transport.responseText;
						}
					}
				);
				
			}
			
		},
		
		DeleteFromCart: function(article_cn_id) {
			
			if(confirm($('CartConfirmText').innerHTML)) {
			
				$('CartForm').action = "../stage_content_ajax.php";
				$('do').value = "DeleteFromCart";
				$('article_cn_id').value = article_cn_id;			
				$('CartForm').request(
					{
						asynchronous: true,
						encoding: 'UTF-8',
						onComplete: function(transport) {
							
							$('Cart').innerHTML = transport.responseText;
						}
					}
				);
				
			}
		
		},
		
		ChangeCart: function() {
			
			$('CartForm').action="../stage_content_ajax.php";
			var tempDo = $('do').value;
			$('do').value = "changeCart";
			$('CartForm').request(
				{
					asynchronous: true,
					encoding: 'UTF-8',
					onComplete: function(transport) {						
						$('CartDiv').innerHTML = transport.responseText;
						$('do').value = tempDo;
					}
				}
			);
			
		},
		
		ShowAccount : function() {
			
			if($('Bankeinzug').checked)
				$('account').style.display = "inline";
			
		},
		
		Checkout: function(step) {
			
			if(step == "5" && !$('agb').checked) {
				alert($('text_agb').innerHTML);
			} else if(step == "5" && !$('datenschutz').checked) {
				alert($('text_datenschutz').innerHTML);
			} else {			
				$('CartForm').action = "";				
				$('CartForm').step.value = step;
				$('CartForm').submit();				
			}
		},
		
		Address: function(AdressType) {
			
			var submitForm = true;
			if(AdressType == "delivery") {
			
				if($('Vorname').value == "" && submitForm) {
					alert($('text_feld').innerHTML);
					submitForm = false;
				}
				if($('Nachname').value == "" && submitForm) {
					alert($('text_feld').innerHTML);
					submitForm = false;
				}
				if($('Strasse').value == "" && submitForm) {
					alert($('text_feld').innerHTML);
					submitForm = false;
				}
				if($('PLZ').value == "" && submitForm) {
					alert($('text_feld').innerHTML);
					submitForm = false;
				}
				if($('Ort').value == "" && submitForm) {
					alert($('text_feld').innerHTML);
					submitForm = false;
				}

			}
			
			if(submitForm) {
			
				$('CartForm').action = "";			
				$('do').value = AdressType;
				$('CartForm').submit();			
				
			}
		
		},
		
		Payment: function(PaymentType) {
			
			if(PaymentType == "regular" && (!$('Vorkasse').checked && !$('Nachnahme').checked && !$('Bankeinzug').checked && !$('Rechnung').checked)) {
				alert($('text_bezahlart').innerHTML);
			}  else if($('Bankeinzug').checked && ($('Kontoinhaber').value == "" || $('Bank').value == "" || $('Kontonummer').value == "" || $('Bankleitzahl').value == "")) {
				alert($('text_konto').innerHTML);
			}  else if($('Bankeinzug').checked && !$('einzug').checked) {
				alert($('text_einzug').innerHTML);
			} else {
			
				$('CartForm').action = "";
				$('do').value = PaymentType;
				$('CartForm').submit();
			
			}										
		
		},
		
		Login: function() {
			
			$('CartForm').action = "";
			$('do').value = "login";
			$('CartForm').submit();
			
		},
		
		/*
		 * ModOrder.Search
		 */
		Search: function(timeout) {  				
				
			$('do').value = "search";
			$('Search').action = "";			
			$('Search').submit();
			/*
			$('Search').request(
				{
					asynchronous: true,
					encoding: 'UTF-8',
					onComplete: function(transport) {
						$('Results').innerHTML = transport.responseText;
					}
				}
			);
			*/
			
		},
		
		/*
		 * ModOrder.Detail
		 */
		Detail: function(article_cn_id) {
  		
			$('do').value = "detail";
			$('article_cn_id').value = article_cn_id;
			$('Search').action = "";
			$('Search').submit();
			/*
			$('Search').request(
				{
					asynchronous: true,
					encoding: 'UTF-8',
					onComplete: function(transport) {
						$('Results').innerHTML = transport.responseText;
					}
				}
			);
			*/
			
		},
		
		/*
		 * ModOrder.Clear
		 */
		Clear: function() {
  		
			var elements = $$('input,select');
			
			for(c = 0; c < elements.length; c++) {
				
				if(elements[c].up("div.FrameColumn") || elements[c].up("div.FrameColumnNarrow", 0)) {
					
					switch(elements[c].tagName.toLowerCase()) {
					
						case "input":							
							if(elements[c].type == "checkbox")								
								elements[c].checked = false;							
							if(elements[c].type == "text")
								elements[c].value = "Stichwortsuche     >";							
							break;
							
						case "select":							
							elements[c].options[0].selected = true;							
							break;
					
					}
					
				}
			
			}
			
			$('Search').action = "";
			$('Search').submit();
			
		}
		
	}
	
	
	var Brandbox = {
	
  	/*
     * Brandbox.content
     */
    content: {
  		
    	/*
       * Brandbox.content.MediaOpen
       */
  		MediaOpen: function(f_name, image_src) {
				
  			if(image_src != "") {
					window.open(
      			$('HTTP_DOMAIN').value + 'tunnel.php' +
      			'?PHPSESSID=' + $F('PHPSESSID') + 
      			'&mod=media' +
      			'&tpl=select_images' + 
      			'&f_name=' + f_name + 
      			'&noform' + 
      			'&window=popup', 
      			'mediafactory', 
      			'width=1000, height=500, menubar=no, scrollbars=yes, status=yes'
      		);			
  			} else {
      		window.open(
      			$('HTTP_DOMAIN').value + 'tunnel.php' +
      			'?PHPSESSID=' + $F('PHPSESSID') + 
      			'&mod=media' +
      			'&tpl=select' +
      			'&f_name=' + f_name + 
      			'&window=popup' + 
      			'&opener=pool', 
      			'mediafactory', 
      			'width=1016, height=600, scrollbars=no'
      		);
  			}
  		},
    	
  		/*
  		 * Brandbox.content.iFrameonFocusIn
  		 */
  		iFrameFocused:'',
  		iFrameonFocusIn: function(f_name) {
  			this.iFrameFocused = f_name;
  		},
			
  		/*
  		 * Brandbox.content.iFramesToText
  		 */
  		iFramesToText: function() {
  			var iframes = document.getElementsByTagName("iframe");
    		for (var c = 0; c < iframes.length; c++) {
					var f_name = iframes[c].name.replace(/iframe_/,"");
					this.iFrameToText(f_name);
				}
  		},
  		
  		/*
  		 * Brandbox.content.iFrameToText
  		 */
			iFrameToText: function(f_name) {
				if(this.iFrameLoaded.indexOf(f_name) == -1) {
					setTimeout("Brandbox.content.iFrameToText('" + f_name + "');", 100);
					return;
				}
  			var f_obj = document.getElementById('iframe_' + f_name).contentWindow;
  			if(document.forms[0].elements[f_name])
					document.forms[0].elements[f_name].value = 
						f_obj.document.body.innerHTML;
			},
			
    	/*
       * Brandbox.content.iFrameLoad
       */
			iFrameLoaded: [],
  		iFrameLoad: function(f_name) {
  			
  			if(!$(f_name))
  				return;
  			
      	var f_value = $(f_name).value;
  			
    		var f_str = 
    			'<style type="text/css">p {margin:0 0 0 0;}</style>' +
    			'<body style="margin:2px;font-family:Verdana,Arial,Helvetica,sans-serif;font-size:10px;">' +
    				f_value +
    			'</body>';
  			
				var f_obj = document.getElementById("iframe_" + f_name).contentWindow;
        
				if (f_value != "") {
      		f_obj.document.open();
      		f_obj.document.writeln(f_str);
      		f_obj.document.close();
      	} else {
  				f_obj.document.write(f_str);
      	}
					
				if(Prototype.Browser.IE) {
				} else {
				}
				
				f_obj.document.designMode = "on";
					
				this.iFrameLoaded.push(f_name);
				
  		}, 
    	
    	/*
       * Brandbox.content.iFrameExec
       */
  		iFrameExec: function(sCommand, bUserInterface, vValue) {
  		
    		f_obj = document.getElementById("iframe_" + bUserInterface).contentWindow;    		
      	f_obj.focus();
      	f_obj.document.execCommand(sCommand, '', vValue ? vValue : '');
      	f_obj.focus();
    			
  		}
  	}
  }