//feedbackform 

feedbackform = {
	chkFormular: function (objectid) {
			var errors	=	 new Array;
		  	var errorText	=	'';
		  	var Email = /^[a-zA-Z0-9-\.\_]+@[a-zA-Z0-9-\_]+\.[a-z0-9-\.\_]{2,}$/;
		  	
		  T$("#FSPHP_message"+objectid).html('');
		  
		  if (T$("#name"+objectid).val() == "") {
		  	   T$("#name"+objectid).addClass("Tcomier");
			   errors.push("Name");
		  }
		  else   T$("#name"+objectid).removeClass("Tcomier");
		  	
		 
		   if (T$("#betreff"+objectid).val() == "") {
		            T$("#betreff"+objectid).addClass("Tcomier");
		            errors.push("Betreff");
		  }
		  else   T$("#betreff"+objectid).removeClass("Tcomier");
		  
		   if (T$("#nachricht"+objectid).val() == "") {
		          T$("#nachricht"+objectid).addClass("Tcomker");
		          errors.push("Nachricht");
		  }
		  else   T$("#nachricht"+objectid).removeClass("Tcomker");
		  
		  if (T$("#mailto"+objectid).val() == "") {
		         T$("#mailto"+objectid).addClass("Tcomier");
		         errors.push("Empfänger");
		  }
		  else   T$("#mailto"+objectid).removeClass("Tcomier");
		  
		  if (T$("#email"+objectid).val().indexOf("@") == -1 || !Email.test(T$("#email"+objectid).val())) {
		         T$("#email"+objectid).addClass("Tcomier");
		         errors.push("Email");
		  }
		  else   T$("#email"+objectid).removeClass("Tcomier");
		  
		  if( ! errors.length > 0)
		  	  feedbackform.mSendData(objectid);
		  else
		  	 {
		  	 	  if(errors.length > 1)
		  	 	{
		  	 	for (i=0; i<errors.length;i++)
		  	 	{
		  	 		if(i == (errors.length-1) )
		  	 			errorText=errorText+"  und "+errors[i];
		  	 		else if(i != 0)
		  	 			errorText=errorText+", "+errors[i];
		  	 		else 
		  	 			errorText=errorText+errors[i];
		  	 		
		  	 	}
		  	 	}
		  	 	 else	errorText=errors[0];
		  	 T$("#FSPHP_message"+objectid).html('<font color="#6C6C6C">Bitte füllen Sie die Felder '+errorText+' aus!</font> <br/>');
		  	 return false;
		  	 }
		
		},
	mSendData: function (objectid) {
	T$('#submitletterbutton'+objectid).attr("disabled", "true");
	var rNachricht	=  encodeURIComponent(T$('#nachricht'+objectid).val());
	var rName	=  encodeURIComponent(T$('#name'+objectid).val());	
	var rBetreff	=  encodeURIComponent(T$('#betreff'+objectid).val());	
	T$.ajax({
	type: "GET",
	dataType: 'jsonp',
	jsonp: 'jsonp_callback',
	url: 'http://af.fs-t-online.de/mailing/feedbackform/feedbackform.php',
	data: "action=jsonp"+"&name="+rName+"&email="+T$('#email'+objectid).val()+"&mailto="+T$('#mailto'+objectid).val()+"&betreff="+rBetreff+"&nachricht="+rNachricht+"&submit="+T$('#submitletterbutton'+objectid).val(),
	success: function (data) {
			if(data['errors'])	T$("#FSPHP_message"+objectid).html(data['errors']);
			else if(data['Meldung'])	T$("#FSPHP_feedbackform_"+objectid).html('<span style="clear:both;text-align:center;width:100%;float:none;"><img src="http://af.fs-t-online.de/mailing/feedbackform/imgs/haken.png" /><br/><br/>'+data['Meldung']+'</span>');
		}
	});
	},
	mChkmaxlength: function (objectid) {
		var max = parseInt(T$('#nachricht'+objectid).attr('maxlength'));
	        if(T$('#nachricht'+objectid).val().length > max){
	            T$('#nachricht'+objectid).val(T$('#nachricht'+objectid).val().substr(0, T$('#nachricht'+objectid).attr('maxlength')));
	        }
	}
}
