/*
	3.6.0.5 (2004/10/18)
	When printing, the ruled line is added to system View table.

	3.8.0.4 (2005/08/08)
	The phenomenon of the header's shifting is corrected.
*/

window.onbeforeprint = BeforPrint ;
window.onafterprint  = AfterPrint ;

function BeforPrint() {
	var indx ;

	var divheaders = document.getElementsByName("divheader");
	var layers     = document.getElementsByName("layer");

	if( null != divheaders && null != layers ) {
		for( indx = 0; indx < divheaders.length; indx++ ) {
			divheaders[indx].style.display = "none";
		}

		for( indx = 0; indx < layers.length; indx++ ) {
			layers[indx].oldScrollTop  = layers[indx].scrollTop;		// 3.8.0.4 (2005/08/08)
			layers[indx].scrollTop	   = 0;								// 3.8.0.4 (2005/08/08)
			layers[indx].oldWidth      = layers[indx].style.width   ;
			layers[indx].style.width   = ""                  ;
			layers[indx].oldHeight     = layers[indx].style.height  ;
			layers[indx].style.height  = ""                  ;
			// 4.3.1.0 (2008/08/29) 印刷時のヘッダー固定外れない不具合対応
			// layers[indx].oldOverflow    = layers[indx].style.overflow;
			// layers[indx].style.overflow = "visible";
			layers[indx].oldOverflowX      = layers[indx].style.overflowX;
			layers[indx].style.overflowX   = "visible";
			layers[indx].oldOverflowY      = layers[indx].style.overflowY;
			layers[indx].style.overflowY   = "visible";

		}
	}

	var table = document.getElementsByName("viewTable");
	if( table != null ) {
		for( indx = 0; indx < table.length; indx++ ) {
			// 4.3.1.0 (2008/08/29) セールにデータない場合枠線表示されない不具合対応
			// 印刷時の枠線を出す方法は border="1" の設定から frame="box" の設定に切替る。
			// table[indx].oldBorder      = table[indx].border
			// table[indx].border         = "1px" ;
			// table[indx].oldCellSpacing = table[indx].cellSpacing
			// table[indx].cellSpacing    = "1px" ;
			table[indx].oldFrame          = table[indx].frame;
			table[indx].frame             = "box" ;

			// 4.3.3.4 (2008/11/01) 印刷時にセール枠を二重線にならないように修正
			table[indx].oldBorderCollapse    = table[indx].style.borderCollapse;
			table[indx].style.borderCollapse = "collapse"              ;
			table[indx].oldCellspacing       = table[indx].cellspacing ;
			table[indx].cellspacing          = "0px"                   ;
		}
	}
}

function AfterPrint() {
	var indx ;

	// 4.3.3.4 (2008/11/01) 内側の戻す処理を先に行うように変更します。
	var table = document.getElementsByName("viewTable");
	if( table != null ) {
		for( indx = 0; indx < table.length; indx++ ) {
			// 4.3.1.0 (2008/08/29) セールにデータない場合枠線表示されない不具合対応
			// 印刷時の枠線を出す方法は border="1" の設定から frame="box" の設定に切替る。
			// table[indx].border      = table[indx].oldBorder ;
			// 4.3.3.4 (2008/11/01) 印刷時にセール枠を二重線にならないように修正
			table[indx].style.borderCollapse = table[indx].oldBorderCollapse ;
			table[indx].frame                = table[indx].oldFrame          ;
			table[indx].cellspacing          = table[indx].oldCellspacing    ;
		}
	}

	var divheaders = document.getElementsByName("divheader");
	var layers  = document.getElementsByName("layer");
	if( null != divheaders && null != layers ) {
		for( indx = 0; indx < divheaders.length; indx++ ) {
			divheaders[indx].style.display = "block";
		}

		for( indx = 0; indx < layers.length; indx++ ) {
			// 4.3.1.0 (2008/08/29) 印刷時のヘッダー固定外れない不具合対応
			// layers[indx].style.overflow = layers[indx].oldOverflow   ;
			layers[indx].style.overflowX   = layers[indx].oldOverflowX  ;
			layers[indx].style.overflowY   = layers[indx].oldOverflowY  ;
			layers[indx].style.width       = layers[indx].oldWidth      ;
			layers[indx].style.height      = layers[indx].oldHeight     ;
			layers[indx].scrollTop	       = layers[indx].oldScrollTop  ;	// 3.8.0.4 (2005/08/08)
		}
	}
}
