﻿var sitefunctions = {
	textresize : function(){
		// show text resizing links
		$("#title").after('<div id="text-resize"><div id="tr-label">TEXT SIZE</div><div id="tr-butts"><a href="#" class="FontSizeInc"><img src="/images/shared/inc.gif" alt="Larger" /></a> <a href="#" class="FontSizeDec"><img src="/images/shared/dec.gif" alt="Smaller" /></a></div></div>');
		var $cookie_name = "isg-FontSize";
		var originalFontSize = '10';
		// if exists load saved value, otherwise store it
		if($.cookie($cookie_name)) {
			var $getSize = $.cookie($cookie_name);
			$("#copy").css({fontSize : $getSize + ($getSize.indexOf("px")!=-1 ? "" : "px")});
		} else {
			$.cookie($cookie_name, originalFontSize);
		}
		// reset link
		$(".FontSizeReset").bind("click", function() {
			$("#copy").css("font-size", originalFontSize);
			$.cookie($cookie_name, originalFontSize);
		});
		// text "+" link
		$(".FontSizeInc").bind("click", function() {
			var currentFontSize = $("#copy").css("font-size");
			var currentFontSizeNum = parseFloat(currentFontSize, 10);
			var newFontSize = currentFontSizeNum*1.2;
			if (newFontSize > 22){newFontSize = currentFontSizeNum;}
			if (newFontSize, 11) {
				$("#copy").css("font-size", newFontSize);
				$.cookie($cookie_name, newFontSize);
			}
			return false;	
		});
		$(".FontSizeDec").bind("click", function() {
		  var currentFontSize = $("#copy").css("font-size");
		  var currentFontSizeNum = parseFloat(currentFontSize, 10);
		  var newFontSize = currentFontSizeNum/1.2;
		  if (newFontSize < 10){newFontSize = currentFontSizeNum;}
		  if (newFontSize, 11) {
		    $("#copy").css("font-size", newFontSize);
		    $.cookie($cookie_name, newFontSize);
		  }
		  return false;
		});
	}
}


$(function() {
    if ($("#bigpics").length){
		$('#bigpics').cycle({
		    fx : 'fade',
		    speed : '2000',
		    timeout : '6000'
		});
    }

    if ($(".accordion").length){
	    $('.accordion').accordion({ 
	        active: '.selected', 
	        header: "dt"
	    })
    }

   	$('a[@rel$="external"]').addClass("external").click(function(){ this.target = "_blank"; });
   	
   	$('#nav a.flow')
		.hover(function(e) {
			$(this).hoverFlow(e.type, { paddingRight: 30 }, 'fast');
		}, function(e) {
			$(this).hoverFlow(e.type, { paddingRight: 19 }, 'fast');
	});
		
	sitefunctions.textresize();
});
