//JQuery Setup
$(document).ready(function(){
 
	//IE6 duct tape
	$.browser.msie6 = $.browser.msie && /MSIE 6\.0/i.test(window.navigator.userAgent) && !/MSIE 7\.0/i.test(window.navigator.userAgent);
	if ($.browser.msie6) {
		// hover fix
		$('#nav li').bind('mouseenter mouseleave', function(){
			$(this).toggleClass('sfhover');
		});
		// Add other IE6 only code here
	}
	
	
	// Some effects rely on an element to be initially hidden,
	// but we only hide them if the user has javascript
	$('.jshide').addClass('hide');
	
	
	//clear form fields
	$('.clearme').one("focus", function() {
		$(this).val("");
	});
	
	// Open external links in new windows
	$('a[@href^="http://"]').addClass('external').attr('target', '_blank');

	// Open pdf links in new windows
	$('a[@href$=".pdf"]').addClass('pdf').attr('target', '_blank');

	// add 'back to top' link when the content is taller than the window
	// this has to be done after flash replacement because the content height changes
	if ($('#content').height() > $(window).height()) {
		$('#content').append('<p class="clear"><a href="#hd">Back to top</a> &uarr;</p>');
	}
	
	// wrap img.caption in a div and use the title attr as a caption  
	$("#content img.caption").each(function(i) {
		var $img = $(this);
		var caption = $img.attr('title');
		var width = $img.attr('width') + 10;
		$img.wrap('<div class="inset" style="width:'+width+'px;"></div>').after("<p>" + caption + "</p>");
	});
	
	
  $.sifr({
    font: 'flash/avantGardeMDBt.swf',
    color: '#3b2638',
    textAlign: 'left',
    before: function(){
      $(this).css({'font-size':'25px', 'font-weight':'normal', 'font-family':'Arial, Helvetica, sans-serif', 'margin-bottom':'20px'});
    }
  });
  $('#content h1').sifr();

});//end document.ready

$(function(){

	var flashModules = {
	
		defaults: {
			// Define the configuation values applied to each module.
			// Each module in flashModules can override these values.
			
			width: 500,
			height: 300,
			wmode: 'transparent',
			flashvars: {
				autoPlay: 'false', // change value to 'true'to play on start
				thisColor: '0x' + '639CCE' // change global hex color (default=639CCE)
			},
			pluginOptions: {version: 8}
		},
		
		modules: [
			// Define the configuration values for each flash module.
			// Change item values in any 'flashvars' section to false to omit,
			// Add any value to override the default value in flashModuleDefaults.
			
			{name: 'homepage', config: {width:566, height:221}}
		]
	};

	for (var j = flashModules.modules.length - 1; j >= 0; j--){
		var module = flashModules.modules[j];
		// combine default config settings with module config settings
		var modConfig = $.extend({}, flashModules.defaults, module.config);
		// combine default flashvars with module flashvars
		modConfig.flashvars = $.extend({}, flashModules.defaults.flashvars, module.config.flashvars);
		modConfig.src = 'flash/' + module.name + '.swf';
		$('#flash-' + module.name).flash(modConfig, flashModules.defaults.pluginOptions);
	}
	
});
