

/*
 這支程式的功用為自動調整有 _rev 的 css
 程式會搜尋 _rev 的 css, 並且把對應的 css 複製到 _rev.
 例如: 有一個 td css 為 t3t1_rev, 程式會把 t3t1 所有的屬性複製到這個 td, 
 原來是什麼顏色, 什麼字型, ... 都會設定過去.
 這支 asp 會 include 在 B2B moneydj_asp, 8640_Proj_Asp
 的 GetExpired.asp 裡面的這兩個 function: JustProlog1 與 ZFAProlog1 
 */

adjustRevCss();
	
// css item object
function cssItem(backgroundColor,color,fontFamily,fontSize,fontWeight,letterSpacing,textAlign,lineHeight,verticalAlign)
{
	/*
	BACKGROUND: #ffffff;
	COLOR: #000000;
	FONT-FAMILY: 新細明體;
	FONT-SIZE: 9.7pt;
	FONT-WEIGHT: normal;
	LETTER-SPACING: 1px;
	TEXT-ALIGN: left;
	LINE-HEIGHT: 140%;
	VERTICAL-ALIGN: middle
	*/
    
	this.backgroundColor = backgroundColor;
	this.color = color;
	this.fontFamily = fontFamily;
	this.fontSize = fontSize;
	this.fontWeight = fontWeight;
	this.letterSpacing = letterSpacing;
	this.textAlign = textAlign;
	this.lineHeight = lineHeight;
	this.verticalAlign = verticalAlign;
}
	
// 調整 _rev css 的底色
function adjustRevCss()
{
	// wait for document ready
	if (document.readyState != 'complete') {
		setTimeout('adjustRevCss()', 5);
		return;
	}
		
	colTD = document.all.tags("td");
				
	if (colTD.length == 0)
		return;
	
	var sCssList = "";	
	var hashBgColor = {};
	var colTDRev = new Array();
	var idx = 0;
		
	for (var i = 0; i < colTD.length; i++) {
		var sClassName = colTD[i].className;
			
		if (sClassName.indexOf('_rev') > 0) {
			sClassName=sClassName.replace('_rev','');
			colTD[i].className = sClassName;
			/*
			colTDRev[idx++] = colTD[i];
			var aTmp = sClassName.split('_');
			var sCss = aTmp[0];
				
			if (sCssList.indexOf(sCss) < 0) {
				sCssList = sCssList + sCss + ",";
					
				var oTD = null;
				var j = 0;
			
				while (colTD[j].className != sCss && j < colTD.length)
				{
					j++;
				}
				
				oCss = new cssItem(getElementStyle(colTD[j], "backgroundColor", "background-color"),
								getElementStyle(colTD[j], "color", "color"),
								getElementStyle(colTD[j], "fontFamily", "font-family"),
								getElementStyle(colTD[j], "fontSize", "font-size"),
								getElementStyle(colTD[j], "fontWeight", "font-weight"),
								getElementStyle(colTD[j], "letterSpacing", "letter-spacing"),
								getElementStyle(colTD[j], "textAlign", "text-align"),
								getElementStyle(colTD[j], "lineHeight", "line-height"),
								getElementStyle(colTD[j], "verticalAlign", "vertical-align")
								);
				
				hashBgColor[sCss] = oCss;
				
			}
			*/
		}
	}
	/*			
	for (var i = 0; i < colTDRev.length; i++) {
		var sClassName = colTDRev[i].className;
		var aTmp = sClassName.split('_');
		var sCss = aTmp[0];
			
		colTDRev[i].style.backgroundColor = hashBgColor[sCss].backgroundColor;
		colTDRev[i].style.color = hashBgColor[sCss].color;
		colTDRev[i].style.fontFamily = hashBgColor[sCss].fontFamily;
		colTDRev[i].style.fontSize = hashBgColor[sCss].fontSize;
		colTDRev[i].style.fontWeight = hashBgColor[sCss].fontWeight;
		colTDRev[i].style.letterSpacing = hashBgColor[sCss].letterSpacing;
		colTDRev[i].style.textAlign = hashBgColor[sCss].textAlign;
		colTDRev[i].style.lineHeight = hashBgColor[sCss].lineHeight;
		colTDRev[i].style.verticalAlign = hashBgColor[sCss].verticalAlign;
	}
	*/
}	
	
// get style by element and properties name
function getElementStyle(elem, IEStyleProp, CSSStyleProp) 
{
	if (elem.currentStyle) 
	    return elem.currentStyle[IEStyleProp];
	else if (window.getComputedStyle) 
	{
	    var compStyle = window.getComputedStyle(elem, "");
	    return compStyle.getPropertyValue(CSSStyleProp);
	}
		
	return "";
}
