$(function(){
    $('a.popup').fancybox();

    $('.hoverable').live('mouseover', function() {
        $(this).addClass('hover');
    }).live('mouseout', function(){
        $(this).removeClass('hover');
    });
    
    $('.opacityHover').live('mouseover', function() {
        $(this).css({'opacity': '0.8'});
    }).live('mouseout', function(){
        $(this).css({'opacity': '1'});
    });
    
    $('.newsIntro').click(function(){
        var href = $('a.more', this).attr('href');
        location = href;
    }).mouseenter(function(){
        $('a.more', this).addClass('hover');
    }).mouseleave(function(){
        $('a.more', this).removeClass('hover');
    });
    
    $('#contactForm').submit(function(){
        $('#name', this).val() ? $('#name', this).removeClass('error') : $('#name', this).addClass('error');
        $('#email', this).val() ? $('#email', this).removeClass('error') : $('#email', this).addClass('error');
        /*$('#phone', this).val() ? $('#phone', this).removeClass('error') : $('#phone', this).addClass('error');*/
        $('#body', this).val() ? $('#body', this).removeClass('error') : $('#body', this).addClass('error');
        var hasError = false;
        $('#contactForm input.text, #contactForm textarea').each(function(i){
            if ($(this).hasClass('error')) {
                hasError = true;
            }
        });
        if (hasError) {
            return false;
        } else {
            return true;
        }
    });
})
