$(document).ready(function() {
	sfHover();
	
	anchors.addBehaviors();
	
	$('#make-time').cycle({ 
    fx:    'fade', 
    speed:  2500 
 });

$(".fancy-img").fancybox({
    openEffect	: 'elastic',
    openEasing : 'easeOutBack',
    	
    closeEffect	: 'elastic',
	closeEasing : 'easeInBack',

   helpers : {
   	title : {
   		type : 'inside'
   	}
   }
});

$("a.fancy-link").fancybox({
		'hideOnContentClick': true
	}); 

$('#gallery').galleria({
   width:900,
	height:600
});

});

/* =================================================================== */
// function to add events crossbrowser
// from: http://www.dustindiaz.com/rock-solid-addevent/
// uncomment the EventCache lines if using EventCache function from code lib
function addEvent( obj, type, fn ) {
	if (obj.addEventListener) {
		obj.addEventListener( type, fn, false );
		//EventCache.add(obj, type, fn);
	}
	else if (obj.attachEvent) {
		obj["e"+type+fn] = fn;
		obj[type+fn] = function() { obj["e"+type+fn]( window.event ); }
		obj.attachEvent( "on"+type, obj[type+fn] );
		//EventCache.add(obj, type, fn);
	}
	else {
		obj["on"+type] = obj["e"+type+fn];
	}
}
/* =================================================================== */
// for suckerfish dhtml menus
// dependencies: jQuery
sfHover = function() {
	$('#navLevelOne li').each( function() {
		$(this).hover( function() {
			$(this).addClass('sfhover');
		}, function() {
			$(this).removeClass('sfhover');
		});
	});
};

/* =================================================================== */
// various link functionality - popups, external, onstate
// original script taken from Jeremy Keith
var anchors = {
	a: Object,
	addBehaviors : function() {
		$('a').each( function() {
			var $a = $(this);
			// external links
			if ( ($a.attr('href')) && ($a.attr('rel')=='external') ) {
				$a.click( function() {
					return anchors.openWin(this,"");
				});
			}
			if ( $a.hasClass('external') || $a.hasClass('pdf') ) {
				$a.click( function(e) {
					$(e).preventDefault;
					return anchors.openWin(this,"");
				});
			}
			// popup
			if ( $a.hasClass('popup') ) {
				$a.click( function() {
					return anchors.openWin(this,"height=550,width=600,scrollbars=yes");
				});
			}
			// popup
			if ( $a.hasClass('demoWindow') ) {
				$a.click( function() {
					return anchors.openWin(this,"height=600,width=800");
				});
			}
			// onstate
			if ( $a.attr('href') == location.href ) {
				$a.addClass('onstate');
			}
		});
	},
	openWin : function(o,params) {
		window.open(o.href, "newwin","" + params + "");
		return false;
	}
};
