//<![CDATA[			
// use $j notation to avoid conflict with
// any episerver JavaScript libraries
var $j = jQuery.noConflict();

$j(document).ready(function() {

	// hover block function  
	$j(function() {
		$j('.hoverBlock').hover(function(){
			var content = $j(this).find(".hoverContent div");
			if (content && content.html()) {
				$j(this).find("img").animate({left:'304px'},{queue:false,duration:400});
			}
		}, function(){
			$j(this).find('img').animate({left:'0px'},{queue:false,duration:400});
		});
	});
	
	// cookie function for remembering the selected section
	$j('div.homeBigPromo h4 a').click(function(){
		setCookie("NavigationHome", this.href, 20);
	});
	
	// top nav first item class
	$j('#mainNav ul li:first').addClass("mainNavFirst")
	
	// add the print function if JS running
	$j("#printPage").html("<a href='javascript:printPage();'>Print</a></p>");
	
	// flash text replacement
	$j.sifr({ path: '/flash/', save: true });
	$j('p.headings').sifr({ font: 'din' });
	$j('h3').sifr({ font: 'din', fontSize: '18px', color: '#000' });
	$j('h1').sifr({ font: 'din' });
	$j('div.rightColHead').sifr({ font: 'din' });
	
	//resets the box height on home page
	var obj01 = $j('#homePromoContainerL>.textBox>.inner');
    var obj02 = $j('#homePromoContainerR>.textBox>.inner');
    if (obj01 && obj02) {
        var box1height = obj01.height();
        var box2height = obj02.height();
        obj01.height(Math.max(box1height, box2height));
        obj02.height(Math.max(box1height, box2height));
    }

});

function printPage(){
	if (window.print)
		{window.print();
	}
}

function checkRedirect() {
	if ( top.location.href.indexOf("/edit/")==-1 ) {
		var userHome = getCookie("NavigationHome");
		if(userHome.length > 0 && document.referrer.search(location.hostname) == -1) {
			top.location.replace(userHome);
		}
	}
}

function setCookie(c_name,value,expiredays) {
	if (!document.cookie) { return ; }
	var exdate=new Date();
	exdate.setDate(exdate.getDate()+expiredays);
	document.cookie=c_name+ "=" +escape(value)+((expiredays==null) ? "" : ";expires="+exdate.toGMTString())+"; path=/";
}

function getCookie(c_name) {
	if (!document.cookie) { return ; }
	if (document.cookie.length>0) {
		c_start=document.cookie.indexOf(c_name + "=");
		if (c_start!=-1) { 
			c_start=c_start + c_name.length+1 ;
			c_end=document.cookie.indexOf(";",c_start);
			if (c_end==-1) { c_end=document.cookie.length ; }
			return unescape(document.cookie.substring(c_start,c_end));
		} 
	}
	return '';
}

//]]>