documentReadyListeners = new Array();

/**
 * Keeps an array of all registered document ready listeners. This
 * are invoked when the page is loaded by full page load or AJAX
 */
function documentReady(fnName){
    documentReadyListeners.push(fnName);
}

/**
 * Invokes all registered document ready listeners
 */
function invokeDocumentReadyListeners(firesifr){
    for (var i = 0; i < documentReadyListeners.length; i++) {
        eval(documentReadyListeners[i] + "()");
    }
    if (firesifr) {
        fireSIFR();
    }
}

/**
 * Define the global document ready handler
 */
jQuery(document).ready(function(){
    invokeDocumentReadyListeners(false);
});

function splitValue(value, token, index){
    var arr = value.split(token);
    return arr[index];
}

String.prototype.stripSpaces = function( ){ return this.replace( /\s/g, "" ); };

function whiteSpace(value){
    value = value.replace(/^\s*|\s*$/g, '');
    return value;
}

function getParam(name){
    name = name.replace(/[\[]/, "\\\[").replace(/[\]]/, "\\\]");
    var regexS = "[\\?&]" + name + "=([^&#]*)";
    var regex = new RegExp(regexS);
    var result = regex.exec(window.location.href);
    if (result == null) 
        return "";
    else 
        return result[1];
}

function addGoogleClickEvent(ident, evCategory, evAction, evLabel) {
    jQuery(ident).click(function(){
		trackEventClick(evCategory, evAction, evLabel);
        return true;
    });
}


// Google Analytics Event Tracking
function trackEventClick(evCategory, evAction, evLabel)
{
    try {
		pageTracker._trackEvent(evCategory.toUpperCase(), evAction.toUpperCase(), evLabel.toUpperCase());
    } catch (err) 
	{}
}


documentReady("extendedFooterClass");
function extendedFooterClass(){
    if (jQuery(".footerContainer") && jQuery(".footerContainer").length > 0) {
        jQuery("#content").addClass("extendedContent");
    }
}

function splitValue(value, token, index)
{
	 var arr = value.split(token);
 	 return arr[index];
}

jQuery(document).ready(function() {
    jQuery('a.movieOverlay').attr('rel', '#overlay');
    jQuery('a.movieOverlay').overlay({ onClose: movieOverlayClose });
    jQuery('a.movieOverlay').click(function(e) {
        e.preventDefault();
        movieOverlayClose();
        var t = setTimeout("movieOverlayLoad('" + jQuery(this).attr('href')+ "')", 500);
    });
});

function movieOverlayLoad(url) {
    var flashVarsVid = { url: url, autoPlay: "true", showSpinner: "true", controls: "scrub,time,duration,volume,fullscreen", colorTheme: "#259DD4", framing: "touchinside" };
    var paramsVid = { menu: 'false', allowFullScreen: "true", allowScriptAccess: "sameDomain", bgColor: "#FFFFFF" };
    var attributesVid = { id: 'movieOverlayPlayer', name: 'movieOverlayPlayer' };
    swfobject.embedSWF('/swf/videoplayer/videoplayer.swf', 'contentWrap', '640', '360', '9.0.28', false, flashVarsVid, paramsVid, attributesVid);
    trackEventClick(siteArea, "Video Overlay", window.location.pathname);
}

function movieOverlayClose() {
    jQuery('#overlay object').replaceWith('<div id="contentWrap"></div>');
}
