//collapse action
function optmenu(obj) {
obj = document.getElementById(obj);	
if (obj.style.display =="none")
	obj.style.display = "block";
else if (obj.style.display =="block") 
	obj.style.display = "none";
}

//change iframe width
function chif_w(h,l) {
tmp = document.getElementById("innertxt");
tmp.src =l;
}


// pop up windows
function openwin(url,h,w,tar) {
style = "height="+ h + ",width=" + w +",left=0,top=0,resizable=yes,scrollbars=yes,toolbar=no,status=no location=no"
popup = window.open(url,tar,style);
var browser=navigator.appName;
if (browser=="Microsoft Internet Explorer") {
 size = this.document.body.scrollHeight
 popup.height=size +"px";
 } else {
 size = this.document.body.offsetHeight 
 popup.height=size +"px";
 }
popup.focus()
}

//pop up windows edit style
function openwin_style(url,h,w,l,t,tar,resize,scrollbars,toolbar,status,location) {
style = "height="+ h + ",width=" + w +",left=" + l + ",top=" + t + ",resizable="+ resize + ",scrollbars=" + scrollbars + ",toolbar=" + toolbar + ",status=" + status + " location= " + location;
popup = window.open(url,tar,style);
var browser=navigator.appName;
if (browser=="Microsoft Internet Explorer") {
 size = this.document.body.scrollHeight
 popup.height=size +"px";
 } else {
 size = this.document.body.offsetHeight 
 popup.height=size +"px";
 }
popup.focus()
}

//return to parent and set iframe
function returnparent(h,l) {
window.opener.focus();
parentif = opener.document.getElementById("innertxt")
parentif.src = l;
//parentif.height =h;
}

//fit content to iframe
function autofitIframe(id){
 var buf = 0;
 var browser=navigator.appName;
 if (browser=="Microsoft Internet Explorer") {
 size = this.document.body.scrollHeight + buf
 parent.document.getElementById(id).style.height=size +"px";
 } else {
 size = this.document.body.offsetHeight + buf
 parent.document.getElementById(id).style.height=size +"px";
 }
  }
/*  
 //fit news to iframe 
function autofitIframe_news(id){
 var buf = 350;
 parent.document.getElementById(id).style.height=buf +"px";
 }
*/
 
function changepath() {
document.getElementById('path').innerHTML = "<a href=\"#\" onClick=\"chif_w(250,\"news.html\");return false\" class=\"htop\" >回首頁</a> &gt; <a class=\"htop\" onclick=\"chif_w(250,\"brief.html\");return false\" href=\"#\">辦公室簡介</a>";
}

var state = false;
var global = false;
var browser=navigator.appName;

/*
function inital_qa(ll,tt,diff) {
obj = document.getElementById('listmenu2');	

var l = ll
var t = tt
if (browser=="Microsoft Internet Explorer") {
 obj.style.left = l + "px";
 obj.style.top = t + "px";
 } else {
 obj.style.left = (l - diff) + "px";
 obj.style.top = t + "px";
}}
*/

//----- enable the scroll bar of the list box or not-----------
/*
function qa_scroll(questno) {
obj = document.getElementById('listmenu2');	
if (questno > 5) 
obj.className = "listmenu_height";
}
*/

//-------------------------------------------------------------------------------------------
function visible_qa() {
global = true
xx = document.getElementById("listmenu2")
if (state) {
xx.style.visibility = "hidden";
state = false
} else if (!state){
xx.style.visibility = "visible";
state = true
}}


function visible_global() {
//alert("dfdfdf");
if (global)
global = false
else {
xx = document.getElementById("listmenu2")
xx.style.visibility = "hidden";
state = false
}}

function global_close_menu() {
obj = frames[0].document.getElementById("listmenu2");
if (obj != null) 
obj.style.visibility = "hidden";
}
//------------------------------------------------------------------------------------------------




//------- check the state of the selected box------------
function check(e){

var target = (e && e.target) || (event && event.srcElement);
var obj = document.getElementById('listmenu2');
var obj2 = document.getElementById('sbox');
if (obj.style.visibility == "visible")
visible = "hidden";
else
visible = "visible";
checkParent(target)?obj.style.visibility='hidden':null;
target.id==obj2.id?obj.style.visibility=visible:null;
}
function checkParent(t){
while(t.parentNode){
if(t==document.getElementById('listmenu2')){
return false
}
t=t.parentNode
}
return true
}

//----- force the select box to close ------
function closesel() {
var obj = document.getElementById('listmenu2');
if (obj==null) 
var obj = parent.document.getElementById('listmenu2');

if (obj ==null) 
var obj = frames[0].document.getElementById("listmenu2");

if (obj !=null)
obj.style.visibility = "hidden";
}


//----- change page language ------------------------
function pagelang(lang) {
fobj = document.getElementById("innertxt");
l = fobj.src;
window.location = lang  + "?page=" + l;
}

//---- change frame src -----------------------
 //fit news to iframe 
function chfrmsrc(src,encode){
	src = (encode)?encodeURI(src):src;
	parent.document.getElementById("innertxt").src=src;
}

  
