
//
// The following script is used to dynamically inject a floating
// header on the top of pages with a search engine and link out to a 
// contact form with any additional details.
//
// Only do anything if jQuery isn't defined
//

//Custom jquery namespace
var j = {};

//Load up jQuery first if it's not already defined..
if (typeof jQuery == 'undefined') {  
    function getScript(url, success) {
        var script = document.createElement('script');
        script.src = url;

        var head = document.getElementsByTagName('head')[0],
        done = false;

        // Attach handlers for all browsers
        script.onload = script.onreadystatechange = function() {
            if (!done && (!this.readyState || this.readyState == 'loaded' || this.readyState == 'complete')) {
                done = true;
                // callback function provided as param
                success();
                script.onload = script.onreadystatechange = null;
                head.removeChild(script);
            };
        };
        head.appendChild(script);
    };
    
    getScript('http://ajax.googleapis.com/ajax/libs/jquery/1.4.4/jquery.min.js', function() {
        if (typeof jQuery=='undefined') {
        // Super failsafe - still somehow failed...
        } else {
            // jQuery loaded!
            j.query = jQuery.noConflict(true);
            
            doNazWork();
        }
    });
} else { // jQuery was already loaded
    j.query = jQuery;
    doNazWork();
};


function doNazWork()
{
    j.query(document).ready(function($){
        //Only do this once!
        if (document.getElementById("migrate_warn_header") != null)
            return;

        //Put our new tag right below the head tag.
        $("body").prepend('<div id="migrate_warn_header"></div>');

        //Fetch the content for display
        if (j.query.browser.safari || j.query.browser.webkit)
        {
            $("#migrate_warn_header").load("/naz_migrate/migrate_header_webkit.html");
        }

        //$("#migrate_warn_header").load("/naz_migrate/migrate_header.html");
    });
}
