var jamp = {

	AjaxPath:'ajax/',
	errorColor:'#AA000A',
	successColor:'#DCDDDE',

	isValidEmail: function(field) {
		var str=$(field).val();
		var filter=/^.+@.+\..{2,3}$/;
		if (filter.test(str)) {
			return true;
		} else {
			return false;
		}
	},

	checkKey: function(e) {
		if(window.event) {
			key = window.event.keyCode;
		} else {
			key = e.keyCode;
		}
		if(key==13) {
			Suche.Do($('Suche').value);
		}
	},
	
	Window:function() {
		window.open('shop.php','Shop','width=200,height=100,scrollbars=no');	
	}

}
	
var Suche = {
	
	Do: function(value) {
		if(value!='') window.location.href='suche.php?suchbegriff='+value;	
	}
	
}

var Sprache = {
	
	Set: function(value) {
		if(value!='') {
			window.location.href='index.php?lang='+value;	
		}
	}
	
}

var Shop = {

	err:0,
	checked:0,
	fieldArr:[
				   {	File:'Shop.php',
						SuccessText: 'Die Bestellung wurde erfolgreich abgeschickt. Sie erhalten eine Bestätigungsemail und werden in Kürze von uns kontaktiert.',
						Fields:	[
									{ Name:'Nachname', Required:true, Type:'text' },
									{ Name:'Vorname', Required:true, Type:'text' },
									{ Name:'Strasse', Required:true, Type:'text' },
									{ Name:'Hausnummer', Required:true, Type:'text' },
									{ Name:'PLZ', Required:true, Type:'text' },
									{ Name:'Ort', Required:true, Type:'text' },
									{ Name:'Telefon', Required:false, Type:'int' },
									{ Name:'Telefax', Required:false, Type:'int' },
									{ Name:'Email', Required:true, Type:'email' },
									
									{ Name:'Zahlungsmethode', Required:false, Type:'radio' },
									
									{ Name:'Kartentyp', Required:true, Type:'select' },
									{ Name:'Karteninhaber', Required:true, Type:'text' },
									{ Name:'Kartennummer', Required:true, Type:'int' },
									{ Name:'GueltigBis_Monat', Required:true, Type:'select' },
									{ Name:'GueltigBis_Jahr', Required:true, Type:'select' },
									
									{ Name:'Kontoinhaber', Required:true, Type:'text' },
									{ Name:'Kontonummer', Required:true, Type:'int' },
									{ Name:'BLZ', Required:true, Type:'int' },
									{ Name:'Bank', Required:true, Type:'text' },
									
									{ Name:'Submit', Required:false, Type:'button' }
								]
				   }
			],
	params:'',
	Text:'',
	i:0,
	u:0,

	setZahlungsmethode: function(id) {
		if(id=='Lastschrift') {
			$('#div_'+id).css('display','block');
			$('#div_Kreditkarte').css('display','none');
		} else {
			$('#div_'+id).css('display','block');
			$('#div_Lastschrift').css('display','none');
		}
	},

	add: function(id) {
		var t = this;
		
		var intVal = parseInt($('#preis_'+id).val());

		if($('#preis_'+id).val()!='') {
			if(intVal>0 || !isNaN($('#preis_'+id).val())) {
				$.ajax({
						type:'POST',
						data:'Mode=add&id='+id+'&anzahl='+intVal,
						url:jamp.AjaxPath+'Shop.php',
						success:function(html) {
							$('#preis_'+id).css('border','1px green solid');
						}
				});
			} else {
				$('#preis_'+id).css('border','1px #E40B20 solid');
			}
		} else {
			$('#preis_'+id).css('border','1px #DCDDDE solid');
		}
	},
	
	del: function(id) {
		
	},
	
	description: function(id) {
		if($('#Hinweis_'+id).css('display')=='block') {
			$('#Hinweis_'+id).css('display','none');	
		} else {
			$('#Hinweis_'+id).css('display','block');
		}
	},
	
	send: function() {
		var t = this;

		t.err = 0;
		t.i = 0;
		t.u = 0;

		$('#formShop input').each(function() {
			if( isNaN($(this).val()) || parseInt($(this).val())<=0 ) {
				t.err = 1;
			}
			if($(this).val()=='' || parseInt($(this).val())<=0) {
				t.i++;
			}
			t.u++;
		});
		
		if(t.i == t.u) {
			$('#errorEmpty').css('display','block');	
		} else {
			$('#errorEmpty').css('display','none');
		}
		
		if(t.err==0 && t.i < t.u) {
			window.location.href='produkteformular.php';
		}
	},
	
	sendForm: function(File) {
		t = Shop;
		t.Text ='';
		t.err = 0;
		this.params = '';
		var Zahlungsmethode = '';

		for(i=0;i<t.fieldArr.length;i++) {
			if(t.fieldArr[i].File==File) {
				t.Text=t.fieldArr[i].SuccessText;
				
				for(k=0;k<t.fieldArr[i].Fields.length;k++) {						
					var Arr = t.fieldArr[i].Fields[k];
					
				
					if($('#Kreditkarte:checked').val()=='Kreditkarte') {					
						if(Arr.Name=='Kartentyp') Arr.Required=true;
						if(Arr.Name=='Karteninhaber') Arr.Required=true;
						if(Arr.Name=='Kartennummer') Arr.Required=true;
						if(Arr.Name=='GueltigBis_Monat') Arr.Required=true;
						if(Arr.Name=='GueltigBis_Jahr') Arr.Required=true;
						
						if(Arr.Name=='Kontoinhaber') Arr.Required=false;
						if(Arr.Name=='Kontonummer') Arr.Required=false;
						if(Arr.Name=='BLZ') Arr.Required=false;
						if(Arr.Name=='Bank') Arr.Required=false;
						Zahlungsmethode = $('#Kreditkarte:checked').val();
					} else if($('#Lastschrift:checked').val()=='Lastschrift') {
						if(Arr.Name=='Kartentyp') Arr.Required=false;
						if(Arr.Name=='Karteninhaber') Arr.Required=false;
						if(Arr.Name=='Kartennummer') Arr.Required=false;
						if(Arr.Name=='GueltigBis_Monat') Arr.Required=false;
						if(Arr.Name=='GueltigBis_Jahr') Arr.Required=false;
						
						if(Arr.Name=='Kontoinhaber') Arr.Required=true;
						if(Arr.Name=='Kontonummer') Arr.Required=true;
						if(Arr.Name=='BLZ') Arr.Required=true;
						if(Arr.Name=='Bank') Arr.Required=true;
						Zahlungsmethode = $('#Lastschrift:checked').val();
					}
					
					if(Arr.Required==true) {
						if(Arr.Type=='text') {
							if($('#Form_'+Arr.Name).val()=='') {
								t.err++;
								$('#Form_'+Arr.Name).css('border','1px '+jamp.errorColor+' solid');
								//$('#Form_'+Arr.Name).style.borderColor=t.errColor;	
							} else {
								$('#Form_'+Arr.Name).css('border','1px '+jamp.successColor+' solid');
								//$('#Form_'+Arr.Name).style.borderColor=t.successColor;
							}
						} else if(Arr.Type=='radio') {
							
						} else if(Arr.Type=='select') {
							if($("#Form_"+Arr.Name+" option:selected").val()=='') {
								t.err++;
								$('#Form_'+Arr.Name).css('border','1px '+jamp.errorColor+' solid');
							} else {
								$('#Form_'+Arr.Name).css('border','1px '+jamp.successColor+' solid');
							}
						} else if(Arr.Type=='int') {
							if($('#Form_'+Arr.Name).val()=='' || isNaN($('#Form_'+Arr.Name).val())) {
								t.err++;
								$('#Form_'+Arr.Name).css('border','1px '+jamp.errorColor+' solid');
								//$('#Form_'+Arr.Name).style.borderColor=t.errColor;
							} else {
								$('#Form_'+Arr.Name).css('border','1px '+jamp.successColor+' solid');
								//$('#Form_'+Arr.Name).style.borderColor=t.successColor;
							}
						} else if(Arr.Type=='checkbox') {
							if($('#Form_'+Arr.Name).checked==false) {
								t.err++;
								$('#Form_'+Arr.Name).css('border','1px '+jamp.errorColor+' solid');
								//$('#Form_'+Arr.Name).style.borderColor=t.errColor;
							} else {
								$('#Form_'+Arr.Name).css('border','1px '+jamp.successColor+' solid');
								//$('#Form_'+Arr.Name).style.borderColor=t.successColor;
							}
						} else if(Arr.Type=='email') {
							if(!jamp.isValidEmail('#Form_'+Arr.Name)) {
								t.err++;
								$('#Form_'+Arr.Name).css('border','1px '+jamp.errorColor+' solid');
								//$('#Form_'+Arr.Name).style.borderColor=t.errColor;
							} else {
								$('#Form_'+Arr.Name).css('border','1px '+jamp.successColor+' solid');
								//$('#Form_'+Arr.Name).style.borderColor=t.successColor;
							}
						}
						
						if(Arr.Type=='radio') {
							this.params+=Arr.Name+'='+Zahlungsmethode+'&';
						} else {
							this.params+=Arr.Name+'='+$('#Form_'+Arr.Name).val()+'&';	
						}
					} else {
						if(Arr.Type=='radio') {
							this.params+=Arr.Name+'='+Zahlungsmethode+'&';
						} else {
							this.params+=Arr.Name+'='+$('#Form_'+Arr.Name).val()+'&';
						}
					}
					
				}
			}
		}
	
		if(t.err<=0) {
			$.ajax({
						type:'post',
						url:jamp.AjaxPath+'Shop.php',
						data:'Mode=send&'+this.params,
						success:function(html) {
							if(html=='done') {
/*								$('html,body').animate({
									scrollTop: $('html').offset().top
								}, 2000);*/
								
								$('.textcontainer').html(t.Text);
							} else {
								
							}
						}
				   });
		}
	}
}


var Shop2 = {

    produktuebersicht:'produkteuebersichtshop.php',

	err:0,
	checked:0,
	fieldArr:[
				   {	File:'Shop2.php',
						SuccessText: '<div style="margin:25px 0px 0px 0px;">Die Bestellung wurde erfolgreich abgeschickt. Sie erhalten eine Bestätigungsemail und werden in Kürze von uns kontaktiert.</div>',
						Fields:	[
									{ Name:'Nachname', Required:true, Type:'text' },
									{ Name:'Vorname', Required:true, Type:'text' },
									{ Name:'Strasse', Required:true, Type:'text' },
									{ Name:'Hausnummer', Required:true, Type:'text' },
									{ Name:'PLZ', Required:true, Type:'text' },
									{ Name:'Ort', Required:true, Type:'text' },
									{ Name:'Telefon', Required:false, Type:'int' },
									{ Name:'Telefax', Required:false, Type:'int' },
									{ Name:'Email', Required:true, Type:'email' },

									{ Name:'Zahlungsmethode', Required:false, Type:'radio' },

									{ Name:'Kartentyp', Required:true, Type:'select' },
									{ Name:'Karteninhaber', Required:true, Type:'text' },
									{ Name:'Kartennummer', Required:true, Type:'int' },
									{ Name:'GueltigBis_Monat', Required:true, Type:'select' },
									{ Name:'GueltigBis_Jahr', Required:true, Type:'select' },

									{ Name:'Kontoinhaber', Required:true, Type:'text' },
									{ Name:'Kontonummer', Required:true, Type:'int' },
									{ Name:'BLZ', Required:true, Type:'int' },
									{ Name:'Bank', Required:true, Type:'text' },

									{ Name:'Submit', Required:false, Type:'button' }
								]
				   }
			],
	params:'',
	Text:'',
	i:0,
	u:0,
    arrowTop:'img/pfeiloben.gif',
    arrowBottom:'img/pfeilunten.gif',

    toggle: function(id,productNo) {
        if($('#produkte_'+id).css('display')=='none') {
            $('#produkte_'+id).slideDown('fast');
            $('#toggle_'+id+'_'+productNo).html('<img src="'+this.arrowTop+'" border="0" width="16" height="16" title="Produkte ausblenden" alt="Produkte ausblenden" align="absmiddle" />Produkte ausblenden');
        } else {
            $('#produkte_'+id).slideUp('fast');
            $('#toggle_'+id+'_'+productNo).html('<img src="'+this.arrowBottom+'" border="0" width="16" height="16" title="Produkte anzeigen" alt="Produkte anzeigen" align="absmiddle" />Produkte anzeigen');
        }
    },

    setZahlungsmethode: function(id) {
		if(id=='Lastschrift') {
			$('#div_'+id).css('display','block');
			$('#div_Kreditkarte').css('display','none');
		} else {
			$('#div_'+id).css('display','block');
			$('#div_Lastschrift').css('display','none');
		}
	},

	add: function(id,productNo) {
		var t = this;

		var intVal = parseInt($('#preis_'+id+'_'+productNo).val());

		if($('#preis_'+id+'_'+productNo).val()!='') {
			if(intVal>0 || !isNaN($('#preis_'+id+'_'+productNo).val())) {
				$.ajax({
						type:'POST',
						data:'Mode=add&id='+id+'&anzahl='+intVal+'&productNo='+productNo,
						url:jamp.AjaxPath+'Shop2.php',
						success:function(html) {
                            if(intVal>0){
                                $('#preis_'+id+'_'+productNo).css('border','1px green solid');
                                $('#link_del_'+id+'_'+productNo).fadeIn('fast');
                            } else {
                                $('#preis_'+id+'_'+productNo).css('border','1px #DCDDDE solid');
                                $('#link_del_'+id+'_'+productNo).fadeOut('fast');
                            }
						}
				});
			} else {
				$('#preis_'+id+'_'+productNo).css('border','1px #E40B20 solid');
			}
		} else {
			$('#preis_'+id+'_'+productNo).css('border','1px #DCDDDE solid');
		}
	},

	del: function(id,productNo) {
        var t = this;

        $.ajax({
                type:'POST',
                data:'Mode=del&id='+id+'&productNo='+productNo,
                url:jamp.AjaxPath+'Shop2.php',
                success:function(html) {
                    if(html>0) {
                        $('#produkte_'+id+' #produkt_item_'+productNo).slideUp('fast');
                    } else {
                        t.delAll(id);
                    }
                }
        });
	},

    delAll: function(id) {
        var t = this;
        
        $.ajax({
                type:'POST',
                data:'Mode=delAll&id='+id,
                url:jamp.AjaxPath+'Shop2.php',
                success:function(html) {
                    if(html>0) {
                        $('#produktbox_'+id).slideUp('fast',function() {
                            window.location.reload();
                        });
                    } else {
                        $('#produktbox_'+id).slideUp('fast',function() {
                            window.location.href=t.produktuebersicht;
                        });
                    }
                }
        });
    },

    delQuantity: function(id,productNo) {
        var t = this;

        $.ajax({
                type:'POST',
                data:'Mode=del&id='+id+'&productNo='+productNo,
                url:jamp.AjaxPath+'Shop2.php',
                success:function(html) {
                    if(html<=0) {
                        t.delAll(id);
                    }

                    $('#preis_'+id+'_'+productNo).val('');
                    $('#preis_'+id+'_'+productNo).css('border','1px #DCDDDE solid');
                    $('#produkte_'+id+' #produkt_item_'+productNo).slideUp('fast');
                    $('#link_del_'+id+'_'+productNo).fadeOut('fast');
                }
        });
    },

	description: function(id) {
		if($('#Hinweis_'+id).css('display')=='block') {
			$('#Hinweis_'+id).css('display','none');
		} else {
			$('#Hinweis_'+id).css('display','block');
		}
	},

	send: function() {
		var t = this;

		t.err = 0;
		t.i = 0;
		t.u = 0;

		$('#formShop input').each(function() {
			if( isNaN($(this).val()) || parseInt($(this).val())<=0 ) {
				t.err = 1;
			}
			if($(this).val()=='' || parseInt($(this).val())<=0) {
				t.i++;
			}
			t.u++;
		});

		if(t.i == t.u) {
			$('#errorEmpty').css('display','block');
		} else {
			$('#errorEmpty').css('display','none');
		}

		if(t.err==0 && t.i < t.u) {
			window.location.href='produkteformularshop.php';
		}
	},

	sendForm: function(File) {
		t = Shop2;
		t.Text ='';
		t.err = 0;
		this.params = '';
		var Zahlungsmethode = '';

		for(i=0;i<t.fieldArr.length;i++) {
			if(t.fieldArr[i].File==File) {
                
				t.Text=t.fieldArr[i].SuccessText;

				for(k=0;k<t.fieldArr[i].Fields.length;k++) {
					var Arr = t.fieldArr[i].Fields[k];


					if($('#Kreditkarte:checked').val()=='Kreditkarte') {
						if(Arr.Name=='Kartentyp') Arr.Required=true;
						if(Arr.Name=='Karteninhaber') Arr.Required=true;
						if(Arr.Name=='Kartennummer') Arr.Required=true;
						if(Arr.Name=='GueltigBis_Monat') Arr.Required=true;
						if(Arr.Name=='GueltigBis_Jahr') Arr.Required=true;

						if(Arr.Name=='Kontoinhaber') Arr.Required=false;
						if(Arr.Name=='Kontonummer') Arr.Required=false;
						if(Arr.Name=='BLZ') Arr.Required=false;
						if(Arr.Name=='Bank') Arr.Required=false;
						Zahlungsmethode = $('#Kreditkarte:checked').val();
					} else if($('#Lastschrift:checked').val()=='Lastschrift') {
						if(Arr.Name=='Kartentyp') Arr.Required=false;
						if(Arr.Name=='Karteninhaber') Arr.Required=false;
						if(Arr.Name=='Kartennummer') Arr.Required=false;
						if(Arr.Name=='GueltigBis_Monat') Arr.Required=false;
						if(Arr.Name=='GueltigBis_Jahr') Arr.Required=false;

						if(Arr.Name=='Kontoinhaber') Arr.Required=true;
						if(Arr.Name=='Kontonummer') Arr.Required=true;
						if(Arr.Name=='BLZ') Arr.Required=true;
						if(Arr.Name=='Bank') Arr.Required=true;
						Zahlungsmethode = $('#Lastschrift:checked').val();
					}

					if(Arr.Required==true) {
						if(Arr.Type=='text') {
							if($('#Form_'+Arr.Name).val()=='') {
								t.err++;
								$('#Form_'+Arr.Name).css('border','1px '+jamp.errorColor+' solid');
								//$('#Form_'+Arr.Name).style.borderColor=t.errColor;
							} else {
								$('#Form_'+Arr.Name).css('border','1px '+jamp.successColor+' solid');
								//$('#Form_'+Arr.Name).style.borderColor=t.successColor;
							}
						} else if(Arr.Type=='radio') {

						} else if(Arr.Type=='select') {
							if($("#Form_"+Arr.Name+" option:selected").val()=='') {
								t.err++;
								$('#Form_'+Arr.Name).css('border','1px '+jamp.errorColor+' solid');
							} else {
								$('#Form_'+Arr.Name).css('border','1px '+jamp.successColor+' solid');
							}
						} else if(Arr.Type=='int') {
							if($('#Form_'+Arr.Name).val()=='' || isNaN($('#Form_'+Arr.Name).val())) {
								t.err++;
								$('#Form_'+Arr.Name).css('border','1px '+jamp.errorColor+' solid');
								//$('#Form_'+Arr.Name).style.borderColor=t.errColor;
							} else {
								$('#Form_'+Arr.Name).css('border','1px '+jamp.successColor+' solid');
								//$('#Form_'+Arr.Name).style.borderColor=t.successColor;
							}
						} else if(Arr.Type=='checkbox') {
							if($('#Form_'+Arr.Name).checked==false) {
								t.err++;
								$('#Form_'+Arr.Name).css('border','1px '+jamp.errorColor+' solid');
								//$('#Form_'+Arr.Name).style.borderColor=t.errColor;
							} else {
								$('#Form_'+Arr.Name).css('border','1px '+jamp.successColor+' solid');
								//$('#Form_'+Arr.Name).style.borderColor=t.successColor;
							}
						} else if(Arr.Type=='email') {
							if(!jamp.isValidEmail('#Form_'+Arr.Name)) {
								t.err++;
								$('#Form_'+Arr.Name).css('border','1px '+jamp.errorColor+' solid');
								//$('#Form_'+Arr.Name).style.borderColor=t.errColor;
							} else {
								$('#Form_'+Arr.Name).css('border','1px '+jamp.successColor+' solid');
								//$('#Form_'+Arr.Name).style.borderColor=t.successColor;
							}
						}

						if(Arr.Type=='radio') {
							this.params+=Arr.Name+'='+Zahlungsmethode+'&';
						} else {
							this.params+=Arr.Name+'='+$('#Form_'+Arr.Name).val()+'&';
						}
					} else {
						if(Arr.Type=='radio') {
							this.params+=Arr.Name+'='+Zahlungsmethode+'&';
						} else {
							this.params+=Arr.Name+'='+$('#Form_'+Arr.Name).val()+'&';
						}
					}

				}
			}
		}

		if(t.err<=0) {
			$.ajax({
						type:'post',
						url:jamp.AjaxPath+'Shop2.php',
						data:'Mode=send&'+this.params,
						success:function(html) {
							if(html=='done') {
/*								$('html,body').animate({
									scrollTop: $('html').offset().top
								}, 2000);*/

								$('.contentsgesamt').html(t.Text);
							} else {

							}
						}
				   });
		}
	}
}


var Form = {
	// fieldArr beinhaltet alle Felder aus dem Formular:
	/*
	 *	KONFIGURIERT FÜR jQuery!!!	
	 *
	 *	File: Die Datei, von der aus die E-Mail versendet wird. Standardmäßig wohl "Mail.php" im "Ajax"-Verzeichnis
	 *	SuccessText: Der Text, der ausgegeben werden soll, wenn das Formular erfolgreich verschickt wurde.
	 *	Fields: Ein Array, mit den Feldname, dem Überprüfungsmodus und dem Feldtypen:
	 *		Name: Ist die ID des Feldes ohne (!) "Form_".
	 *		Required: Ist Required auf true gesetzt, wird es auf Gültigkeit überprüft, andernfalls rutscht es so durch
	 *		Type:
	 *				text: Ist ein ganz normales Textfeld oder Textareafeld. Wird dann auf leer geprüft
	 *				int: Ist ein numerisches Feld und prüft, ob nur gültige Zahlen verwendet wurden
	 *				email: Ist ein "Textfeld", jedoch wird geprüft, ob die eingebene E-Mail Adresse gültig ist
	 *				checkbox: Prüft, ob bei dem Checkboxfeld der Haken gesetzt wurde
	 *				button: Ist der Sende- bzw. Abbrech-button.
	 *
	*/
	fieldArr:[
			   {	File:'Mail.php',
			   		SuccessText: 'Die Kontaktanfrage wurde erfolgreich versendet.',
					Fields:	[
								{ Name:'Nachname', Required:true, Type:'text' },
								{ Name:'Vorname', Required:true, Type:'text' },
								{ Name:'Strasse', Required:false, Type:'text' },
								{ Name:'Hausnummer', Required:false, Type:'text' },
								{ Name:'Telefon', Required:false, Type:'int' },
								{ Name:'Telefax', Required:false, Type:'int' },
								{ Name:'Email', Required:true, Type:'email' },
								{ Name:'Mitteilung', Required:true, Type:'text' },
								{ Name:'Submit', Required:false, Type:'button' }
							]
			   }
			 ],
	
	err:0,
	i:0,
	params:'',
	Text:'',
	
	errorHandling: {
		init:function(File) {
			t = Form;
			t.Text='';
			t.err=0;
			this.params='';

			for(i=0;i<t.fieldArr.length;i++) {
				if(t.fieldArr[i].File==File) {
					t.Text=t.fieldArr[i].SuccessText;
					
					for(k=0;k<t.fieldArr[i].Fields.length;k++) {						
						var Arr = t.fieldArr[i].Fields[k];
						
						if(Arr.Required==true) {
							if(Arr.Type=='text') {
								if($('#Form_'+Arr.Name).val()=='') {
									t.err++;
									$('#Form_'+Arr.Name).css('border','1px '+jamp.errorColor+' solid');
									//$('#Form_'+Arr.Name).style.borderColor=t.errColor;	
								} else {
									$('#Form_'+Arr.Name).css('border','1px '+jamp.successColor+' solid');
									//$('#Form_'+Arr.Name).style.borderColor=t.successColor;
								}
							} else if(Arr.Type=='int') {
								if($('#Form_'+Arr.Name).val()=='' || isNaN($('#Form_'+Arr.Name).val())) {
									t.err++;
									$('#Form_'+Arr.Name).css('border','1px '+jamp.errorColor+' solid');
									//$('#Form_'+Arr.Name).style.borderColor=t.errColor;
								} else {
									$('#Form_'+Arr.Name).css('border','1px '+jamp.successColor+' solid');
									//$('#Form_'+Arr.Name).style.borderColor=t.successColor;
								}
							} else if(Arr.Type=='checkbox') {
								if($('#Form_'+Arr.Name).checked==false) {
									t.err++;
									$('#Form_'+Arr.Name).css('border','1px '+jamp.errorColor+' solid');
									//$('#Form_'+Arr.Name).style.borderColor=t.errColor;
								} else {
									$('#Form_'+Arr.Name).css('border','1px '+jamp.successColor+' solid');
									//$('#Form_'+Arr.Name).style.borderColor=t.successColor;
								}
							} else if(Arr.Type=='email') {
								if(!jamp.isValidEmail('#Form_'+Arr.Name)) {
									t.err++;
									$('#Form_'+Arr.Name).css('border','1px '+jamp.errorColor+' solid');
									//$('#Form_'+Arr.Name).style.borderColor=t.errColor;
								} else {
									$('#Form_'+Arr.Name).css('border','1px '+jamp.successColor+' solid');
									//$('#Form_'+Arr.Name).style.borderColor=t.successColor;
								}
							}
						}
						
						this.params+=Arr.Name+'='+$('#Form_'+Arr.Name).val()+'&'
					}
				}
			}
		
			if(t.err<=0) {
				$.ajax({
							type:'post',
							url:jamp.AjaxPath+'Kontakt.php',
							data:this.params,
							success:function(html) {
								if(html=='done') {
								//	$('.fliesstext').html(t.Text);
								window.location.href='kontaktbestaetigung';
								} else {
									
								}
							}
					   });
			}
		}
	},
	save:function(File) { this.errorHandling.init(File); }
}

var Newsletter = {
	
	error:0,
	fieldArr:[
				{ Name:'Anrede', Output:'Anrede', Required:false, Type:'text' },
				{ Name:'Name', Output:'Name', Required:true, Type:'text' },
				{ Name:'Vorname', Output:'Vorname', Required:true, Type:'text' },
				{ Name:'Email', Output:'E-Mail', Required:true, Type:'email' }
			 ],
	params:'',
	errorParams:'',
	
	Aktivieren: function(Bereich,Aktivierung,Email) {
		$.ajax({
				type:'post',
				url:jamp.AjaxPath+'Newsletter.php',
				data:'Mode='+Bereich+'&Aktivierung='+Aktivierung+'&Email='+Email,
				success:function(html) {
					if(html=='done') {
						$('.fliesstext').html('Sie haben sich erfolgreich für den Newsletter freigeschaltet.');
						for(i=0;i<Newsletter.fieldArr.length;i++) {
							$('#'+Newsletter.fieldArr[i].Name).val('');	
						}
					} else {
						$('.fliesstext').html(html);
					}
				}
			});
	},
	
	Deaktivieren: function(Bereich,Aktivierung,Email) {
		$.ajax({
				type:'post',
				url:jamp.AjaxPath+'Newsletter.php',
				data:'Mode='+Bereich+'&Aktivierung='+Aktivierung+'&Email='+Email,
				success:function(html) {
					if(html=='done') {
						$('.fliesstext').html('Sie haben sich erfolgreich aus dem Newsletterverteiler entfernt.');
						for(i=0;i<Newsletter.fieldArr.length;i++) {
							$('#'+Newsletter.fieldArr[i].Name).val('');	
						}
					} else {
						$('.fliesstext').html(html);
					}
				}
			});
	},
	
	Abonnieren: function() {
		this.error=0;
		this.params='';
		this.errorParams='';
		
		for(i=0;i<this.fieldArr.length;i++) {
			if(this.fieldArr[i].Required==true) {
				if(this.fieldArr[i].Type=='text') {
					if(jQuery.trim($('#'+this.fieldArr[i].Name).val())=='') {
						$('#'+this.fieldArr[i].Name).css('border','1px '+jamp.errorColor+' solid');
						
						this.errorParams+=this.fieldArr[i].Name+'['+this.fieldArr[i].Output+']='+jQuery.trim($('#'+this.fieldArr[i].Name).val())+'&';
						
						this.error++;
					} else {
						$('#'+this.fieldArr[i].Name).css('border','1px '+jamp.successColor+' solid');	
					}
				} else if(this.fieldArr[i].Type=='email') {
					if(!jamp.isValidEmail('#'+this.fieldArr[i].Name)) {
						$('#'+this.fieldArr[i].Name).css('border','1px '+jamp.errorColor+' solid');
						
						//this.errorParams+=this.fieldArr[i].Name+'['+this.fieldArr[i].Output+']='+jQuery.trim($('#'+this.fieldArr[i].Name).val())+'&';
						//StatusBox.SetParams('Email[E-Mail]={Email}&');
						this.error++;
					} else {
						$('#'+this.fieldArr[i].Name).css('border','1px '+jamp.successColor+' solid');	
					}
				}
				
			}
			this.params+=this.fieldArr[i].Name+'='+$('#'+this.fieldArr[i].Name).val()+'&';
		}
		
		if(this.error>0) {
			/*StatusBox.SetParams(this.errorParams);
			StatusBox.Execute();*/
		} else {
			$.ajax({
				type:'post',
				url:jamp.AjaxPath+'Newsletter.php',
				data:'Mode=Abonnieren&'+Newsletter.params,
				success:function(html) {
					if(html=='accept') {
						$('.fliesstext').html('Sie haben sich erfolgreich für den Newsletter registriert. Ihnen wird in Kürze eine E-Mail mit einem Bestätigungslink geschickt, den Sie öffnen müssen, um für den Newsletter freigeschaltet zu werden.');
						for(i=0;i<Newsletter.fieldArr.length;i++) {
							$('#'+Newsletter.fieldArr[i].Name).val('');	
						}
					} else {
						$('.fliesstext').html(html);
					}
				}
			});
		}
	},
	
	Abmelden: function() {
		this.error=0;
		this.params='';
		this.errorParams='';
		
		if($('#EmailAbmelden').val()=='') {
			this.error++;
			$('#EmailAbmelden').css('border','1px '+jamp.errorColor+' solid');
			this.errorParams+='EmailAbmelden[E-Mail]='+jQuery.trim($('#EmailAbmelden').val())+'&';
		} else if(!jamp.isValidEmail('#EmailAbmelden')) {
			this.error++;
			$('#EmailAbmelden').css('border','1px '+jamp.errorColor+' solid');
			StatusBox.SetParams('Email[E-Mail]={Email}&');
			//this.errorParams+='EmailAbmelden[E-Mail]='+jQuery.trim($('#EmailAbmelden').val())+'&';
		} else {
			this.params+='Email='+$('#EmailAbmelden').val()+'&';
			$('#EmailAbmelden').css('border','1px '+jamp.successColor+' solid');	
		}
		
		if(this.error>0) {
			/*StatusBox.SetParams(this.errorParams);
			StatusBox.Execute();*/
		} else {
			$.ajax({
				type:'post',
				url:jamp.AjaxPath+'Newsletter.php',
				data:'Mode=Abmelden&'+Newsletter.params,
				success:function(html) {
					if(html=='decline') {
						$('.fliesstext').html('Sie haben sich erfolgreich abgemeldet. Ihnen wird eine E-Mail mit einem Bestätigungslink zu gesendet, den Sie öffnen müssen.');
						$('#EmailAbmelden').val('');	
					} else {
						$('.fliesstext').html(html);
					}
				}
			});	
		}
	}
}

function TurnOver(url,wenn) {
	if(!url) var url='';
	wenn.style.backgroundImage = "url('"+url+"img/buttonon.gif')";
}

function TurnOut(url,wenn) {
	if(!url) var url='';
	wenn.style.backgroundImage = "url('"+url+"img/buttonoff.gif')";
}
