if(!window.ND){window.ND={};window.NextDigital=window.ND;}

/*********sIFR*********/
 var helvetmedext = {
  src: '/assets/swf/helvetica-neue-med-ext.swf'
  ,ratios: [8, 1.41, 10, 1.33, 11, 1.31, 15, 1.29, 19, 1.28, 26, 1.25, 35, 1.24, 42, 1.23, 45, 1.22, 46, 1.23, 67, 1.22, 70, 1.21, 72, 1.22, 75, 1.21, 76, 1.22, 80, 1.21, 81, 1.22, 1.21]
};
 var helvetext = {
  src: '/assets/swf/helvitica-neue-ext.swf'
  ,ratios: [6, 1.41, 9, 1.35, 15, 1.29, 21, 1.25, 22, 1.22, 27, 1.24, 28, 1.23, 32, 1.22, 33, 1.23, 39, 1.22, 51, 1.21, 54, 1.2, 55, 1.21, 91, 1.2, 93, 1.19, 94, 1.2, 98, 1.19, 99, 1.2, 109, 1.19, 110, 1.2, 1.19]
};

sIFR.activate(helvetmedext);
sIFR.activate(helvetext);
//sIFR.debug.ratios({ src: '/themes/default/swf/helvitica-neue-ext.swf', selector: 'h2' });


(function($){

	// Adds :hover functionality to IE6
	ND.ieHover = function() {
		if ($.browser.msie && $.browser.version.substr(0,3) == "6.0") {
			var ul_array = $("ul.hoverable");
			for (var i = 0; i < ul_array.length; i++) {
				//Add 'hover' classes
				var listItems = $(ul_array[i]).children("li");
				for (var k = 0; k < listItems.length; k++) {
					$(listItems[k]).hover(function(){$(this).addClass("hover");}, function(){$(this).removeClass("hover");});
				}
			}
				
			/*input button hovers*/
			var clsholder;
			//$("input.btn-post-comment").hover(function(){$(this).addClass("btn-post-comment-hover");},function(){$(this).removeClass("btn-post-comment-hover");});
			$(".form-buttons input").hover(
				function()
				{
					clsholder = str = $(this).attr("class") + "-hover";
					$(this).addClass(str);
				},
				function()
				{
					$(this).removeClass(clsholder);
				}
			);
				
		}
		
			
		
	};
	
	ND.ie6FirstChild = function() {
		$("div.split .main p:first").addClass("first-child");
	};
	
	ND.animateMenu = function() {
	
		createHoverEffect = function(obj, on) {
			if (on) {
				obj.children(".hovereffect").fadeIn(300);
				obj.children("ul").fadeIn(150);
			}
			else {
				obj.children(".hovereffect").fadeOut(300);
				obj.children("ul").fadeOut(150);
			}
		}
		
		if (!($.browser.msie && $.browser.version.substr(0,3) == "6.0"))
			$(".menu > li > a").after("<div class='hovereffect'></div>");
		
		$(".menu > li:not(:has(.current))").hover(function() {
			createHoverEffect($(this), true);
		}, function(){
			createHoverEffect($(this), false);
		});
			
	};
	
	ND.expandBehaviour = function(){
		//create expanders behaviour
		$("a.expander").click(
			function()
			{
				var item = $(this).attr("href").replace("#","");
				if(document.getElementById(item))
				{
					if($("#"+item).attr("class").match("hidden"))
					{
						$("#"+item).removeClass("hidden");
						$(this).addClass("expander-open");
						//call sifr function to sifr any elements that may have been hidden
						ND.resifrExpanderElements();
					}
					else
					{
						$("#"+item).addClass("hidden");
						$(this).removeClass("expander-open");
						/*hide all expander items that may be within the item*/
						$("#"+item+" a.expander").each(
							function()
							{
								iitem = $(this).attr("href").replace("#","");
								if(document.getElementById(iitem))
								{
									$("#"+iitem).addClass("hidden");
									$(this).removeClass("expander-open");
								}
							}
						);
					}
				}
				
				return false;
			}
		);
	};
	
	/*function to call when openeing an extender item, so that all elements that need to be sifr'd in the hidden element to be shown, will be sifr'd*/
	ND.resifrExpanderElements = function()
	{
	
		sIFR.replace(helvetmedext, {
			selector: 'td.td-sifr span',
			css: [
		        '.sIFR-root { color: #4ba9d7; font-weight: bold; text-align: center;}'
		      ]
		});
		sIFR.replace(helvetext, {
			selector: 'div.large-buttons div.button span',
			css: [
		        '.sIFR-root {font-weight: bold;}'
		        ,'a { text-decoration: none; text-align: center;}'
		        ,'a:link { color: #ffffff;}'
		        ,'a:hover { color: #424242;}'
		      ]
		});
		sIFR.replace(helvetext, {
			selector: 'div.buttons div.button span',
			css: [
		        '.sIFR-root {font-weight: bold;}'
		        ,'a { text-decoration: none; text-align: center;}'
		        ,'a:link { color: #424242;}'
		        ,'a:hover { color: #ffffff;}'
		      ]
		});
	}
	
	
	//sifr elements required
	ND.sifrElements = function()
	{
		/*header elements*/
		sIFR.replace(helvetmedext, {
			selector: '.header-actions dl dt',
			css: [
		        '.sIFR-root { color: #0099CC; }'
		      ]
		});
		sIFR.replace(helvetmedext, {
			selector: '.header-actions dl dd',
			css: [
		        '.sIFR-root { color: #3a3a3c; }'
		      ]
		});
		/*headings*/
		sIFR.replace(helvetext, {
			selector: 'h2',
			css: [
		        '.sIFR-root { color: #4b4b4d; font-weight: bold;}'
			    ,'a { text-decoration: none;cousor:hand}'
		        ,'a:link { color: #424242;}'
		        ,'a:hover { color: #4b4b4d;text-decoration: underline;}'
		      ]
		});
		/*homepage elements*/
		sIFR.replace(helvetmedext, {
			selector: 'div.homepage div#banner h3',
			css: [
		        '.sIFR-root { color: #4b4b4d; font-size:27px; font-weight: bold;}'
		      ]
		});
		
		sIFR.replace(helvetmedext, {
			selector: 'div.homepage p.sifrd',
			css: [
		        '.sIFR-root { color: #4b4b4d;}'
		      ]
		});
		sIFR.replace(helvetmedext, {
			selector: 'div.homepage div.reg-form label',
			css: [
		        '.sIFR-root { color: #449ed3;}'
		      ]
		});
		sIFR.replace(helvetmedext, {
			selector: 'div.homepage div#features h3',
			css: [
		        '.sIFR-root { color: #449ed3; font-weight: bold; text-align: center;}'
		      ]
		});
		sIFR.replace(helvetext, {
			selector: 'div.homepage div.feature h4',
			css: [
		        '.sIFR-root { color: #4b4b4d; font-weight: bold; text-align: center;}'
		        ,'a { text-decoration: none; text-align: center;}'
		        ,'a:link { color: #4b4b4d;}'
		        ,'a:hover { color: #4b4b4d; text-decoration: underline;}'
		      ]
		});
		sIFR.replace(helvetmedext, {
			selector: '.homepage div#content h3',
			css: [
		        '.sIFR-root { color: #ffffff; font-weight: bold; text-align: left;}'
		        ,'a { font-size:17px;color: #ffffff;text-decoration: none; text-align: left;}'
		        ,'a:link { color: #ffffff;}'
		        ,'a:hover { color: #ffffff; text-decoration: underline;}'
		      ]
		});
		/*content elements*/
		sIFR.replace(helvetmedext, {
			selector: 'p.sifrd',
			css: [
		        '.sIFR-root { color: #4b4b4d; font-weight: bold;}'
		      ]
		});
		sIFR.replace(helvetmedext, {
			selector: 'td.td-sifr span',
			css: [
		        '.sIFR-root { color: #4ba9d7; font-weight: bold; text-align: center;}'
		      ]
		});
		sIFR.replace(helvetext, {
			selector: 'div.large-buttons div.button span',
			css: [
		        '.sIFR-root {font-weight: bold;}'
		        ,'a { text-decoration: none; text-align: center;}'
		        ,'a:link { color: #ffffff;}'
		        ,'a:hover { color: #424242;}'
		      ]
		});
		sIFR.replace(helvetext, {
			selector: 'div.buttons div.button span',
			css: [
		        '.sIFR-root {font-weight: bold;}'
		        ,'a { text-decoration: none; text-align: center;}'
		        ,'a:link { color: #424242;}'
		        ,'a:hover { color: #ffffff;}'
		      ]
		});
		sIFR.replace(helvetmedext, {
			selector: '.icon-listing .icon-item .info h3',
			css: [
		        '.sIFR-root { color: #008DD0; font-weight: bold;}'
		        ,'a { text-decoration: none;}'
		        ,'a:link { color: #008DD0;}'
		        ,'a:hover { color: #008DD0;}'
		      ]
		});
	};
	
	//add hover class for link buttons
	ND.buttonHover = function() {
		$("div.buttons div.button").hover(
			function()
			{
				$(this).addClass("button-hover");
			},
			function()
			{
				$(this).removeClass("button-hover");
			}
		);
	};
	
	ND.floPlayer = function()
	{
		if(document.getElementById("player"))
		{
			if($("html").attr("class").match("has-flash"))
			{
				$("#player").css("display", "block");
				$("#flash-player p").css("display", "none");
				flowplayer("player", {src: "/assets/swf/flowplayer-3.1.5.swf", wmode: 'opaque'});
			}
		}
	};
	
	// On load
	$(function() {
		ND.sifrElements();
		ND.ieHover();
		ND.animateMenu();
		ND.ie6FirstChild();
		ND.expandBehaviour();
		ND.buttonHover();
		ND.floPlayer();
	});

})($);
/*
$(function(){
$(".menu li a").click(function(){
    //alert("test");
	//$(this).removeClass("");
	$(this).addClass("current");
});
});
*/


