var $_GLOBAL = {};

// pageid.js version
$_GLOBAL.ver = {
	 "blog7"		: "10"
	,"blog7photo"	: "4"
	,"blog7icp"		: "6"
};

// flash template info
$_GLOBAL.flash_template = {};

// 推广位数据配置
$_GLOBAL.popularizeConfig={
	"content" : '<a style="color:red;" href="http://t.sina.com.cn" target="_blank">微博：最火交流工具</a> <a style="color:red;" href="http://t.sina.com.cn/pub/star" target="_blank">看明星动态</a>'
};

// 克隆模板数据配置以及名人广告模板数据 
$_GLOBAL.clone_conf=['9_4','10_66'];
$_GLOBAL.famous_conf={
	"10_58":{
		template_clone_pic: '<img src="http://simg.sinajs.cn/blog7newtpl/image/10/10_58/images/anniu.gif" />',
		template_clone_link: "",
		template_clone_other: ""
	},
	"10_56":{
		template_clone_pic: '<img src="http://simg.sinajs.cn/blog7newtpl/image/10/10_56/images/anniu.gif" />',
		template_clone_link: "",
		template_clone_other: ""
	},
	"10_67":{
		template_clone_pic: '<img src="http://simg.sinajs.cn/blog7newtpl/image/10/10_67/images/anniu.gif" />',
		template_clone_link: "",
		template_clone_other: ""
	}
};
$_GLOBAL.GUANWANG={
	"10_26":{
		template_clone_pic: '<img src="http://simg.sinajs.cn/blog7newtpl/image/10/10_26/images/anniu.jpg" />',
		template_clone_link: "http://kobe.sina.com.cn/",
		template_clone_other: ""
	}
};
$_GLOBAL.cloneTemplateConfig = {
	"9_4": {
		template_clone_pic: "<img src='http://simg.sinajs.cn/blog7newtpl/image/9/9_4/images/anniu.gif' />",
		template_clone_link: "",
		template_clone_other: ""
	},
	"18_1": {
		template_clone_pic: "<img src='http://simg.sinajs.cn/blog7newtpl/image/18/18_1/images/anniu.gif' />",
		template_clone_link: "",
		template_clone_other: '<a href="http://finance.sina.com.cn/333/2010-02-05/guest920.shtml" target="_blank" style="color:#000000;right:0px;position:absolute;top:-56px;font-size:14px;font-weight:bold;text-decoration:underline;">进入3·15调查问卷</a>',
		count_id:"00000201",
		count_text:"<span style='right:0px;position:absolute;top:-28px;left:-30px'>新浪网友已经进行了<span style='color:#ff00ff'>#{template_pv}</span>次传递</span>"
	},
	"18_2": {
		template_clone_pic: "<img src='http://simg.sinajs.cn/blog7newtpl/image/18/18_2/images/anniu.gif' />",
		template_clone_link: "",
		template_clone_other: '<a href="http://finance.sina.com.cn/333/2010-02-05/guest920.shtml" target="_blank" style="color:#51584D;right:0px;position:absolute;top:-56px;font-size:14px;font-weight:bold;text-decoration:underline;">进入3·15调查问卷</a>',
		count_id:"00000201",
		count_text:"<span style='right:0px;position:absolute;top:-28px;left:-30px'>新浪网友已经进行了<span style='color:#ff00ff'>#{template_pv}</span>次传递</span>"
	},
	"18_3": {
		template_clone_pic: "<img src='http://simg.sinajs.cn/blog7newtpl/image/18/18_3/images/anniu.gif' />",
		template_clone_link: "",
		template_clone_other: '<a href="http://finance.sina.com.cn/333/2010-02-05/guest920.shtml" target="_blank" style="color:#000000;right:0px;position:absolute;top:-56px;font-size:14px;font-weight:bold;text-decoration:underline;">进入3·15调查问卷</a>',
		count_id:"00000201",
		count_text:"<span style='right:0px;position:absolute;top:-28px;left:-30px'>新浪网友已经进行了<span style='color:#ff00ff'>#{template_pv}</span>次传递</span>"
	},
	"18_4": {
		template_clone_pic: "<img src='http://simg.sinajs.cn/blog7newtpl/image/18/18_4/images/anniu.gif' />",
		template_clone_link: "",
		template_clone_other: '<a href="http://finance.sina.com.cn/333/2010-02-05/guest920.shtml" target="_blank" style="color:#447292;right:0px;position:absolute;top:-56px;font-size:14px;font-weight:bold;text-decoration:underline;">进入3·15调查问卷</a>',
		count_id:"00000201",
		count_text:"<span style='right:0px;position:absolute;top:-28px;left:-30px'>新浪网友已经进行了<span style='color:#ff00ff'>#{template_pv}</span>次传递</span>"
	},
	"18_5": {
		template_clone_pic: "<img src='http://simg.sinajs.cn/blog7newtpl/image/18/18_5/images/anniu.gif' />",
		template_clone_link: "",
		template_clone_other: '<a href="http://finance.sina.com.cn/333/2010-02-05/guest920.shtml" target="_blank" style="color:#5F4B3B;right:0px;position:absolute;top:-56px;font-size:14px;font-weight:bold;text-decoration:underline;">进入3·15调查问卷</a>',
		count_id:"00000201",
		count_text:"<span style='right:0px;position:absolute;top:-28px;left:-30px'>新浪网友已经进行了<span style='color:#ff00ff'>#{template_pv}</span>次传递</span>"
	},
	"18_6": {
		template_clone_pic: "<img src='http://simg.sinajs.cn/blog7newtpl/image/18/18_6/images/anniu.gif' />",
		template_clone_link: "",
		template_clone_other: '<a href="http://finance.sina.com.cn/333/2010-02-05/guest920.shtml" target="_blank" style="right:0px;position:absolute;top:-56px;font-size:14px;font-weight:bold;text-decoration:underline;">进入3·15调查问卷</a>',
		count_id:"00000201",
		count_text:"<span style='right:0px;position:absolute;top:-28px;left:-30px'>新浪网友已经进行了<span style='color:#ff00ff'>#{template_pv}</span>次传递</span>"
	},
	"18_7": {
		template_clone_pic: "<img src='http://simg.sinajs.cn/blog7newtpl/image/18/18_7/images/anniu.gif' />",
		template_clone_link: "",
		template_clone_other: '<a href="http://finance.sina.com.cn/333/2010-02-05/guest920.shtml" target="_blank" style="right:0px;position:absolute;top:-56px;font-size:14px;font-weight:bold;text-decoration:underline;">进入3·15调查问卷</a>',
		count_id:"00000201",
		count_text:"<span style='right:0px;position:absolute;top:-28px;left:-30px'>新浪网友已经进行了<span style='color:#ff00ff'>#{template_pv}</span>次传递</span>"
	},
	"18_8": {
		template_clone_pic: "<img src='http://simg.sinajs.cn/blog7newtpl/image/18/18_8/images/anniu.gif' />",
		template_clone_link: "",
		template_clone_other: '<a href="http://finance.sina.com.cn/333/2010-02-05/guest920.shtml" target="_blank" style="right:0px;position:absolute;top:-56px;font-size:14px;font-weight:bold;text-decoration:underline;">进入3·15调查问卷</a>',
		count_id:"00000201",
		count_text:"<span style='right:0px;position:absolute;top:-28px;left:-30px'>新浪网友已经进行了<span style='color:#ff00ff'>#{template_pv}</span>次传递</span>"
	},
	"18_9": {
		template_clone_pic: "<img src='http://simg.sinajs.cn/blog7newtpl/image/18/18_9/images/anniu.gif' />",
		template_clone_link: "",
		template_clone_other: '<a href="http://finance.sina.com.cn/333/2010-02-05/guest920.shtml" target="_blank" style="color:#4C7191;right:0px;position:absolute;top:-56px;font-size:14px;font-weight:bold;text-decoration:underline;">进入3·15调查问卷</a>',
		count_id:"00000201",
		count_text:"<span style='right:0px;position:absolute;top:-28px;left:-30px'>新浪网友已经进行了<span style='color:#ff00ff'>#{template_pv}</span>次传递</span>"
	},
	"18_10": {
		template_clone_pic: "<img src='http://simg.sinajs.cn/blog7newtpl/image/18/18_10/images/anniu.gif' />",
		template_clone_link: "",
		template_clone_other: '<a href="http://finance.sina.com.cn/333/2010-02-05/guest920.shtml" target="_blank" style="color:#000000;right:0px;position:absolute;top:-56px;font-size:14px;font-weight:bold;text-decoration:underline;">进入3·15调查问卷</a>',
		count_id:"00000201",
		count_text:"<span style='right:0px;position:absolute;top:-28px;left:-30px'>新浪网友已经进行了<span style='color:#ff00ff'>#{template_pv}</span>次传递</span>"
	},
	"10_38":{
		template_clone_pic: '<img src="http://simg.sinajs.cn/blog7newtpl/image/10/10_38/images/anniu.gif" />',
		template_clone_link: "",
		template_clone_other: ""
	},
	"10_68":{
		template_clone_pic: '<img src="http://simg.sinajs.cn/blog7newtpl/image/10/10_68/images/anniu.gif" />',
		template_clone_link: "",
		template_clone_other: ""
	},
	"10_69":{
		template_clone_pic: '<img src="http://simg.sinajs.cn/blog7newtpl/image/10/10_69/images/anniu.gif" />',
		template_clone_link: "",
		template_clone_other: ""
	}
};

// 动态模板的配置信息，宽|高
$_GLOBAL.flashtemplate = {
	"13_1": { width:950,height:266 },
	"13_2": { width:950,height:266 },
	"13_3": { width:950,height:266 },
	"13_4": { width:950,height:266 },
	"13_5": { width:950,height:306 },
	"13_6": { width:950,height:306 },
	"13_7": { width:950,height:286 },
	"13_8": { width:950,height:266 },
	"13_9": { width:950,height:266 },
	"13_10": { width:950,height:265 },
	"13_11": { width:950,height:266 },
	"13_12": { width:950,height:276 },
	"13_13": { width:950,height:286 },
	"13_14": { width:950,height:266 },
	"13_15": { width:950,height:306 },
	"13_16": { width:950,height:266 },
	"13_17": { width:950,height:266 },
	"13_18": { width:950,height:266 },
	"13_19": { width:950,height:313 },
	"13_20": { width:950,height:266 },
	"10_57": { width:950,height:302 }
};

// --- End of GLOBAL config ---

(function (){
	//- debug -
	var __debug_mode = false; //should be false
	//- sina lib version - TODO 
	var __sina_ver = "0.0.1";
	
	// js base domain
	var __js_domain = "http://sjs.sinajs.cn/";
	
	// @desc add DOM onload Event
	var __addDOMLoadEvent = function(func){
	    var __load_events;
	    var __load_timer;
//		var binded = false;
	    if (!__load_events) {
	        var init = function(){
	            // quit if this function has already been called
	            if (arguments.callee.done) {
	                return;
	            }
	            // flag this function so we don't do the same thing twice
	            arguments.callee.done = true;
	            // kill the timer
	            if (__load_timer) {
	                clearInterval(__load_timer);
	                __load_timer = null;
	            }
	            // execute each function in the stack in the order they were added
	            for (var i = 0; i < __load_events.length; i++) {
	                __load_events[i]();
	            }
	            __load_events = null;
	        };
	        // for Mozilla/Opera9
	        if (document.addEventListener) {
	            document.addEventListener("DOMContentLoaded", init, false);
//				binded = true;
	        }
	        // for Internet Explorer
	        /*@cc_on @*/
	        /*@if (@_win32)
	         var domlen = document.getElementsByTagName("*").length;
	         var domnum = 0;
	         (function () {
	         if(domnum != domlen) {
	         setTimeout(arguments.callee, 500);
	         }
	         else {
	         setTimeout(init, 500);
	         }
	         domnum = domlen;
	         })();
	         @end @*/
	        // for Safari
	        if (/WebKit/i.test(navigator.userAgent)) { // sniff
	            __load_timer = setInterval(function(){
	                if (/loaded|complete/.test(document.readyState)) {
	                    init(); // call the onload handler
//	                    binded = true;
	                }
	            }, 10);
	        }
	        // for other browsers
//			if(binded == false){
				window.onload = init;
//			}
	        // create event function stack
	        __load_events = [];
	    }
	    // add function to event stack
	    __load_events.push(func);
	};
	
	// 绑定事件
	var addEvent = function(elm, func, evType, useCapture) {
		var _el = $E(elm);
		if(_el == null){ return; }
		if(typeof useCapture == "undefined"){
			useCapture = false;
		}
		if(typeof evType == "undefined"){
			evType = "click";
		}
		if(_el.addEventListener){
			_el.addEventListener(evType, func, useCapture);
			return true;
		}else if(_el.attachEvent){
			var r = _el.attachEvent("on" + evType, func);
			return true;
		}else{
			_el['on' + evType] = func;
		}
	};
	
	var __addFocusEvent = function(fFocusFunction){
		//TODO not available during the dev
		if(window.excute != null && typeof window.excute == "function"){
			excute();
			excute = null;
		}
	};
	
	if(__debug_mode){
		document.write('<script type="text/javascript" src="' + __js_domain + 'bind2/debug/debug_base.js"></script>');
		document.write('<script type="text/javascript" src="' + __js_domain + 'bind2/debug/debug.js"></script>');
	}
	
	window.__load_js = function(){
	    var url = "";
		if(__debug_mode == true){
			url = 	__js_domain + "bind2/index.php?product=" + scope.$PRODUCT_NAME + "&pageid=" + scope.$pageid
						+ "&rnd=" + new Date().getTime();
			document.write('<script type="text/javascript" src="' + url + '" charset="utf-8"></script>');
		}else{
			// 取得 JS 版本号
			var jsver =	(typeof $_GLOBAL != "undefined" && $_GLOBAL.ver != null)
							? $_GLOBAL.ver[scope.$PRODUCT_NAME] || "-1"
							: "-1";
			url = 	__js_domain + scope.$PRODUCT_NAME + "/" + scope.$pageid + ".js?"
					+ jsver + ".js";
			document.write('<script type="text/javascript" src="' + url + '" charset="utf-8"></script>');
		}
	};
	
	window.__render_page = function(){
		__addDOMLoadEvent(main);
		addEvent(document.body, __addFocusEvent, "focus");
		addEvent(window, __addFocusEvent, "scroll");
		addEvent(document.body, __addFocusEvent, "mousemove");
		addEvent(document.body, __addFocusEvent, "mouseover");
	};
	
	if (typeof scope.$setDomain == "undefined" || scope.$setDomain == true) {
		document.domain = "sina.com.cn";
	}
})();