﻿/*

==================================================================

LTrim(string):去除左边的空格

==================================================================

*/

function LTrim(str)

{

    var whitespace = new String(" \t\n\r");
    var s = new String(str);
    if (whitespace.indexOf(s.charAt(0)) != -1)
    {

        var j=0, i = s.length;
        while (j < i && whitespace.indexOf(s.charAt(j)) != -1)
        {
		j++;
        }
        s = s.substring(j, i);
    }
    return s;
}

 
/*

==================================================================

RTrim(string):去除右边的空格

==================================================================

*/

function RTrim(str)

{

    var whitespace = new String(" \t\n\r");
    var s = new String(str);
    if (whitespace.indexOf(s.charAt(s.length-1)) != -1)

    {   var i = s.length - 1;
        while (i >= 0 && whitespace.indexOf(s.charAt(i)) != -1)
        {
			i--;
        }
        s = s.substring(0, i+1);
    }
    return s;

}

 

/*

==================================================================

Trim(string):去除前后空格

==================================================================

*/

function Trim(str)

{
    return RTrim(LTrim(str));

}



function checkTab(url){
//alert(url);
var currentTab = window.event.srcElement;
var frame = document.getElementById("windowItem");
var selectedTab = document.getElementById("selectedTabName");
var lastSelectedTab = document.getElementById(selectedTab.value);
//将上次选中的标签置为未选中，将选中的标签标为选中
//lastSelectedTab.style.backgroundColor = "white";
//currentTab.style.backgroundColor = "red";
lastSelectedTab.className = "windowBar_tab_unselected";
currentTab.className = "windowBar_tab_selected";
selectedTab.value = currentTab.id;
//将嵌入窗口的链接改成新标签的链接
frame.src = url;
}

function findObj(theObj, theDoc)
{
  var p, i, foundObj;
  
  if(!theDoc) theDoc = document;
  if( (p = theObj.indexOf("?")) > 0 && parent.frames.length)
  {
    theDoc = parent.frames[theObj.substring(p+1)].document;
    theObj = theObj.substring(0,p);
  }
  if(!(foundObj = theDoc[theObj]) && theDoc.all) foundObj = theDoc.all[theObj];
  for (i=0; !foundObj && i < theDoc.forms.length; i++) 
    foundObj = theDoc.forms[i][theObj];
  for(i=0; !foundObj && theDoc.layers && i < theDoc.layers.length; i++) 
    foundObj = findObj(theObj,theDoc.layers[i].document);
  if(!foundObj && document.getElementById) foundObj = document.getElementById(theObj);
  
  return foundObj;
}
// JavaScript/readable_MM_functions/showHideLayers
function showHideLayers()
{ 
  var i, visStr, obj, args = showHideLayers.arguments;
  for (i=0; i<(args.length-2); i+=3)
  {
    if ((obj = findObj(args[i])) != null)
    {
      visStr = args[i+2];
      if (obj.style)
      {
        obj = obj.style;
        if(visStr == 'show') visStr = 'visible';
        else if(visStr == 'hide') visStr = 'hidden';
      }
      obj.visibility = visStr;
    }
  }
}

// JavaScript/events/getMouseLoc
function moveLayerToMouseLoc(theLayer, offsetH, offsetV)
{
  var obj;
  if ((findObj(theLayer))!=null)
  {
    if (document.layers)  //NS
    {
      document.onMouseMove = getMouseLoc;
      obj = document.layers[theLayer];
      obj.left = mLoc.x +offsetH-200;
      obj.top  = mLoc.y +offsetV;
    }
    else if (document.all)//IE
    {
      getMouseLoc();
      obj = document.all[theLayer].style;
      obj.pixelLeft = mLoc.x +offsetH-200;
      obj.pixelTop  = mLoc.y +offsetV;
    }
    showHideLayers(theLayer,'','show');
  }
}
// get mouse location
function Point(x,y) {  this.x = x; this.y = y; }
mLoc = new Point(-500,-500);
function getMouseLoc(e)
{
  if(!document.all)  //NS
  {
    mLoc.x = e.pageX;
    mLoc.y = e.pageY;
  }
  else               //IE
  {
    mLoc.x = event.x + document.body.scrollLeft;
    mLoc.y = event.y + document.body.scrollTop;
  }
  return true;
}
//NS init:
if(document.layers){ document.captureEvents(Event.MOUSEMOVE); document.onMouseMove = getMouseLoc; }

//上传附件调用函数——开始
var currentRowIndex = 1;
function addFile(formname){
	var form1 = document.getElementById(formname);
	var row = form1.insertRow(-1);
	var cell = row.insertCell(0);
	cell.id = "td_file_"+currentRowIndex;
	var str = "附件"+currentRowIndex+"：<input type='file' name='DOCUMENTATTACHMENT_"+currentRowIndex+"'>";
	str = str + "  ";
	str = str + "<input type='button' name='del' onClick='deleteRow(td_file_"+currentRowIndex+")' value='删除' class='button_nobg'>";
	cell.innerHTML = str;
	currentRowIndex++;
}
function deleteRow(currTd){
	var objTd = currTd;//document.getElementById(currTd);
	var objTr = objTd.parentElement;
	var objTable = objTr.parentElement;
	var currRowIndex = objTr.rowIndex;	
	
	if(objTable.rows.length==0 || currRowIndex==-1)
	{
		alert("对不起，你首先必须选择要删除的行！！！");
		return;
	}
	if(confirm("确定删除?"))
	{
		objTable.deleteRow(currRowIndex);
		currRowIndex = 0;
	}
	else
	{
		for(var j=1;j<objTable.rows.length;j++)
		{
			objTable.rows[j].cells[0].bgColor = "#ffffff";
			currRowIndex = 0;
		}
	}
}
//上传附件调用函数——结束

function public_Labels(label1, label2, label3, label4, label5, label6, label7){
t1.innerText = label1;
t2.innerText = label2;
t3.innerText = label3;
t4.innerText = label4;
t5.innerText = label5;
t6.innerText = label6;
t7.innerText = label7;
}
//a public function that the container uses to pass in values for the card containers
function public_Contents(contents1, contents2, contents3, contents4, contents5, contents6, contents7){
t1Contents.innerHTML = contents1;
t2Contents.innerHTML = contents2;
t3Contents.innerHTML = contents3;
t4Contents.innerHTML = contents4;
t5Contents.innerHTML = contents5;
t6Contents.innerHTML = contents6;
t7Contents.innerHTML = contents7;
init();
}
//sets the default display to tab 1
function init(){
tabContents.innerHTML = t1Contents.innerHTML;
}
//this is the tab switching function
var currentTab;
var tabBase;
var firstFlag = true;

function changeTabs(){
if(firstFlag == true){
currentTab = t1;
tabBase = t1base;
firstFlag = false;
}
if(window.event.srcElement.className == "tab"){
currentTab.className = "tab";
tabBase.style.backgroundColor = "white";
currentTab = window.event.srcElement;
tabBaseID = currentTab.id + "base";
tabContentID = currentTab.id + "Contents";
tabBase = document.all(tabBaseID);
tabContent = document.all(tabContentID);
currentTab.className = "selTab";
tabBase.style.backgroundColor = "";
tabContents.innerHTML = tabContent.innerHTML;
}}
	function sendAction(myAction,frmname)
	{
		//myAction =  encodeURI(myAction.replace("#","\\"));
		//alert("test33333333333");
		document.forms(frmname).action = myAction;
		
		/*var inputs=document.getElementsByName("docId");
		alert(inputs[0].value);
		
			var inputs=document.getElementsByName("docId");
		alert(inputs[0].value);
		*/
		//document.forms(frmname).submit();
		
	}
	
	function displayTable(tblId)
	{
		if(tblId.style.display=="none") 
			tblId.style.display = "block";
		else  
			tblId.style.display = "none";
	}
	
	function displayIMG(Id) 
	{ 
		//alert(Id.src);
		if(Id.getAttribute("Expanded") == "no"){
			Id.setAttribute("Expanded", "yes");
			Id.src = "/images/arrow1.gif";
		}else{
			Id.setAttribute("Expanded", "no");
			Id.src = "/images/ball1.gif"
		}		
	} 

	// JavaScript Document
　　var IsDroped =false; 

　　function mouseout() 

　　{ 

　　 //window.event.srcElement.style.color = '#ffffff';//鼠标移开时置为白色 

　　} 

　　function mouseover() 

　　{ 

　　 //window.event.srcElement.style.color = 'red';//鼠标进入时置为红色//鼠标进入时置为红色 

　　} 

　　function doMenu(MenuID) 

　　{ 

　　 var CurMenu = document.all(MenuID); 

　　 //为避免闪烁,如果下拉菜单已经显示则不重画. 

　　 if (IsDroped==true) 

　　 { 

　　 window.event.cancelBubble = true; 

　　 return false; 

　　 } 

　　 window.event.cancelBubble = true; 

　　 TempMenu = CurMenu; 

　　 //计算下拉菜单的位置 

　　 x = window.event.srcElement.offsetLeft + window.event.srcElement.offsetParent.offsetLeft+195; 
    // x=event.clientX-50;

　　 x2 = x + window.event.srcElement.offsetWidth+10; 

　　// y = event.clientY+20; 
       
	   y =  window.event.srcElement.offsetTop+ window.event.srcElement.offsetParent.offsetTop+window.event.srcElement.offsetHeight+180;
　　 CurMenu.style.top = y; 

　　 CurMenu.style.left = x; 

　　 CurMenu.style.clip = "rect(0 0 0 0)"; 

　　 CurMenu.style.display = "block"; 

　　 //延时2毫秒后再显示菜单,保证ToolbarMenu.offsetHeight有值,避免从主菜单移向下拉菜单时下拉菜单消失. 

　　 window.setTimeout("showMenu()", 100); 

　　 return true; 

　　} 

　　function showMenu() 

　　{ 

　　 y2 = y + TempMenu.offsetHeight+10; 

　　 TempMenu.style.clip = "rect(auto auto auto auto)"; 

　　 IsDroped =true;//下拉菜单已经显示 

　　} 

　　function hideMenu() 

　　{ 

　　 //如果在下拉菜单的范围之内移动则不隐藏. 

　　 cY = event.clientY + document.body.scrollTop; 

　　 if (cY>=(y-5) && cY<(y2+5) && event.clientX >= (x+5) && event.clientX <= x2 || 

　　 cY>0 && cY<(y+5) && event.clientX >= (x+5) && event.clientX <= x2-5) 

　　 { window.event.cancelBubble = true; return;} 

　　 //隐藏 

　　 TempMenu.style.display = "none"; 

　　 window.event.cancelBubble = true; 

　　 IsDroped =false; 

　　} 
function showIframe(fId,key)
{
if (document.getElementById(fId).style.display=="none")
{
document.getElementById(fId).style.display="block";
}
else
{
document.getElementById(fId).style.display="none";
}

}
function CheckAll(form)
  {
  for (var i=0;i<form.elements.length;i++)
    {
    var e = form.elements[i];
    if (e.name != 'chkall')
       e.checked = form.chkall.checked;
    }
}
/*
全部选中
*/
function viewSelectAll(form)
  {	  
  for (var i=0;i<form.elements.length;i++)
    {
    var e = form.elements[i];    
    e.checked = true;    
	}
}
/*
全部取消选中
*/
function viewUnSelectAll(form)
  {
  for (var i=0;i<form.elements.length;i++)
    {
    var e = form.elements[i];    
    e.checked = false;    
	}
}
/*
全部清空所填写的值
*/
function formClearAll(form)
  {	  
  for (var i=0;i<form.elements.length;i++){
  		var e = form.elements[i];    
		if (e.type == 'text'){
			e.value = "";   
		}
   }
}

function showAttach(attid){
var obj=document.getElementById(attid);
obj.style.visibility="visible";
obj.style.left=300;
obj.style.top=100;
obj.style.background="#efefef";
MM_dragLayer(attid,'',0,0,255,22,true,false,-1,-1,-1,-1,false,false,0,'',false,'');
}
function hideAtt(attid){
var obj=document.getElementById(attid);
obj.style.visibility="hidden";
}
/*
操作确认
*/
function confirmUrl(url,msg){
	
	//alert("original:"+url);
	//alert("convert:"+unicodeFromUtf8(url));
	url=encodeURI(unicodeFromUtf8(url));
	//alert("after:"+url);
	//var url=decodeURI(url);

	if(msg=="") msg = "确实要进行此操作吗?此操作不可恢复！";
	question = confirm(msg);
	//alert(question);
	if (question != "0"){
		//alert("action!"); 
		//alert(url);
		//alert("操作成功！");
		//window.location.href=urlnew;
		//alert("操作成功！");
		window.location.href=url;
		//alert(window.location.href);
		
	}	
}
/*
删除附件操作确认
*/
function confirmDeleteAttach(url,msg){
	if(msg=="") msg = "确实要进行此操作吗?此操作不可恢复！";
	question = confirm(msg);
	if (question != "0"){		
		
		var xmlhttp =getXmlHttp();

		try{
			//alert(url);
			xmlhttp.open("POST", url, false);
			
			xmlhttp.setRequestHeader("Content-Type","application/x-www-form-urlencoded")
			
			xmlhttp.send(null);	
			
		}catch(e){
			alert(e);
		}
       alert("操作成功！");
	   window.location.reload();		
	}
}
/**
function openSelectWindow(kName,fieldName,searchKey){
	alert("/control/getCollapseKeywordSelectSrc?keywordSelect="+kName+"&searchKey="+searchKey);
	keywordSelect("/admin/control/getCollapseKeywordSelectSrc?keywordSelect="+kName+"&searchKey="+searchKey,fieldName,"",true,"onlyLeaf");
}
**/
/*
后台执行链接的函数
*/
function sendQuietUrl(url,msg){
	if(msg==""){
		var xmlhttp =getXmlHttp();
		try{
			//alert(url);
			xmlhttp.open("POST", url, false);
			xmlhttp.setRequestHeader("Content-Type","text/html")
			xmlhttp.send(null);				
		}catch(e){
			alert(e);
		}
	}else{	
		question = confirm(msg);
		if (question != "0"){	
			var xmlhttp =getXmlHttp();
			try{
				//alert(url);
				xmlhttp.open("POST", url, false);
				xmlhttp.setRequestHeader("Content-Type","application/x-www-form-urlencoded")
				xmlhttp.send(null);				
			}catch(e){
				alert(e);
			}
		}else{
			return;	
		}
	}
	window.location.reload();
}

/*
弹出小窗口的方法
*/
function kmpPopWindow(url,msg){
	loc_x=event.clientX-event.offsetX-100;
  	loc_y=event.clientY-event.offsetY+170;	
	window.open(url,"newform","height=300,width=400,toolbar=no,menubar=no,scrollbars=yes,resizable=yes,location=no,status=no;top="+loc_y+",left="+loc_x)
}

/*
在页面上显示提示信息的方法
*/
var itemTipDivId = "itemTipDiv";
var dStyle;
function openItemTip(msg){	
	var showContainer = document.getElementById(itemTipDivId);	
	if(showContainer==null){
		showContainer = document.createElement("div");
		showContainer.id = itemTipDivId;		
	}	
	//alert(msg);	
	showContainer.style.position = "absolute";
	document.body.appendChild(showContainer);
	dStyle = showContainer.style;
	popUpHelp(msg);
	//showContainer.style.value = "position:absolute; left:"+loc_x+"px; top:"+loc_y+"px; width:352px; height:196px; z-index:3";	
}

/*
弹出提示信息
*/
function popUpHelp(str){	
    var bodyHeight = document.body.offsetHeight;
    var bodyWidth = document.body.offsetWidth - 27;
    var content = str;
    for(i=0;i<str.length;i++)
					{
						if(content.indexOf("<")!=-1)
						{
							content = content.replace("<","&lt;");
						}
						if(content.indexOf(">")!=-1)
						{
							content = content.replace(">","&gt;");
						}
					}
       s = '<TABLE BGCOLOR=#808080 BORDER=0 CELLPADDING=0 CELLSPACING=1><TR><TD><TABLE WIDTH=' + bodyWidth + ' height=60 BORDER=0 CELLPADDING=0 CELLSPACING=0 BGCOLOR=#EEEEEE>' +
        '<TR>' +
                '<td align="left" rowspan="2" width="34" valign="middle"><img src="/images/tips.gif" width="27"' +
                   ' height="36">'+
                '</td>' +
                '<td align="left"><strong>帮助提示...</strong></td>'+
            '</TR>' +
            '<TR>' +
                '<TD>' 
                    + content +  
                '</TD>'+
            '</TR>' +
'</TABLE></TD></TR></TABLE>';

    document.all[itemTipDivId].innerHTML = s;	
    dStyle.left = document.body.scrollLeft + 3;
    dStyle.top = document.body.scrollTop + bodyHeight - 65;
    dStyle.width = 140;
    dStyle.visibility = "visible";
	
}

function closeHelp(){
    dStyle.visibility = "hidden";
}

function generateItemDynamic(propertyItem,contentType,useKeywordSelect) {

		
		var propertyName=propertyItem.name;

		if(contentType=="date"){
			propertyItem.style.width="185px";
			var notNullElement=generateCalendarElement(propertyName);
			propertyItem.parentNode.appendChild(notNullElement);
			propertyItem.checkType="date";	
		}
		
		if(contentType=="number"){
			
			propertyItem.checkType="number";	
		}
				
		
		
		//去掉选择
		
		if(!useKeywordSelect){
		
			var selectNodes=propertyItem.parentNode.getElementsByTagName("a");
		
		
			if(selectNodes!=null){
				for(var i=0;i<selectNodes.length;i++){
				//alert("innerHTML:"+selectNodes[i].tagName);
				selectNodes[i].removeNode(true);
				}
			}
		}
		

}	

function generateNotnullItem(propertyItem,allowNull) {

		
		
		if(allowNull!="是"){
			var notNullElement=generateNotAllowNullElement();
			propertyItem.parentNode.appendChild(notNullElement);
			propertyItem.allowNull="false";	
		}
		
	
}	
	
function generateNotAllowNullElement() {
	
		var notNullElement=document.createElement("font");
		notNullElement.appendChild(document.createTextNode("*"));
		notNullElement.style.color="red";
		return notNullElement;

}




function generateCalendarElement(propertyName) {
		
		var calendarElement=document.createElement("img");
		calendarElement.calendarIdFieldName=propertyName;
		calendarElement.src="/images/cal.gif";
		
		calendarElement.style.cursor="pointer";
		var calendarId=propertyName+"_1";
		
		calendarElement.onmouseover=function(){
			
			var pName=this.calendarIdFieldName;
			var calendarId=pName+"_1";
			
				eval("this.style.background='red';");
				eval("Calendar.setup({inputField:'"+pName+"' ,ifFormat:'%Y-%m-%d',showsTime:false,timeFormat:'24',align:'cR',button:'"+calendarId+"',singleClick :true});");
		}
		calendarElement.onmouseout=function(){
				eval("this.style.background='black'");
		}
		
		calendarElement.onclick=function(){
				eval("Calendar.setup({inputField:'"+pName+"' ,ifFormat:'%Y-%m-%d',showsTime:false,timeFormat:'24',align:'cR',button:'"+calendarId+"',singleClick :true});");
		}
		calendarElement.id=propertyName+"_1";
		
		return calendarElement;

}

function setupCalendar() {
	Calendar.setup({inputField     :   'docProperty1' ,ifFormat       :    '%Y-%m-%d',showsTime      :    false,timeFormat     :    '24',align          :    'cR',button         :    'contractDate_1',singleClick    :    true});
	
}

/**
*生成遮盖页面add by skywave at 20060316
*/
function showCoverPage(){
	var screenWidth=screen.width;
	if(screenWidth<1024) {
		screenWidth=1024;
		}
	var screenHeight=screen.height;
	//var screenHeight = document.offsetheight;
	if(screenHeight<768){
		screenHeight=768;
		}
	//alert(screenHeight);
	var tdHeight=screenHeight/3;
	
	

	var root=document.createElement("div");
	root.id="coverDiv";
	root.style.visibility="visible";
	root.style.heigth=screenHeight;
	root.style.width=screenWidth;
	root.className="coverDiv";
	//root.sytle.position="absolute";
	//root.sytle.top="0px";
	
	
	var str="<center><table cellpadding=\"0\" cellspacing=\"0\" width=\"100%\"  class=\"coverPage\"><tr><td class=\"coverPage_opacity\" height=\""+tdHeight+"\">&nbsp;</td><td class=\"coverPage_opacity\">&nbsp;</td><td class=\"coverPage_opacity\">&nbsp;</td></tr><tr><td class=\"coverPage_opacity\" height=\"100\">&nbsp;</td><td width=\"300\" align=\"center\"  class=\"coverPage_message\"><div ><span>系统处理中，请稍侯...</span></div></td><td class=\"coverPage_opacity\">&nbsp;</td></tr><tr><td class=\"coverPage_opacity\" height=\""+(tdHeight+tdHeight+800)+"\">&nbsp;</td><td class=\"coverPage_opacity\">&nbsp;</td><td class=\"coverPage_opacity\">&nbsp;</td></tr></table></center>	";
	//alert(str);

	root.innerHTML=str;
	
	var coverPage=document.getElementById("coverPage");
	
	if(coverPage!=null){
		//alert("aaaa:"+coverPage.tagName);
		coverPage.appendChild(root);
	}


}

function initSearchForm(initVisible,viewName){
	
	var cookieName="searchFormVisibile"+viewName;	
	var searchForm=document.getElementById("searchFormDiv");
	
	var searchFormDiv_anchor=document.getElementById("searchFormDiv_anchor");
	
	var searchFormVisibile=kmpGetCookie(cookieName);
	
	//alert("get:"+searchFormVisibile);
	
	
	if(searchForm!=null){
			//alert("initSearchForm:"+kmpGetCookie(cookieName));
			if(searchFormVisibile=="true"){
				searchForm.style.display="block";
				kmpSetCookie(cookieName,"true",1);
				searchFormDiv_anchor.style.backgroundImage = "url(/images/down.gif)";
			}else{			
				searchForm.style.display="none";
				kmpSetCookie(cookieName,"false",1);
				searchFormDiv_anchor.style.backgroundImage = "url(/images/up_1.gif)";
			}
			
	}
		

}


function showSearchForm(viewName){
	
	var cookieName="searchFormVisibile"+viewName;
	var searchForm=document.getElementById("searchFormDiv");
	
	
	var searchFormVisibile=kmpGetCookie(cookieName);
	
	var searchFormDiv_anchor=document.getElementById("searchFormDiv_anchor");
	
	if(searchForm!=null){
		//alert("before:"+kmpGetCookie(cookieName));
		if(searchFormVisibile=="true"){
			searchForm.style.display="none";
			kmpSetCookie(cookieName,"false",1);
			searchFormDiv_anchor.style.backgroundImage = "url(/images/up_1.gif)";
		}else{			
			searchForm.style.display="block";
			kmpSetCookie(cookieName,"true",1);
			searchFormDiv_anchor.style.backgroundImage = "url(/images/down.gif)";
		}
		//alert("after:"+kmpGetCookie("searchFormVisibile"));
				
		}
	
	}


function kmpSetCookie(cookieName,cookieValue,nDays) {

 var today = new Date();
 var expire = new Date();

 if (nDays==null || nDays==0) nDays=1;

 expire.setTime(today.getTime() + 3600000*24*nDays);

 document.cookie = cookieName+"="+escape(cookieValue)
                 + ";expires="+expire.toGMTString()+";path=/";
				
}

function kmpGetCookie(cookieName) {
 var theCookie=""+document.cookie;
 //alert("theCookie:"+theCookie);
 var ind=theCookie.indexOf(cookieName);
 if (ind==-1 || cookieName=="") return ""; 
 var ind1=theCookie.indexOf(';',ind);
 if (ind1==-1) ind1=theCookie.length; 
 return unescape(theCookie.substring(ind+cookieName.length+1,ind1));
}


function kmpDeleteCookie(cookieName) {
 var today = new Date();
 var expire = new Date();
 
 expire.setTime(today.getTime() - 3600000*24*2);
 document.cookie = cookieName+"="+escape(cookieValue)
                 + ";expires="+expire.toGMTString();
}

/*********编码转换************/

 function  chineseFromUtf8Url(strUtf8)
{  
	var  bstr  =  "";  
	var  nOffset  =  0; //  processing  point  on  strUtf8  
	 
	if(  strUtf8  ===  ""  )  
	{
		return  "";  
	}
	 
	strUtf8  =  strUtf8.toLowerCase();  
	nOffset  =  strUtf8.indexOf("%e");  
	if(  nOffset  ==  -1  )  
	{
		return  strUtf8;  
	}
	 
	while(  nOffset  !=  -1  )  
	{  
		bstr  +=  strUtf8.substr(0,  nOffset);  
		strUtf8  =  strUtf8.substr(nOffset,  strUtf8.length  -  nOffset);  
		if(  strUtf8  === "" ||  strUtf8.length  <  9  )  //  bad  string  
		{
			return  bstr; 
		}
		 
		bstr  +=  utf8CodeToChineseChar(strUtf8.substr(0,  9));  
		strUtf8  =  strUtf8.substr(9,  strUtf8.length  -  9);  
		nOffset  =  strUtf8.indexOf("%e");  
	}  
	 
	return  bstr  +  strUtf8;  
}  
 
function  unicodeFromUtf8(strUtf8)
{  
	var  bstr  =  "";  
	var  nTotalChars  =  strUtf8.length; //  total  chars  to  be  processed.  
	var  nOffset  =  0; //  processing  point  on  strUtf8  
	var  nRemainingBytes  =  nTotalChars; //  how  many  bytes  left  to  be  converted  
	var  nOutputPosition  =  0;  
	var  iCode,  iCode1,  iCode2; //  the  value  of  the  unicode.  
	 
	while  (nOffset  <  nTotalChars)  
	{  
		iCode  =  strUtf8.charCodeAt(nOffset);  
		if  ((iCode  &  0x80)  ===  0) //  1  byte.  
		{  
			if  (  nRemainingBytes  <  1  ) //  not  enough  data  
			{
				break;  
			}
			 
			bstr  +=  String.fromCharCode(iCode  &  0x7F);  
			nOffset  ++;  
			nRemainingBytes  -=  1;  
		}  
		else  if  ((iCode  &  0xE0)  ==  0xC0) //  2  bytes  
		{  
			iCode1  = strUtf8.charCodeAt(nOffset  +  1);  
			if  (  nRemainingBytes  <  2 || //  not  enough  data  
			 (iCode1  &  0xC0)  !=  0x80  ) //  invalid  pattern  
			{  
				break;  
			}  
			 
			bstr  +=  String.fromCharCode(((iCode  &  0x3F)  <<  6) |  (  iCode1  &  0x3F));  
			nOffset  +=  2;  
			nRemainingBytes  -=  2;  
		}  
		else  if  ((iCode  &  0xF0)  ==  0xE0) //  3  bytes  
		{  
			iCode1  = strUtf8.charCodeAt(nOffset  +  1);  
			iCode2  = strUtf8.charCodeAt(nOffset  +  2);  
			if  (  nRemainingBytes  <  3 || //  not  enough  data  
			 (iCode1  &  0xC0)  !=  0x80 || //  invalid  pattern  
			 (iCode2  &  0xC0)  !=  0x80  )  
			{  
				break;  
			}  
			 
			bstr  +=  String.fromCharCode(((iCode  &  0x0F)  <<  12) |
			((iCode1  &  0x3F)  << 6) |  
			(iCode2  &  0x3F));  
			nOffset  +=  3;  
			nRemainingBytes  -=  3;  
		}  
		else //  4  or  more  bytes  --  unsupported  
		{	
			break;  
		}
	}  
	 
	if  (nRemainingBytes  !==  0)  
	{  
		//  bad  UTF8  string.  
		return  "";  
	}  
	 
	return  bstr;  
}  
 
function  utf8CodeToChineseChar(strUtf8)  
{  
	var  iCode,  iCode1,  iCode2;  
	iCode  =  parseInt("0x"  +  strUtf8.substr(1,  2),0);  
	iCode1  =  parseInt("0x"  +  strUtf8.substr(4,  2),0);  
	iCode2  =  parseInt("0x"  +  strUtf8.substr(7,  2),0);  
	 
	return  String.fromCharCode(((iCode  &  0x0F)  <<  12) |
	((iCode1  &  0x3F)  << 6) |  
	(iCode2  &  0x3F));  
}  

function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,"toolbar=yes,location=yes,directories=yes,status=yes,menubar=yes,scrollbars=yes,resizable=yes,copyhistory=yes");
  //window.location.href = theURL;
}




