(function ( $ ) {
var sample = { sample: true };
// DOM may not be complete

$(document).ready(function() {
    $(".imgover").imageOver();
    
    $(window).resize(function() {
        $('#banner').height(cycleHeight('#banner'));
    });
});

$(window).load(function() {
    $('#banner').height(cycleHeight('#banner'));
	$('#banner').cycle({ 
	    fx:     'scrollHorz', 
	    speed:   1000,
	    timeout: 6000,
	    delay:  -2000,
	    pause: true
	});
	
	$("a[rel^='prettyPhoto']").prettyPhoto({
		theme: 'light_square', /* light_rounded / dark_rounded / light_square / dark_square / facebook */
		social_tools:false
	});
});

$.fn.imageOver = function() {
    return this.each(function() {
        var objSrc = $(this).attr("src");
        var ftype = objSrc.substring(objSrc.lastIndexOf("."), objSrc.length);
        var objSrcOver = objSrc.replace(ftype, "-ovr" + ftype);
        // var objSrcActive = objSrc.replace(ftype, "-active" + ftype);

        //        $(this).parent().append('<img src=\"'+objSrcOver+'\ class=' + 'hide' + ' />');
        //        $(this).parent().append('<img src=\"'+objSrcActive+'\ class=' + 'hide' + ' />');

        $(this).hover(function() {
            $(this).attr("src", objSrcOver);
        }, function() {
            $(this).attr("src", objSrc);
        });
    });
}; 

function cycleHeight(cycleObj) {
    var maxHeight = 0; 
    $(cycleObj).children().each(function() {
        var height = $(this).outerHeight();      
        if ( height > maxHeight ) { maxHeight = height; }
    });
    return maxHeight;
}

}( jQuery ));
