﻿(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);

function browseDown(){
	var browse = $(this);
	browse.children("UL.BrowseSites").fadeIn(80);
}
function browseUp(){
	var browse = $(this);
	browse.children("UL.BrowseSites").fadeOut(100);
}
function dropDown(){
	var browse = $(this);
	browse.addClass("FlyingDropHover");
	browse.children("DIV.DropContent").slideDown(200);
}
function dropUp(){
	var browse = $(this);
	browse.children("DIV.DropContent").slideUp(250,function(){
		browse.removeClass("FlyingDropHover");
		});
}
$(document).ready(function(){
	$("LI.Partners").hoverIntent({ 
		sensitivity: 8,
		interval: 50,
		over: browseDown,
		timeout: 500,
		out: browseUp
		});
	$("A.FlyingDropLink").hover(function(){ 
		$("DIV.FlyingDrop").addClass("FlyingDropHovering");
		}, function() {
		$("DIV.FlyingDrop").removeClass("FlyingDropHovering");
		});
	$("A.FlyingDropLink").toggle(function(){ 
		$("DIV.FlyingDrop").addClass("FlyingDropHover");
		$("DIV.FlyingDrop").children("DIV.DropContent").slideDown(200);
		}, function() {
		$("DIV.FlyingDrop").children("DIV.DropContent").slideUp(250,function(){
			$("DIV.FlyingDrop").removeClass("FlyingDropHover");
			});
		});
});

$(document).ready(function(){
	$.fn.search = function() {
	return this.focus(function() {
		if( this.value == this.defaultValue ) {
			this.value = "";
		}
	}).blur(function() {
		if( !this.value.length ) {
			this.value = this.defaultValue;
		}
	});
};
$(".search-box").search();
});

var FlashHeed = (function(window) {
    var document = window.document;
    var gsub = function(string, pattern, replacement) {
        var result = '', source = string, match;
        while (source.length > 0) {
            if (match = source.match(pattern)) {
                result += source.slice(0, match.index);
                result += replacement;
                source  = source.slice(match.index + match[0].length);
            } else {
                result += source, source = '';
            }
        }
        return result;
    };
    var heed = function(el) {
        if(el === undefined || el === null) var el = document;
        var objects = el.getElementsByTagName('object');
        var len = objects.length;
        var i;
        for(i = 0; i < len; i++) {
            var o = objects[i];
            var params = o.getElementsByTagName('param');
            var params_length = params.length;
            var embeds = o.getElementsByTagName('embed');
            var embed = null;
            if(embeds.length > 0) var embed = embeds[0];
            // Handle embed tag (for non-IE)
            if(embed) {
                // Need to set the embed wmode attribute
                // In this case, we need to remove and re-add the child node
                embed.setAttribute('wmode', 'transparent');
                var nx = embed.nextSibling, pn = embed.parentNode;
                pn.removeChild(embed);
                pn.insertBefore(embed, nx);
            }
            // Handle param tags (for IE)
            var correct_wmode_found = false;
            var incorrect_wmode_found = false;
            for(var j = 0; j < params_length; j++) {
                if(params[j].name === 'wmode') {
                    if(/transparent/i.test(params[j].value) || /opaque/i.test(params[j].value)) {
                        // an existing wmode with "transparent" or "opaque" is found
                        correct_wmode_found = true;
                    } else {
                        incorrect_wmode_found = true;
                    }
                }
            }
            if(!correct_wmode_found || incorrect_wmode_found) {
                var html = o.outerHTML;
                var nx = o.nextSibling, pn = o.parentNode;
                // Do a string replacement for a window param that IE injects be default to the innerhtml
                html = gsub(html, /<param name="wmode".*?>/i, '');
                // Add the correct transparent wmode param
                html = gsub(html, /<\/object>/i, '<PARAM NAME="WMode" VALUE="Transparent"></object>');
                // Totally remove the object tag from the dom
                pn.removeChild(o);
                // Add it to our new div, only to clobber it immediately.
                // This is the only way we've found to force IE to unrender the object.
                // We use a new container for this because you can't mess with the innerhtml
                // of an object tag. (throws a runtime error)
                var div = document.createElement("div");
                div.appendChild(o);
                div.innerHTML = '';
                // Update it with our new HTML that has the correct param tag
                div.innerHTML = html;
                // Finally, insert this new div back in the original spot
                pn.insertBefore(div, nx);
            }
        }
    }
    return {
        heed: heed
    }
})(window);
