function addLoadEvent(func){
	var oldonload = window.onload;
	if(typeof window.onload != "function"){
		window.onload = func;
	}else{
		window.onload = function(){
			oldonload();
			func();
		}
	}
}
//µ¼º½¶¨Î»

function news_current(){	
var wintitle=window.document.title;
if(wintitle=="KWIG_About"){
	document.getElementById("nav").getElementsByTagName("a")[0].id="m1Curr";
	}
if(wintitle.indexOf("Key Advantages")!=-1){
	document.getElementById("nav").getElementsByTagName("a")[1].id="m2Curr";
	}
if(wintitle.indexOf("structure")!=-1){
	document.getElementById("nav").getElementsByTagName("a")[2].id="m3Curr";
	}
if(wintitle.indexOf("Water treatment")!=-1){
	document.getElementById("nav").getElementsByTagName("a")[0].id="m1Curr";
	}
if(wintitle.indexOf("Wastewater treatment")!=-1){
	document.getElementById("nav").getElementsByTagName("a")[1].id="m2Curr";
	}
if(wintitle.indexOf("Desalination")!=-1){
	document.getElementById("nav").getElementsByTagName("a")[2].id="m3Curr";
	}
if(wintitle.indexOf("Water reclamation")!=-1){
	document.getElementById("nav").getElementsByTagName("a")[3].id="m4Curr";
	}
if(wintitle.indexOf("Dazhou")!=-1){
	document.getElementById("nav").getElementsByTagName("a")[0].id="m1Curr";
	}
if(wintitle.indexOf("Tianjin")!=-1){
	document.getElementById("nav").getElementsByTagName("a")[1].id="m2Curr";
	}
if(wintitle.indexOf("Shandong")!=-1){
	document.getElementById("nav").getElementsByTagName("a")[2].id="m3Curr";
	}	
if(wintitle.indexOf("Dingzhou")!=-1){
	document.getElementById("nav").getElementsByTagName("a")[3].id="m4Curr";
	}
if(wintitle.indexOf("Xuanhua")!=-1){
	document.getElementById("nav").getElementsByTagName("a")[4].id="m5Curr";
	}
}
addLoadEvent(news_current);


function Request(strName){
var strHref = window.location.href;
var intPos = strHref.indexOf("?");
var strRight = strHref.substr(intPos + 1);
var arrTmp = strRight.split("~");
for(var i = 0; i < arrTmp.length; i++) {
var arrTemp = arrTmp[i].split("=");
if(arrTemp[0].toUpperCase() == strName.toUpperCase()) return arrTemp[1];
}
return "";
}

// JavaScript Document
Object.extend = function(destination, source) {  
  for (var property in source) {  
    destination[property] = source[property];  
  }  
  return destination;  
} 
function strReplace(element,key,url,options){
	this.element=document.getElementById(element);
	this.key=key;
	this.url=url;
	this.options={
		linkClass:'',
		updateAfter:function(){}
	}
	if(options){
		Object.extend(this.options,options)
	}
	this.myReplace();
}
strReplace.prototype.myReplace=function(){
	var reg = new RegExp(this.key, "g");  	
	var replaceStr="<a href='"+this.url+"' class='"+this.options.linkClass+"''>"+this.key+"</a>";
	this.element.innerHTML=this.element.innerHTML.replace(reg,replaceStr);
}

// JavaScript Document
Object.extend = function(destination, source) {  
  for (var property in source) {  
    destination[property] = source[property];  
  }  
  return destination;  
} 
function strReplace(element,key,options){
	this.element=document.getElementById(element);
	this.key=key;
	this.options={
		tag:"a",
		attr:{},
		updateAfter:function(){}
	}
	if(options){
		Object.extend(this.options,options)
	}
	this.tag=this.options.tag;
	this.attr=this.options.attr;
	this.myReplace();
}
strReplace.prototype.myReplace=function(){
	var reg = new RegExp(this.key, "g");
	var attrStr='';
	var value='';
	for(key in this.attr){
		value=this.attr[key];
		if(key=="className"){
			key="class";
		}
		attrStr=attrStr+" "+key+"='"+value+"'";
	}
	var replaceStr="\<"+this.tag+attrStr+">"+this.key+"\</"+this.tag+">"
	this.element.innerHTML=this.element.innerHTML.replace(reg,replaceStr);
}
