

/* ------------------------------------------------ JQUERY COOKIES FUNCTION ------------------------------------------------ */

jQuery.cookie=function(name,value,options){if(typeof value!='undefined'){options=options||{};if(value===null){value='';options=$.extend({},options);options.expires=-1}var expires='';if(options.expires&&(typeof options.expires=='number'||options.expires.toUTCString)){var date;if(typeof options.expires=='number'){date=new Date();date.setTime(date.getTime()+(options.expires*24*60*60*1000))}else{date=options.expires}expires='; expires='+date.toUTCString()}var path=options.path?'; path='+(options.path):'';var domain=options.domain?'; domain='+(options.domain):'';var secure=options.secure?'; secure':'';document.cookie=[name,'=',encodeURIComponent(value),expires,path,domain,secure].join('')}else{var cookieValue=null;if(document.cookie&&document.cookie!=''){var cookies=document.cookie.split(';');for(var i=0;i<cookies.length;i++){var cookie=jQuery.trim(cookies[i]);if(cookie.substring(0,name.length+1)==(name+'=')){cookieValue=decodeURIComponent(cookie.substring(name.length+1));break}}}return cookieValue}};

/* ------------------------------------------------ JQUERY COOKIES FUNCTION ------------------------------------------------ */

function xtractFile(data){
var m = data.match(/(.*)\/([^\/\\]+)(\.\w+)$/);
if(m == null) { m = "null"; }
return {path: m[1], file: m[2], extension: m[3]}
}



jQuery(document).ready(function() 
{

	if(typeof sIFR == "function"){
	
		// This is the preferred "named argument" syntax
		sIFR.replaceElement( named(
						   {
							   sSelector:".homePanel h1 span", sFlashSrc:"/flash/franklinGothic_18pt.swf", 
							   sColor:"#ffffff", sCase:"upper", sWmode:"transparent"
							}));
		sIFR.replaceElement( named(
						   {
							   sSelector:".callToAction h3 span", sFlashSrc:"/flash/franklinGothic_18pt.swf", 
							   sColor:"#ffffff", sCase:"upper", sWmode:"transparent"
							}));
				sIFR.replaceElement( named(
						   {
							   sSelector:".homePanel h3 span", sFlashSrc:"/flash/franklinGothic_18pt.swf", 
							   sColor:"#ffffff", sCase:"upper", sWmode:"transparent"
							}));
		sIFR.replaceElement( named(
						   {
							   sSelector:".sidepanel h2 span", sFlashSrc:"/flash/franklinGothic_18pt.swf", 
							   sColor:"#ffffff", sCase:"upper", sWmode:"transparent"
							}));
	};

	/* ------------------------------------------------ FONT SIZE TOGGLE ------------------------------------------------ */
	// If there's a cookie present for this site, assign the font size based on this value.
	if($.cookie('fontSizeCookie'))
	{
		var getCookie = parseFloat($.cookie('fontSizeCookie'));
		jQuery("#mainWrapper").css({ 'font-size' : getCookie+'em' });
	}
	
	// Increase the font size based on <current cookie size> + 0.25.
	jQuery("a.font_inc").click(function() 
	{
		if($.cookie('fontSizeCookie'))
		{
			
			$.cookie('fontSizeCookie', parseFloat($.cookie('fontSizeCookie'))+0.25, { path: '/' });
			jQuery("#mainWrapper").css({ 'font-size' : parseFloat($.cookie('fontSizeCookie'))+'em' });
		}
		else // No Cookie Present? Set a Cookie based on initial step-up (0.25), then increase font size
		{
			$.cookie('fontSizeCookie', 1.25, { path: '/' });
			jQuery("#mainWrapper").css({ 'font-size' : parseFloat($.cookie('fontSizeCookie'))+'em' });
		}
	});
	
	// Decrease the font size based on <current cookie size> - 0.25.
	jQuery("a.font_dec").click(function() 
	{
		if($.cookie('fontSizeCookie'))
		{
			if(parseFloat($.cookie('fontSizeCookie')) > 1.0)
			{
				$.cookie('fontSizeCookie', parseFloat($.cookie('fontSizeCookie'))-0.25, { path: '/' });
				jQuery("#mainWrapper").css({ 'font-size' : parseFloat($.cookie('fontSizeCookie'))+'em' });
			}
		}
	});
	/* ------------------------------------------------ FONT SIZE TOGGLE ------------------------------------------------ */

	jQuery(function() {
		jQuery(".carousel").jCarouselLite({
			btnNext: ".next",
			btnPrev: ".prev",
			visible: 2,
			auto: 3000,
			speed: 400
		});
	});

	// Utilities Tooltips
	jQuery(".utilities li").hover(
		function() 
		{ jQuery(this).children("p").fadeIn("fast"); },
		function() 
		{ jQuery(this).children("p").fadeOut("fast"); }
	);
	
	// Assign Zebra Cols to News Headlines
	var i = 0;
	jQuery(".homeNews ul li").each( function(i){
		i % 2 == 0 ? jQuery(this).addClass("zebra_row_0") : jQuery(this).addClass("zebra_row_1");
		i++;
	});
	// Assign Zebra Cols to subnav links
	i = 0;
	jQuery("#subnav ul li").each( function(i){
		i % 2 == 0 ? jQuery(this).addClass("zebra_row_0") : jQuery(this).addClass("zebra_row_1");
		i++;
	});

	// Jquery Lightbox
	$(function() { $('.galleryLightbox li a, .cmaImgs a').lightBox(); });

	 // highlight the current side-bar subnav link.
    if (document.getElementById("subnav")) {
        var sublinks = document.getElementById("subnav").getElementsByTagName("a");
        for (var i = 0; i < sublinks.length; i++)
        { if (sublinks[i].href == document.location.href) { sublinks[i].parentNode.className += " currentPage"; } }
    }
	// animated the sub menu
	jQuery("#subnav ul li a").hover(
		function(){ jQuery(this).parent("li").animate({ marginRight: "0px"}, 200 ); },								
		function(){ jQuery(this).parent("li").animate({ marginRight: "15px"}, 200 ); }	
	);
	
	if(document.getElementById("homeFlash"))
	{
		var so = new SWFObject("/flash/homepage_003.swf", "flash_area", "950", "270", "8", "#ffffff");
		so.addVariable("parseFileName", "/flash/homepage_003.xml");
		so.write("homeFlash");  
	}
	
	if(document.getElementById("subFlash"))
	{
		var so = new SWFObject("/flash/subLoader.swf", "flash_area", "950", "190", "8", "#ffffff");
		so.addVariable("parseFileName", "/flash/subpage.xml");
		so.write("subFlash");  
	}
	
	// put classes on links to file types
	if(document.getElementById("maincontent"))
	{
		var dls = document.getElementById("maincontent").getElementsByTagName("a");
		var link_class = "dlicon ";
		for(var x = 0; x < dls.length; x++)
		{
			var parsedObject = xtractFile(dls[x].href);
			if(parsedObject.extension) { dls[x].className = dls[x].className + " " + link_class + parsedObject.extension.substring(1, parsedObject.extension.length).toLowerCase(); }
		} // end for
	}// end if(getElement)




}); // END jQuery(document).ready

