$(function() {
		   
	$('#loadreferenz li a').click(function(){
										   
		$('.pics').cycle('stop');

		var id     = $(this).attr('rel');
		var toLoad = id;
		$('#referenz').html('<span id="load"><b>LOADING...</b></span>');
		$('#referenz').load(toLoad,'',showNewContent())  
 
		function showNewContent() {  
			$('#referenz').fadeIn('normal',hideLoader());  
		}  
		function hideLoader() {  
			$('#load').fadeOut('normal');  
		}
		
	});		
		   
	$('#navi,.subnavi,.right .list,#loadreferenz').localScroll();
	$('.pics').after('<div id="nav"><span>') 
	.cycle({ 
    fx:     'fade', 
    speed:    900, 
    timeout: 5000,
	pause:   true,
	pauseOnPagerHover: true,
	before : onBefore,
	after:   onAfter,
    pager:  '#nav'
	});
	
	function onBefore() {
    $('#nav span').html('');
	}	
	
	function onAfter() {
    $('#nav span').html('<b>' + this.title + '</b>');
	}

$("form").submit(function(){

var str = $("form").serialize();

   $.ajax({
   type: "POST",
   url: "contact.php",
   data: str,
   success: function(msg){
    
$("#note").ajaxComplete(function(event, request, settings){

if(msg == 'OK') // Message Sent? Show the 'Thank You' message and hide the form
{
result = '<div class="notification_ok">Your message has been sent. Thank you!</div>';
$("#fields").hide();
}
else
{
result = msg;
}

$(this).html(result);

});

}

 });

return false;

});

	
});