$(function() {
	$('.error').hide();
	$('input.text-input').css({backgroundColor:"#98c6d8"});
  	$('input.text-input').focus(function(){
    	$(this).css({backgroundColor:"#213b60",color:"#ffffff"});
  	});
	
  	$('input.text-input').blur(function(){										
   		$(this).css({backgroundColor:"#98c6d8",color:"#213b60"});
  	});
	
	$('textarea').focus(function(){
		$(this).css({backgroundColor:"#213b60",color:"#ffffff"});						 
	});
	
	$('textarea').blur(function(){										
   		$(this).css({backgroundColor:"#98c6d8",color:"#213b60"});
  	});
	
	
	
	$('#submit').click(function(){
		//validate and process from here
				
		$('.error').hide();
			
			var news= $("input#news:checked").val();
							
			var jahresbericht= $("input#jahresbericht:checked").val();
			
			var halbjahresbericht= $("input#halbjahresbericht:checked").val();
			
			var portrait= $("input#portrait:checked").val();
			
			var berichte= $("input#berichte:checked").val();
			
			var newsabo= $("input#newsabo:checked").val();
			
			var infos= $("input#infos:checked").val();
			
			var loeschen= $("input#loeschen:checked").val();
			
			var sprache= $('input:radio[@name="sprache"]:checked').val();
			
			var name= $('input#name').val();
				if (name == "") {
					$('label#name_error').show();
					$('input#name').focus();
					return false;
				}
			
			var vorname= $('input#vorname').val();
				if (vorname == "") {
					$('label#vorname_error').show();
					$('input#vorname').focus();
					return false;
				}
			
			var firma= $('input#firma').val();
			
			var funktion= $('input#funktion').val();
							
			var adresse= $('input#adresse').val();
				if (adresse == "") {
					$('label#adresse_error').show();
					$('input#adresse').focus();
					return false;
				}
								
			var ort= $('input#ort').val();
				if (ort == "") {
						$('label#ort_error').show();
						$('input#ort').focus();
						return false;
					}
			
			var land= $('input#land').val();
						
			var tel= $('input#tel').val();
			
			var fax= $('input#fax').val();
			
			var email = $('input#email').val();
			var reg = /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/;
   				if(reg.test(email) == false) {
      				$('label#email_error').show();
					$('input#email').focus();
      				return false;
   				}	
			
			var mitteilung= $('textarea#mitteilung').val();
			
			var dataString= 'name= ' + name + '&vorname= ' + vorname + '&firma= ' + firma + '&funktion= ' + funktion + '&adresse= ' + adresse + '&ort= ' + ort + '&land= ' + land + '&tel= ' + tel + '&fax= ' + fax + '&email= ' + email + '&news= ' + news + '&jahresbericht= ' + jahresbericht + '&halbjahresbericht= ' + halbjahresbericht + '&portrait= ' + portrait + '&berichte= ' + berichte + '&newsabo= ' + newsabo + '&infos= ' + infos + '&loeschen= ' + loeschen + '&sprache= ' + sprache + '&mitteilung= ' + mitteilung;
			
   			//alert (dataString);return false;
			
  			$.ajax({  
   				type: "POST",  
  				url: "http://www.swiss-prime-site.ch/bin/bestellung.php",  
   				data: dataString,   
  				success: function() { 
   					$('fieldset#bestellungen').html("<div class='error'></div>");  
   					$('div.error').html("<p>Vielen Dank f&uuml;r Ihre Mitteilung.</p>")  
  					.hide()  
  					.fadeIn(1500);  
 				}  
  			});
			return false;
		
	});	   
});

