/**************************
* LocalData version:1.0
* author: luogc 2009-5-21
* client data store( using  Flex ShareObject or cookie)
**************************/
var LocalData = new function()
{
	this.flag=false;
	this.get = function(key)
	{
		if(this.flag)
		{
			try{
			    return this.getShareObject("bj12530",key);
			}catch(e){
			    return this.getCookie(key);
			}
		}
		else
		{
			return this.getCookie(key);
		}
	};
	this.set=function(key,value)
	{
		if(this.flag)
		{
			try{
				this.setShareObject("bj12530",key,value);
			}catch(e){
				this.setCookie(key,value);
			}
		}
		else
		{
			this.setCookie(key,value);
		}
	};
	this.getShareObject=function(local,key)
	{
		return document.getElementById("_Share_Object").getData(local,key);
	};
	this.setShareObject=function(local,key,value)
	{
		document.getElementById("_Share_Object").setData(local,key,value);
	};
	this.getCookie=function(key)
	{
		var arg = key+"=";
		var tem=document.cookie;
		if(tem!=null)
		{
			var pos1 = tem.indexOf(arg);
			var pos2 = tem.indexOf(";",pos1);
			if (pos1==-1){return null;}
			if (pos2==-1){pos2=tem.length;}
			tem=tem.substring((pos1+arg.length),pos2);
			return unescape(tem);
		}
		return "";
	};
	this.setCookie=function(key,value,expires,path,domains,secure)
	{
		if(expires)
		{
			expires=expires*1000*60*60*24;
		}
		var expires_date=new Date(new Date().getTime()+(expires));
		document.cookie=key+"="+escape(value)+
		((expires)?";expires="+expires_date.toGMTString():"")+
		((path)?";path="+path:"")+
		((domains)?";domain="+domains:"")+
		((secure)?";secure":"");
	};
	this._flashVersion=function()
	{
		var flashVersion=0;   //flash version
		var isIE=this.isIE(); //if is IE 

		if(isIE)
		{
			var swf = new ActiveXObject('ShockwaveFlash.ShockwaveFlash'); 
			if(swf){
				VSwf=swf.GetVariable("$version");
				flashVersion=parseInt(VSwf.split(" ")[1].split(",")[0]); 
			}
		}
		else
		{
			if (navigator.plugins && navigator.plugins.length > 0)
			{
				var swf=navigator.plugins["Shockwave Flash"];
				if(swf)
				{
					var words = swf.description.split(" ");
					for (var i = 0; i < words.length; ++i)
					{
						if (isNaN(parseInt(words[i]))) continue;
						flashVersion = parseInt(words[i]);
					}
				}
			}
		}
		return flashVersion;
	};
	this.isIE = function(){ return (/*@cc_on!@*/0);};
	this._init=function()
	{
        this.flag = (this._flashVersion() >= 9);
	};
	this._init();
};