﻿/*
Xdrive Library File

@version 1.0
@Revised: 18th November 2010
@license: Custom Development - No Copying without prior consent


A. Function to call to include any Js Files
1. Include this file to have access to the $$, $ find functions
2. Menu Functions
*/



//A. Include Function
function include(file,linktype) {
    var script = document.createElement('script');
    if (linktype == "in")
    {
        script.src = getsysUrl() + file;
    }
    else {
        script.src = file;
    }
    
    script.type = 'text/javascript';
    script.defer = true;



    document.getElementsByTagName('head').item(0).appendChild(script);
}


//When the document is ready, load the setup files

jQuery(document).ready(loadSetup());

function loadSetup() {

    include('_sysFiles/plugins/prototype.js','in');
    include('_sysFiles/plugins/xdlib/xdlib_functions.js','in');
    //include('_sysFiles/plugins/cufon-yui.js','in');
    //include('_sysFiles/plugins/Avenir_500.font.js','in');

    




    //1. XDLib Find Functions
    //include('../../assets/plugins/xdlib_find.js'); 

    //2. <Menu Hover Functions
    //include('../../assets/plugins/xdlib_menu.js');

    //3. Tabs Functions
    include('_sysFiles/plugins/xdlib/xdlib_tabs.js','in');

    //4. Alert Functions
    include('_sysFiles/plugins/xdlib/xdlib_alert.js', 'in');

    //include('http://connect.facebook.net/en_US/all.js#appId=153011448103719&amp;xfbml=1', 'out');

    
    include('_sysFiles/plugins/xdlib/xdlib_readXML.js', 'in');

    //5. Date Picker Functions
    //include('_sysFiles/plugins/xdlib/xdlib_datepicker.js');

    //3. Help Functions
    //include('_sysFiles/plugins/xdlib/xdlib_help.js');

    //Session Auto Logout
    //include('_sysFiles/plugins/xdlib/xdlib_autoLogout.js');


    //Read Only Page Control
    //include('_sysFiles/plugins/xdlib/xdlib_readonly.js');

    //6. Form selector functions
    //include('../../assets/plugins/xdlib_formSelect.js');





    function addLoadListener(fn) {
        //mozilla and friends
        if (typeof window.addEventListener != 'undefined') {
            window.addEventListener('load', fn, false);
        }
        //opera
        else if (typeof document.addEventListener != 'undefined') {
            document.addEventListener('load', fn, false);
        }
        //innernetz exploder
        else if (typeof window.attachEvent != 'undefined') {
            window.attachEvent('onload', fn);
        }
        //the rest is pretty much for browsers that I doubt your 
        //CSS or anything else still supports like IE/Mac
        else {
            var oldfn = window.onload;
            if (typeof window.onload != 'function') {
                window.onload = fn;
            }
            else {
                window.onload = function () {
                    oldfn();
                    fn();
                };
            }
        }
    }

    addLoadListener(stateReady);



    //setPageHeights();
}

function stateReady() {
    //XDMenu.init();
    XDAlert.init();
    XDTabs.init();
    //XDDatePicker.init();
    // XDDatePicker.init();

    //Cufon - Avenir Replacements
    Cufon.replace('h1');
    Cufon.replace('h2');

    //Setup the Menu Expander
    $('Browse_Categories').onclick = function () {
        if ($('nav_all_categories').style.display == "block") {
            $('nav_all_categories').style.display = "none";
        }
        else
            $('nav_all_categories').style.display = "block";

        writeCategoryIndex();

           
    };

    $('nav_all_categories_close').onclick = function () { $('nav_all_categories').style.display = "none"; };
}

function writeCategoryIndex() {
    if ($('nav_all_categories_content').innerHTML.length == 0) {
        
        XDLoadXML.init();
        //$('nav_all_categories_content').innerHTML = "<h1>BUSH</h1>";
    }
}





