//JQuery Setup

$(function(){

 

//Important functions to fire first!

//-------------------------------------------------------------------------------

  	

	//IE6 duct tape

	$('#nav ul li, #utility-nav ul li').bind('mouseenter mouseleave', function(){

		$(this).toggleClass('sfhover');

	});	

	

	//png fix

	$(document).pngFix();

	

	//IE6 Upgrade Warning

	//set cookie handler

	var alertBox = $.cookie('ie_alert');

	//if cookie val "noshow" then hide message - user has already seen this message!

	if(alertBox == 'noshow') {

		$('#alert').css('display', 'none');

		}else{

		$('#alert').css('display', 'block');

	}

	//click to close behavior

	$('.ie-alert-link').click(function() {

		$('#alert').slideToggle("slow");

		$.cookie('ie_alert', 'noshow', { expires: 14 });

	});

	//-- /end ie6 warning



// Utilities

//-------------------------------------------------------------------------------



	// Anti-spam email obfuscator

	$('.kelly-email').jcAntiSpam({

		emailCommonName: 'kelly@kellyschwartz.com',//Name displayed in link text, e.g., 'Email So-And-So'

		emailName: 'kelly',//First half of primary email address; before "@" symbol

		emailDomain: 'kellyschwartz.com',// Full Primary email domain name

		emailCcName: '',//First half of CC email address; before "@" symbol

		emailCcDomain: ''//CC email domain name

	});

	



// Standard Flash Modules

//-------------------------------------------------------------------------------

	

	// Define the default configuation values

	// followed by individual module configuration.

	// Values for individual modules will override the defaults

	var flashModules = {

		

		defaults: {			

			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: 9}

		},

	

	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: 'logo', config: {width: 531, height: 112}}

	]

	};

	

	// Loop through the defined modules 

	// and do flash replacement for any that are on the current page

	for (var j = flashModules.modules.length - 1; j >= 0; j--){

		var module = flashModules.modules[j];

		// combine default config settings with individual 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 = 'swf/' + module.name + '.swf';

		$('#flash-' + module.name).flash(modConfig, flashModules.defaults.pluginOptions);

	}







//Basic HTML functions

//---------------------------------------------------------------------------------



	// 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 ($('body #content').height() > $(window).height()) {

	$('#content').append('<p class="top-link"><a href="#">Back to top &uarr;</a></p>');

	}

	

	// Some effects rely on an element to be initially hidden,

	// but we only hide them if the user has javascript

	$('.jshide').addClass('hide');



	// Open external links in new windows

	$('a[href^="http://"]').not('[href*="kellyschwartz.com"]').addClass('external').attr('target', '_blank');

	

	// Open pdf links in new windows

	$('a[href$=".pdf"]').addClass('pdf').attr('target', '_blank');



});//end document.ready
