


	window.onload = function() {
	
	
	
		
		
		
		
		
		/**
		*
		*	INITIALIZE AJAX FORM (KUNDENSTIMMEN)
		*
		**/
		
		if($('form_kundenstimmen')) {
		
			fks = $('form_kundenstimmen');
			fks.setAttribute('onsubmit', 'return sendKundenstimme()');
			fks.onsubmit = function() { sendKundenstimme(); return false; }
		
		}
		
		
		
		
		
		
		
		/**
		*
		*	INITIALIZE AJAX FORM (NEWSLETTER)
		*
		**/
		
		if($('order_newsletter')) {
		
			fks = $('form_newsletter');
			fks.setAttribute('onsubmit', 'return orderNewsletter()');
			fks.onsubmit = function() { orderNewsletter(); return false; }
		
		}
		
		
		
	
	}
	
	
	
	
	function switchTestimonials() {
	
		objs = $('testimonials').getElementsByTagName('div');
		visible = 0;
		
		for(i=0; i<objs.length; i++) {
		
			if(Element.visible(objs[i].id)) {
			
				new Effect.Fade(objs[i].id, { 
					duration:2,
					afterFinish:function(obj) { obj.element.style.zIndex = 1; }
				});
				
				visible = i;
				
				nextImg = (objs[visible+1]) ? (visible+1) : 0;

				$(objs[nextImg].id).style.zIndex = 10;
				new Effect.Appear(objs[nextImg].id, {
					duration:2
				});
				
				break;
				
			}
		
		}
	
	}
	
	
		
	
	function toggleSBItem(obj) {
	
		// reset all items
		sbItems = $('sb_list').getElementsByTagName('div');
		for(i=0; i<sbItems.length; i++) {
			if(Element.visible(sbItems[i])) { 
				new Effect.BlindUp(sbItems[i], { duration:.3 });
				sbItems[i].parentNode.className = '';
			}
		}
	
		// blind down current one
		obj = $('sb' + obj);
		if(!Element.visible(obj)) {
			new Effect.BlindDown(obj, { duration:.3 });
			obj.parentNode.className = 'active';
		}
		
	}
	
	
	function toggleFAQItem(obj) {
	
		// reset all items
		faqItems = $('faq_list').getElementsByTagName('div');
		for(i=0; i<faqItems.length; i++) {
			if(Element.visible(faqItems[i])) { 
				new Effect.BlindUp(faqItems[i], { duration:.3 });
				faqItems[i].parentNode.className = '';
			}
		}
	
		// blind down current one
		obj = $('faq' + obj);
		if(!Element.visible(obj)) {
			new Effect.BlindDown(obj, { duration:.3 });
			obj.parentNode.className = 'active';
		}
		
	}
	
	
	
	
	
	
	
	function sendKundenstimme() {
	
		new Ajax.Request('/ajax/kundenstimme.php', {
			method:'post',
			postBody:getFormValues('form_kundenstimmen'),
			onFailure:function() { alert('ajax request error'); },
			onSuccess:function(t) {
				Element.update('scriptcontainer', t.responseText);
			}
		});
		
		return false;
		
	}
	
	
	









	function orderNewsletter() {
	
		new Ajax.Request('/ajax/newsletter.php', {
			method:'post',
			postBody:getFormValues('form_newsletter'),
			onFailure:function() { alert('ajax request error'); },
			onSuccess:function(t) {
				Element.update('scriptcontainer', t.responseText);
			}
		});
		
		return false;
		
	}
	








	
	
	
	
	
	
	function getFormValues(formID) {
	
		if($(formID)) {
		
			returnstring = '';
		
			form_inputs = $(formID).getElementsByTagName('input');
			form_textareas = $(formID).getElementsByTagName('textarea');
			
			for(i=0; i<form_inputs.length; i++) {
				if(form_inputs[i].name) {
					returnstring += '&' + form_inputs[i].name + '=' + encodeURI(form_inputs[i].value);
				}
			}
			
			for(i=0; i<form_textareas.length; i++) {
				if(form_textareas[i].name) {
					returnstring += '&' + form_textareas[i].name + '=' + encodeURI(form_textareas[i].value);
				}
			}
		
			return returnstring.substring(1);
		
		}
	
	}
	
	
	
	
	
	
	function showSedcardFAQ() {
	
		if($('faq_daten_anlegen')) {
		
			if(!$('popcontainer')) {
		
				obj = $('faq_daten_anlegen');

				pop = document.createElement('div');
				pop.style.background = 'url(/imgs/clear.gif)';
				pop.style.display = 'none';
				pop.style.width = '100%';
				pop.style.height = '100%';
				pop.style.position = 'absolute';
				pop.style.top = '0px';
				pop.style.left = '0px';
				pop.id = 'popcontainer';
				pop.innerHTML = obj.innerHTML;

				document.getElementsByTagName('body')[0].appendChild(pop);
				Element.hide($('popcontainer').getElementsByTagName('div')[0]);
				Element.show('popcontainer');

				$('popcontainer').getElementsByTagName('div')[0].innerHTML = $('popcontainer').getElementsByTagName('div')[0].innerHTML + '<p><a class="close" href="#" onclick="return showSedcardFAQ();">Hinweis schlie&szlig;en</a></p>';

				new Effect.Fade('container', { duration:0.6, to:0.1 });
				new Effect.Appear($('popcontainer').getElementsByTagName('div')[0], { duration:0.6 });
				
			}
			
			else {
			
				new Effect.Fade($('popcontainer').getElementsByTagName('div')[0], { duration:0.6 });
				new Effect.Appear('container', { duration:0.6, to:1.0, afterFinish:function() { Element.remove('popcontainer'); } });

			}
			
		}
		
		return false;
	
	}
	
	
	
	
	
	
	
	function doRegistrierung() {
	
		if($('registerform')) {
		
			new Ajax.Request('/ajax/registrierung.php', {
				method:'post',
				postBody:Form.serialize('registerform'),
				onFailure:function() { alert('ajax request error'); },
				onSuccess:function(t) { 
				
					if(/class="error"/.test(t.responseText)) {
					
						$('errorcontainer').innerHTML = t.responseText;
						new Effect.Appear('errorlistcontainer', { duration:0.5 });
						
					}
					
					else {
					
						$('errorcontainer').innerHTML = '<span id="waitforajax">bitte warten...</span>';
						Element.hide('b_registrieren');
						
						
						window.setTimeout(function() {
					
							Element.hide('formcontainer');

							$('formcontainer').innerHTML = '<h4>Vielen Dank!</h4><p>Die Registrierung wurde erfolgreich abgeschlossen. Du kannst dich jetzt mit deiner E-Mail-Adresse und deinem Passwort einloggen und von unseren Angeboten Gebrauch machen!</p><p>Deine Zugangsdaten wurden soeben auch an die angegebene Adresse geschickt.</p>';

							new Effect.Appear('formcontainer', { duration:0.5 });
							
						}, 1500);
						
					}
				
				}
			});
	
		}
	
		return false;
	
	}
	
	
	
	
	
	
	
	
	
	
	
	
	function bb_nextStep(step) {
	
		if(step == 2) {

			new Effect.Fade('bb_step1', {
				afterFinish:function() {
				
					new Ajax.Request('/ajax/bildbearbeitung_imglisting.php', {
						postBody:'bbjid='+$('bbjid').innerHTML,
						onFailure:function() { alert('ajax request error'); },
						onSuccess:function(t) {
						
							Element.update('bb_imglisting', t.responseText);
							new Effect.Appear('bb_step2');
						
						}
					});
					
					
				}
			});

		}
		
		
		if(step == 3) {
		
			new Effect.Fade('bb_step2', {
				afterFinish:function() {
				
					new Ajax.Request('/ajax/bildbearbeitung_orderform.php', {
						postBody:Form.serialize('bb_orderform') + '&bbjid='+$('bbjid').innerHTML,
						onFailure:function() { alert('ajax request error'); },
						onSuccess:function(t) {
						
							Element.update('ajaxrequestexecuter', t.responseText);
							new Effect.Appear('bb_step3');
						
						}
					});
				
				}
			});
			
		}
		
		
		if(step == 4) {
		
			new Ajax.Request('/ajax/bildbearbeitung_finish.php', {
				postBody:Form.serialize('bb_finishform') + '&bbjid='+$('bbjid').innerHTML + '&' + Form.serialize('bb_orderform'),
				onFailure:function() { alert('ajax request error'); },
				onSuccess:function(t) { 
				
					if(/class="error"/.test(t.responseText)) {
					
						Element.hide('bb_finish_fourth');
						Element.update('bb_finish_fourth', t.responseText);
						new Effect.Appear('bb_finish_fourth');
						
					}
					
					else {
					
						new Effect.Fade('bb_step3', {
							afterFinish:function() {
								Element.update('bb_step3', '<p>Vielen Dank f&uuml;r Deine Beauftragung. Deine Daten wurden erfolgreich gespeichert und an uns &uuml;bermittelt.</p>');
								new Effect.Appear('bb_step3');
							}
						});
						
					}
				
				}
			});
		
		}
	
	}
	







	function doAGB() {
		
		if(!$('popcontainer')) {

			pop = document.createElement('div');
			pop.style.background = 'url(/imgs/clear.gif) #000';
			pop.style.display = 'none';
			pop.style.width = '100%';
			pop.style.height = '100%';
			pop.style.position = 'absolute';
			pop.style.top = '0px';
			pop.style.left = '0px';
			pop.id = 'popcontainer';

			pop2 = document.createElement('div');
			pop2.style.display = 'none';
			pop2.style.width = '700px';
			pop2.style.height = '450px';
			pop2.style.position = 'absolute';
			pop2.style.top = '50%';
			pop2.style.left = '50%';
			pop2.style.margin = '-220px 0 0 -350px';
			pop2.style.overflow = 'hidden';
			pop2.id = 'popcontent';
			
			document.getElementsByTagName('body')[0].appendChild(pop);
			document.getElementsByTagName('body')[0].appendChild(pop2);
			
			new Ajax.Request('/ajax/agb.php', {
				onSuccess:function(t) { 
					Element.update('popcontent', '<div style="text-align:right; height:30px;"><a href="#" onclick="return doAGB();" style="color:#fff; font-weight:bold; text-decoration:none; font-size:18px;" title="AGB schlie&szlig;en">[ x ]</a></div><div style="background:#fff; padding:25px; overflow:auto; height:370px; width:650px;">' + t.responseText + '</div>');
					new Effect.Appear('popcontainer', { 
						duration:0.5,
						to:0.6,
						afterFinish:function() {
							new Effect.Appear('popcontent', { 
								duration:0.5
							});
						}
					});
				}
			});
			
		}

		else {

			new Effect.Fade('popcontent', { duration:0.6 });
			new Effect.Fade('popcontainer', { duration:0.6,
				afterFinish:function() {
				
					Element.remove('popcontainer'); 
					Element.remove('popcontent'); 
					
				}
			});

		}
			
		return false;	
	
	}
	
	
	
	// Zahlen autom. addieren function zaehler() {   var anzahl = document.Form.anzahl.value;
	   	document.Form.ausgabeN.value=anzahl*3;
	document.Form.ausgabeB.value=(anzahl*3)*(19/100+1);

 }
	
	
	
	
	
	function sendKontakt() {
	
		new Ajax.Request('/ajax/kontakt.php', {
			postBody:Form.serialize('kontaktform'),
			onFailure:function() { alert('ajax request error'); },
			onSuccess:function(t) {
			
				if(/class="error"/.test(t.responseText)) {
				
					Element.hide('kontakt_right');
					Element.update('kontakt_right', t.responseText);
					new Effect.Appear('kontakt_right');
				
				}
				
				else {
				
					Element.hide('kontakt_right');
					Element.update('kontakt_left', '<p>Deine Anfrage wurde erfolgreich gesendet.</p><p>Vielen Dank!</p>');
					
				}
			
			}		
		});
		
		return false;
	
	}






	
	function sendkd() {
	
		new Ajax.Request('/ajax/kd.php', {
			postBody:Form.serialize('kdform'),
			onFailure:function() { alert('ajax request error'); },
			onSuccess:function(t) {
			
				if(/class="error"/.test(t.responseText)) {
				
					Element.hide('kd_right');
					Element.update('kd_right', t.responseText);
					new Effect.Appear('kd_right');
				
				}
				
				else {
				
					Element.hide('kd_right');
					Element.update('kd_left', '<p>Deine Anfrage wurde erfolgreich gesendet.</p><p>Vielen Dank!</p>');
					
				}
			
			}		
		});
		
		return false;
	
	}
	
	
	
	
	
	
	
	function va_nextStep(step) {
	
		if(step == 2) {

			new Effect.Fade('va_step1', {
				afterFinish:function() {
				
					new Effect.Appear('va_step2');
					
				}
			});

		}
		
		
		if(step == 3) {
		
			new Ajax.Request('/ajax/visitenkarten_autogrammkarten_finish.php', {
				postBody:Form.serialize('va_orderform') + '&vajid='+$('vajid').innerHTML,
				onFailure:function() { alert('ajax request error'); },
				onSuccess:function(t) { 

					if(/class="error"/.test(t.responseText)) {

						Element.hide('va_right');
						Element.update('va_right', t.responseText);
						new Effect.Appear('va_right');

					}

					else {

						Element.hide('va_right');
						Element.update('content-main', '<p>Deine Auftragsdaten wurde erfolgreich an uns &uuml;bermittelt.</p><p>Vielen Dank!</p>');

					}
				
				}			
			});
			
		}
		
		
		return false;
		
	
	}
	

