/**
 * @author Simplimation
 */



/*
 * Console logger
 * 
 * Message variables
 *  %s	String
 *  %d, %i	Integer (numeric formatting is not yet supported)
 *  %f	Floating point number (numeric formatting is not yet supported)
 *  %o	Object hyperlink
 * 
 *  only logs if globalVars.log = true
 */

$.log = function() {
  	if(window.console) {
		if($.browser.safari){
			// Safari console
			var args = arguments[0];
			window.console.log(args); // fix to show args, Safari doesn't like .apply
		}
		if ($.browser.mozilla) {
			// Firefox with firebug
			window.console.log.apply(this, arguments);
		}
  	} else {
  		// no Firebug
    	//alert(message);
	}
};



$(document).ready(function(){
	
	// de-obfuscate SPAM-proof email addresses
		function deobfuscate(x){
			return x.replace("--@--","@");
		}
		$("a").each(function (i){
			var h = this.href;
			if (h.indexOf("mailto")==0) {
				var t = deobfuscate($(this).html());
				this.href = deobfuscate(h);
				$(this).html(t);
			}
		});
		
	// handle external links
		// (add https and don't include urls that start with site domain
		var pre = "/LINK/";				// prefix to add to URL for GA tracking code
		$('a[href^="http://"]')
			.addClass('external')			// add CSS class for styling
			.attr('target', '_blank')		// open in popup window
			.click(function(){				// GA tracking code
				var href = $(this).attr("href");
				href = href.substr(7,9999);	// trim off http://
				var i = href.indexOf("www.");	// trim off www.
				if (i===0){
					href = href.substr(4,9999);
				}
				href = encodeURI(href);		// encode URL
				$.log(pre + href);			// log href to console
				//pageTracker._trackPageview(pre + href)	// GA tracker code
				//return false;				// cancel link action
			})
		;

	// round corners
	$("#slogan, #nav_extra ul").nifty("normal");
	$("#page_wrap, #nav_main li.active>a").nifty("big");

	/* event banners animation */
	$(".event-banner img")
		.fadeTo('fast',.9)
		.hover(
			function(){
				$(this).fadeTo('fast',1);
			},
			function(){
				$(this).fadeTo('fast',.9);
			}
		)
	
	
	/* tabs */

		$(".tabs a").wrapInner("<span></span>");
		$(".tabs").tabs({ fx: { opacity: 'toggle' } });


	/* fancybox photo lightbox viewer */
	
		$(".image-list a").fancybox({
			'hideOnContentClick': true,
			'zoomOpacity'			: true,
			'overlayShow'			: true,
			'zoomSpeedIn'			: 500,
			'zoomSpeedOut'			: 500
		});

	/* video player */
	
		$(".video a").videoPlayer({
			// default options:			
			 autostart: "false",
			 playerpath: "/js/",		// relative path to player.swf (e.g. /js/)
			 playerfile: "player.swf",	// filename of Flash player
			 width: "100%",		// player width
			 height: "100%",		// player height
			 frontcolor: "ffffff",		// control bar foreground color
			 backcolor: "457bb4",			// control bar background color
			 lightcolor: "ec870e",		// progress and volume bar color
			 screencolor: "457bb4",		// screen bg color
			 flashbgcolor: "457bb4"	// flash background color
		});
	
});
