$(document).ready(function(){

    $('a[rel=external]').click(function(){
        window.open($(this).attr('href')); return false;
    });

    $('a[rel=popup]').click(function(){
        window.open($(this).attr('href'), 'popUp', 'width=300,height=200,status=0,toolbar=0'); return false;
    });

    $("a[rel^='light']").prettyPhoto();

    $('input[type=image], img.hover').each( function(){ 
        // Preload
        var x = new Image();
        x.src = this.src.substring(0, this.src.length - 5) + "2.jpg";

        // Mouseover
        $(this).mouseover( function(){ 
            this.src = this.src.substring(0, this.src.length - 5) + "2.jpg"; 
        });

        // Mouseout
        $(this).mouseout( function(){
            if (this.src.substring( (this.src.length - 5) , (this.src.length) ) == "2.jpg" ) { 
                this.src = this.src.substring(0, this.src.length - 5) + "1.jpg"; 
            }
        });
        if ($('form#contactForm').length > 0) {
            $('.prePopulate').example(function() { return $(this).attr('title')}, {className: 'fade'});
        }
    });

    $("ul.tabs").tabs("div.panes > div");

});
