﻿var Ontos = window.Ontos || {};
var ontos = window.ontos || {};
ontos.widgets = ontos.widgets || {};

if (!Ontos.bootstap_done) {
	
	Ontos.bootstap_scripts = Ontos.bootstap_scripts || [
	    ["ext-base.js", "base"]
	    ,["ext-all-debug.js", "ext"]
	    ,["widgets-lib.js", "widgets"]
	    ,["widgets.js", "widgets"]
	];
	
	Ontos.bootstap_styles = Ontos.bootstap_styles || [
	 	["css/ext-all.css", "ext"]
	 	,["css/widgets.css", "widgets"]
	 	,["css/bookmark-widgets.css","bookmark_widgets"]
	 	,["css/bookmark.css","bookmark"]
	 	,["css/common.css","common"]
	];
	
	try { if(_ontos_url){}; }catch(e){ _ontos_url = "http://62.117.115.98:6622/inews/";}
	if(typeof _ontos_api_url == "undefined"){ _ontos_api_url = _ontos_url + "api/";}
	if(typeof _path_prefix == "undefined"){ _path_prefix = _ontos_url + "widgets/";}
	if(typeof _custom_widgets_path_prefix == "undefined"){ custom_widgets_path_prefix = _path_prefix;}
	if(typeof _ontos_blank_image_url == "undefined" ){ _ontos_blank_image_url = _path_prefix + "images/default/s.gif";}
	try { if(_history){}; }catch(e){ _history = false;}
	try { if(_cache){}; }catch(e){ _cache = "ON";}
	try { if(_ontology){}; }catch(e){ _ontology = "Common.English";}
	try { if(_period){}; }catch(e){ _period = 24;}
	try { if(_igoogle){}; }catch(e){ _igoogle = false;}
	
	var head = document.getElementsByTagName("head")[0];
	
	for (var i = 0; i < Ontos.bootstap_styles.length; ++i) {
		var item = Ontos.bootstap_styles[i];
		document.write('<link rel="stylesheet" type="text/css" href="' + _path_prefix + item[0] + '">');
	}
	
	for (var i = 0; i < Ontos.bootstap_scripts.length; ++i) {
		var item = Ontos.bootstap_scripts[i];
		document.write('<script type="text/javascript" src="' + _path_prefix + item[0] + '"></script>');
	}
	
	if (_igoogle) {
		var x = location.hostname.indexOf('.')+1;
	    if (x>0) document.domain = location.hostname.substring(x);
	}
	/*
	if (_history) {
		document.write('<form id="history-form" class="x-hidden">' +
				'<input type="hidden" id="x-history-field" />' +
				'<iframe id="x-history-frame"></iframe>' +
				'</form>');
	}
*/
	Ontos.bootstap_done = true;
}
function checkTimeZone() {
    var gmtstr = new Date().getGMTOffset(true);
    var hours = 60*60*1000;
    var hh = gmtstr.split(":");
    var offsetL = parseInt(hh[0].substr(1,3));
    var offsetR = parseInt(hh[1].substr(0,2));
    var sign = hh[0].substr(0,1);
    var offset = (offsetL+offsetR)*hours;
    if (sign == "+") return offset;
        else {
        return -offset;    
    }
}

