function popup(mylink,windowname)
{
	if (! window.focus)return true;
	var href;
	if (typeof(mylink) == 'string')
	   href=mylink;
	else
	   href=mylink.href;
	window.open(href, windowname, 'resizable=yes,scrollbars=yes');
	return false;
}

function savefile(filename) { 
	var w=window.open(filename,"_blank","top=2000;left=2000"); 
	w.document.execCommand("SaveAs"); 
	w.close(); 
	return false;
} 

function has(element){
	return typeof(element)!="undefined";
}

function hasId(id){
	if (document.getElementById(id)==null) return false;
	return typeof(document.getElementById(id))!="undefined";
}

function show(obj) { 
	var properties=new Array(); 
	var i=0;
	for(var p in obj){
		properties[i]=p;
		i=i+1;  
	}
	properties.sort();  
	//properties.sort(function(a,b){return a.toString()>b.toString();});  
	var s="";
	for(j=0;j<properties.length;j++){
		var q=properties[j];
		try{
			s+=typeof(obj[q])+"\t"+q+" = "+obj[q]+"\n";
		}catch(e){}
	}
	alert(s);
}

/* --------- 打印 -------------- */
function printpreview(){
	try{
		document.all.page_body.style.overflow="visible";
		document.all.wb.execWB(7,1);
		document.all.page_body.style.overflow="auto";
	}catch(e){
		document.all.page_body.style.overflow="auto";
		alert('浏览器因安全原因禁止使用ActiveX控件，请使用浏览器菜单打印页面');
	}
	return false;
}

/* -------- 显示时间 ---------- */
var isMonth=new Array("1月","2月","3月","4月","5月","6月","7月","8月","9月","10月","11月","12月");
var isDay=new Array("星期日","星期一","星期二","星期三","星期四","星期五","星期六","星期日");

function showTime(){
	var today;
	today=new Date();
	Year=today.getYear();
	FDate=today.getDate();
	Hour=today.getHours();
	if (Hour<10) Hour='0'+Hour;
	Minute=today.getMinutes();
	if (Minute<10) Minute='0'+Minute;
	Second=today.getSeconds();
	if (Second<10) Second='0'+Second;
	Time=Hour+':'+Minute+':'+Second;
	s=Year+"年"+isMonth[today.getMonth()]+FDate+"日 "+isDay[today.getDay()]+" "+Time;
	labTime.innerText=s;
	setTimeout("showTime()",1000);
}

/* -------- 树形节点切换 ---------- */
function switchTreeNode(title){
	var node=getParentById(title,"node");
	var icon=getChildById(node,"node_icon");
	var child=getChildById(node,"node_child");
  if (child.style.display=='none'){
  	child.style.display='inline';		
		icon.src='img/tree_node_open.gif';
  }else{ 
    child.style.display='none';
		icon.src='img/tree_node_close.gif';
  }
  node.focus();
  return false;
}

/// 获取指定元素的父元素,条件:id=parentId
function getParentById(element,parentId){
	var x=element.parentElement;
	if (!has(x)) return null;
	if (x.id==parentId) return x;
	return getParentById(x,parentId);
}

/// 获取指定元素的子元素,条件:id=childId
function getChildById(element,childId){
	var x,y,i;
	x=element.childNodes;
	if (!has(x)) return null;
	
	for(i=0;i<x.length;i++){
		y=x[i];
		if (y.id==childId) {return y};
		z=getChildById(y,childId);
		if (z!=null) {return z};
	}
	return null;
}



