


$().ready(function() {
  $('#nl').jqm({
    trigger: '#nlTrigger',
    overlay: 30, /* 0-100 (int) : 0 is off/transparent, 100 is opaque */
    overlayClass: 'whiteOverlay'})
    .jqDrag('.jqDrag'); /* make dialog draggable, assign handle to title */
  
  // Close Button Highlighting. IE doesn't support :hover. Surprise?
  $('input.jqmdX')
  .hover(
    function(){ $(this).addClass('jqmdXFocus'); }, 
    function(){ $(this).removeClass('jqmdXFocus'); })
  .focus( 
    function(){ this.hideFocus=true; $(this).addClass('jqmdXFocus'); })
  .blur( 
    function(){ $(this).removeClass('jqmdXFocus'); 
  });
  

 /*********/ 
	 $('#cb').jqm({
    trigger: '#cbTrigger',
    overlay: 30, /* 0-100 (int) : 0 is off/transparent, 100 is opaque */
    overlayClass: 'whiteOverlay'})
    .jqDrag('.jqDrag'); /* make dialog draggable, assign handle to title */
  
  // Close Button Highlighting. IE doesn't support :hover. Surprise?
  $('input.jqmdX')
  .hover(
    function(){ $(this).addClass('jqmdXFocus'); }, 
    function(){ $(this).removeClass('jqmdXFocus'); })
  .focus( 
    function(){ this.hideFocus=true; $(this).addClass('jqmdXFocus'); })
  .blur( 
    function(){ $(this).removeClass('jqmdXFocus'); });
  
  
 /*********/ 
 $('#wc').jqm({
    trigger: '#wcTrigger, #wcTrigger2',
    overlay: 30, /* 0-100 (int) : 0 is off/transparent, 100 is opaque */
    overlayClass: 'whiteOverlay'})
    .jqDrag('.jqDrag'); /* make dialog draggable, assign handle to title */
  
  // Close Button Highlighting. IE doesn't support :hover. Surprise?
  $('input.jqmdX')
  .hover(
    function(){ $(this).addClass('jqmdXFocus'); }, 
    function(){ $(this).removeClass('jqmdXFocus'); })
  .focus( 
    function(){ this.hideFocus=true; $(this).addClass('jqmdXFocus'); })
  .blur( 
    function(){ $(this).removeClass('jqmdXFocus'); });


//submission scripts
  $('.newsletterForm').submit( function(){
  		//statements to validate the form	
		var filter = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
		var email = document.getElementById('email');
		var anrede = document.getElementById('anrede');
//		alert(anrede.selectedIndex);
		if (!filter.test(email.value))
		{
			$('.email-missing').show();
		}
		else {$('.email-missing').hide();
		}
		if (document.cform1.vorname.value == "")
		{
			$('.vorname-missing').show();
		}
		else {$('.vorname-missing').hide();}	
		
		if (document.cform1.nachname.value == "")
		{
			$('.nachname-missing').show();
		}
		else {$('.nachname-missing').hide();
		}		
		
		if (anrede.selectedIndex < 1)
		{
			$('.anrede-missing').show();
		}
		else {$('.anrede-missing').hide();
		}	
		
		if ((document.cform1.vorname.value == "") || (anrede.selectedIndex < 1) || (!filter.test(email.value)) || (document.cform1.nachname.value == "")){
			return false;
		} 
		
		if ((document.cform1.vorname.value != "") && (anrede.selectedIndex > 0) && (filter.test(email.value)) && (document.cform1.nachname.value != "")) {
			
			//hide the form
			$('.newsletterForm').hide();
			$('.save').show();
			//send the ajax request
			
			/*
			$.post('mail.php',{name:$('#name').val(),
							  email:$('#e-mail').val(),
							  message:$('#message').val()},
		
		
			//return the data
			function(data){
			  //hide the graphic
			 
			 
			});
			*/
			
			setTimeout('sendData()', 2000);

			
			return false;
		} 
  });
  
	$("a.linkNL").click(function () {
		$('#nl').fadeIn("slow");
	});
	
	$("a.linkCB").click(function () {
		$('#cb').fadeIn("slow");
	});
	
	$("a.linkWC").click(function () {
		$('#wc').fadeIn("slow");
	});


   $('.callbackForm').submit( function(){

		if (document.cform2.name.value == "")
		{
			$('.name-missing').show();
		}
		else {$('.name-missing').hide();}	
		
		if (document.cform2.telefon.value == "")
		{
			$('.telefon-missing').show();
		}
		else {$('.telefon-missing').hide();
		}		
	
		if ((document.cform2.name.value == "") || (document.cform2.telefon.value == "")){
			return false;
		} 
		
		if ((document.cform2.name.value != "") && (document.cform2.telefon.value != "")) {
			//hide the form
			$('.callbackForm').hide();
			$('.save2').show();
			//send the ajax request
			
			/*
			$.post('mail.php',{name:$('#name').val(),
							  email:$('#e-mail').val(),
							  message:$('#message').val()},
		
		
			//return the data
			function(data){
			  //hide the graphic
			 
			 
			});
			*/
			
			setTimeout('sendData2()', 2000);

			
			return false;
		} 
  });
   
   $('.infoForm').submit( function(){
								   
		var filter = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
		var email = document.getElementById('email2');

		if (!filter.test(email.value))
		{
			$('.email2-missing').show();
		}
		else {$('.email2-missing').hide();
		}

		if (document.cform3.vorname.value == "")
		{
			$('.vorname2-missing').show();
		}
		else {$('.vorname2-missing').hide();}	
		
		if (document.cform3.nachname.value == "")
		{
			$('.nachname2-missing').show();
		}
		else {$('.nachname2-missing').hide();
		}
		
		if (document.cform3.www.value == "")
		{
			$('.www-missing').show();
		}
		else {$('.www-missing').hide();
		}
		
		if (document.cform3.firma.value == "")
		{
			$('.firma-missing').show();
		}
		else {$('.firma-missing').hide();
		}
		
		if (document.cform3.telefon.value == "")
		{
			$('.telefon2-missing').show();
		}
		else {$('.telefon2-missing').hide();
		}
		
		if (document.cform3.www.value == "")
		{
			$('.www-missing').show();
		}
		else {$('.www-missing').hide();
		}
		
	
		if ((document.cform3.vorname.value == "") || (document.cform3.nachname.value == "") 
		|| (document.cform3.email.value == "") || (document.cform3.www.value == "") 
		|| (document.cform3.telefon.value == "") || (document.cform3.firma.value == "")) {
			return false;
		} 
		
		if ((document.cform3.vorname.value != "") && (document.cform3.nachname.value != "")
		   && (document.cform3.email.value != "") && (document.cform3.www.value != "")
		   && (document.cform3.telefon.value != "") && (document.cform3.firma.value != "")) {
			//hide the form
			$('.infoForm').hide();
			$('.save3').show();
			//send the ajax request
			
			/*
			$.post('mail.php',{name:$('#name').val(),
							  email:$('#e-mail').val(),
							  message:$('#message').val()},
		
		
			//return the data
			function(data){
			  //hide the graphic
			 
			 
			});
			*/
			
			setTimeout('sendData3()', 2000);

			
			return false;
		} 
  });
  
  
});

function getWCwindow()
{
$("a.linkWC").click(function () {
		$('#wc').fadeIn("slow");
	});

//$('#wc').fadeIn("slow");
}

function sendData()
{
 document.cform1.submit();
}
function sendData2()
{
 document.cform2.submit();
}
function sendData3()
{
 document.cform3.submit();
}

