//Image Preloader jQuery Plugin
(function($) {
  var cache = [];
  $.preLoadImages = function() {
    var args_len = arguments.length;
    for (var i = args_len; i--;) {
      var cacheImage = document.createElement('img');
      cacheImage.src = arguments[i];
      cache.push(cacheImage);
    }
  }
})(jQuery)
function AC_FL_RunContent(){var ret = AC_GetArgs(  arguments, ".swf", "movie", "clsid:d27cdb6e-ae6d-11cf-96b8-444553540000", "application/x-shockwave-flash");AC_Generateobj(ret.objAttrs, ret.params, ret.embedAttrs);}
function AC_GetArgs(args, ext, srcParamName, classid, mimeType){var ret = new Object();ret.embedAttrs = new Object();ret.params = new Object();ret.objAttrs = new Object();for (var i=0; i < args.length; i=i+2){var currArg = args[i].toLowerCase();switch (currArg){	case "classid":break;case "pluginspage":ret.embedAttrs[args[i]] = args[i+1];break;case "src":case "movie":	args[i+1] = AC_AddExtension(args[i+1], ext);ret.embedAttrs["src"] = args[i+1];ret.params[srcParamName] = args[i+1];break;case "onafterupdate":case "onbeforeupdate":case "onblur":case "oncellchange":case "onclick":case "ondblClick":case "ondrag":case "ondragend":case "ondragenter":case "ondragleave":case "ondragover":case "ondrop":case "onfinish":case "onfocus":case "onhelp":case "onmousedown":case "onmouseup":case "onmouseover":case "onmousemove":case "onmouseout":case "onkeypress":case "onkeydown":case "onkeyup":case "onload":case "onlosecapture":case "onpropertychange":case "onreadystatechange":case "onrowsdelete":case "onrowenter":case "onrowesxit":case "onrowsinserted":case "onstart":case "onscroll":case "onbeforeeditfocus":case "onactivate":case "onbeforedeactivate":case "ondeactivate":case "type":case "codebase":ret.objAttrs[args[i]] = args[i+1];break;case "width":case "height":case "align":case "vspace": case "hspace":case "class":case "title":case "accesskey":case "name":case "id":case "tabindex":ret.embedAttrs[args[i]] = ret.objAttrs[args[i]] = args[i+1];break;default:ret.embedAttrs[args[i]] = ret.params[args[i]] = args[i+1];}}ret.objAttrs["classid"] = classid;if (mimeType) ret.embedAttrs["type"] = mimeType;return ret;}
function AC_AddExtension(src, ext){if (src.indexOf('?') != -1){return src.replace(/\?/, ext+'?');}else{return src + ext;}}
function AC_Generateobj(objAttrs, params, embedAttrs){var str = '<object ';for (var i in objAttrs){str += i + '="' + objAttrs[i] + '" ';}str += '>';for (var i in params){str += '<param name="' + i + '" value="' + params[i] + '" /> ';}str += '<embed ';for (var i in embedAttrs){str += i + '="' + embedAttrs[i] + '" ';}str += ' ></embed></object>';document.write(str);}
function openYouTube(id){
	openTube('<object width="480" height="355"><param name="movie" value="http://www.youtube.com/v/'+id+'?rel=0&color1=0xB9CFE0&color2=0xA5C7DD&border=1&hl=en&fs=1&hd=1" /><param name="allowFullScreen" value="true" /><param name="allowscriptaccess" value="always" /><embed src="http://www.youtube.com/v/'+id+'?rel=0&color1=0xB9CFE0&color2=0xA5C7DD&border=1&hl=en&fs=1&hd=1" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="480" height="355"></embed></object>');
	$('#ytheader').height('375px');
}

function openTube(str){
	var yt = str;
	if($("#ytpopup") && $("#ytpopup").size() > 0){
		$("#ytplayer").html(yt);
	}else{
		$('#body').append('<div id="ytpopup" class="window"><div id="ytheader"><div id="ytclose"><a href="#" class="close">Close</a></div><div id="ytplayer">'+yt+'</div></div></div>');
		$('.window .close').click(function (e) {
			$("#ytplayer").html('');
			e.preventDefault();
			$('#mask').hide();
			$('.window').hide();
		});	
	}
	var $id = $('#ytpopup');
	
	var maskHeight = $(document).height();
	var maskWidth = $(window).width() + $(window).scrollLeft();
	$('#mask').css({'width':maskWidth,'max-width':maskWidth,'height':maskHeight});
	$('#mask').fadeTo("slow",0.8);
	var winH = $(window).height();
	var winW = $(window).width();
	$id.centerize();
	$id.fadeIn(1800);
}

function openKineticoTube(vid){
	vid = '/assets/video/'+vid;
	openTube("<div class=\"tube-css\"><div class=\"video-js-box\"><video id=\"example_video_1\" class=\"video-js\" width=\"480\" height=\"355\" controls=\"controls\" preload=\"auto\" poster=\"" + vid + ".png\"><source src=\"" + vid + ".mp4\" type='video/mp4; codecs=\"avc1.42E01E, mp4a.40.2\"' /><source src=\"" + vid + ".webm\" type='video/webm; codecs=\"vp8, vorbis\"' /><source src=\"" + vid + ".ogv\" type='video/ogg; codecs=\"theora, vorbis\"' /><object id=\"flash_fallback_1\" class=\"vjs-flash-fallback\" width=\"480\" height=\"380\" type=\"application/x-shockwave-flash\" data=\"http://releases.flowplayer.org/swf/flowplayer-3.2.1.swf\"><param name=\"movie\" value=\"http://releases.flowplayer.org/swf/flowplayer-3.2.1.swf\" /><param name=\"allowfullscreen\" value=\"true\" />"+
	"<param name=\"flashvars\" value='config={\"playlist\":[\"" + window.location.protocol.replace(':', '') + "://" + window.location.host + vid + ".png\", {\"url\": \"" + window.location.protocol.replace(':', '') + "://" + window.location.host + vid + ".mp4\",\"autoPlay\":false,\"autoBuffering\":true}],\"plugins\":{\"controls\":{\"autoHide\":\"never\",\"backgroundColor\":\"#BACFE2\",\"buttonColor\":\"#505050\",\"durationColor\":\"#333333\",\"timeColor\":\"#333333\",\"height\":\"28\",\"bottom\":\"0\"}},\"screen\":{\"bottom\":\"25\"}}' />"+
	"<img src=\"" + vid + ".png\" width=\"480\" height=\"355\" alt=\"Poster Image\" title=\"No video playback capabilities.\" /></object></video></div></div>");
	$('#ytheader').height('400px');
    VideoJS.setupAllWhenReady({controlsBelow: true, controlsHiding: false});
}
var addthis_config = {
	username: 'kinetico',"data_track_clickback":true, data_ga_tracker:'UA-1803236-1'
}
$(document).ready(function(){
	//Asynchronous AddThis
	$.getScript("http://s7.addthis.com/js/250/addthis_widget.js?domready=1",function(d,s){
		// excellent state initialization code here
	});
	//New Windows/Tabs Links
	$("a[href^='http'],area[href^='http']").click(function(e){
		if($(this).attr("href").search(window.location.host) == -1){
			e.preventDefault();
			if($(this).hasClass('YouTube')){
				$(this).removeClass('YouTube');
				openYouTube($(this).attr('class'));
				$(this).addClass('YouTube');
			}else{
				window.open(this.href);
			}
			return false;
		}
	});
	
	$("a.KineticoTube").click(function(e){
		e.preventDefault();
		$(this).removeClass('KineticoTube');
		openKineticoTube($(this).attr('class'));
		$(this).addClass('KineticoTube');
		return false;
	});
	
	// bind "click" event for links with title="submit"
	$(".submitbtn,.submitbtn a").css({display:'block'});
	$(".submitbtn a").css({display:'block'});
	$(".submitbtn").css({display:'block'});
	$("a.submitbtn,.submitbtn a").click(function(e){
		e.preventDefault();
		// it submits the form it is contained within
		$(this).parents("form").submit();
		return false;
	});
	//Drop Down Menu
	if($("ul.menu").size() > 0){
		$("ul.menu").superfish();
	}
	//Searchbox
	$('.searchbox').each(function(index) {
		var $s = $(this);
		if($s.size() && $s.attr('value').length === 0){
			$s.attr('value', 'Enter your ZIP/Postal Code');
		}
		$s.focus(function () {
			var str = $(this).attr('value') + "";
			if(str == "Enter your ZIP/Postal Code"){
				$(this).attr('value', '');
			}
		});
		$s.blur(function () {
			var str = $(this).attr('value') + "";
			if(str == ""){
				$(this).attr('value', 'Enter your ZIP/Postal Code');
			}
		});
	});
	//Image Rollovers
	$("img.hover").each(function(index,el){
		jQuery.preLoadImages($(el).attr('src').replace('.', '-hover.'));
		$(el).mouseover(function(event){
			$(el).attr('src', $(el).attr('src').replace('-hover', ''));
			$(el).attr('src', $(el).attr('src').replace('.', '-hover.'));
		});
		$(el).mouseout(function(event){
			$(el).attr('src', $(el).attr('src').replace('-hover', ''));
		});
	});
	//jQuery Modal Window
	$('#mask').click(function () {
		$(this).hide();
		$('.window').hide();
		$("#ytplayer").html('');
	});
	//IE 6 PNG Fix
	//$(document).pngFix();
	$('#home .right').pngFix();
	$('.learnmore').pngFix();
	$('#houseaffect').pngFix();
	$('#search').pngFix();
	$('#tierFour').pngFix();
	$('#difference a').pngFix();
	$('#navOurProducts').pngFix();
	$('#recognizedby').pngFix();
	$('#products a:first,#specialty-water-filters #products').pngFix();
	
	try{
		document.execCommand("BackgroundImageCache",false,true);
	}catch(err){}
});
;(function($){
	$.fn.centerize = function () {
		this.css("position","absolute");
		this.css("top", ( $(window).height() - this.height() ) / 2+$(window).scrollTop() + "px");
		this.css("left", ( $(window).width() - this.width() ) / 2+$(window).scrollLeft() + "px");
		return this;
	};
})(jQuery);
/*HOVER INTENT */
/**
* hoverIntent r5 // 2007.03.27 // jQuery 1.1.2+
* <http://cherne.net/brian/resources/jquery.hoverIntent.html>
* 
* @param  f  onMouseOver function || An object with configuration options
* @param  g  onMouseOut function  || Nothing (use configuration options object)
* @author    Brian Cherne <brian@cherne.net>
*/
(function($){$.fn.hoverIntent=function(f,g){var cfg={sensitivity:7,interval:100,timeout:0};cfg=$.extend(cfg,g?{over:f,out:g}:f);var cX,cY,pX,pY;var track=function(ev){cX=ev.pageX;cY=ev.pageY;};var compare=function(ev,ob){ob.hoverIntent_t=clearTimeout(ob.hoverIntent_t);if((Math.abs(pX-cX)+Math.abs(pY-cY))<cfg.sensitivity){$(ob).unbind("mousemove",track);ob.hoverIntent_s=1;return cfg.over.apply(ob,[ev]);}else{pX=cX;pY=cY;ob.hoverIntent_t=setTimeout(function(){compare(ev,ob);},cfg.interval);}};var delay=function(ev,ob){ob.hoverIntent_t=clearTimeout(ob.hoverIntent_t);ob.hoverIntent_s=0;return cfg.out.apply(ob,[ev]);};var handleHover=function(e){var p=(e.type=="mouseover"?e.fromElement:e.toElement)||e.relatedTarget;while(p&&p!=this){try{p=p.parentNode;}catch(e){p=this;}}if(p==this){return false;}var ev=jQuery.extend({},e);var ob=this;if(ob.hoverIntent_t){ob.hoverIntent_t=clearTimeout(ob.hoverIntent_t);}if(e.type=="mouseover"){pX=ev.pageX;pY=ev.pageY;$(ob).bind("mousemove",track);if(ob.hoverIntent_s!=1){ob.hoverIntent_t=setTimeout(function(){compare(ev,ob);},cfg.interval);}}else{$(ob).unbind("mousemove",track);if(ob.hoverIntent_s==1){ob.hoverIntent_t=setTimeout(function(){delay(ev,ob);},cfg.timeout);}}};return this.mouseover(handleHover).mouseout(handleHover);};})(jQuery);
/*SUPERFISH*/
/*
 * Superfish v1.4.8 - jQuery menu widget
 * Copyright (c) 2008 Joel Birch
 *
 * Dual licensed under the MIT and GPL licenses:
 * 	http://www.opensource.org/licenses/mit-license.php
 * 	http://www.gnu.org/licenses/gpl.html
 *
 * CHANGELOG: http://users.tpg.com.au/j_birch/plugins/superfish/changelog.txt
 */
;(function($){
		$.fn.superfish = function(op){
			if ($.browser.msie && $.browser.version == 7){	
				//*:first-child+html #nav .menu ul li a{overflow:inherit;text-indent:0;width:100%;}
				$('#nav .menu ul li a').css({width:'100%'});
				$('div.nhr:lt(3)').each(function() {
					$(this).width($(this).parent().width());
				});
			}
			if (!$.browser.msie || $.browser.version >= 6){ // Do not allow for IE7
				var sf = $.fn.superfish,
					c = sf.c,
					$arrow = $(['<span class="',c.arrowClass,'"> &#187;</span>'].join('')),
					over = function(){
						var $$ = $(this), menu = getMenu($$);
						clearTimeout(menu.sfTimer);
						$$.showSuperfishUl().siblings().hideSuperfishUl();
					},
					out = function(){
						var $$ = $(this), menu = getMenu($$), o = sf.op;
						clearTimeout(menu.sfTimer);
						menu.sfTimer=setTimeout(function(){
							if ($.browser.msie && $.browser.version <= 8){
								$(this).find('div.drop').css('visibility','hidden');
							}
							o.retainPath=($.inArray($$[0],o.$path)>-1);
							$$.hideSuperfishUl();
							if (o.$path.length && $$.parents(['li.',o.hoverClass].join('')).length<1){over.call(o.$path);}
						},o.delay);	
					},
					getMenu = function($menu){
						var menu = $menu.parents(['ul.',c.menuClass,':first'].join(''))[0];
						sf.op = sf.o[menu.serial];
						return menu;
					},
					addArrow = function($a){ $a.addClass(c.anchorClass).append($arrow.clone()); };
				return this.each(function() {
					var s = this.serial = sf.o.length;
					var o = $.extend({},sf.defaults,op);
					o.$path = $('li.'+o.pathClass,this).slice(0,o.pathLevels).each(function(){
						$(this).addClass([o.hoverClass,c.bcClass].join(' '))
							.filter('li:has(div)').removeClass(o.pathClass);
					});
					sf.o[s] = sf.op = o;
					$('li',this)[($.fn.hoverIntent && !o.disableHI) ? 'hoverIntent' : 'hover'](over,out).each(function() {
						if (o.autoArrows) addArrow( $('>a:first-child',this));
					}).not('.'+c.bcClass).hideSuperfishUl();
					var $a = $('a',this);
					$a.each(function(i){
						var $li = $a.find(':nth-child('+i+')').parents('li');
						$a.find(':nth-child('+i+')').focus(function(){over.call($li);}).blur(function(){out.call($li);});
					});
					o.onInit.call(this);
				}).each(function() {
					var menuClasses = [c.menuClass];
					if (sf.op.dropShadows  && !($.browser.msie && $.browser.version < 7)) menuClasses.push(c.shadowClass);
					$(this).addClass(menuClasses.join(' '));
				});
			}
		};
		var sf = $.fn.superfish;
		sf.o = [];
		sf.op = {};
		sf.IE7fix = function(){
			var o = sf.op;
			if ($.browser.msie && $.browser.version > 6 && o.dropShadows && o.animation.opacity!=undefined)
				this.toggleClass(sf.c.shadowClass+'-off');
			};
		sf.c = {
			bcClass     : 'sf-breadcrumb',
			menuClass   : 'sf-js-enabled',
			anchorClass : 'sf-with-ul',
			arrowClass  : 'sf-sub-indicator',
			shadowClass : 'sf-shadow'
		};
		sf.defaults = {
			hoverClass	: 'sfHover',
			pathClass	: 'overideThisToUse',
			pathLevels	: 1,
			delay		: 600,
			animation	: {opacity:'show'},
			speed		: 'normal',
			autoArrows	: false,
			dropShadows : true,
			disableHI	: false,		// true disables hoverIntent detection
			onInit		: function(){}, // callback functions
			onBeforeShow: function(){},
			onShow		: function(){},
			onHide		: function(){}
		};
		$.fn.extend({
			hideSuperfishUl : function(){
				var o = sf.op,
					not = (o.retainPath===true) ? o.$path : '';
				o.retainPath = false;
				var $ul = $(['li.',o.hoverClass].join(''),this).add(this).not(not).removeClass(o.hoverClass).find('div:first').hide().css('visibility','hidden');
				o.onHide.call($ul);
				//$(this).find('div').css('visibility','hidden');
				//$(this).find('div.drop').css('opacity',1);
				$(this).find('div.drop').css('visibility','hidden');
				return this;
			},
			showSuperfishUl : function(){
				var o = sf.op,
					sh = sf.c.shadowClass+'-off',
					$ul = this.addClass(o.hoverClass).find('div:first').css('visibility','visible');
					$(this).find('div').css('visibility','visible');
					//$(this).find('div.drop').css('opacity',1);
				sf.IE7fix.call($ul);
				o.onBeforeShow.call($ul);
				$ul.removeClass(sf.c.shadowClass+'-off');
				if (!$.browser.msie || ($.browser.msie && $.browser.version > 8)){
					$ul.animate(o.animation,o.speed,function(){ sf.IE7fix.call($ul); o.onShow.call($ul); });
				}else if($.browser.version == 8){
					$ul.addClass(sf.c.shadowClass+'-off');
					$ul.show();
					$ul.find('>ul,div[class!="drop"][class!="form"]').css('opacity', .3).animate({'opacity': 1},o.speed,function(){ 
						$ul.find('>ul,div').show();
						$ul.removeClass(sf.c.shadowClass+'-off');
						o.onShow.call($ul);
					});
					$ul.css('backgroundPosition',($ul.width()-602)+'px '+($ul.height()-600)+'px').delay(300).animate({'background-position': ($ul.width()-602 + 7)+'px '+($ul.height()-600 + 4)+'px'}, 500, 'swing', function(){ });
				}else{
					$ul.show();
					o.onShow.call($ul);
				}
				return this;
			}
		});
})(jQuery);
/**
 * Background-Position Animations 1.2.1
 * @author Alexander Farkas
 * v. 1.21
 */
(function(b){if(!document.defaultView||!document.defaultView.getComputedStyle){var d=jQuery.curCSS;jQuery.curCSS=function(g,e,h){if(e==="background-position"){e="backgroundPosition"}if(e!=="backgroundPosition"||!g.currentStyle||g.currentStyle[e]){return d.apply(this,arguments)}var f=g.style;if(!h&&f&&f[e]){return f[e]}return d(g,"backgroundPositionX",h)+" "+d(g,"backgroundPositionY",h)}}var c=b.fn.animate;b.fn.animate=function(e){if("background-position" in e){e.backgroundPosition=e["background-position"];delete e["background-position"]}if("backgroundPosition" in e){e.backgroundPosition="("+e.backgroundPosition}return c.apply(this,arguments)};function a(f){f=f.replace(/left|top/g,"0px");f=f.replace(/right|bottom/g,"100%");f=f.replace(/([0-9\.]+)(\s|\)|$)/g,"$1px$2");var e=f.match(/(-?[0-9\.]+)(px|\%|em|pt)\s(-?[0-9\.]+)(px|\%|em|pt)/);return[parseFloat(e[1],10),e[2],parseFloat(e[3],10),e[4]]}b.fx.step.backgroundPosition=function(f){if(!f.bgPosReady){var h=b.curCSS(f.elem,"backgroundPosition");if(!h){h="0px 0px"}h=a(h);f.start=[h[0],h[2]];var e=a(f.options.curAnim.backgroundPosition);f.end=[e[0],e[2]];f.unit=[e[1],e[3]];f.bgPosReady=true}var g=[];g[0]=((f.end[0]-f.start[0])*f.pos)+f.start[0]+f.unit[0];g[1]=((f.end[1]-f.start[1])*f.pos)+f.start[1]+f.unit[1];f.elem.style.backgroundPosition=g[0]+" "+g[1]}})(jQuery);
/**
 * --------------------------------------------------------------------
 * jQuery-Plugin "pngFix"
 * Version: 1.2, 09.03.2009
 * by Andreas Eberhard, andreas.eberhard@gmail.com
 *                      http://jquery.andreaseberhard.de/
 *
 * Copyright (c) 2007 Andreas Eberhard
 * Licensed under GPL (http://www.opensource.org/licenses/gpl-license.php)
 *
 * Changelog:
 *    09.03.2009 Version 1.2
 *    - Update for jQuery 1.3.x, removed @ from selectors
 *    11.09.2007 Version 1.1
 *    - removed noConflict
 *    - added png-support for input type=image
 *    - 01.08.2007 CSS background-image support extension added by Scott Jehl, scott@filamentgroup.com, http://www.filamentgroup.com
 *    31.05.2007 initial Version 1.0
 * --------------------------------------------------------------------
 */
(function(a){jQuery.fn.pngFix=function(d){d=jQuery.extend({blankgif:"blank.gif"},d);var c=(navigator.appName=="Microsoft Internet Explorer"&&parseInt(navigator.appVersion)==4&&navigator.appVersion.indexOf("MSIE 5.5")!=-1);var b=(navigator.appName=="Microsoft Internet Explorer"&&parseInt(navigator.appVersion)==4&&navigator.appVersion.indexOf("MSIE 6.0")!=-1);if(jQuery.browser.msie&&(c||b)){jQuery(this).find("img[src$=.png]").each(function(){jQuery(this).attr("width",jQuery(this).width());jQuery(this).attr("height",jQuery(this).height());var l="";var g="";var f=(jQuery(this).attr("id"))?'id="'+jQuery(this).attr("id")+'" ':"";var m=(jQuery(this).attr("class"))?'class="'+jQuery(this).attr("class")+'" ':"";var i=(jQuery(this).attr("title"))?'title="'+jQuery(this).attr("title")+'" ':"";var j=(jQuery(this).attr("alt"))?'alt="'+jQuery(this).attr("alt")+'" ':"";var h=(jQuery(this).attr("align"))?"float:"+jQuery(this).attr("align")+";":"";var e=(jQuery(this).parent().attr("href"))?"cursor:hand;":"";if(this.style.border){l+="border:"+this.style.border+";";this.style.border=""}if(this.style.padding){l+="padding:"+this.style.padding+";";this.style.padding=""}if(this.style.margin){l+="margin:"+this.style.margin+";";this.style.margin=""}var k=(this.style.cssText);g+="<span "+f+m+i+j;g+='style="position:relative;white-space:pre-line;display:inline-block;background:transparent;'+h+e;g+="width:"+jQuery(this).width()+"px;height:"+jQuery(this).height()+"px;";g+="filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src='"+jQuery(this).attr("src")+"', sizingMethod='scale');";g+=k+'"></span>';if(l!=""){g='<span style="position:relative;display:inline-block;'+l+e+"width:"+jQuery(this).width()+"px;height:"+jQuery(this).height()+'px;">'+g+"</span>"}jQuery(this).hide();jQuery(this).after(g)});jQuery(this).find("*").each(function(){var f=jQuery(this).css("background-image");if(f.indexOf(".png")!=-1){var e=f.split('url("')[1].split('")')[0];jQuery(this).css("background-image","none");jQuery(this).get(0).runtimeStyle.filter="progid:DXImageTransform.Microsoft.AlphaImageLoader(src='"+e+"',sizingMethod='scale')"}});jQuery(this).find("input[src$=.png]").each(function(){var e=jQuery(this).attr("src");jQuery(this).get(0).runtimeStyle.filter="progid:DXImageTransform.Microsoft.AlphaImageLoader(src='"+e+"', sizingMethod='scale');";jQuery(this).attr("src",d.blankgif)})}return jQuery}})(jQuery);
