/* -------------------------------------------------------------------------- */
/**
 *    @fileoverview
 *       external js/css files loader.
 *
 *    @version 2.0.20090910
 */
/* -------------------------------------------------------------------------- */
if(typeof BAJL=="undefined"){BAJL={}}BAJL.ImportJS=function(B){if(!B||typeof B!="string"){throw new TypeError("BAJL.ImportJS: first argument must be a file name or file path or full URL.")}else{var D=arguments.callee;var A=(B.match("/"))?"":D.dir;var C=A+B;if(!D.isImported(C)){if(D.isCapableOfDOM()){(D.getHeadElement().appendChild(document.createElement("script"))).src=C}else{document.write('<script type="text/javascript" src="'+C+'"><\/script>')}D.imported.push(C)}}};BAJL.ImportJS.dir="./";BAJL.ImportJS.imported=[];BAJL.ImportJS.isImported=function(C){if(!C||typeof C!="string"){throw new TypeError("BAJL.ImportJS.isImported: first argument must be a file name or file path or full URL.")}else{for(var A=0,B=false;(A<this.imported.length&&!B);A++){B=(this.imported[A]==C)}return B}};BAJL.ImportJS.isCapableOfDOM=function(){return false};BAJL.ImportJS.getHeadElement=function(){var A=arguments.callee;return A._cache_||(A._cache_=document.getElementsByTagName("head")[0])};BAJL.ImportJS.from=function(D){if(!D||typeof D!="string"){throw new TypeError("BAJL.ImportJS.from: first argument must be a directory path or a file name.")}else{if(D.match("/")){if(D.substr(D.length-1)!="/"){throw new TypeError("BAJL.ImportJS.from: first argument must end with '/' in the case of specifying directory path.")}else{this.dir=D}}else{var B=this.getHeadElement().getElementsByTagName("script");for(var C=0,E=B.length;C<E;C++){var A=B[C].src.split("/");if(A.pop()==D){this.dir=A.join("/")+"/";break}}}}return this.dir};BAJL.ImportCSS=function(D,C){if(!D||typeof D!="string"){throw new TypeError('BAJL.ImportCSS: argument "path" must be a file name or file path or full URL.')}else{if(C&&typeof C!="string"){throw new TypeError('BAJL.ImportCSS: argument "media" must be a string.')}else{var F=arguments.callee;var A=(D.match("/"))?"":F.dir;var E=A+D;if(!F.isImported(E)){if(F.isCapableOfDOM()){var B=document.createElement("link");B.rel="stylesheet";B.type="text/css";B.href=E;B.media=C||"all";F.getHeadElement().appendChild(B)}else{document.write('<link rel="stylesheet" type="text/css" href="'+E+'" media="'+(C||"all")+'" />')}F.imported.push(E)}return B}}};BAJL.ImportCSS.dir="./";BAJL.ImportCSS.imported=[];BAJL.ImportCSS.isImported=BAJL.ImportJS.isImported;BAJL.ImportCSS.isCapableOfDOM=BAJL.ImportJS.isCapableOfDOM;BAJL.ImportCSS.getHeadElement=BAJL.ImportJS.getHeadElement;BAJL.ImportCSS.from=function(A){if(!A||typeof A!="string"){throw new TypeError("BAJL.ImportCSS.from: first argument must be a directory path or a file name.")}else{if(A.match("/")){if(A.substr(A.length-1)!="/"){throw new Error("BAJL.ImportCSS.from: first argument must end with '/' in the case of specifying directory path.")}else{this.dir=A}}else{throw new Error("BAJL.ImportCSS.from: first argument must end with '/' in the case of specifying directory path.")}}return this.dir};

/* --------------- import external scripts --------------- */
BAJL.ImportJS.from('import.js');
BAJL.ImportJS('jquery.js');
BAJL.ImportJS('bajl.unified.js');
BAJL.ImportJS('bajl.main.js');

/* --------------- import external styles --------------- */
BAJL.ImportCSS.from('/assets/css/001/');

/* --------------- import page local scripts --------------- */
(function () {
// URL Dispatcher
// http://less.carbonfairy.org/post/1414938831
var dispatcher={location:window.location,stash:[]
    ,connect:function(a,b){if(a||a===0){a=a.valueOf();if(typeof a!="object"||a instanceof RegExp)a={pathname:a};dispatcher.stash.push([a,b])}return dispatcher}
    ,and:function(){var a=dispatcher.stash,b=a.length;b&&(a[b-1][2]=!0);return dispatcher}
    ,dispatch:function(a){for(var a=a||dispatcher.location,b=dispatcher.stash,c={},g=0,d;d=b[g];++g){var h=d[0],i=d[1];d=d[2];var j=!1,f;for(f in h){var e=a[f];if(e)if(e=dispatcher.match(h[f],e),j=!!e)c[f]=e;else break}if(j&&
    (i&&i(c),!d))break}dispatcher.clear();return dispatcher}
    ,match:function(a,b){var c;a instanceof RegExp?c=a.exec(b)||!1:(a=a.toString(),c=b.indexOf(a)!=-1&&a);return c}
    ,clear:function(){dispatcher.stash=[];return dispatcher}};

dispatcher
    .connect('/company/access/', function () { BAJL.ImportJS(BAJL.ImportJS.dir + 'imports/company_access.js'); })
    .connect(/^\/(index\.html)?$/i, function () { BAJL.ImportJS(BAJL.ImportJS.dir + 'imports/home.js'); })
    .dispatch()
;

})();

