   $(document).ready(function() {
	   $("span.email").each(function(i) {
	      var $email = $(this);
	      var address = $email.text()
	         .replace(/\s*\[at\]\s*/, '@')
	         .replace(/\s*\[dot\]\s*/g, '.');
	      $email.html('<a href="mailto:' + address + '">'
	         + address +'</a>');
	   });
	});

$(document).ready(function(){
					 // links openen in nieuw venster
  	        $('a[rel=extern]').attr('target','_blank');
  	        $('a[rel=nofollow]').attr('target','_blank');						 
					
					// start menuitems
							 $('a.tab').hover(function(){ // uitklappen
							 							 		var id = $(this).attr('id');	
									
									$('#tmenu p').empty();
									
									if(id == 'tab1') {
									  $('#tmenu p').append("&quot;28-6 Web, Media en Bedrijf&quot; ");	
										$('#tmenu').fadeIn('slow');																	
									}	else if(id == 'tab2') {
									  $('#tmenu p').append("&quot;Hoe ik te werk ga..&quot; ");	
										$('#tmenu').fadeIn('slow');																	
									}	else if(id == 'tab3'){
									  $('#tmenu p').append("&quot;Mijn vorige opdrachten..&quot; ");	
										$('#tmenu').fadeIn('slow');	
									} else if(id == 'tab4'){
									  $('#tmenu p').append("&quot;Wie ben ik en waarom doe ik wat ik doe?&quot; ");	
										$('#tmenu').fadeIn('slow');	
									} else if(id == 'tab5'){
									  $('#tmenu p').append("&quot;Geheel vrijblijvend!&quot; ");	
										$('#tmenu').fadeIn('slow');	
									}																									
										 
               }, function() { // na inklappen	
							 			$('#tmenu').animate({opacity: 1.0}, 3000)
										.fadeOut('slow', function() { $('#tmenu p').empty(); });										
																		
										//$('#tmenu').fadeOut('slow');
									  //$('#tmenu p').empty();																			
          		 }); 
							 
					// logo linkje home
							 $('a.home').hover(function(){ // uitklappen
									
									$('#tmenu p').empty();

									  $('#tmenu p').append("&quot;Terug naar de homepage van 28-6 Design&quot; ");	
										$('#tmenu').fadeIn('slow');																									
										 
               }, function() { // na inklappen	
							 			$('#tmenu').animate({opacity: 1.0}, 3000)
										.fadeOut('slow', function() { $('#tmenu p').empty(); });																													
          		 }); 							 
							 
							 //hoogte #transp
							 $(function() {
							  var hoogte = $(document).height();
										hoogte = hoogte - 50;
										$('#transp').css("height", hoogte + 'px');																																																	
							 }); 
		 
					});
					
/***************************/
// jquery Popup dankzij:
//Author: Adrian "yEnS" Mato Gondelle
//website: www.yensdesign.com
//email: yensamg@gmail.com
//license: Feel free to use it, but keep this credits please!					
/***************************/

//SETTING UP OUR POPUP
//0 means disabled; 1 means enabled;
var popupStatus = 0;

//loading popup with jQuery magic!
function loadPopup(){
	//loads popup only if it is disabled
	if(popupStatus==0){
		$("#backgroundPopup").css({
			"opacity": "0.7"
		});
		$("#backgroundPopup").fadeIn("slow");
		$("#popupContact").fadeIn("slow");
		popupStatus = 1;
	}
}

//disabling popup with jQuery magic!
function disablePopup(){
	//disables popup only if it is enabled
	if(popupStatus==1){
		$("#backgroundPopup").fadeOut("slow");
		$("#popupContact").fadeOut("slow");
		popupStatus = 0;
	}
}

//centering popup
function centerPopup(){
	//request data for centering
	var windowWidth = document.documentElement.clientWidth;
	var windowHeight = document.documentElement.clientHeight;
	var popupHeight = $("#popupContact").height();
	var popupWidth = $("#popupContact").width();
	//centering
	$("#popupContact").css({
		"position": "absolute",
		"top": windowHeight/2-popupHeight/2,
		"left": windowWidth/2-popupWidth/2
	});
	//only need force for IE6
	
	$("#backgroundPopup").css({
		"height": windowHeight
	});
	
}

//CONTROLLING EVENTS IN jQuery
$(document).ready(function(){
	
	//LOADING POPUP
	//Click the button event!
	$("#tab5").click(function(){
		//centering with css
		centerPopup();
		//load popup
		loadPopup();
	});
	
	//Nog een keer?
	$("#schakel").click(function(){
		//centering with css
		centerPopup();
		//load popup
		loadPopup();
	});
	
	//Nog een keer?
	$("a.schakel").click(function(){
		//centering with css
		centerPopup();
		//load popup
		loadPopup();
		
		if($.browser.safari){ bodyelem = $("body") } else{ bodyelem = $("html,body") }
			// Scroll naar top $('html')
           bodyelem.animate({
              scrollTop: $("#main_container").offset().top
            }, 2000);			
			
	});
				
	//CLOSING POPUP
	//Click the x event!
	$("#popupContactClose").click(function(){
		disablePopup();
	});
	//Click out event!
	$("#backgroundPopup").click(function(){
		disablePopup();
	});
	//Press Escape event!
	$(document).keypress(function(e){
		if(e.keyCode==27 && popupStatus==1){
			disablePopup();
		}
	});

});
// einde jquery popup

// BEGIN Contactformulier jquery ajax
    $(document).ready(function(){
    	$("#submit").click(function(){					   				   
    		$(".error").hide();
    		var hasError = false;
    		var emailReg = /^([\w-\.]+@([\w-]+\.)+[\w-]{2,4})?$/;
    		
    		var emailFromVal = $("#emailFrom").val();
    		if(emailFromVal == '') {
    			$("#emailFrom").after('<br /><span class="error">Voer een emailadres in.</span>');
    			hasError = true;
    		} else if(!emailReg.test(emailFromVal)) {	
    			$("#emailFrom").after('<br /><span class="error">Voer een geldig emailadres in.</span>');
    			hasError = true;
    		}

    		var subjectVal = $("#subject").val();
    		if(subjectVal == '') {
    			$("#subject").after('<br /><span class="error">Typ een onderwerp.</span>');
    			hasError = true;
    		}				
    		
    		var messageVal = $("#message").val();
    		if(messageVal == '') {
    			$("#message").after('<br /><span class="error">Typ een bericht.</span>');
    			hasError = true;
    		}
    		
				var emailToVal = "info@28-6design.nl";
    		
    		if(hasError == false) {
    			$(this).hide();
    			$("#sendEmail li.buttons").append('<img src="http://www.filmaddict.nl/images/laden.gif" alt="Laden.." id="loading" />');
    			
    			$.post("feedback/sendemail.php",
       				{ emailTo: emailToVal, emailFrom: emailFromVal, subject: subjectVal, message: messageVal },
       					function(data){
    						$("#sendEmail").slideUp("normal", function() {				   
    							
    							$("#sendEmail").before('<h1>Gelukt!</h1><p>Bedankt, het bericht is naar 28/6 Design verzonden..</p>');											
    						});
       					}
    				 );
    		}
    		
    		return false;
    	});						   
    });						 							
// EINDE Contactformulier jquery ajax	
	
   $(document).ready(function(){		 				
    	$('a[rel=sidebar]').click(function(){
         title = document.title;  
         url = window.location.href; 
          
            if (window.sidebar) { // Mozilla Firefox Bookmark 
                window.sidebar.addPanel(title, url,""); 
            } else if( window.external ) { // IE Favorite 
                window.external.AddFavorite( url, title); } 
            else if(window.opera && window.print) { // Opera Hotlist 
                return true; } 
    	});
	});	
		
   $(document).ready(function() {
   	$('ul#filter a').click(function() {																		
   		$(this).css('outline','none');
   		$('ul#filter .current').removeClass('current');
   		$(this).parent().addClass('current');
   
   		//var filterVal = $(this).text().toLowerCase().replace(' ','-');
				var filterVal = $(this).attr('id').toLowerCase();
   
   		if(filterVal == 'alles') {
   			$('ul#portfolio li.hidden').fadeIn('slow').removeClass('hidden');
   		} else {
   			$('ul#portfolio li').each(function() {
   				if(!$(this).hasClass(filterVal)) {
   					$(this).fadeOut('normal').addClass('hidden');
   				} else {
   					$(this).fadeIn('slow').removeClass('hidden');
   				}
   			});						 
				}
   		return false;

   	});
   });  		
   

   
