/*
This JS is an include for all externally linking JS/CSS files required for DB form
(c) 2008 Central Desktop Inc.
*/
if (typeof cd_static_url == 'undefined') {
    var cd_static_url = 'https://static3.centraldesktop.com';
}

if( (typeof Calendar === 'function') && (typeof common_tasks !== 'undefined') && (typeof ajax_params !== 'undefined')) {
    //alert( "In CD");
} else {
    //alert( "Outside CD");

    // These 2 lines fix a couple JS errors w/o including a couple more files
    function rand() { return Math.random(); }
    if (typeof spid == 'undefined') var spid = '';

    /**
     * This is a fallback mechanism... remember that this file used to be referenced
     * directly from the database web form template. I've since changed that so we
     * have version information available and compressed + concatenated all the included
     * scripts into 1 (/js/cc/cd_external.js) and updated the database web form template
     * accordingly. However since we can't update existing forms on other sites, this
     * catches that case and includes the cd_external.js file (with a random string
     * version so its always up to date).
     */
    if (typeof CD == 'undefined') {
        var r  = parseInt(rand() * 100000000);
        document.write('<script type="text/javascript" src="'+cd_static_url+'/js/cc/cd_external.v'+r+'.js"></script>');
    /**
     * We do still have to include these CSS files though, provided we're running this
     * code from inside cd_external.js (THIS file is part of /js/cc/cd_external, take a
     * look and see what I mean)
     */
    } else {
        document.write('<link rel="stylesheet" type="text/css" href="'+cd_static_url+'/js/calendar/calendar-blue'+CD.v.css+'.css" />');
        document.write('<link rel="stylesheet" type="text/css" href="'+cd_static_url+'/css/ext_include'+CD.v.css+'.css" />');
    }
}

