   //http://www.reynoldsftw.com/2009/03/live-email-validation-with-jquery/
   function isValidEmailAddress(emailAddress) {  
   var pattern = new RegExp(/^(("[\w-\s]+")|([\w-]+(?:\.[\w-]+)*)|("[\w-\s]+")([\w-]+(?:\.[\w-]+)*))(@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$)|(@\[?((25[0-5]\.|2[0-4][0-9]\.|1[0-9]{2}\.|[0-9]{1,2}\.))((25[0-5]|2[0-4][0-9]|1[0-9]{2}|[0-9]{1,2})\.){2}(25[0-5]|2[0-4][0-9]|1[0-9]{2}|[0-9]{1,2})\]?$)/i);  
   return pattern.test(emailAddress);  
   }       

function validateEmail() {	
	var email = $('#email').val();
	if (email == null) return;
	var email_img = $('#email_check').get(0);
	if(email == 0 || email == "" ) {
		email_img.src="/media/665504/email_go.gif";
		return;
	}
	if(isValidEmailAddress(email))  {
		//Create (or update) the value of a cookie to expire in 200 days:
		$.cookie('email', email, { expires: 200 });		
		email_img.src="/media/665499/email_ok.gif";
	} else {  
		email_img.src="/media/665504/email_go.gif";
	}
   }


$(function() {

    // set the default options for all scrollpanes on this page
    //$.extend($.fn.jScrollPane.defaults, {showArrows:true});

    $('#items').jScrollPane({showArrows:true});

    $('#email').keyup(function(){
	validateEmail();
    });

    $('#email').click(function(){
	var val = $(this).get(0).value;
	if (val == 'e-mail') $(this).get(0).value='';
    });
    $("#email").Watermark("e-mail");

    validateEmail();

    //Category desc
    //$('.shortText').css({opacity:0, display:'block'});
    
    $('h1').hover(function(){			    
	$('.shortText').stop()
		.css({opacity:0, display:'block'})
		.animate({opacity:.9},{queue:false,duration:500});
    }, function(){
        var desc = $('.shortText');
	$('.shortText').stop().animate({opacity:0},{queue:false, duration:500, complete: function() {desc.hide()} });
    });

    $('a[rel="projects"]').colorbox({fixedWidth:700, fixedHeight:700, iframe:true, 
contentCurrent:'Projekt {current} z {total}',
contentPrevious:'předchozí',
contentNext:'následující',
modalClose:'zavřít'
});

    $('div.outer div.desc').click(function () {
	var link = $(this).parent().find('a');
       link.trigger('click');
    });

});


