﻿$(function(){
	
	// Font replacements
	Cufon.replace('ul.navigation li > a.toplevel', { fontFamily: 'intreg' });
	Cufon.replace('#sidenav li a', { fontFamily: 'intreg', hover: true });
	Cufon.replace('#content h1, #content h2, #content h3, ul.crumbs li, h3.subnav_title', { fontFamily: 'intreg' });
	Cufon.replace('#content .nkp_txtblock li.linetxt', { fontFamily: 'intreg' });
	Cufon.replace('#content .nkp_txtblock li.line2', { fontFamily: 'intlightcon' });

	// Initalize interactive elements
	nkpInteractive.mainNavigation();
	
	// Disable caching for IE
	try {
	 document.execCommand('BackgroundImageCache', false, true);
	} catch(e) {}
});

var nkpInteractive = {
	mainNavigation : function(){

		$('#header ul.navigation li').hoverIntent(
			function(){
				$(this).addClass('open');
				$('ul', this).slideDown().queue(false);
			},
			function(){
				$('ul', this).slideUp().queue(false);
				$(this).removeClass('open');
			}
		);
	},
	textBlock : function(){
		
		$('#three_features .img_col').each(function(){
			var imgLink = $('a', this).attr('href');
			if(imgLink == "#" || imgLink == "undefined"){
				// do nothing
				$('a', this).remove();
			} else {
				$('a', this).remove();
				$(this).wrapInner("<a href='"+imgLink+"'></a>");
			}
		});
		
		$('#three_features .img_col').hoverIntent(
			function(){
				$('.nkp_txtblock', this).fadeIn(600);
			},
			function(){
				var _this = this;
				$('.nkp_txtblock', this).fadeOut(300);
			}
		);
	},
	singleTextBlock : function(){
		
		var singleImgLink = $('#three_features .single_img_col a').attr('href');
		
		if(singleImgLink == "#" || singleImgLink == "undefined")
		{
			$('#three_features .single_img_col a').remove();
		} else {
			$('#three_features .single_img_col a').remove();
			$('#three_features .single_img_col').wrapInner("<a href='"+singleImgLink+"'></a>");
		}
		
		$('#three_features .single_img_col').hoverIntent(
			function(){
				$('.nkp_txtblock', this).fadeIn(600);
			},
			function(){
				var _this = this;
				$('.nkp_txtblock', this).fadeOut(300);
			}
		);
	}
};


