/********************************************
Basis of dwsFramework , Writen by CNLei@dws
*********************************************/
Array.prototype.remove = function(dx) {
    if(isNaN(dx) || dx>this.length){return false;}
    this.splice(dx,1);
}
String.prototype.getNumber = function() {return this.replace(/[^\d]/g,""); }
String.prototype.replaceAll = stringReplaceAll;
function stringReplaceAll(AFindText,ARepText){
 var raRegExp = new RegExp(AFindText.replace(/([\(\)\[\]\{\}\^\$\+\-\*\?\.\"\'\|\/\\])/g,"\\$1"),"ig");
 return this.replace(raRegExp,ARepText);
}
var dwsFw = {};
var dwsBrowser = {};
dwsBrowser.agt = navigator.userAgent.toLowerCase();
dwsBrowser.isW3C = document.getElementById ? true:false;
dwsBrowser.isIE = ((dwsBrowser.agt.indexOf("msie") != -1) && (dwsBrowser.agt.indexOf("opera") == -1) && (dwsBrowser.agt.indexOf("omniweb") == -1));
dwsBrowser.isNS6 = dwsBrowser.isW3C && (navigator.appName=="Netscape") ;
dwsBrowser.isOpera = dwsBrowser.agt.indexOf("opera") != -1;
dwsBrowser.isGecko = dwsBrowser.agt.indexOf("gecko") != -1;
dwsBrowser.ieTrueBody  =function (){
	return (document.compatMode && document.compatMode!="BackCompat")? document.documentElement : document.body;
}
var dwsElement={
  addClassName: function(element, className) {
    if (!(element = $(element))) return;
	dwsElement.delClassName(element, className);
	element.className=element.className+" "+className;
  },
  delClassName: function(element, className) {
    if (!(element = $(element))) return;
	var arrClssOld=element.className.replaceAll("  "," ");
	arrClssOld=arrClssOld.split(" ");
	for (var i=arrClssOld.length-1;i>=0;i--){
	 if (className==arrClssOld[i]){
	 arrClssOld.remove(i);
	 }
	}
	element.className=arrClssOld.join(" ");
  },
	isChild		: function(cNode,pNode){
		while(cNode!=null){
			cNode=cNode.parentNode;
			if(cNode==pNode) return true; 
		}
		return false;
	},
	getChild	: function(oChild,oParent){
		oParent.appendChild(oChild);
	},
	rePos	: function(obj,nLt,nTop){
		var o=$(obj);
		o.style.left	= nLt + "px";
		o.style.top		= nTop + "px";
	},
	getXYWH	: function(o){
		var nLt=0;
		var nTp=0;
		var offsetParent = o;
		while (offsetParent!=null && offsetParent!=document.body) {
			nLt+=offsetParent.offsetLeft;
			nTp+=offsetParent.offsetTop;
			if(dwsBrowser.isIE){
				parseInt(offsetParent.currentStyle.borderLeftWidth)>0?nLt+=parseInt(offsetParent.currentStyle.borderLeftWidth):"";
				parseInt(offsetParent.currentStyle.borderTopWidth)>0?nTp+=parseInt(offsetParent.currentStyle.borderTopWidth):"";
			}
			offsetParent=offsetParent.offsetParent;
		}
		return {"X":nLt, "Y":nTp, "W":o.offsetWidth, "H":o.offsetHeight}
	}
}
var dwsPosition={
	rePos	: function(obj,nLt,nTop){
		var o=$(obj);
		o.style.left	= nLt + "px";
		o.style.top		= nTop + "px";
	}
}
function $(element) {
	return document.getElementById(element)?document.getElementById(element):element;
}
document.getElementsByClassName = function(className,oBox) {
	 this.d= oBox || document;
	 var children = this.d.getElementsByTagName('*') || document.all;
	 var elements = new Array();
	 for (var i = 0; i < children.length; i++) {
		 var child = children[i];
		 var classNames = child.className.split(' ');
		 for (var j = 0; j < classNames.length; j++) {
			 if (classNames[j] == className) {
				 elements.push(child);
				 break;
			 }
		 }
	 }
	 return elements;
}

$Cls = document.getElementsByClassName ;
var dwsTAB = {
	idSuffix		: "_Tabs",
	tabTagName		: "li",
	activeClassName	: "active",
	waitInterval	: null,
	delayTime		: 30,
	tempTAB			: null
}
dwsTAB.init = function(){
	for(var i=0;i<arguments.length;i++) {
			var oTabBox=document.getElementById(arguments[i]+dwsTAB.idSuffix);
			var arrTabs=oTabBox.getElementsByTagName(dwsTAB.tabTagName);	
			var oCurrTAB=null;
			for(var j=0;j<arrTabs.length;j++) {
				oCurrTAB=arrTabs[j];
				if(oCurrTAB.parentNode!=oTabBox) continue;
				var oTabLink=oCurrTAB.getElementsByTagName("a")[0];
				var sDataStaut=oTabLink.getAttribute("rel");
				oCurrTAB.setActive=function(bactive){
					var oDataId = this.getElementsByTagName("a")[0].getAttribute("urn");
					if(bactive){
						this.status="active";
						dwsElement.addClassName(this,dwsTAB.activeClassName);
						dwsElement.delClassName($(oDataId),"hidden");
					}else{
						this.status="normal";
						dwsElement.delClassName(this,dwsTAB.activeClassName);
						dwsElement.addClassName($(oDataId),"hidden");
					}
				}
				oCurrTAB.getTabData=function(){
					this.setActive(true);
					this.parentNode.activetab.setActive(false);
					this.parentNode.activetab=this;					
					var oTabLink=this.getElementsByTagName("a")[0];
				}
				oCurrTAB.onmouseover=function(aEvent){
					var myEvent = window.event ? window.event : aEvent;
					var fm=myEvent.fromElement;
					if(dwsElement.isChild(fm,this) || fm==this) return;
					if(this.status=="active") return;
					dwsTAB.tempTAB=this;
					clearTimeout(dwsTAB.waitInterval);
					dwsTAB.waitInterval=window.setTimeout("dwsTAB.tempTAB.getTabData();",dwsTAB.delayTime);
				}
				oCurrTAB.onmouseout=function(aEvent){
					var myEvent = window.event ? window.event : aEvent;
					var em=myEvent.toElement;
					if(dwsElement.isChild(em,this) || em==this) return;
					if(this.status=="active") return;
					clearTimeout(dwsTAB.waitInterval);
				}
				if(sDataStaut.indexOf("#default")!=-1){
					oCurrTAB.setActive(true);
					oTabBox.activetab=oCurrTAB;
				} else {
					oCurrTAB.setActive(false);
				}

			}
		if(oTabBox.activetab==null) oTabBox.activetab=arrTabs[0];
	}
}

dwsTAB.init2 = function(){
	for(var i=0;i<arguments.length;i++) {
			var oTabBox=document.getElementById(arguments[i]+dwsTAB.idSuffix);
			var arrTabs=oTabBox.getElementsByTagName(dwsTAB.tabTagName);	
			var oCurrTAB=null;
			for(var j=0;j<arrTabs.length;j++) {
				oCurrTAB=arrTabs[j];
				if(oCurrTAB.parentNode!=oTabBox) continue;
				var oTabLink=oCurrTAB.getElementsByTagName("a")[0];
				var sDataStaut=oTabLink.getAttribute("rel");
				oCurrTAB.setActive=function(bactive){
					var oDataId = this.getElementsByTagName("a")[0].getAttribute("urn");
					if(bactive){
						this.status="active";
						dwsElement.addClassName(this,dwsTAB.activeClassName);
						dwsElement.delClassName($(oDataId),"hidden");
					}else{
						this.status="normal";
						dwsElement.delClassName(this,dwsTAB.activeClassName);
						dwsElement.addClassName($(oDataId),"hidden");
					}
				}
				oCurrTAB.getTabData=function(){
					this.setActive(true);
					this.parentNode.activetab.setActive(false);
					this.parentNode.activetab=this;					
					var oTabLink=this.getElementsByTagName("a")[0];
				}
				oCurrTAB.onclick=function(aEvent){
					var myEvent = window.event ? window.event : aEvent;
					var fm=myEvent.fromElement;
					if(dwsElement.isChild(fm,this) || fm==this) return;
					if(this.status=="active") return;
					dwsTAB.tempTAB=this;
					dwsTAB.tempTAB.getTabData();
					//clearTimeout(dwsTAB.waitInterval);
					//dwsTAB.waitInterval=window.setTimeout("dwsTAB.tempTAB.getTabData();",dwsTAB.delayTime);
				}
				if(sDataStaut.indexOf("#default")!=-1){
					oCurrTAB.setActive(true);
					oTabBox.activetab=oCurrTAB;
				} else {
					oCurrTAB.setActive(false);
				}

			}
		if(oTabBox.activetab==null) oTabBox.activetab=arrTabs[0];
	}
}

dwsFw.setHome = function(o,s){
	if (dwsBrowser.isIE) {
		o.style.behavior='url(#default#homepage)';
		o.setHomePage(s);
		return(false);
	}
}
dwsFw.addFavUrl = function(title,url) {
	if (window.sidebar) { 
		window.sidebar.addPanel(title, url,""); 
	} else if( dwsBrowser.isIE ) {
		window.external.AddFavorite( url, title);
	} else if(dwsBrowser.isOpera && window.print ) {
		  var elem = document.createElement('a');
		  elem.setAttribute('href',url);
		  elem.setAttribute('title',title);
		  elem.setAttribute('rel','sidebar');
		  elem.click();
	}
}
var oldBoxNo=0;
function nextFace(sParentId,sSubBoxTag,n){
var arrFaceBox=$(sParentId).getElementsByTagName(sSubBoxTag);
var nNewBoxNo=oldBoxNo+n;
nNewBoxNo<0?nNewBoxNo=(arrFaceBox.length-1):"";
nNewBoxNo>=arrFaceBox.length?nNewBoxNo=0:"";
for (var i=0;i<arrFaceBox.length;i++ ) {
 arrFaceBox[i].style.display=i==nNewBoxNo?"":"none";/**/
}
oldBoxNo=nNewBoxNo;
}
var dwsPopMsg = {};
dwsPopMsg.show = function(o,sId,nOffX,nOffY){
this.offX = nOffX || 0;
this.offY = nOffY || 0;
var oBox = $(sId);
var nPos = dwsElement.getXYWH(o);
var nLt,nTop;
nLt = nPos.X + (nPos.W/2) + this.offX;
nTop = nPos.Y + this.offY;
dwsElement.rePos(oBox,nLt,nTop);
dwsElement.delClassName(oBox,"hidden");
//alert(nPos.X);
}
dwsPopMsg.close = function(sId){
var oBox = $(sId);
dwsElement.addClassName(oBox,"hidden");
}
function chgInp(o){
	o.value=o.value==o.defaultValue?"":o.value;
	o.onblur= function(){
		this.value=this.value==""?this.defaultValue:this.value;
	}
}


// search input
var dwsSearch = {
	hoverBtn	: function(o,s){
		dwsElement.addClassName(o,s);
		o.onmouseout = function(){
			dwsElement.delClassName(this,s);
		}
	},
	doInput	: function(o){
		if (o.value==o.defaultValue) {
			o.value="";
		}
		o.onblur = function(){
			o.value==""?o.value=o.defaultValue:"";
		}
	}
}



// flash nochick


var ie = (document.defaultCharset && document.getElementById && !window.home);
var opera9 = false;
if (ie){
var ver=navigator.appVersion.split("MSIE")
ver=parseFloat(ver[1])
ie = (ver >=6)
}else if (navigator.userAgent.indexOf("Opera")!=-1) {
var versionindex=navigator.userAgent.indexOf("Opera")+6
if (parseInt(navigator.userAgent.charAt(versionindex))>=9)
opera9 = true;
}
var oswap = (ie || opera9)
if (oswap){
document.write ("<style id='hideObject'> object{display:none;} </style>");
}
objectSwap = function(){
if (!document.getElementsByTagName){
return;
}
var stripQueue = [];
var objects = document.getElementsByTagName('object');
for (var i=0; i<objects.length; i++){ 
var o = objects[i]; 
var h = o.outerHTML;
var params = "";
var hasFlash = true;
for (var j = 0; j<o.childNodes.length; j++) {
var p = o.childNodes[j];
if (p.tagName == "PARAM"){
if (p.name == "flashVersion"){
hasFlash = detectFlash(p.value);
if (!hasFlash){
o.id = (o.id == "") ? ("stripFlash"+i) : o.id;
stripQueue.push(o.id);
break;
}
} 
params += p.outerHTML; 
}
} 
if (!hasFlash){
continue;
} 
if (!oswap){
continue;
} 
if (o.className.toLowerCase().indexOf ("noswap") != -1){
continue;
} 
var tag = h.split(">")[0] + ">"; 
var newObject = tag + params + o.innerHTML + " </OBJECT>"; 
o.outerHTML = newObject;
}
if (stripQueue.length) {
stripFlash(stripQueue)
}
if (oswap){
document.getElementById("hideObject").disabled = true;
}
}
detectFlash = function(version){
if(navigator.plugins && navigator.plugins.length){
var plugin = navigator.plugins["Shockwave Flash"];
if (plugin == undefined){
return false;
}
var ver = navigator.plugins["Shockwave Flash"].description.split(" ")[2];
return (Number(ver) >= Number(version))
} else if (ie && typeof (ActiveXObject) == "function"){
try{
var flash = new ActiveXObject("ShockwaveFlash.ShockwaveFlash." + version);
return true;
}
catch(e){
return false;
}
}
return true;
}
stripFlash = function (stripQueue){
if (!document.createElement){
return;
}
for (var i=0; i<stripQueue.length; i++){
var o = document.getElementById(stripQueue[i]);
var newHTML = o.innerHTML; 
newHTML = newHTML.replace(/<!--\s/g, "");
newHTML = newHTML.replace(/\s-->/g, "");
newHTML = newHTML.replace(/<embed/gi, "<span"); 
var d = document.createElement("div");
d.innerHTML = newHTML;
d.className = o.className;
d.id = o.id;
o.parentNode.replaceChild(d, o);
}
}
var tempFunc = window.onload;
window.onload = function(){
if (typeof (tempFunc) == "function"){
try{
tempFunc();
} catch(e){}
}
objectSwap();
}
// 表格变色
function trColor(id, css1, css2, ln){
var trs = $(id).getElementsByTagName("tr");
if(!ln)ln=0;
if(!css2)css2="";
for(i=ln;i<trs.length;i++){
trs[i].onmouseover=function(){
this.className=css1;}
trs[i].onmouseout=function(){
this.className=css2;}}}

