function goDown(){
	var menu = $(this);
	menu.children("UL.menu-drop").fadeIn(150);
	menu.addClass("selected");
}
function goUp(){
	var menu = $(this);
	menu.children("UL.menu-drop").fadeOut(150);
	menu.removeClass("selected");
}
$(document).ready(function(){
	$("P.Add").show();
	$("DIV.CommentsForm").hide();
	$("A.ShowCommentsForm").click(function(){
		$("DIV.CommentsForm").show();
		$("P.Add").hide();
	});
	$("LI.menu-tabdrop").hoverIntent({ 
		sensitivity: 10,
		interval: 100,
		over: goDown,
		timeout: 70,
		out: goUp
		});
    $("DIV.CarouselListNO").jCarouselLite({
        btnNext: ".ButtonNext",btnPrev: ".ButtonPrev",visible: 1,scroll: 1,auto: 6000,speed: 750
    });
	$("#Enter").focus(function() {
		if( this.value == this.defaultValue ) {
			this.value = "";
		}
	}).blur(function() {
		if( !this.value.length ) {
			this.value = this.defaultValue;
		}
	});
	$(".t-scroll").click(function(event){		
		event.preventDefault();
		$('html,body').animate({scrollTop:$(this.hash).offset().top}, 500);
	});
});

$(function() {
  var timer = setInterval( switchTweets, 8000);
  var counter = 0;
  function switchTweets() {
    if (counter ==0) { counter++; return; }
    $('li','.switchTweets')
      .stop()
      .fadeOut('fast')
      .filter( function() { return this.id.match('Tweet' + counter); })   
      .fadeIn('fast');
    counter == 6? counter = 0 : counter++; 
  }
});

$(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);
