function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; 
  document.MM_sr=new Array; 
  for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){
	  document.MM_sr[j++]=x; 
	  if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];
	}
}

function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}

/* open Swf */
function openSwf(openfile) {
	var win_child=window.open( "web/reader/open_swf.jsp?path="+openfile,"Moker","directories=no,location=no,menubar=no,toolbar=no,scrollbars=yes,resize=yes,height=300,width=400,left=200,top=10").focus();
}


/* form submit */
function chc( code ){ //雜誌詳細資料
	document.form_smt.Lprg.value = "maga" ;
	document.form_smt.code.value = code ;
	document.form_smt.submit();
}
function chcO( code ){ //訂閱:雜誌詳細資料
	document.form_smt.Lprg.value = "ordMaga" ;
	document.form_smt.code.value = code ;
	document.form_smt.submit();
}
function chglce( id , page ){ //章節精彩換頁
	document.form_smt.Lprg.value = "lce" ;
	document.form_smt.id.value = id ;
	document.form_smt.page.value = page ;
	document.form_smt.submit();
}
function chglh( id , page ){ //歷史換頁
	document.form_smt.Lprg.value = "lh" ;
	document.form_smt.id.value = id ;
	document.form_smt.page.value = page ;
	document.form_smt.submit();
}
function chgm( mid ){ //左選單
	document.form_smt.Lprg.value = "lmu" ;
	document.form_smt.mid.value = mid ;
	//document.form_smt.pub_intv.value = "41M" ;
	document.form_smt.pub_intv.value = "X" ;
	document.form_smt.submit();
}
function chgmca( id , page  ){ //詳細資料裏的雜誌類別會呼叫
	document.form_smt.mid.value = "A4" ;
	document.form_smt.Lprg.value = "lmu" ;
	document.form_smt.id.value = id ;
	document.form_smt.page.value = page ;
	document.form_smt.submit();
}
function chglca( id , page , totalCnt  ){ //A4.左選單.傳 totalCnt 給下一頁 footer 記 log
	document.form_smt.mid.value = "A4" ;
	document.form_smt.Lprg.value = "lmu" ;
	document.form_smt.id.value = id ;
	document.form_smt.page.value = page ;
	document.form_smt.totalCnt.value = totalCnt ;
	document.form_smt.submit();
}

function chgca( mid , kind , page , Lt ){ 
	document.form_smt.Lprg.value = "lmu" ;
	document.form_smt.mid.value = mid ;
	document.form_smt.listType.value = Lt ;
	document.form_smt.page.value = page ;
	if( mid=="A1" )
		document.form_smt.pub_intv.value = kind ;
	else
		document.form_smt.id.value = kind ;
	document.form_smt.submit();
}
function chgad( ){ //至進階頁
	document.form_smt.Lprg.value = "adv" ;
	document.form_smt.submit();
}
function chgarp( page , listType ){ //進階結果換頁
	document.form_smt.Lprg.value = "adR" ;
	document.form_smt.page.value = page ;
	document.form_smt.listType.value = listType ;
	document.form_smt.submit();
}
function chgOrdp( Aid , page ){ //訂閱:a_magazine.換頁 , Aid = Axxxx
	document.form_smt.Lprg.value = "ordHtm" ;
	document.form_smt.listType.value = "2" ;
	document.form_smt.page.value = page ;
	document.form_smt.id.value = Aid ;
	//document.form_smt.guid.value = guid ;
	document.form_smt.submit();
}
function chgOrdYN( Aid , page , isOrd ){ //訂閱:a_magazine.換頁 , Aid = Axxxx
	document.form_smt.Lprg.value = "ordHtm" ;
	document.form_smt.listType.value = "2" ;
	document.form_smt.isOrd.value = isOrd ;
	document.form_smt.page.value = page ;
	document.form_smt.id.value = Aid ;
	//document.form_smt.guid.value = guid ;
	document.form_smt.submit();
}
function OrdSnt( Aid , act ){ //訂閱:單種雜誌訂閱或取消 . 送出 form
	document.form_smt.Lprg.value = "ordOne" ;
	document.form_smt.Aid.value = Aid ;
	document.form_smt.act.value = act ;
	document.form_smt.submit();
}
function chgA4( Aid , page , listType ){ //A4.分類目錄.各種雜誌換頁
	document.form_smt.Lprg.value = "lmu" ;
	document.form_smt.listType.value = listType ;
	document.form_smt.page.value = page ;
	document.form_smt.id.value = Aid ;
	document.form_smt.mid.value = "A4" ;
	document.form_smt.submit();
}
function sendQry( Qtype ){ //ez Qry smt
	var str = document.QryForm.Qstr.value ;
	if( str.trim().length==0 ){
		alert("請輸入查詢關鍵字 !");
		return;
	}else{
		var new_str = s2t( str ); //簡轉繁
		if( new_str.length==0 || new_str==str ) //若跟原來的 str 相同
			new_str = t2s( str ) ; //則繁轉簡
		if( new_str.length>0 )
			document.QryForm.new_str.value = new_str ; //轉換過後的字串:簡 -> 繁
		document.QryForm.Qtype.value = Qtype ;
		document.QryForm.listType.value = "2" ;
		document.QryForm.submit();
	}
}
function sendQry( ){ //ez Qry smt
	var str = document.QryForm.Qstr.value ;
	if( str.trim().length==0 ){
		alert("請輸入查詢關鍵字 !");
		return;
	}else{
		document.QryForm.listType.value = "2" ;
		document.QryForm.submit();
	}
}
function setQtype( Qtype ){ //設定 Qtype
	document.QryForm.Qtype.value = Qtype ;
}
function HotQry( str ){ //ez Qry smt
	var new_str = s2t( str );
	if( new_str.length==0 || new_str==str ) //若跟原來的 str 相同
		new_str = t2s( str ) ; //繁轉簡
	if( new_str.length>0 )
		document.QryForm.new_str.value = new_str ; //轉換過後的字串:簡 -> 繁
	document.QryForm.Qstr.value = str ;
	document.QryForm.LogType.value = "S3" ;
	document.QryForm.Qtype.value = "m" ;
	document.QryForm.listType.value = "2" ;
	document.QryForm.submit();
}
function chgez( page , listType ){ //全文檢索結果換頁
	var str = document.QryForm.Qstr.value ;
	var new_str = s2t( str );
	if( new_str.length==0 || new_str==str ) //若跟原來的 str 相同
		new_str = t2s( str ) ; //繁轉簡
	if( new_str.length>0 )
		document.form_smt.new_str.value = new_str ; //轉換過後的字串:簡 -> 繁
	document.form_smt.Lprg.value = "ez" ;
	document.form_smt.page.value = page ;
	document.form_smt.listType.value = listType ;
	document.form_smt.submit();
}
function setF( ){ //set isFirst = Y
	document.form_smt.isFirst.value = "Y" ;
}
function chgsf( code ){
	document.sframe.location = "web/reader/down_rec.jsp?code="+code ;
}
String.prototype.trim = function () {
  return this.replace(/^\s+|\s+$/g, "");
}

function chghtm( name ){ //全文檢索結果換頁
	document.form_smt.Lprg.value = "htm" ;
	document.form_smt.code.value = name ;
	document.form_smt.submit();
}


//用來紀錄作用中頁籤的ID 預設是第一個頁籤
var currentLayer = "cell1";
//用來紀錄作用中頁籤的頁面ID 預設是第一個頁面

var currentDiv = "d1";
//showLayer()函式，參數為觸發該函式的元素及所屬頁面ID
function showLayer(obj,div){
	//若目前的currentLayer不等於obj.id 表示要換頁面
	if(currentLayer!=obj.id) {
		//先改變上一個頁籤及頁面的樣式

		showIt(currentLayer,currentDiv,false);
		//重設currentLayer及currentDiv的值

		currentLayer = obj.id;
		currentDiv = div;
		//最後再改變目前頁籤及頁面的樣式
		showIt(currentLayer,currentDiv,true);
	}
}
//showIt()函式，參數為currentLayer、currentDiv及模式

//mode為true時 則表示目前作用中 所以要顯示
//mode為false時 則表示目前非作用中 所以要隱藏
function showIt(o,d,mode){
	var obj = document.getElementById(o);
	//**var div = document.getElementById(d);
	//改變className則表示改變該元素所用的class
	obj.className = mode?"s-sele1":"s-sele2";
	//**div.style.display = mode?"block":"none";
}