﻿// JavaScript Document
<!--
//事件处理改变相关对象的样式
function chg_thisclass(obj,clsName,event_type)
{
	var event_obj;
	event_obj=eval(obj);
	if (event_type==1) {
		if (clsName!=""){
			event_obj.className +=" "+clsName;
		}
	}
	else {
		if (clsName!=""){
			//event_obj.className=event_obj.className.replace(" "+clsName,"");
			event_obj.className=event_obj.className.replace(clsName,"");
		}
	}
}

//事件处理改变相关对象的样式
function chg_theclass(total_num,now_i,clsName,obj_type,other_var)
{
	var event_obj,obj_idstr;
	obj_idstr="";
	if(obj_type)
	{
		//设定导航对向的id名称
		if(obj_type==1)
		{
			obj_idstr="top_menu";
		}
		else if(obj_type==2)
		{
			obj_idstr="submenu_" + other_var + "_";
		}
	}
	for(var i=0;i<=total_num;i++)
	{
		var the_itemstr=obj_idstr + i;
		if(document.getElementById(the_itemstr))
		{
			event_obj=document.getElementById(the_itemstr);
			if(now_i==i)
			{
				event_obj.className = clsName;
			}
			else
			{
				event_obj.className = event_obj.className.replace(clsName,"");
			}
		}
	}
}

//改变附加标签对象的样式
function attach_objclass(obj,clsName,event_type){
	var event_obj=document.getElementById(obj);
	if (event_type==1) {
		if (clsName!=""){
			event_obj.className +=" "+clsName;
		}
	}
	else {
		if (clsName!=""){
			//event_obj.className=event_obj.className.replace(" "+clsName,"");
			event_obj.className=event_obj.className.replace(clsName,"");
		}
	}	
}

//浏览图片新窗口
function open_newpic(obj)
{
	var op_obj;
	op_obj=eval(obj);
	window.open(obj.value,"review_pic");
}

//转向新的链接页面
function redirect_url(urlpage,selObj)
{
	if (urlpage!="")
	{
		eval("self.location='"+ urlpage + selObj.options[selObj.selectedIndex].value +"'");
	}
}

//当鼠标滑过文本框并在文本框内时的事件
//document.onmouseover=mover_inputevent;	//----------用此方法会引起与链接标签的信息提示发生冲突
document.attachEvent("onmouseover",mover_inputevent);
function mover_inputevent()
{
	var event_obj=event.srcElement;
	if (event_obj.tagName=="INPUT") {
		if (event_obj.type.toLowerCase()=="text" || event_obj.type.toLowerCase()=="password") {
			chg_thisclass(event_obj,'msover_border',1);
		}	
	}
}
//当鼠标滑出文本框时的事件
//document.onmouseout=mout_inputevent;	//----------用此方法会引起与链接标签的信息提示发生冲突
document.attachEvent("onmouseout",mout_inputevent);
function mout_inputevent()
{
	var event_obj=event.srcElement;
	if (event_obj.tagName=="INPUT") {
		if (event_obj.type.toLowerCase()=="text" || event_obj.type.toLowerCase()=="password") {
			chg_thisclass(event_obj,'msover_border',0);
		}	
	}
}

//复制指定对象的标签值
function copyObjValue(obj)
{
	var theObj=document.getElementById(obj);
	var clipBoardContent=theObj.value;
	window.clipboardData.setData("Text",clipBoardContent);
}

//显示隐藏标签对象
function showhide_objdiv(div_obj,event_obj){
	if(document.getElementById(div_obj))
	{
		var showhide_obj=document.getElementById(div_obj);
		if (event_obj==1)
		{	
			showhide_obj.style.display="";
		}
		else
		{		
			showhide_obj.style.display="none";
		}
	}
}

//显示隐藏新对象
function chg_thedisplay(obj,newObj)
{
	var event_obj;
	event_obj=eval(obj);
	if (document.getElementById(newObj)) {
		var theNewObj=document.getElementById(newObj);
		if(event_obj.checked==true)
		{
			theNewObj.style.display="";
		}
		else
		{
			theNewObj.style.display="none";
		}
	}
}

//显示隐藏新对象
function chg_thevisibility(obj,newObj)
{
	var event_obj;
	event_obj=eval(obj);
	if (document.getElementById(newObj)) {
		var theNewObj=document.getElementById(newObj);
		if(event_obj.checked==true)
		{
			theNewObj.style.visibility="visible";
		}
		else
		{
			theNewObj.style.visibility="hidden";
		}
	}
}

//显示隐藏新对象
function chg_thehidden(obj,newObj)
{
	var event_obj;
	event_obj=eval(obj);
	if (document.getElementById(newObj)) {
		var theNewObj=document.getElementById(newObj);
		if(event_obj.checked==true)
		{
			theNewObj.style.display="none";
		}
		else
		{
			theNewObj.style.display="";
		}
	}
}

//改变对象的值
function chg_theobjval(obj,newObj)
{
	var event_obj;
	event_obj=eval(obj);
	if (document.getElementById(newObj)) {
		var theNewObj=document.getElementById(newObj);
		if(event_obj.selectedIndex>=0)
		{
			theNewObj.value=event_obj.options[event_obj.selectedIndex].value;
		}
	}
}

//打开固定新窗口
var open_winobj=null;
function open_newwindow(url_var,win_name,winwidth,winheight)
{
	var win_width=screen.width;
	if(winwidth)
	{
		win_width=winwidth;
	}
	var win_height=screen.height;
	if(winheight)
	{
		win_height=winheight;
	}
	if(open_winobj)
	{
		open_winobj.close();
		open_winobj=null;
	}
	open_winobj=window.open(url_var,win_name,"width=" + win_width + ",height=" + win_height + ",top=0,left=0,scrollbars=1, resizable=yes");
}

//打开固定窗口模式二
function open_fixwindow(url_var,winwidth,winheight)
{
	var left_x,top_y;
	var win_width=screen.width-300;
	if(winwidth)
	{
		win_width=winwidth;
	}
	var win_height=screen.height-250;
	if(winheight)
	{
		win_height=winheight;
	}
	left_x=parseInt((screen.width-win_width)/2);
	top_y=parseInt((screen.height-win_height)/2);
	window.showModalDialog(url_var,"Arguments","dialogHeight: " + win_height + "px; dialogWidth: " + win_width + "px; dialogTop: " + top_y + "px; dialogLeft: " + left_x + "px; edge: Raised; center: no; help: no; resizable: no; status: no; scroll: auto;");
}

//关闭该对象的窗口
function thewindow_close(iswin_obj)
{
	//if(iswin_obj){open_winobj=null;}
	window.close();
	//this.close();
}

//打开新窗口
function open_thewin(url_var,win_name,winwidth,winheight,win_type)
{
	var win_width=screen.width;
	if(winwidth)
	{
		win_width=winwidth;
	}
	var win_height=screen.height;
	if(winheight)
	{
		win_height=winheight;
	}
	if(win_type)
	{
		window.open(url_var,win_name,"width=" + win_width + ",height=" + win_height + ",top=0,left=0,toolbar=no, menubar=no, scrollbars=no, resizable=yes,location=no, status=no");
	}
	else
	{
		window.open(url_var,win_name,"width=" + win_width + ",height=" + win_height + ",top=0,left=0,scrollbars=1, resizable=yes");
	}
}

//打开新窗口
function open_newwin(url_var,win_name,winwidth,winheight)
{
	var win_width=screen.width;
	if(winwidth)
	{
		win_width=winwidth;
	}
	var win_height=screen.height;
	if(winheight)
	{
		win_height=winheight;
	}	
	window.open(url_var,win_name,"width=" + win_width + ",height=" + win_height + ",top=0,left=0,toolbar=no, menubar=no, scrollbars=no, resizable=yes,location=no, status=no");
}

//改变父窗体的对象值
function set_parentobj(parentObj,newValue)
{
	var theDoc_Obj;
	if(window.opener)
	{
		theDoc_Obj=window.opener.document;
	}
	else
	{
		theDoc_Obj=window.parent.document;
	}
	if(theDoc_Obj.getElementById(parentObj))
	{
		var parent_obj=theDoc_Obj.getElementById(parentObj);
		if(newValue)
		{
			parent_obj.value=newValue;
		}
	}
	//window.close();
	thewindow_close(1);
}

//改变链接对象自己的连接网址
function changeASelf(obj,hrefFront,otherObj)
{
	var theObj=eval(obj);
	var idObj=null;
	if(document.getElementById(otherObj))
	{
		idObj=document.getElementById(otherObj);
	}
	if(idObj.value)
	{
		theObj.target="_blank";
		theObj.href=hrefFront + idObj.value;
	}
	else
	{
		theObj.target="_self";
		theObj.href="#";	
	}
}

//查看文件并浏览文件的连接网址
function viewThe_Obj(hrefFront,otherObj)
{
	var idObj=null;
	if(document.getElementById(otherObj))
	{
		idObj=document.getElementById(otherObj);
	}
	if(idObj.value)
	{
		open_newwindow(hrefFront + idObj.value,'viewfile_window');
	}
}

//改变对象的显示状态
function chgoption_show(event_obj,chg_obj)
{
	var eventObj=eval(event_obj);
	var chgObj=document.getElementById(chg_obj);
	var theValue=eventObj.options[eventObj.selectedIndex].value;
	if(!theValue)
	{
		chgObj.style.display="";
	}
	else
	{
		chgObj.style.display="none";
	}
}

//改变对象的显示状态
function chgoption_show2(event_obj,chg_obj,chg_obj2)
{
	var eventObj=eval(event_obj);
	var chgObj=document.getElementById(chg_obj);
	var chgObj2=document.getElementById(chg_obj2);
	var theText=eventObj.options[eventObj.selectedIndex].text;
	var theValue=eventObj.options[eventObj.selectedIndex].value;
	if(!theValue)
	{
		chgObj.value="";
		chgObj.style.display="";
		chgObj2.readOnly=false;
		chgObj2.className="";
	}
	else
	{
		chgObj.value=theText;
		chgObj.style.display="none";
		chgObj2.readOnly=true;
		chgObj2.className="bg_readonly";
	}
	chgObj2.value=theValue;
}

//改变链接对象的链接值
function chgalink_href(event_obj,chgsel_obj,the_urlStr)
{
	var eventObj=eval(event_obj);
	var theSelObj=document.getElementById(chgsel_obj);
	var theSelVal=theSelObj.options[theSelObj.selectedIndex].value;
	if(theSelVal>0)
	{
		eventObj.href=the_urlStr + theSelVal;
	}
	else
	{
		eventObj.href='#';
	}
}

//弹出显示新层窗口的操作界面
function openPopDiv(divId,divBgId,mWidth,mHeight){
	if(document.getElementById(divId))
	{
		var outerObj=document.getElementById(divId);
		var outerBgObj=document.getElementById(divBgId);
		var divState = outerObj.style.display;	//获取弹出层状态 "block" 或 "none"
		if(divState!='block')
		{
			var ch=document.documentElement.clientHeight || document.body.clientHeight || 0;
			var sh=document.body.scrollHeight || document.body.offsetHeight;
			var st=window.pageYOffset || document.documentElement.scrollTop || document.body.scrollTop || 0;
			var sl=window.pageXOffset || document.documentElement.scrollLeft || document.body.scrollLeft || 0;
			var cw=document.documentElement.clientWidth || document.body.clientWidth || 0;
			
			if(!mWidth){ mWidth=600; }
			outerObj.style.width = mWidth + "px";
			if(mHeight)
			{
				outerObj.style.height = mHeight + "px";
			}
			else
			{
				mHeight=outerObj.offsetHeight;
			}
			var theMouseY=event.y?event.clientY:event.pageY;
			var leftX=parseInt((cw-mWidth)/2 + sl);
			var editPopManage,bgHeight,yHeight,topY=0;
			bgHeight=(sh > ch ? sh : ch);
			//对于可视化编辑状态下的直接上传显示
			editPopManage=getTheCookie("editPopManage");
			if(editPopManage==1)
			{
				topY=parseInt(theMouseY + 20);
			}
			else
			{
				//判断ie与firefox的区别
				if(window.pageYOffset)
				{
					topY=parseInt(theMouseY + 20);
				}
				else
				{
					topY=parseInt(theMouseY + 20 + st);
				}
				if(mHeight>0)
				{
					yHeight=topY + 10;
					yHeight=yHeight + parseInt(mHeight);
					if(yHeight > bgHeight)
					{
						bgHeight=yHeight;
					}
				}
			}
			
			outerObj.style.left = leftX + "px";
			outerObj.style.top = topY + "px";
				
			outerObj.style.position="absolute";
			outerObj.style.display = 'block';
			
			outerBgObj.style.height = bgHeight + 'px';
			outerBgObj.style.width = cw + 'px';
			outerBgObj.style.display = 'block';
		}else
		{
			outerObj.style.display = 'none';
			outerBgObj.style.display = 'none';
		}
	}
}

//对属性参数的默认值的相关操作
function showhide_defaultval(selObj,theObj1,theObj2)
{
	var eventObj=eval(selObj);
	var theValue=eventObj.options[eventObj.selectedIndex].value;
	if(theValue=='text')
	{
		if(document.getElementById(theObj1))
		{
			document.getElementById(theObj1).style.display="none";
		}
		if(document.getElementById(theObj2))
		{
			document.getElementById(theObj2).style.display="";
		}
	}
	else
	{
		if(document.getElementById(theObj1))
		{
			document.getElementById(theObj1).style.display="";
		}
		if(document.getElementById(theObj2))
		{
			document.getElementById(theObj2).style.display="none";
		}
	}	
}

//设置Cookies的参数值
function setTheCookie(name, value)		//cookies设置
{
	var cookie_name=getTheDomain(1);
	cookie_name=cookie_name + name;
	var argv = setTheCookie.arguments;
	var argc = setTheCookie.arguments.length;
	var expires = (argc > 2) ? argv[2] : null;
	if(expires!=null)
	{
		var LargeExpDate = new Date ();
		LargeExpDate.setTime(LargeExpDate.getTime() + (expires*1000*3600*24));
	}
	document.cookie = cookie_name + "=" + escape(value)+((expires == null) ? "" : ("; expires=" +LargeExpDate.toGMTString())) + "; path=/";
}

//读取Cookies的参数值
function getTheCookie(Name)			//cookies读取
{
	var cookie_name=getTheDomain(1);
	cookie_name=cookie_name + Name;
	var search = cookie_name + "=";
	if(document.cookie.length > 0) 
	{
		offset = document.cookie.indexOf(search);
		if(offset != -1) 
		{
			offset += search.length;
			end = document.cookie.indexOf(";", offset);
			if(end == -1) end = document.cookie.length;
			return unescape(document.cookie.substring(offset, end));
		}
		else return ""
	}
}

//返回访问网站的主机域名
function getTheDomain(rep_var)
{
	var theHost,thePort,theDomain;
	theHost=location.hostname;
	thePort=location.port;
	theDomain=theHost;
	if(thePort!="80" && thePort!="")
	{
		//theDomain=theHost + ":" + thePort;
	}
	if(rep_var==1)
	{
		theDomain=theDomain.replace(".","");
		theDomain=theDomain.replace(":","");
	}
	return theDomain;
}

//设置浮动框架对象的链接参数
function setFrame_IdUrl(frameId,frameUrl)
{
	if(document.getElementById(frameId))
	{
		if(frameUrl)
		{
			document.getElementById(frameId).src=frameUrl;
		}
	}
}

//-->
