function $(el){
	if(typeof el == 'string')
		return document.getElementById(el);
	if(typeof el == 'object')
		return el;
	return null;
}
var CookieManager = {
	getExpiresDate:function(days, hours, minutes) {
	    var ExpiresDate = new Date();
	    if (typeof days == "number" && typeof hours == "number" && 
	        typeof hours == "number") {
	        ExpiresDate.setDate(ExpiresDate.getDate() + parseInt(days));
	        ExpiresDate.setHours(ExpiresDate.getHours() + parseInt(hours));
	        ExpiresDate.setMinutes(ExpiresDate.getMinutes() + parseInt(minutes));
	        return ExpiresDate.toGMTString();
	    }
	},  
	_getValue:function(offset) {
	    var endstr = document.cookie.indexOf (";", offset);
	    if (endstr == -1) {
	        endstr = document.cookie.length;
	    }
	    return unescape(document.cookie.substring(offset, endstr));
	},
	get:function(name) {
	    var arg = name + "=";
	    var alen = arg.length;
	    var clen = document.cookie.length;
	    var i = 0;
	    while (i < clen) {
	        var j = i + alen;
	        if (document.cookie.substring(i, j) == arg) {
	            return this._getValue(j);
	        }
	        i = document.cookie.indexOf(" ", i) + 1;
	        if (i == 0) break; 
	    }
	    return "";
	},
	set:function(name, value, expires, path, domain, secure) {
	    document.cookie = name + "=" + escape (value) +
	        ((expires) ? "; expires=" + expires : "") +
	        ((path) ? "; path=" + path : "") +
	        ((domain) ? "; domain=" + domain : "") +
	        ((secure) ? "; secure" : "");
	},
	remove:function(name,path,domain) {
	    if (this.get(name)) {
	        document.cookie = name + "=" +
	            ((path) ? "; path=" + path : "") +
	            ((domain) ? "; domain=" + domain : "") +
	            "; expires=Thu, 01-Jan-70 00:00:01 GMT";
	    }
	},
	clear:function(){
		var cookies = document.cookie.split(';');
		for(var i=0; i < cookies.length; i++)
			this.remove(cookies[i].split('=')[0]);
	}
}
function FlashWriter(args){
	this.params = {};
	this.variables = {};
	this.properties = { url:'', width:300, height:225,id:''};
	for(var i in args)
		this.properties[i] = args[i];
}
FlashWriter.prototype = {
	render:function(){
		var html='<object  classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0" width="'+ this.properties.width +'" height="'+ this.properties.height +'"  id="'+this.properties.id+'"  name="'+this.properties.id+'">';
		html += '<param name="movie" value="'+this.properties.url+'">';
        html += '<param name="FlashVars" value="'+this.getVariableString()+'">';
		//html += '<param name="wmode" value="opaque">';
		html += this.getParamString(true);
        html += '<embed src="'+this.properties.url+ '" width="'+ this.properties.width +'" height="'+this.properties.height+'"  id="'+this.properties.id+'" name="'+this.properties.id+'"'+this.getParamString(false)+' FlashVars="'+this.getVariableString()+'" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />';  
        html+='</object>';

        return html;
	},
	addParam:function(name, value){
		this.params[name] = value;
	},
	addVariable:function(name, value){
		this.variables[name] = value;
	},
	getVariableString:function(){
		var arr = [];
		for(var i in this.variables)
			arr.push(i+"="+this.variables[i])
		return arr.join('&');
	},
	getParamString:function(isIE){
		var arr = [];
		for(var i in this.params)
			if(isIE)
				arr.push('<param name="'+i+'" value="'+this.params[i]+'">');
			else
				arr.push(i+"="+this.params[i]);
		return arr.join(' ');
	},
	write:function(el){
		var o = document.getElementById(el);
		if(o == null) return;
		
		if(CookieManager.get('userid').length > 0)
			this.addVariable('uid',CookieManager.get('userid'));
		else
			this.addVariable('userid','');			
		if(CookieManager.get('sid').length > 0)	
			this.addVariable('sid',CookieManager.get('sid'));
		else
			this.addVariable('sid','');	
		if(CookieManager.get('location').length > 0)
			this.addVariable('locid',CookieManager.get('location'));
		else
			this.addVariable('locid','');		
		
		var ref = location.href;

/*
		var rindex=ref.indexOf("#");
		
		if(rindex!=-1)
		{
			ref=ref.substring(0, rindex);
			alert(ref);
		}
*/
		if(ref.length > 0)
			this.addVariable('pageurl',ref);
		else
			this.addVariable('pageurl','');

	    //fo.addVariable("from","free");
	    //fo.addVariable("adcpid",1210);
	
		var fls=this.getVersion();
		
		if(!(parseInt(fls[0]+fls[1]+fls[2])>901))//版本小于901 则提示
		{
			var otishi='<div style="!important;margin:50px auto;width:288px;height:163px;border:2px outset #05ABEA;background-color:#eee;">';
			otishi+='<p style="padding:20px;line-height:160%;color:#000;font-size:12px;">请先确认是否安装了 最新Flash 播放器<br/>请点击安装按钮</p>';
			otishi+='<a style="display:block;height:31px;width:115px;line-height:31px;font-size:12px;color:#000;text-decoration:none;text-align:center;margin:10px auto 0 auto;border:2px outset #999;" href="http://get.adobe.com/flashplayer/" target="_blank">安装</a></div>';
			
			o.style.width=this.properties.width;
			o.style.height=this.properties.height;
			o.innerHTML =otishi;			
			if(document.getElementById('wmpDiv'))//直播播放器隐藏wmp播放器		
				document.getElementById('wmpDiv').style.display="none";

		}
		else
		{
			o.innerHTML = this.render();
		}		
	},
	getVersion:function(){
	var b=[0,0,0];
	if(navigator.plugins&&navigator.mimeTypes.length){
		var a=navigator.plugins["Shockwave Flash"];
		if(a&&a.description){
			b=a.description.replace(/^\D+/,"").replace(/\s*r/,".").replace(/\s*[a-z]+\d*/,".0").split(".")
		}
	}else{
		if(navigator.userAgent&&navigator.userAgent.indexOf("Windows CE")>=0){
			var c=1;
			var f=3;
			while(c){
				try{
					f++;
					c=new ActiveXObject("ShockwaveFlash.ShockwaveFlash."+f);
					b=[f,0,0]
				}catch(d){
					c=null
				}
			}
		}else{
			try{
				var c=new ActiveXObject("ShockwaveFlash.ShockwaveFlash.7")
			}catch(d){
				try{
					var c=new ActiveXObject("ShockwaveFlash.ShockwaveFlash.6");
					b=[6,0,21];
					c.AllowScriptAccess="always"
				}catch(d){
					if(b.major==6){
						return b
					}
				}
				try{
					c=new ActiveXObject("ShockwaveFlash.ShockwaveFlash")
				}catch(d){}
			}
			if(c!=null){
				b=c.GetVariable("$version").split(" ")[1].split(",")
			}
		}
	}
	return b
}
}

