// JavaScript Document
function $_getID(id)
{
	return document.getElementById(id);
}


function FrameRedirect(frameId, url)
{
	if (($_getID(frameId) != null) && (url != "#") && (url.length > 0))
	{
		window.frames[frameId].location.href = url;
	}
}	

//构建子菜单项及填充类;
function SelectMenu(menuItem, lefturl)
{
			FrameRedirect('Melyy_Leftifr', lefturl);
			//break;
	
	//alert(subMenuId);
	if ($_getID("txtSelectedMenuId").value == menuItem.id)
		return;
	menuItem.className = "Current";
	if ($_getID("txtSelectedMenuId").value.length > 0)
		$_getID($_getID("txtSelectedMenuId").value).className = "";
	$_getID("txtSelectedMenuId").value = menuItem.id;
}

function MouseOver(menuItem)
{
	if ($_getID("txtSelectedMenuId").value == menuItem.id)
		return;
	menuItem.className = "hover";
}

function MouseOut(menuItem)
{
	if ($_getID("txtSelectedMenuId").value == menuItem.id)
		return;
	menuItem.className = "";
}

function SubmenuMouseOver(menuItem, subMenuId)
{
	menuItem.className = "hover";
	if (subMenuId == '')
		return;
	var subMenu = $_getID(subMenuId);
	if (subMenu == null)
		return;
	var offsetTop = menuItem.offsetTop; 
	var offsetLeft = menuItem.offsetLeft; 
	var offsetWidth = menuItem.offsetWidth; 
	var offsetHeight = menuItem.offsetHeight; 
	while( menuItem = menuItem.offsetParent ) 
	{ 
		offsetTop += menuItem.offsetTop; 
		offsetLeft += menuItem.offsetLeft; 
	}
	
	subMenu.style.left = offsetLeft + "px";
	subMenu.style.top = (offsetTop + offsetHeight - 3) + "px";
	subMenu.className = "porcelain2show"; 
}

function SubmenuMouseOut(menuItem)
{
	menuItem.className = "";
}
function leftList(thisID,thisImgID)
{
	thisID = $_getID(thisID);
	if (thisID.style.display == 'none')
	{
		thisID.style.display = '';
	}
	else
	{
		thisID.style.display = 'none';
	}
}
//换肤.
function SetCookie(name,value)//两个参数，一个是cookie的名子，一个是值
{
	var Days = 30; //此 cookie 将被保存 30 天
	var exp  = new Date();    //new Date("December 31, 9998");
	exp.setTime(exp.getTime() + Days*24*60*60*1000);
	document.cookie = name + "="+ escape (value) + ";expires=" + exp.toGMTString();
}
function getCookie(name)//取cookies函数        
{
	var arr = document.cookie.match(new RegExp("(^| )"+name+"=([^;]*)(;|$)"));
	 if(arr != null) return unescape(arr[2]); 
	 return null;
}

function MyMoodClass(thisMood)
{
	$_getID("cssLink").href =thisMood;
}
//显示、隐藏菜单
function switchSysTop(obj){    
	if (document.all("Melyy_Top").style.display==""){
	 obj.src="../Images/ManageMain/Topgoout.gif";
	 obj.title='显示';
	 document.all("Melyy_Top").style.display="none";
	 }
	else{         
	 obj.src="../Images/ManageMain/Topgoin.gif";
	 obj.title='隐藏';
	 document.all("Melyy_Top").style.display="" ;
	}
}
//取得日期和星期
function initArray(){
	 this.length=initArray.arguments.length
	 for(var i=0;i<this.length;i++)
	 this[i+1]=initArray.arguments[i] 
}
 
function initTime(){
	today=new Date();
    var d=new initArray("星期日","星期一","星期二","星期三","星期四","星期五","星期六"); 
    document.write(today.getYear(),"年",today.getMonth()+1,"月",today.getDate(),"日 ",d[today.getDay()+1],"&nbsp;");  	
}

	
function settimes(){   
	  var time= new Date();   
	  hours  = time.getHours();   
	  mins  = time.getMinutes();   
	  secs  = time.getSeconds();   
	  if(hours<10)hours="0"+hours;   
	  if(mins<10)mins="0"+mins;   
	  if(secs<10)secs="0"+secs;	     
	  eval("document.all.timediv.innerHTML='"+hours+":"+mins+":"+secs+"'");   
	  setTimeout("settimes()",1000);   
}
/*
 模拟windows模态对话框。
 Author: HxyMan
 Thanks: Laomi,Fssunwin
 Update: 2008-1-20
*/
var MSWnd={
	$:function(d){return document.getElementById(d)},
	move:0,
	eventStartX:0,
	eventStartY:0,
	wndStartX:0,
	wndStartY:0,
	d:{a:'MSWnd',b:'MSWndtitle',c:'MSWndchild',d:'MSWndstatus',e:'MSWndiframe',g:'MSWndcanvas',w:'MSWnd'},
	e:null,
	x:function(){return MSWnd.e.clientX;},
	y:function(){return MSWnd.e.clientY;},
	drag_start:function(e){
		MSWnd.e=e;
		MSWnd.move=1;
		MSWnd.eventStartX=MSWnd.x();
		MSWnd.eventStartY=MSWnd.y();
		MSWnd.wndStartX=MSWnd.$(MSWnd.d.a).offsetLeft;
		MSWnd.wndStartY=MSWnd.$(MSWnd.d.a).offsetTop;
	},
	drag_stop:function(e){
		MSWnd.e=e;
		MSWnd.move=0;
	},
	drag:function(e){
		MSWnd.e=e;
		if(MSWnd.move){
			MSWnd.$(this.d.a).style.left=MSWnd.wndStartX+(MSWnd.x()-MSWnd.eventStartX)+'px';
			MSWnd.$(this.d.a).style.top=MSWnd.wndStartY+(MSWnd.y()-MSWnd.eventStartY)+'px';
			try{document.selection.empty();}catch(er){}
		}
	},
	close:function(){
		MSWnd.$(MSWnd.d.a).style.display='none';MSWnd.$(MSWnd.d.g).style.display='none';
		var a=document.body;a.removeChild(MSWnd.$(MSWnd.d.a));//a.removeChild(MSWnd.$(MSWnd.d.g));
	},
	onfocus:function(){
		MSWnd.flash(2);
	},
	flash:function(n){
		MSWnd.$(MSWnd.d.b).className='MSWndfocus';
		setTimeout(function(){MSWnd.$(MSWnd.d.b).className='MSWndtitle';},50);
		if(n>1){setTimeout(function(){MSWnd.flash(n-1);},100);}
	},
	open:function(){
		var de=document.documentElement;
		var w=window.innerWidth || self.innerWidth || (de&&de.clientWidth) || document.body.clientWidth;
		var ch=window.innerHeight || self.innerHeight || (de&&de.clientHeight) || document.body.clientHeight;
		if (self.pageYOffset) {
			var st=self.pageYOffset;
		} else if (de&&de.scrollTop){	 // Explorer 6 Strict
			var st=de.scrollTop;
		} else if (document.body) {// all other Explorers
			var st=document.body.scrollTop;
		}
		if (window.innerHeight && window.scrollMaxY) {	
			var sh=window.innerHeight + window.scrollMaxY;
		} else if (document.body.scrollHeight > document.body.offsetHeight){ // all but Explorer Mac
			var sh=document.body.scrollHeight;
		} else { // Explorer Mac...would also work in Explorer 6 Strict, Mozilla and Safari
			var sh=document.body.offsetHeight;
		}
		var a=arguments;
		MSWnd.title=a[0]||'信息窗口';
		MSWnd.para=a[1];//网址或者要显示的内容
		MSWnd.width=a[2]||300;
		MSWnd.height=a[3]||200;
		MSWnd.type=null==a[4]?1:a[4];//1-框架,2-直接显示内容
		MSWnd.canvas=a[5]||{bgc:'#fff',opa:0.1};
		MSWnd.left=a[6]||(w-MSWnd.width)/2+'px';
		MSWnd.top=a[7]||(ch-(MSWnd.height||200))/2+st+'px';
		var dc=document,s='';
		var o=dc.createElement("div");
		o.id=MSWnd.d.a;
		o.className='MSWnd';
		o.style.width=MSWnd.width+'px';
		o.style.height=MSWnd.height+'px';
		o.style.left=MSWnd.left;
		o.style.top=MSWnd.top;
		s+='<div id="'+MSWnd.d.b+'" class="MSWndtitle" onmousedown="'+MSWnd.d.w+'.drag_start(event)" onmouseup="'+MSWnd.d.w+'.drag_stop(event)" onmousemove="'+MSWnd.d.w+'.drag(event)">';
		s+='<span style="float:right"><a href="javascript:'+MSWnd.d.w+'.close();" class="MSWndclose">×</a></span>'+MSWnd.title;
		s+='</div>';
		s+='<div id="'+MSWnd.d.c+'" class="MSWndchild">';
		s+=1==MSWnd.type?('<iframe id="'+MSWnd.d.e+'" name="'+MSWnd.d.e+'" src="about:blank"  style="width:100%;height:'+(MSWnd.height-40)+'px;" frameborder="0" hspace="0"></iframe>'):('<div style="padding:10px;">'+MSWnd.para+'</div>');
		s+='</div>';
		o.innerHTML=s;
		dc.body.appendChild(o);
		var f=0;
		o=MSWnd.$(MSWnd.d.g);
		if(!o){f=1;o=dc.createElement("div");}
		o.id=MSWnd.d.g;
		o.className='MSWndcanvas';
		o.style.height=(sh>ch?sh:ch)+'px';
		o.style.width=w+'px';
		s=MSWnd.canvas;
		o.style.backgroundColor=s.bgc;
		o.style.filter='alpha(opacity='+(s.opa*100)+')';
		o.style.display='block';
		if(f){o.onclick=function(){MSWnd.onfocus()};dc.body.appendChild(o)};
		if(1==MSWnd.type){MSWnd.$(MSWnd.d.e).src=MSWnd.para;}
	}
}
function send_root_request(url) {//初始化、指定处理函数、发送请求的函数
	 http_request = false;
	 if(window.XMLHttpRequest) {
	  http_request = new XMLHttpRequest();	  
	  if (http_request.overrideMimeType) {//设置MiME类别
		http_request.overrideMimeType('text/xml');
	  }
	}
	else if (window.ActiveXObject) { // IE浏览器
	  try {
		http_request = new ActiveXObject("Msxml2.XMLHTTP");
	  }catch (e){
		try {
			http_request = new ActiveXObject("Microsoft.XMLHTTP");
	  }catch (e) {

		}
	  }
	}

	if (!http_request) { // 异常，创建对象实例失?
	  window.alert("不能创建XMLHttpRequest对象实例.");
	  return false;
	}
	http_request.onreadystatechange = processRootRequest;
	// 确定发送请求的方式和URL以及是否同步执行下段代码	
	http_request.open("POST", url, true);
	http_request.send(null);
	//
}
function processRootRequest() {		
if (http_request.readyState == 4) { // 判断对象状态
	if (http_request.status != 200) { // 信息已经成功返回，开始处理信息	 			   	
		 alert("您所请求的页面有异常。");
	   }
	}
}
function AddUrl(){
  var thisurl='文件地址'+(document.myform.DownloadUrl.length+1)+'|http://'; 
  var url=prompt('请输入文件地址名称和链接，中间用“|”隔开：',thisurl);
  if(url!=null&&url!=''){document.myform.DownloadUrl.options[document.myform.DownloadUrl.length]=new Option(url,url);}
}
function ModifyUrl(){
  if(document.myform.DownloadUrl.length==0) return false;
  var thisurl=document.myform.DownloadUrl.value; 
  if (thisurl=='') {alert('请先选择一个文件地址，再点修改按钮！');return false;}
  var url=prompt('请输入文件地址名称和链接，中间用“|”隔开：',thisurl);
  if(url!=thisurl&&url!=null&&url!=''){document.myform.DownloadUrl.options[document.myform.DownloadUrl.selectedIndex]=new Option(url,url);}
}
function DelUrl(){
  if(document.myform.DownloadUrl.length==0) return false;
  var thisurl=document.myform.DownloadUrl.value; 
  if (thisurl=='') {alert('请先选择一个文件地址，再点删除按钮！');return false;}
  document.myform.DownloadUrl.options[document.myform.DownloadUrl.selectedIndex]=null;
}