function GE(id){
	if (document.getElementById){
		return document.getElementById(id);
	}else if (document.all){
		return document.all[id];
	}else if (document.layers){
		return document.layers[id];
	}else{
		return null;
	}
}
function findPosX(obj){
	var curleft = 0;
	if (obj.offsetParent){
		while (obj.offsetParent){
			curleft += obj.offsetLeft
			obj = obj.offsetParent;
		}
	}
	else if (obj.x)
		curleft += obj.x;
	return curleft - document.body.scrollLeft;
}
function findPosY(obj){
	var curtop = 0;
	if (obj.offsetParent){
		while (obj.offsetParent){
			curtop += obj.offsetTop
			obj = obj.offsetParent;
		}
	}else if (obj.y){
		curtop += obj.y;
	}
	return curtop - document.body.scrollTop;;
}
String.prototype.trim =
function trim()
{
	return this.replace(/(^\s*)|(\s*$)/g, "");
}

//function LoginInfo(){
//	send_request('','ShowLoinInfo',)
//
//}
//function ShowLoginInfo(){
//	
//}
var ifcheck = true;
function CheckAll(form)
{
	for (var i=0;i<form.elements.length;i++)
	{
		var e = form.elements[i];
		if(e.name=='selid[]'){
			e.checked = ifcheck;
		}
	}
	ifcheck = ifcheck == true ? false : true;
}

/*设置和获取Cookie*/
function EclassGetCookie(name) 
{
 var CookieFound = false;
 var start = 0;
 var end = 0;
 var CookieString = document.cookie;

 var i = 0;
 while (i <= CookieString.length) 
 {
	 start = i ;
	 end = start + name.length;
	 if (CookieString.substring(start, end) == name)
	 {
		 CookieFound = true;
		 break; 
	 }
	 i++;
 }
 if (CookieFound)
 {
	 start = end + 1;
	 end = CookieString.indexOf(";",start);
	 if (end < start)
		 end = CookieString.length;
	 var getvalue = CookieString.substring(start, end);
	 return unescape(getvalue);
 }
 return "";
}
function EclassSetCookie(cookieName,cookieValue)
{    
	var dat=new Date();
	dat.setTime(dat.getTime()+24*3600*1000);//在当时时间上加1天        
	window.document.cookie = cookieName + "=" + escape(cookieValue)+";expires="+ dat.toGMTString()+";path=/;domain=.91class.com;";
}
function EclassDelCookie(cookieName){
	var dat=new Date();
	dat.setTime(dat.getTime()-24*3600*1000);//在当时时间上减1天        
	window.document.cookie = cookieName + "=;expires="+ dat.toGMTString()+";path=/;domain=.91class.com;";
}

function EclassSetInput(inputname){
	var inputCookie	= EclassGetCookie("Eclass_"+inputname);
	var inputValue  = document.getElementById(inputname).value;
	if(inputCookie!=inputValue){
		document.getElementById(inputname).value = inputCookie;
	} 
}

function openupload(inputname,type){
	window.open("http://images.91class.com/file_attach.php?action=addimg&type="+type+"&inputtype=editor&inputname="+inputname,'_blank','Width=600px;Height=400px;status:no;menubar:no;scrollbars:yes;resizable:yes');
}
function openftpupload(inputname){
	window.open("http://res.91class.com/ftp_attach.php?inputname="+inputname,'_blank','Width=600px;Height=400px;status:no;menubar:no;scrollbars:yes;resizable:yes');
}

function logincheck(){
	var url = "/ajax/check_login.php?username="+eclassuser;
	var x   = new XHR('loginshow');
	x.get(url);
}

function loginshow(ret){
	
	if(ret=="login"){
		alert("对不起，您的帐号在别处登录，您被迫下线！");
		window.location.href = "http://www.91class.com/login.php?action=quit";
	}
}