/**
* CN公共JS
* author TangPeng
* date 2010-7-22 上午08:45:20
* @param args
*/
/******************************
var _ec=new plug_ec();
		var options = {expires:1,path:'/',domain:_ec.domain,secure:true}
		_ec._cookie("aaa","abc");
		alert(_ec._cookie("aaa"));
		
	(1) 搜索引擎推广标识 site=baidu-XXXX; cookie主键 site
	(2) 广告位标识 adcode=123-1212-232;    cookie主键 adcode
	(2) 联盟标识  union=XXX;   cookie主键 union  
								unionsid=1212;   cookie主键 unionsid
*******************************/

	function plug_ec(){
		//主域名
		this._domain = '9978.cn';
		//js cookie 参数
		this._cookieOptions = function(expires,path){
			path = path || '/';
			return expires ? {expires: expires,path: path,domain:this._domain} : {path: path,domain:this._domain};
		};
		//js cookie 操作
		//options = {expires:365,path:'/',domain:this._domain,secure:true}
		this._cookie = function(name, value, options){
					if(typeof value != 'undefined')
					{
						options = options || {expires:365,path:'/',domain:this._domain,secure:true};
						if (value === null){
							value = '';options.expires = -1;
						}
					  var expires = '';
					  if(options.expires	&& (typeof options.expires == 'number' || options.expires.toUTCString)) {
						var date;
						if (typeof options.expires == 'number'){
							date = new Date();date.setTime(date.getTime()	+ (options.expires * 24 * 60 * 60 * 1000));
						}else{
							date = options.expires;
						}
						expires = '; expires=' + date.toUTCString(); // use expires attribute, max-age is not supported by IE
					}
					var path = options.path ? '; path=' + options.path : '';
					var domain = options.domain ? '; domain=' + options.domain : '';
					var secure = options.secure ? '; secure' : '';
					document.cookie = [name, '=', encodeURIComponent(value), expires, path,domain, secure].join('');
				} else {
					var cookieValue = null;
					if (document.cookie && document.cookie != '') {
						var cookies = document.cookie.split(';');
						for (var i = 0; i < cookies.length; i++) {
							var cookie = (cookies[i] || "").replace( /^\s+|\s+$/g, "" );
							if (cookie.substring(0, name.length + 1) == (name + '=')) {
								cookieValue = decodeURIComponent(cookie.substring(name.length + 1));
								break;
							}
						}
					}
					return cookieValue;
				}
		};
		//获取URL参数
		this._getUrlParam = function(sBase, sParam) {
			var param="";
			try{
					var re = eval("/" + sParam + "=([^&]*)/");
					if (re.test(sBase)) {
						param = RegExp.$1;
					}
				}catch(e){}
					return param;
		};
	}
	/************************************************
	*加入收藏夹,设置主页
	***********************************************/
	
function AddFavorite(sURL, sTitle) { 
    try 
    { window.external.addFavorite(sURL, sTitle); } 
    catch (e){ 
        try 
        { window.sidebar.addPanel(sTitle, sURL, ""); } 
        catch (e) { alert("加入收藏失败，请使用Ctrl+D进行添加");  } 
    } 
} 
function SetHome(obj,vrl){ 
    try{ obj.style.behavior='url(#default#homepage)';obj.setHomePage(vrl);  } 
    catch(e){ 
        if(window.netscape) { 
            try {netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect"); } 
            catch (e) { alert("此操作被浏览器拒绝！\n请在浏览器地址栏输入“about:config”并回车\n然后将 [signed.applets.codebase_principal_support]的值设置为'true',双击即可。"); } 
            var prefs = Components.classes['@mozilla.org/preferences-service;1'].getService(Components.interfaces.nsIPrefBranch); 
            prefs.setCharPref('browser.startup.homepage',vrl); 
         } 
    } 
}
	
/*==================================================
 * copyright(c)2010 北京叁加伍网络科技有限公司 http://www.3jia5.com
 * @author 		TangPeng
 * 即时通讯统计
 * 页面热区统计
 * =================================================
jQuery(document).ready(function(){
	jQuery('img[src="http://www.guangfa99.com/3158kf/init_3.gif"]').click(function() {
		analyser_c.tools._userid ='8';
	  analyser_c.tools._itemid = '70';
	  analyser_c.tools._typeid = '0';
	  analyser_c.tools._domainid ='60';
		analyser_c.tools.counts();
	});
});
 */
var analyser_c = window.analyser_c = {};
analyser_c.tools = {
	_userid : '0',
	_itemid : '0',
	_typeid : '0',//0 即时通讯,1 QQ
	_domainid :'0',
	_host : 'http://usercn.3158.cn',
	current : function(){
		return window.location.href;
	},
	//判断是否有中文
	isChinese : function(temp){
		var patrn=/[\u4E00-\u9FA5]|[\uFE30-\uFFA0]/gi; 
		if(!patrn.exec(temp)){ 
			return false; 
		}else{ 
			return true; 
		} 
	},
	betaURI : function(uri){
	if(uri == null || uri == '') return '';
	else return (analyser_c.tools.isChinese(uri)?encodeURI(uri):uri).replace(/&/g,'@');
	},
	counts : function(){//即时通讯
		var analyser_content='domainid='+analyser_c.tools._domainid;
		analyser_content+='&userid='+analyser_c.tools._userid;
		analyser_content+='&itemid='+analyser_c.tools._itemid;
		analyser_content+='&current='+analyser_c.tools.betaURI(analyser_c.tools.current());
		analyser_content+='&type='+analyser_c.tools._typeid;
		var imgSrc='http://'+analyser_c.tools._host+'/engine/count.html?'+ analyser_content;
 document.write('<img id="3JIA5-CORP-ANALYSERCLICK-count" src="'+imgSrc+'" style="width:0px;height:0px; display:\"none\""/>');
/*
	  var oBody = document.getElementsByTagName("body").item(0);
		var oImg = document.getElementById('3JIA5-CORP-ANALYSERCLICK');
		if(oImg) {
			oBody.removeChild(oImg);
		}
		oImg = document.createElement('img');
		oImg.width=0;
		oImg.height=0;
		oImg.style.display='none';
		oImg.id='3JIA5-CORP-ANALYSERCLICK';
		oImg.src=imgSrc;
		oBody.appendChild(oImg);
		*/
	},
	hotspot : function(kid,x,y){//热区
		var analyser_content='domainid='+analyser_c.tools._domainid;
		analyser_content+='&userid='+analyser_c.tools._userid;
		analyser_content+='&itemid='+analyser_c.tools._itemid;
		analyser_content+='&current='+analyser_c.tools.betaURI(analyser_c.tools.current());
		analyser_content+='&pagekid='+kid;
		analyser_content+='&x_asis='+x;
		analyser_content+='&y_asis='+y;
		var imgSrc='http://'+analyser_c.tools._host+'/engine/hotspot.html?'+ analyser_content;
		 document.write('<img id="3JIA5-CORP-ANALYSERCLICK-host" src="'+imgSrc+'" style="width:0px;height:0px; display:\"none\""/>');
/*
	  var oBody = document.getElementsByTagName("body").item(0);
		var oImg = document.getElementById('3JIA5-CORP-ANALYSERCLICK');
		if(oImg) {
			oBody.removeChild(oImg);
		}
		oImg = document.createElement('img');
		oImg.width=0;
		oImg.height=0;
		oImg.style.display='none';
		oImg.id='3JIA5-CORP-ANALYSERCLICK';
		oImg.src=imgSrc;
		oBody.appendChild(oImg);
		*/
	}
	
}




