window.VJS = window.VJS || {};
VJS.v65Toolkit = { 
    injectTag: function(options){
        var defaultSettings = {
            "type":null,
            "url":null,
            "callback":null,
            "node":"script",
            "cache":true
        };
        for(var i in defaultSettings) {
            if(typeof options[i] == 'undefined') { options[i] = defaultSettings[i]; }
        }
        var parentOfNode = document.getElementsByTagName(options.node)[0];
        if(options.type == 'stylesheet') {
            if (document.createStyleSheet) {
                document.createStyleSheet(options.url);
                return this;
            } else {
                cssTag = '<link rel="stylesheet" type="text/css" href="' + options.url + '" />';
                document.getElementsByTagName(parentOfNode)[0].appendChild(cssTag);
                return this;
            }
        } else if(options.type == 'script') {
            var script = document.createElement('script');
            script.type = 'text/javascript';
            ts = new Date().getTime();
            if (script.readyState) {
                script.onreadystatechange = function(){
                    if (script.readyState == 'loaded' || script.readyState == 'complete') {
                        script.onreadystatechange = null;
                        if(typeof options.callback == 'function') {
                            options.callback();
                        }
                    }
                };
            } else {
                script.onload = function(){
                    if(typeof options.callback == 'function') {
                        options.callback();
                    }
                };
            }
            if(options.cache == false) {
                options.url += (/\?/.test(options.url) ? '&' : '?') + 'vjsNoCache=' + ts;
            }
            script.src = options.url;
            parentOfNode.parentNode.insertBefore(script,parentOfNode);
        }
    },
	checkPage: function(targetPage) {
		if(typeof PageName == 'function') {
			if (PageName().split('#')[0] == targetPage.toLowerCase()) {
				return true;
			} else {
				if(targetPage.toLowerCase() == 'default.asp') {
					if(PageName().split('#')[0] == '') {
						return true;
					}
					return false;
				}
			}
		}
	}
};
