// get mouse pointer position

var jtongfu_browserObject=new Object();
jtongfu_browserObject.BrowserType = (navigator.appVersion.match(/MSIE/)) ? 'IE' : 'NS' ;

function jtongfu_loadFilesInIframe(fileUrls){
	this.fileUrls=fileUrls;
	this.taskCount=0;
	this.loadFile=function(file){
		if(file == null || file == ''){
			this.doneLoad();
			return;
		}
		var _doc = document.getElementsByTagName('head')[0];
	    var js = document.createElement('iframe');
	    js.setAttribute('width', '0');
	    js.setAttribute('height', '0');
	    js.setAttribute('frameborder', 'no');
	    js.setAttribute('src', file);
	    js.caller=this;
	    _doc.appendChild(js);
	    if(!/*@cc_on!@*/0){ //if not IE
	        //Firefox2、Firefox3、Safari3.1+、Opera9.6+ support js.onload
	        js.onload=function(){
	            this.caller.doneLoad();
	        }
	    }
	    else{
	        //IE6、IE7 support js.onreadystatechange
	        js.onreadystatechange=function(){
	            if(js.readyState == 'loaded'
	            	|| js.readyState == 'complete'){
	                this.caller.doneLoad();
	            }
	        }
	    }
	}
	this.doneLoad=function(){
		this.taskCount--;
		if(this.taskCount == 0
			&& this.afterLoad != null)
			this.afterLoad();
	}
	this.load=function(){
		this.taskCount = this.fileUrls.length;
		for(ii=0;ii<this.fileUrls.length;ii++)
			this.loadFile(this.fileUrls[ii]);
	}
    this.afterLoad = null;
}

function jtongfu_loadJSFiles(fileUrls){
	this.fileUrls=fileUrls;
	this.taskCount=0;
	this.loadJSFile=function(file){
		if(file == null || file == ''){
			this.doneLoad();
			return;
		}
		var _doc = document.getElementsByTagName('head')[0];
	    var js = document.createElement('script');
	    js.setAttribute('type', 'text/javascript');
	    js.setAttribute('src', file);
	    js.caller=this;
	    _doc.appendChild(js);
	    if(!/*@cc_on!@*/0){ //if not IE
	        //Firefox2、Firefox3、Safari3.1+、Opera9.6+ support js.onload
	        js.onload=function(){
	            this.caller.doneLoad();
	        }
	    }
	    else{
	        //IE6、IE7 support js.onreadystatechange
	        js.onreadystatechange=function(){
	            if(js.readyState == 'loaded'
	            	|| js.readyState == 'complete'){
	                this.caller.doneLoad();
	            }
	        }
	    }
	}
	this.doneLoad=function(){
		this.taskCount--;
		if(this.taskCount == 0
			&& this.afterLoad != null)
			this.afterLoad();
	}
	this.load=function(){
		this.taskCount = this.fileUrls.length;
		for(ii=0;ii<this.fileUrls.length;ii++)
			this.loadJSFile(this.fileUrls[ii]);
	}
    this.afterLoad = null;
}

function jtongfu_getObjectXY(obj){
	var tmpPos = new Object();
	tmpPos.x = 0;
	tmpPos.y = 0;
	var tmpObj = obj;
	do{
		
		if(tmpObj != null){
			//alert(tmpObj.tagName);
			//alert(tmpObj.offsetLeft+'|'+tmpObj.offsetTop);
			tmpPos.x += tmpObj.offsetLeft;
			tmpPos.y += tmpObj.offsetTop;
		}
		tmpObj = (tmpObj.offsetParent != null && tmpObj.tagName != 'BODY') ? tmpObj.offsetParent : null ;
	}
	while(tmpObj != null);
	//tmpPos.x += parseInt(document.documentElement.scrollLeft);
	//tmpPos.y += parseInt(document.documentElement.scrollTop);
	return tmpPos;
}

function jtongfu_obj1(obj){
	this.obj=obj;
	this.l;
	this.t;
	this.w;
	this.h;
	this.r;
	this.b;
	this.init=function(){
		var tmpPos = jtongfu_getObjectXY(this.obj);
		this.l = tmpPos.x;
		this.t = tmpPos.y;
		this.w = parseInt(this.obj.offsetWidth);
		this.h = parseInt(this.obj.offsetHeight);
		this.r = this.l+this.w;
		this.b = this.t+this.h;
		//alert('l:'+this.l+'\nt:'+this.t+'\nw:'+this.w+'\nh:'+this.h+'\nr:'+this.r+'\nb:'+this.b);
	}
	this.inme=function(x,y){
		if((x>=this.l&&y>=this.t&&y&&x<=this.r&&y<=this.b))
			return true;
		return false;
	}
	this.init();
}

function CallJTongfuScript(src){
	document.write('<script language="javascript" type="text/javascript" src="js/jtongfu/jtongfu.'+src+'.js"></script>');
}

function appendEvent(obj, sEvtName, Func){
	if(typeof(obj.length) != 'undefined'){
		for(ii=0;ii<obj.length;ii++)
			appendEventElement(obj[ii], sEvtName, Func);
	}
	else
		appendEventElement(obj, sEvtName, Func);
}

function appendEventElement(obj, sEvtName, Func){
	if(document.addEventListener){
		sEvtName = sEvtName.replace(/^on/i, "");
		obj.addEventListener(sEvtName, Func, false);
	}
	else if(document.attachEvent){
		if(obj[sEvtName]==null)
			obj[sEvtName] = Func;
		else
			obj.attachEvent(sEvtName, Func);
	}
}

function $(id){
	return document.getElementById(id);
}

function envSL(){
	return (document.body.scrollLeft>0)?document.body.scrollLeft:document.documentElement.scrollLeft;
}

function envST(){
	return (document.body.scrollTop>0)?document.body.scrollTop:document.documentElement.scrollTop;
}

function apendMMEvent(){
	
}

var mousePositionJTongfu = new Object();
function getMousePos(eve){
	if(window.event){
		mousePositionJTongfu.x = window.event.x+envSL();
		mousePositionJTongfu.y = window.event.y+envST();
	}
	else{
		mousePositionJTongfu.x = eve.clientX+envSL();
		mousePositionJTongfu.y = eve.clientY+envST();
	}
}

function SetCookie(name,value,expired,path,domain)
{
	var argv=SetCookie.arguments;
	var argc=SetCookie.arguments.length;
	var expires = new Date();
	if(expired == null)
		expired = 24*60*60*1000*365;
	if(path != null)
		path = ";path="+path;
	else
		path = "";
	if(domain != null)
		domain = ";domain="+domain;
	else
		domain = "";
	expires.setTime(expires.getTime()+(expired));
	cookieStr = name+"="+escape(value)+((expires==null)?"":(";expires="+expires.toGMTString()))+(path)+(domain);
	//alert(cookieStr);
	document.cookie = cookieStr;
}

function GetCookie(name)
{
	var abc=document.cookie.split("; ");
	var cstr="";
	var rstr="";
	var nlen=name.length;
	for(i=0;i<abc.length;i++)
	{
		cstr=abc[i].indexOf(name+"=");
		if(cstr!=-1)
		{
			cstr=cstr+nlen+1;
			rstr=unescape(abc[i].substring(cstr,abc[i].length));
			break;
		}
	}
	if(rstr)
		return rstr;
	else
		return null;
}

