/**
作者 汪浩
修改 郝俊杰 
创建时间 2008-4-16
修改时间 2008-4-21
描述	用来获取播放链接的rid 直接调用getRid() 获取id,此id存放在cookie里面 如果存在获取 如果不存在设置 cookie有效期是10年 
**/
function RealRidCookie()
{
	this.rnCookie = new Object();
	this.rcName="CNRNRID";
}
RealRidCookie.prototype.getRid = function(){
	var rid;
	var rcVal=this.getCookie("CNRNRID");
	if(!rcVal){
		rcVal=this.setRidCookie();
	}
	this.setupRnCookie(rcVal);
	//alert(rnCookie.rid);
	return this.rnCookie.rid;
}

RealRidCookie.prototype.setupRnCookie =function(rcVal){
	//alert(rcVal);
	var vals=rcVal.split("&");
	for(var i=0;i<vals.length;i++){
		//alert(vals[i]);
		var kv=vals[i].split("=");
		eval("this.rnCookie."+kv[0]+"=\""+kv[1]+"\";");
	}
}
RealRidCookie.prototype.getValue = function(c,v){
	if(c.indexOf(v) < 0) return "";
        var cV = new RegExp(".*" + v +"=([^&]*)(&|$).*");
        return c.replace(cV,"$1");
}

RealRidCookie.prototype.setRidCookie = function(){
	var rcVal="";
	var cv="1.0";
	var rid=this._rid_generater();
	rcVal="cv="+cv+"&rid="+rid;
	this.setCookie(this.rcName,rcVal,3650);
	return rcVal;
}
RealRidCookie.prototype.getCookie =function(cookieName)
{
	var cookieArray = new Array();
        var cRE = new RegExp("(\;|^)[^;]*("+cookieName+")\=([^;]*)(;|$)");
        cookieArray = cRE.exec(document.cookie);
        if( cookieArray != null ){
                return cookieArray[3];
        }
        return "";
}

RealRidCookie.prototype.getCookieVal= function(offset)
{
	var endstr = document.cookie.indexOf(";", offset);
	if(endstr == -1)
	{
		endstr = document.cookie.length;
	}
	return unescape(document.cookie.substring(offset, endstr));
}

RealRidCookie.prototype.setCookie= function( name, value, days ) {
        var exp = new Date();
        var days2Live = exp.getTime() + (24 * 60 * 60 * 1000 * days);
        exp.setTime(days2Live );
        var domname=".real.com";
        document.cookie = name+"="+value+"; expires=" + exp.toGMTString() + "; domain=" + domname+"; path=/";
}
RealRidCookie.prototype._rid_addzero= function(nRaw,b)   {   
	var strNum = nRaw + "";
	var nCount = b - strNum.length;
	for(var i = 1; i <= nCount;i++) { 
	strNum = "0" + strNum; 
	} 
	return strNum; 
} 

RealRidCookie.prototype._rid_generater =function(){	
	var dt = new Date();
	var ts=Date.parse(dt)+dt.getUTCMilliseconds();
	var rnd=Math.floor(Math.random()*9999999);
	return ts+this._rid_addzero(rnd,7);
}
var rid_cookie = new RealRidCookie(); 
var rid = rid_cookie.getRid();
var cn='';
var real_uid ="";
if (cookie = rid_cookie.getCookie("RNPlayer")){
    cn  = rid_cookie.getValue(cookie,"CN");
}
if (typeof(getRealLogonName)=="function")
{
	real_uid = getRealLogonName();
}