/*
 * Brita Common Code
 *
 */

// init the $brita namespace. All functions should be part of this namespace
var $brita = window.$brita || {};  

// initialize all functions on document ready
$(document).ready( function() {
	$clxcommon.initExternal();
	
	$clxcommon.createLink('#header h2', '/');
	
	// preloading the navigation images. 
	if (document.images){
		pic1= new Image(); 
		pic1.src="/images/nav_products.gif"; 
		pic2= new Image(); 
		pic2.src="/images/nav_news.gif"; 
		pic3= new Image(); 
		pic3.src="/images/nav_about.gif"; 
		pic4= new Image(); 
		pic4.src="/images/nav_support.gif"; 
		pic5= new Image(); 
		pic5.src="/images/nav_you.gif";
	}

	$clxcommon.attachClickAnalytics('promo');

	$clxcommon.initWarning();
		
	$("button.skip").click( function() {
		if (window.location.pathname.indexOf('filter-for-good') > -1)
			window.location.href='/my-brita/register-complete/';
		else
			window.location.href='/my-brita/filter-for-good/';
	} );
   // add additional fxns as needed
});

// fix the nav in IE6. The jquery method causes some flicker, so we do it this way
sfHover = function() {
	var sfEls = document.getElementById("mainNav").getElementsByTagName("LI");
	for (var i=0; i<sfEls.length; i++) {
		sfEls[i].onmouseover=function() {
			this.className+=" sfhover";
		}
		sfEls[i].onmouseout=function() {
			this.className=this.className.replace(new RegExp(" sfhover\\b"), "");
		}
	}
}
if (window.attachEvent) window.attachEvent("onload", sfHover);