var navVersion=navigator.appVersion.toLowerCase();
var bIsIE5 = (navVersion.indexOf("msie 5.0")!=-1) || (navVersion.indexOf("msie 5.5")!=-1) || (navVersion.indexOf("msie 6.0")!=-1) || (navVersion.indexOf("msie 7.0")!=-1);
var frame;

var styleWin;
if (window.opener){
	styleWin=launchParameters["styleWin"];
}else{
	styleWin=dialogArguments;
}

function SetStyle(selector, attribute, val){
	selector = selector.toLowerCase();
	var ss = frame.document.styleSheets(0);
	
	for(var i=0; i<ss.rules.length; i++){
		if (ss.rules(i).selectorText.toLowerCase()==selector){
			try{
				ss.rules(i).style.setAttribute(attribute,val,0);
			}catch(e){
			}
			break;
		}
	}
}

// 取出指定的属性值
function GetValue(selector, attribute)
{
	
	var val = "";
	selector = selector.toLowerCase();
	var ss = frame.document.styleSheets(0);
	
	for(var i=0; i<ss.rules.length; i++){
		if (ss.rules(i).selectorText.toLowerCase()==selector){
			val = ss.rules(i).style.getAttribute(attribute);
			break;
		}
	}
	
	if (val == null){
		return "";
	}else{
		return val;
	}
	
	//return frame.document.styleSheets(0).rules(8).style.getAttribute("background");
}


// 批量设置表单值
function BatchGetValue(selector, prefix)
{
	tmp = "";
	var fm = document.getElementById("theForm");
	for(var i=0; i<fm.elements.length; i++){
		var ele = fm.elements[i];
		//tmp += ele.tagName +"\r\n";
		if (ele.id.indexOf(prefix)==0){
			if (ele.tagName.toLowerCase()=="input"){
				ele.value = GetValue(selector, ele.id.substr(prefix.length));
			}else if (ele.tagName.toLowerCase()=="select"){
				tmp = GetValue(selector, ele.id.substr(prefix.length));
				for(var j=0; j<ele.options.length; j++){
					if (ele.options[j].value==tmp){
						ele.options[j].selected = true;
					}
				}
			}
		}
	}
	//alert(tmp);
	
}

// 批量设置修改后显示效果
function BatchSetValue(selector, prefix)
{
	var fm = document.getElementById("theForm");
	for(var i=0; i<fm.elements.length; i++){
		var ele = fm.elements[i];
		if (ele.id.indexOf(prefix)==0){
			SetStyle(selector, ele.id.substr(prefix.length), ele.value);
		}
	}
}

// 返回指定元素所有样式表值
function BatchGetStyle(selector, prefix){
	var tmp = "";
	var fm = document.getElementById("theForm");
	for(var i=0; i<fm.elements.length; i++){
		var ele = fm.elements[i];
		if (ele.id.indexOf(prefix)==0){
			var s = ele.id.substr(prefix.length);
			s = s.replace(/([A-Z])/g, "-$1").toLowerCase();
			if (ele.value.length==0){
				if (s=="width" && (prefix=="fbl_" || prefix=="fbr_")){
				}else{
					continue;
				}
			}
			if ((prefix=="fbl_" || prefix=="fbr_") && s=="width" && (ele.value=="" || ele.value=="0" || ele.value=="0px")){
				// 宽度为0时设为display:none，否则opera显示不正常
				tmp += "display:none;";
			}else{
				tmp += s +":"+ ele.value +";";
			}
			// 栏目头部高度和副导航栏同时设line-height
			if ((prefix=="ftm_" || prefix=="nsm_") && s=="height"){
				tmp += "line-height:"+ ele.value +";";
			}
			//SetStyle(selector, ele.id.substr(prefix.length), ele.value);
		}
	}
	return tmp;
}