/**
 * json for ajax 数据回调
 * design by jeftom
 * date: 2009-08-30 15:10:56
 */


// 初始化
var FBrowser=new Object();
FBrowser.isIE=((navigator.userAgent.indexOf('MSIE')==-1)?false:true);
FBrowser.isIE7=((FBrowser.isIE&&window.XMLHttpRequest)?true:false);
FBrowser.isIE6=((FBrowser.isIE&&!window.XMLHttpRequest&&window.ActiveXObject)?true:false);
FBrowser.isFirefox=((navigator.userAgent.indexOf('Firefox')==-1)?false:true);
FBrowser.isOpera=((navigator.userAgent.indexOf('Opera')==-1)?false:true);

function JSONscriptRequest(fullUrl){
	this.fullUrl=fullUrl;
	this.noCacheIE='&noCacheIE='+(new Date()).getTime();
	this.headLoc=document.getElementsByTagName("head").item(0);
	this.scriptId='JscriptId'+JSONscriptRequest.scriptCounter++;
};
JSONscriptRequest.scriptCounter=1;
JSONscriptRequest.prototype.buildScriptTag=function(charset){
	this.scriptObj=document.createElement("script");
	this.scriptObj.setAttribute("type","text/javascript");
	if (charset)
	{
		this.scriptObj.setAttribute("charset", charset);
	}
	this.scriptObj.setAttribute("src",this.fullUrl);
};
JSONscriptRequest.prototype.removeScriptTag=function(){
	this.headLoc.removeChild(this.scriptObj);
};
JSONscriptRequest.prototype.addScriptTag=function(){
	this.headLoc.appendChild(this.scriptObj);
};

// 获取json长度
function getJsonLength(jsonData) {
	var jsonLength = 0;
	for (var i in jsonData)
	{
		jsonLength++;
		//return jsonData[i][1];
	}
	return jsonLength;
};

// 字符串编码函数
function encodeAndEscape(a){
	if(encodeURIComponent)return encodeURIComponent(a);
	if(escape)return escape(a)
	return a;
};
// 获取对象
function Fid(id){
	return document.getElementById(id);
};
