if (typeof(g_hname) == "undefined")
{
	var g_hname = null;
	if (location)
	{
		g_hname = location.hostname;
	}
	else
	{
		g_hname = g_location.hostname;
	}
	if (g_hname.indexOf('.') != g_hname.lastIndexOf('.'))
	{
		g_hname = g_hname.substring(g_hname.indexOf('.')+1);
	}
}
var config = {};

function displaydiv(event,obj)
{
    
	obj = $get(obj);

    config[obj.id] = obj;

	Event.stops(event);
	removediv(event,obj);

}

function removediv(event,extobj)
{
    
	for(var p in config)
	{

		if(config[p].nodeName && config[p].nodeType == 1)
		{
			var obj = $get(config[p]);
			if(!obj) continue; 
			if(obj.style.display == 'none') continue;
			if(obj == extobj) continue;
			var _x = Event.realX(event),_y = Event.realY(event);
			var postion = getAbsRect(obj);
			var withIn  = (_y >= postion[1] && _y< postion[3] && _x>= postion[0] && _x< postion[2]);
			if(!withIn)
			{ 
				obj.style.display = 'none';
				delete config[p];
           
			}            
       
		}
    
	}    

}


Event.observe(document.body||document,'click',removediv,false);
function errorInfo(ecode)
{
    
	if (ecode)
	{
		setOperateInfo(ecode);
	}
	else
	{
		setOperateInfo('网络繁忙，请稍后重试或<a href="http://www.zhongsou.com/kefu/zskf.htm" target=_blank>直接联络我们！</a>');
	}

	//setTimeout("var obj = document.getElementById(\"operate_info\");if(obj.innerHTML.indexOf(\"网络繁忙\") >= 0){obj.innerHTML = \"\";obj.style.display=\"none\"}",5000);

}

function tipInfo(flag)
{

	if(flag == 1)
	{
		setOperateInfo("保存成功！");
		setTimeout("var obj = document.getElementById(\"operate_info\");if(obj.innerHTML.indexOf(\"保存成功\") >= 0){obj.innerHTML = \"\";obj.style.display=\"none\"}",2000);
	}
	else
	{
		setOperateInfo("您已进行了修改,请点击左边的保存按钮!");
	
		setTimeout("var obj = document.getElementById(\"operate_info\");{obj.innerHTML = \"\";obj.style.display=\"none\"}",5000);
	}

}

var layer = null;
	
function divhide()
{
	g_iswork = 0;
	if(layer && layer.parentNode)
	{
		layer.parentNode.removeChild(layer);
		var tmpObj = document.getElementById("maskalertmask");
		if (!isNull(tmpObj))
		{
			tmpObj.style.display = 'none';
		}
	}
}
function createDiv(id,left,top,width,html)
{
	divhide();
	g_iswork = 1;
	var div = $e(id, document.body);
	div.id = id;
	div.style.position = "absolute";
	div.style.width = width+"px";
	div.style.left = left + "px";
	div.style.top = top + "px";
	div.innerHTML = html;
	div.style.display = '';

	var mask = document.getElementById("maskalertmask");
	if(mask)
	{
			mask.style.left = left + "px";
			mask.style.top = top + "px";
			mask.style.width = div.style.width;
			mask.style.height = div.offsetHeight + 'px';
			mask.style.zIndex = '10';
			mask.style.display = '';
	}
	else
	{
			var lFrame = $("iframe","alertmask", document.body);
			lFrame.id = "maskalertmask";
			lFrame.style.position = 'absolute';
			lFrame.style.left = left + "px";
			lFrame.style.top = top + "px";
			lFrame.style.width = div.style.width;
			lFrame.style.height = div.offsetHeight + 'px';
			lFrame.style.zIndex = '10';
			lFrame.style.border = '0px';
			lFrame.style.filter = "progid:DXImageTransform.Microsoft.Alpha(style=0,opacity=0)";
			lFrame.style.display = '';
	}
	layer = div;
	return div;
}
	
function getInfoObj(flag,str,purl,flag2)
{
	if (str == null || str == "")
	{
		str = '只有注册用户才能使用此功能！';
	}
	if (purl == null || purl == "")
	{
		purl = 'http://i.zhongsou.com/rd.php';
	}
	var l = (document.body.offsetWidth - 340) / 2;
	var t = (Event.scrollY() + 200);
	var s = '<table class="title" cellspacing=0 cellpadding=0 border=0 width="100%">';
	s +='<tbody><tr>';
	s +='<td class=td1 width="9%"><img src="http://i0.zhongso.com/images/edit_alert.gif" ></td>';
	s +='<td class=td2 width="84%" style="padding-left:1px;">提示信息</td>';
	s +='<td class=td3 width="7%"><img src="http://i0.zhongso.com/images/close_alert.gif" alt=关闭 id=closed></td>';
	s +='</tr></tbody></table>';
	s +='<div id="flt_set"><span>&nbsp;'+str+'&nbsp;</span></div>';
	s +='<table width="100%">';
	s +='<tbody>';
	s +='<tr>';
	s +='<td  class="flt_btn">';
	if (flag == 1)
	{
		s +='<input class="flt_btn2em flt_btn_w"  type="button" name="button1" id="button1" value="确 定" /><td width="33%"></td></td>';
	}
	else if (flag == 3)
	{
		s +='<input class="flt_btn2em flt_btn_w"  type="button" name="button1" id="button1" value="确 定" />&nbsp;&nbsp;&nbsp;&nbsp;<input class="flt_btn2em flt_btn_w"  type="button" name="button2" id="button2" value="取 消" /></td>';
	}
	else if (flag == 4)
	{
		s +='<input class="flt_btn2em flt_btn_w"  type="button" name="button1" id="button1" value="关 闭" /><td width="33%"></td></td>';
	}
	else
	{
		s +='<input class="flt_btn2em flt_btn_w"  type="button" name="button1" id="button1" value="登 录" />&nbsp;&nbsp;&nbsp;&nbsp;<input class="flt_btn2em flt_btn_w"  type="button" name="button2" id="button2" value="注 册" />&nbsp;&nbsp;&nbsp;&nbsp;<input class="flt_btn2em flt_btn_w"  type="button" name="button2" id="button3" value="取 消" />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</td>';
	}
	s +='</tr>';
	s +='</tbody>';
	s +='</table>';
	s +='</div>';
	var div = createDiv("flt_alert",l,t,"340",s);
	div.style.zIndex = '1000002';
	document.getElementById("closed").onclick = function(){return function(){divhide();}}().bind(this);
	var inputs = div.getElementsByTagName("input");
	if (flag == 1 || flag == 4)
	{
		inputs[0].onclick = function(){
		divhide();
		}
	}
	else if (flag == 3)
	{
		if (flag2 == "copyp")
		{
			 inputs[0].onclick = function(purl){
				return function(){
					divhide();
					copyPage1(purl);
				}
			}(purl).bind(this);
			
			inputs[1].onclick = function(){
				divhide();
			}
		}
	}
	else
	{
		if (flag2 == 1)
		{
			inputs[0].onclick = function(purl){
				return function(){
					divhide();
					var w = window.screen.width - 10;
					var h = window.screen.height - 10;
					var option = 'top=0, left=0, toolbar=yes, menubar=yes, scrollbars=yes, resizable=yes,location=yes, status=yes,height='+h+', width='+w;
					window.open("http://uid."+g_hname+"/igportal/login.aspx?page="+purl,'',option);
				}
			}(purl).bind(this);
			inputs[1].onclick =function(purl){
				return function(){
					divhide();
					var w = window.screen.width - 10;
					var h = window.screen.height - 10;
					var option = 'top=0, left=0, toolbar=yes, menubar=yes, scrollbars=yes, resizable=yes,location=yes, status=yes,height='+h+', width='+w;
					window.open("http://uid."+g_hname+"/igportal/reg.aspx",'',option);
				}
			}(purl).bind(this);
		}
		else
		{
			inputs[0].onclick = function(purl){
				return function(){
					if(!location)
					{
							g_location.href = "http://uid."+g_hname+"/igportal/login.aspx?page="+purl;
					}
					else
					{
							location.href = "http://uid."+g_hname+"/igportal/login.aspx?page="+purl;
					}
				}
			}(purl).bind(this);
			inputs[1].onclick =function(purl){
				return function(){
					if(!location)
					{
							g_location.href = "http://uid."+g_hname+"/igportal/reg.aspx";
					}
					else
					{
							location.href = "http://uid."+g_hname+"/igportal/reg.aspx";
					}
				}
			}(purl).bind(this);
		}
		inputs[2].onclick = function(){
			divhide();
		}
	}
	div = null;
	inputs = null;
}

function getAlertBox(l,t,w,word){
		var s = '<table class="title" cellspacing=0 cellpadding=0 border=0 >'
		+'<tbody><tr>'
		+'<td class=td1><img src="http://i0.zhongso.com/images/edit_alert.gif" ></td>'
		+'<td class=td2 style="padding-left:1px;">提示信息</td>'
		+'<td class=td3><img src="http://i0.zhongso.com/images/close_alert.gif" alt=关闭 id=closed></td>'
		+'</tr></tbody></table>'
		
		+'<div id="flt_set"><img src="http://i0.zhongso.com/images/shezhi.gif" />'+word+'<span></span></div>'
		+'<table width="76%">'
		+'<tbody>'
		+'<tr>'
		+'<td class="flt_btn" align="center">'
		+'<input type="submit" name="Submit2" value=" 确定 ">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</td>'
		+'</tr>'
		+'</tbody>'
		+'</table>'
		+'</div>';
		
		var div = createDiv("flt_alert",l,t,w,s);
		div.style.zIndex = '1000002';
		document.getElementById("closed").onclick = function(){return function(){divhide();}}().bind(this);
		var inputs = div.getElementsByTagName("input");
		
		inputs[0].onclick = function(){
			return function(){
				divhide();	
			}
		}();
		s = null;
		div = null;
		inputs = null;
}

function createUpdateInfo(obj)
{
	var handleMask = document.getElementById("TB_HideBack");
	if (!handleMask)
	{
		handleMask = document.createElement('iframe');
		handleMask.id="TB_HideBack";
		handleMask.style.width = '0px';
		handleMask.style.heigth = '0px';
		handleMask.style.zIndex = 99;
		handleMask.style.filter = 'alpha(opacity=40)';
		handleMask.style.position = 'absolute';
		handleMask.style.top = '0px';
		handleMask.style.opacity = '0';
		document.body.appendChild(handleMask); 
	}
	handleMask.style.width = "100%";
	handleMask.style.height = document.body.scrollHeight + "px";
	handleMask.style.zIndex = "9999999";
	handleMask.style.top = '0px';
	handleMask.style.left = '0px';
	handleMask.style.display = ''
	var t = 0;
	if (typeof window.pageYOffset == "number")
	{
		t = window.pageYOffset;
	}
	else
	{
		if (document.body && (document.body.scrollLeft || document.body.scrollTop))
		{
			t = document.body.scrollTop;
		}
		else
		{
			if (document.documentElement && (document.documentElement.scrollLeft || document.documentElement.scrollTop)) 
			{
				t = document.documentElement.scrollTop;
			}
		}
	}
	obj.style.zIndex = handleMask.style.zIndex+1;
	handleMask = null;
}

function closeUpdateInfo()
{
	divhide();
	var handleMask = document.getElementById("TB_HideBack");
	if (handleMask)
	{
		handleMask.style.display = 'none';
		handleMask = null;
	}
}

function updateInfo1()
{
	var l = (document.body.offsetWidth - 340) / 2;
	var t = (Event.scrollY() + 200);

	var s ='<div class="layout_wrapper">';
	s +='<div class="layout">';
	s +='<div class="layout_title"><div class="l">友好提示</div><span><img alt="关闭" src="http://i0.zhongso.com/images/close_tc.gif" alt=关闭 id="closed"/></span></div>';
	s +='<div class="info_tc_content">';
	s +='<div class="left_info"></div>';
	s +='<div class="right_content" style="width:220px">门户升级可能会修改现在门户的页面，但这是一个不可逆的操作，是否确认升级?';
	s +='<br>升级后，请打开所有页面进行保存，以保证升级顺利和完成。';
	s +='<div class="margin10">';
	s +='<input type="button" value="确认" class="margin40"/>';
	s +='<input type="button" value="取消" class="margin12"/></div></div>';
	s +='</div>';
	s +='</div>';
	s +='</div>';
	var div = createDiv("flt_alert",l,t,"330",s);
	createUpdateInfo(div);
	document.getElementById("closed").onclick = function(){return function(){closeUpdateInfo();}}().bind(this);
	var inputs = div.getElementsByTagName("input");
	 inputs[0].onclick = function(){
		return function(){
			closeUpdateInfo();
			updnavi();
		}
	}().bind(this);
	
	inputs[1].onclick = function(){
		closeUpdateInfo();
	}
	div = null;
	inputs = null;
}
function updateInfo2()
{
	var l = (document.body.offsetWidth - 340) / 2;
	var t = (Event.scrollY() + 200);

	var s ='<div class="layout_wrapper">';
	s +='<div class="layout">';
	s +='<div class="layout_title"><div class="l">友好提示</div></div>';
	s +='<div class="info_tc_content">';
	s +='<div class="left_img"><img src="http://i0.zhongso.com/space/imgs/loading_tc.gif" width="32px" height="32px"/></div>';
	s +='<div class="right_content" style="width:215px"><span class="margin15 font14 b">门户升级中，请稍等&hellip;</span>';
	s +='<p></p>升级需要一段时间，您可以泡一杯茶或冲一杯咖啡</div>';
	s +='</div>';
	s +='</div>';
	s +='</div>';
	var div = createDiv("flt_alert",l,t,"330",s);
	createUpdateInfo(div);
	div = null;
}

//本文件定义了取数据的接口 
var CCOM = CLASS();
CCOM.declare = function()
{
	// 对象成员
	this.requests = [];
	this.loading = '<table width="100%" height="100%"><tr><td align="center" valign="middle">正在加载... 请稍候</td></tr></table>';
	this.failure = '<table width="100%" height="100%"><tr><td align="center" valign="middle">对方服务器繁忙，请稍后重试</td></tr></table>';
	this.retry = '<table width="100%" height="100%"><tr><td align="center" valign="middle">网络繁忙，请耐心等待</td></tr></table>';
	this.xmldoms = [];
	this.timerID=[];
	
	// 对象函数
	this.create = function(){}
	this.loadPage = function(url){}
	this.getCity = function(url,callback){}
	this.getAsyncCity = function(url,callback){}
    this.Load = function(wnd,fpath,doc,callback){}
	this.LoadRSS = function(obj,callback){}
	this.CreatXmlDoc = function(){}
	this.getModuleInfo = function(igno,nick,secure,pageno,flag){}
	this.uploadPageInfo = function(url,callback){}
	this.uploadModuleContent = function(url,callback){}
	}

//------------------------------------------------------------
CCOM.implement(
{
	// 构造对象
	create : function()
	{
		this.requests.push(new Ajax.CRequest(false));
	},
	readPage : function(url)
	{
		this.requests[0].get(url);
		return this.requests[0].getText();
	},
	uploadModuleContent : function(url,callback)
	{
		return this.postAsyncReq(url,callback);
	},
	uploadPageInfo : function(url,callback)
	{
		return this.postAsyncReq(url,callback);
	},
	loadPage : function(url,callback)
	{
		return this.getAsyncReq(url, callback);
	},
	getCity : function(url,callback)
	{
		return this.getAsyncCity(url,callback);
	},
	getAsyncCity : function(url,callback)
	{
		var request = null;
		if (request==null){
			request = new Ajax.CRequest(true);
			request.times=0;
			request.using = true;
			request.completeFlag = false;
			request.tag = 0;
		}
		request.completeFlag = false;
		request.tag = 0;
		request.event.onComplete = function(){request.completeFlag=true;setTimeout(callback,2);};
		setTimeout(function(){var times=request.times;setTimeout(function(){if (!request.completeFlag && times==request.times) {request.tag=1;request.disconnect();}},10000);},0);
		request.get(url);
		return request;
	},
	getAsyncReq : function(url,callback)
	{
		var request = null;
		if (request==null){
			request = new Ajax.CRequest(true);
			request.times=0;
			request.using = true;
			request.completeFlag = false;
			request.tag = 0;
		}
		request.completeFlag = false;
		request.tag = 0;
		request.event.onComplete = function(){request.completeFlag=true;setTimeout(callback,2);};
		setTimeout(function(){var times=request.times;setTimeout(function(){if (!request.completeFlag && times==request.times) {request.tag=1; request.disconnect();}},20000);},0);
		request.get(url);
		return request;
	},
	postAsyncReq : function(url,callback)
	{
		var request = null;
		if (request==null){
			request = new Ajax.CRequest(true);
			request.times=0;
			request.using = true;
			request.completeFlag = false;
			request.tag = 0;
		}
		request.using = true;
		request.completeFlag = false;
		request.tag = 0;
		request.event.onComplete = function(){request.completeFlag=true;setTimeout(callback,2);};
		setTimeout(function(){var times=request.times;setTimeout(function(){if (!request.completeFlag && times==request.times) {request.tag=1; request.disconnect();}},20000);},0);
		request.post(url);
		return request;
	},
	CreatXmlDoc : function(){
		var xmldoc=null;
		if (window.ActiveXObject)
		{
			xmldoc=new ActiveXObject("Microsoft.XMLDOM");
		}
		// code for Mozilla, Firefox, Opera, etc.
		else if (document.implementation && document.implementation.createDocument)
		{
			xmldoc=document.implementation.createDocument("","",null);
		}
		else
		{
			alert('Your browser cannot handle this script');
		}
		return xmldoc;
	},
	Load : function(rurl){
		try
		{
			var xmldoc = this.CreatXmlDoc();
			if(xmldoc != null)
			{      
				xmldoc.async=false;
				var Ret = xmldoc.load(rurl);
				if(Ret == false || xmldoc.xml == "")
				{
					return null;
				}
				return xmldoc;
			}
			return null;
		}
		catch(e){return null;}
	},
	LoadRSS : function(obj,callback){
		try
		{		
		    obj.RDoc = this.CreatXmlDoc();
		    obj.xflag = 0;
    		if (obj.rurl.indexOf("/np/updnavi") > 0)
			{
				  obj.t1 = setTimeout(function(obj,callback){
					return function(){
						if(obj.xflag != 1){
							try{if(obj.RDoc){obj.RDoc.abort();}}catch(e){}
							obj.loadstatus = false;
							obj.RDoc = null; 
							obj.t2 = setTimeout(callback,0);
						}
					}
				}(obj,callback).bind(this),60000);

			}
			else
			{
				obj.t1 = setTimeout(function(obj,callback){
					return function(){
						if(obj.xflag != 1){
							try{if(obj.RDoc){obj.RDoc.abort();}}catch(e){}
							obj.loadstatus = false;
							obj.RDoc = null; 
							obj.t2 = setTimeout(callback,0);
						}
					}
				}(obj,callback).bind(this),20000);
			}
    		
		    if(ie())
			{
				obj.RDoc.onreadystatechange = function(obj){return function(){
					var ret = this.CheckRssState(obj.RDoc);
					if(ret == 0)
					{
						obj.t3 =setTimeout(callback,2);
						obj.xflag = 1;

					}
				}}(obj).bind(this);	
			}
    			
		    if(firefox())
			{
		        obj.RDoc.onload = function(obj){		        
		            return function(){obj.t3 =setTimeout(callback,2); obj.xflag = 1;
		            }		        
		        }(obj).bind(this);
		    }
            
		    var status = obj.RDoc.load(obj.rurl);		
		    if(status == false){
			    obj.RDoc = null;
			    obj.loadstatus = false;
			    obj.t4 = setTimeout(callback,2);
			    obj.xflag = 1;
		    }
		}catch(e){ alert(e);}
	},
	CheckRssState : function (xdobj){
		var state = xdobj.readyState;
		if (state == 4){
			return xdobj.parseError;
		}
		else
		{
			return -1;
		}
	},
	getModuleInfo : function(igno,nick,secure,pageno,flag)//从服务器端取得module信息
	{ 
		var rurl;
		if (flag == 1)
		{
			rurl = g_host + "/portal/guest?ig="+igno+"&nick="+nick+"&code="+secure+"&gu="+pageno;
		}
		else
		{
			if(pageno == "")
			{
				rurl = g_host + "/portal/ps?ig="+igno+"&nick="+nick+"&code="+secure;
			}
			else
			{
				rurl = g_host + "/portal/ps?ig="+igno+"&nick="+nick+"&code="+secure+"&pageId="+pageno;
			}
		}
		return this.Load(rurl);
			
	}
	
});

