jQuery(document).ready(function($){

// sweet magic line nav from http://css-tricks.com/jquery-magicline-navigation/


    var $el, leftPos, newWidth,
        $mainNav = $("#main_nav")
    

    $mainNav.append("<li id='magic-line'></li>");
    
    var $magicLine = $("#magic-line");
    
    $magicLine
        .width($(".current_page_item").width())
        .css("left", $(".current_page_item a").position().left)
        .data("origLeft", $magicLine.position().left)
        .data("origWidth", $magicLine.width());
        
    $("#main_nav li").find("a").hover(function() {
        $el = $(this);
        leftPos = $el.position().left;
        newWidth = $el.parent().width();
        
        $magicLine.stop().animate({
            left: leftPos,
            width: newWidth
        });
    }, function() {
        $magicLine.stop().animate({
            left: $magicLine.data("origLeft"),
            width: $magicLine.data("origWidth")
        });    
    });
    
    
// STOP magic line nav
    



// FOR tipsy tooltips
	$('.tool_tip').tipsy({gravity: 's', fade: 'true', html: 'true'});
// STOP tooltips




// Close bottom Bar

// delicious cookie for bar_status open or closed...
function createCookie(name,value,days) {
	if (days) {
		var date = new Date();
		date.setTime(date.getTime()+(days*24*60*60*1000));
		var expires = "; expires="+date.toGMTString();
	}
	else var expires = "";
	document.cookie = name+"="+value+expires+"; path=/";
}


$("a.close_bar").click(function()
	{
		createCookie('bar_status', 'closed', '1');
		$("#site-bottom-bar").animate({"bottom": "-50px"}, 2000);
		$("img.open_bar").animate({"bottom": "60px"}, 1500);
		return false;
});

$("a.open_bar").click(function()
	{
		createCookie('bar_status', 'opened', '1');
		$("#site-bottom-bar").animate({"bottom": "0px"}, 2000);
		$("img.open_bar").animate({"bottom": "-60px"}, 1500);
		return false;
});

function eraseCookie(name) {
	createCookie(name,"",-1);
//	window.location = "/fundraiser/";
}
	
	
// stop bottom bar




// PORTFOLIO LARGE IMAGE VIEWER LOGIC

	$("#port_wrapper").fadeOut(1000); 


	// preloader image logic	
	var loading = $("#loading");

	function showLoading(){
		loading
			.css({visibility:"visible"})
			.css({opacity:"1"})
			.css({display:"block"});
	}

	function hideLoading(){
		loading.fadeTo(4000, 0);
	};
	// stop preloader image logic


	function fadeInBg() {
		
		$("#port_wrapper").fadeIn(2000, fadeInPort);
		
		function fadeInPort() {
			$(".holder").animate({"left": "50%"}, 2500);
			$("#close_btn").show(1500);
		}
		hideLoading();
    }				

	function showCopy() {
		$("#portfolio_copy").fadeIn(1000);
	}
	
	// portfolio image loading logic
	
	$("img.port_image").click(function(){
		
		var id = $(this).attr("id");  // used to determine which image to get based on the thumbnail image id tag
		showLoading(); //fade in the animated loading gif
		
		
		$("#port_wrapper").fadeOut(1000, loadPortImg);  // fade out current image (if any) and calls the img loading function

			function loadPortImg() {				
				
				$(".holder").empty();  // clear any imaage currently loaded
				$(".holder").append("<img id='loaded_img' src='' / >");  // add new empty image tag as loading "shell"
				
				$("#loaded_img").load(function() {  // once the loaded_img div is fully loaded call fadeInBg funciton					
					showCopy();
					fadeInBg();
				});

				$("#loaded_img").attr("src","/wp-content/uploads/" + id + ".jpg");  // now add the selected img src to the appended img tag (once this loads fully the fadeInBg function is called
				
			} // stop loadPortImg function			

	return false;

	});  // stop thumbnail click function


// CLOSE BUTTON


// for closing portfolio/re-entry...
  
 $(".close_btn").click(function()
  {
	$("#close_btn").fadeOut(1400);
	$(".holder").animate({"left": "-6000px"}, 1500, "linear", portsDone);
	function portsDone(){
		$("#port_wrapper").fadeOut(1000);
		$(".holder").css("left", "-2000px");
	}
	return false;
 });

  
// stop slide in and slide out

// STOP LARGE PORT IMAGE VIEWING LOGIC


// port image rollover

 $("img.port_image").mouseover(function()
  {
//	$('.view_larger').stop().fadeIn('fast', '');
	$(this).stop().fadeTo('slow', 0.5, '');
 });

 $("img.port_image").mouseout(function()
  {
//	$('.view_larger').stop().fadeOut('fast', '');
	$(this).stop().fadeTo('slow', 1, '');
 });




 $(".ngg-gallery-thumbnail a").each(function (arr){
   if ($(this).attr("title").substr(0,5)=="Video"){
     $(this).attr("rel","shadowbox;width=405;height=340");
     $(this).attr("href",$(this).children("img").attr("title"));
   }
 })




}); //stop jquery




////// SIFR


var TradeGothic = {src: '/wp-content/themes/Nashville_Interactive/flash/TradeGothic.swf' };

sIFR.activate(TradeGothic);


    var TradeGothic = {
      src: '/wp-content/themes/Nashville_Interactive/flash/TradeGothic.swf'
      ,ratios: [7,1.32,11,1.31,13,1.24,14,1.25,19,1.23,27,1.2,34,1.19,42,1.18,47,1.17,48,1.18,69,1.17,74,1.16,75,1.17,1.16]
    };

    sIFR.domains = ['www.nashvilleinteractive.com'];
    sIFR.useStyleCheck = true;

    sIFR.replace(TradeGothic, {selector: 'h2.sifr', wmode: 'transparent'
		,css: {
    	    '.sIFR-root': { 'font-size': '2em', 'color': '#FFFFFF', 'letter-spacing': -1}
		   ,'a': { 'text-decoration': 'none', 'color': '#FFFFFF' }
	       ,'a:link': { 'text-decoration': 'none', 'color': '#FFFFFF' }
    	   ,'a:hover': { 'text-decoration': 'none', 'color': '#E6C391' }
	      }
	});

    sIFR.replace(TradeGothic, {selector: 'h3.sifr', wmode: 'transparent'
		,css: {
    	    '.sIFR-root': { 'font-size': '1.6em', 'color': '#FFFFFF', 'letter-spacing': -1}
		   ,'a': { 'text-decoration': 'none', 'color': '#FFFFFF' }
	       ,'a:link': { 'text-decoration': 'none', 'color': '#FFFFFF' }
    	   ,'a:hover': { 'text-decoration': 'none', 'color': '#E6C391' }
	      }
	});

    sIFR.replace(TradeGothic, {selector: 'h1.sifr', wmode: 'transparent'
      ,css: {
        '.sIFR-root': { 'font-size': '2.5em', 'color': '#FFFFFF' }
      }
        ,filters: {
        Glow: {
          knockout: false
          ,distance: 0
          ,color: '#FFFFFF'
          ,strength: 1
        }
      }

    });

    sIFR.replace(TradeGothic, {selector: '.news_title h1', wmode: 'transparent'
      ,css: {
        '.sIFR-root': { 'font-size': '2.5em', 'color': '#442a0f' }
      }
        ,filters: {
        Glow: {
          knockout: false
          ,distance: 0
          ,color: '#FFFFFF'
          ,strength: 1
        }
      }

    });



// STOP SIFR  