$(document).ready(function() {
		
	
	//if submit button is clicked
	$('#submit').click(function () {		
		
		//Get the data from all the fields
		var name = $('input[name=name]');
		var email = $('input[name=email]');
		//var website = $('input[name=website]');
		var comment = $('textarea[name=comment]');

		//Simple validation to make sure user entered something
		//If error found, add hightlight class to the text field
		if (name.val()=='') {
			name.addClass('hightlight');
			return false;
		} else name.removeClass('hightlight');
		
		if (email.val()=='') {
			email.addClass('hightlight');
			return false;
		} else email.removeClass('hightlight');
		
		if (comment.val()=='') {
			comment.addClass('hightlight');
			return false;
		} else comment.removeClass('hightlight');
		
		//organize the data properly
		var data = 'name=' + name.val() + '&email=' + email.val() + '&comment='  + encodeURIComponent(comment.val());
		
		//var data = 'name=' + name.val() + '&email=' + email.val() + '&website=' + 
		//website.val() + '&comment='  + encodeURIComponent(comment.val());
		
		
		//disabled all the text fields
		$('.text').attr('disabled','true');
		
		//show the loading sign
		//$('.loading').show();
		$('.loading_form').fadeIn('slow'); // Better animation
		
		//start the ajax
		$.ajax({
			//this is the php file that processes the data and send mail
			url: "process.php",	
			
			//GET method is used
			type: "GET",

			//pass the data			
			data: data,		
			
			//Do not cache the page
			cache: false,
			
			//success
			success: function (html) {				
				//if process.php returned 1/true (send mail success)
				if (html==1) {					
					//hide the form
					//$('.form').fadeOut('slow');	
					$('.form').slideUp(1500, function() {
						// Animation complete.
						//$('.done').slideDown('slow');
						//$('.done').slideDown(1100);
						$('.done').fadeIn(1000);
					  });
					//show the success message
					//$('.done').fadeIn('slow');
					
				//if process.php returned 0/false (send mail failed)
				} else alert('Ein unerwarteter Fehler ist aufgetreten, versuchen Sie es sp&auml;ter bitte erneut!');				
			}		
		});
		
		//cancel the submit button default behaviours
		return false;
	});	
	
	
	
	$().piroBox({
			my_speed: 200, //animation speed
			//slideShow : true, // true == slideshow on, false == slideshow off
			//slideSpeed : 4, //slideshow duration in seconds(3 to 6 Recommended)
			bg_alpha: 0.95, //background opacity
			close_all : '.piro_close,.piro_overlay' // add class .piro_overlay(with comma)if you want overlay click close piroBox

	});
	//QTip
	// By suppling no content attribute, the library uses each elements title attribute by default
   $('a[href][alt]').qtip({
      content: {
         text: false // Use each elements title attribute
      },
		position: {
      	   corner: {
        	 target: 'bottomMiddle',//topMiddle
        	 tooltip: 'center' //center
      		}
   		},
      style: { 
      width: 160,
      padding: 5,
      //background: '#fff',
      textAlign: 'center',
      border: {
         width: 1,
         radius: 4,
         color: '#bababa'
      },
	 tip: 'topMiddle', //topMiddle
      name: 'light' // Inherit the rest of the attributes from the preset dark style
   }
   });
   // NOTE: You can even omit all options and simply replace the regular title tooltips like so:
   // $('#content a[href]').qtip();
});	
/*Shadowbox.init({
 handleOversize: 'drag',
 overlayOpacity: 0.95,
 fadeDuration: 0.2,
 viewportPadding: 35
});*/
Cufon('h1', {
	fontWeight: 'bold',
	textTransform: 'uppercase',
	fontSize: '25px',
	letterSpacing: '+1px'
});
Cufon('.content a', {
	fontSize: '23px',
	letterSpacing: '+1px',
	hover: true
});
Cufon('p', {
	fontSize: '23px',
	letterSpacing: '+1px'
});
Cufon('.formular', {
	fontSize: '16px',
	fontWeight: 'normal',
	letterSpacing: '+1px'
});
Cufon('#footer', {
	fontSize: '13px',
	hover: true,
	letterSpacing: '+1px'
});
