/*window.onerror = function(){
	return true;
}*/
String.prototype.Trim = function(){
	return this.replace(/(^\s*)|(\s*$)/g, "");
}
String.prototype.LTrim = function(){
	return this.replace(/(^\s*)/g, "");
}
String.prototype.Rtrim = function(){
	return this.replace(/(\s*$)/g, "");
}

function trim(str){
  if(str==null) return "";
  if(str.length==0) return "";
  var i=0,j=str.length-1,c;
  for(;i<str.length;i++){
    c=str.charAt(i);
    if(c!=' ') break;

  }
  
  for(;j>-1;j--){
    c=str.charAt(j);
    if(c!=' ') break;
  }
  if(i>j) return "";
  return str.substring(i,j+1); 
}

function isEmpty(str){
	var value=trim(str);
	if(value.length !=0)return false;
	return true;
}
window.ClearEvent=function(){
	event.cancelBubble=false;
	var sSrcTagName=event.srcElement.tagName.toLowerCase();
	return (sSrcTagName=="textarea" || sSrcTagName=="input" || sSrcTagName=="select");
}
window.ClearKey=function(){
	event.cancelBubble=false;
	var iKeyCode=event.keyCode;
	if ((event.keyCode==8
		||event.keyCode==78
		||event.keyCode==37
		||event.keyCode==39
		||event.keyCode==116
		||event.keyCode==82
		||event.keyCode==121
		||event.keyCode==115)
		||(event.srcElement.tagName == "A" && event.shiftKey)){
		event.returnValue=false;
		return false;
	}
	return true;
}
with (window.document){
	//oncontextmenu=onselectstart=ondragstart=window.ClearEvent;
	//oncontextmenu=window.ClearEvent;
	//onkeydown=window.ClearKey;
}
function ne_wf_initActiveStyleSheet(){
	if(window.screen.width>900){
		var i, a, main;
		for(i=0; (a = document.getElementsByTagName('link')[i]); i++) {
	    	if(a.getAttribute('rel').indexOf('style') != -1 && a.getAttribute('href')) {
	        	if(a.getAttribute('href').indexOf("S800x600_")==0)
	        		a.disabled = true;
	    	}
	    }
	}
}

function correctPNG(){
	for(var i=0; i<document.images.length; i++){
		var img = document.images[i];
		var imgName = img.src.toUpperCase();
		if (imgName.substring(imgName.length-3, imgName.length) == "PNG"){
			var imgID = (img.id) ? "id='" + img.id + "' " : "";
			var imgClass = (img.className) ? "class='" + img.className + "' " : "";
			var imgTitle = (img.title) ? "title='" + img.title + "' " : "title='" + img.alt + "' ";
			var imgStyle = "display:inline-block;" + img.style.cssText;
			if (img.align == "left") 
				imgStyle = "float:left;" + imgStyle;
			if (img.align == "right") 
				imgStyle = "float:right;" + imgStyle;
			if (img.parentElement.href) 
				imgStyle = "cursor:hand;" + imgStyle;
			var strNewHTML = "<span " + imgID + imgClass + imgTitle 
		   		+ " style=\"" + "width:" + img.width + "px; height:" + img.height + "px;" + imgStyle + ";"
		   		+ "filter:progid:DXImageTransform.Microsoft.AlphaImageLoader"
		   		+ "(src='" + img.src + "', sizingMethod='scale');\"></span>";
	   		img.outerHTML = strNewHTML;
	   		i = i-1;
		}
	}
}
/**************************** StringUtil ****************************/
StringUtil = {
	nullToEmpty : function(strIn){
		if(strIn)
			if(strIn != null)
				return strIn;
		return "";
	},
	emptyToNull : function(strIn){
		if(strIn){
			if(strIn == ""){
				return null;
			}else{
				return strIn;
			}
		}else{
			return null;
		}
	}
}
/*************************** common util **********************/
ne_Common = {
	openDialog : function(url,param,width,height){
		if(param==null)
			param="";
		if(width==null)
			width=780;
		if(height==null)
			height=428;
		return window.showModalDialog(url,param,'dialogwidth: '+width+'px; dialogheight: '+height+'px; center: 1; status: 0; help: 0; scroll: 0; resizable: 0;');
	},
	openDialogEx : function(url,param,width,height,context){
		var iframePanel = "dialogPanel.ne?";
		if(context){
			iframePanel=context + "/" + iframePanel;
		}
		return ne_Common.openDialog(iframePanel + url,param,width,height);
	},
	openWindow : function(url,name,width,height){
		if(name==null)
			name="_blank";
		if(width==null)
			width=780;
		if(height==null)
			height=428;
		if (document.all){
	    	var xMax = screen.width, yMax = screen.height;
		}
	    else if(document.layers){
	      	var xMax = window.outerWidth, yMax = window.outerHeight;
		}
	    else{
	      	var xMax = 640, yMax=480;
		}
	    var xOffset = (xMax - width)/2, yOffset = (yMax - height)/2;
	    var newWindow = window.open(url,name,'width='+width+'px,height='+height+'px,screenX='+xOffset+',screenY='+yOffset+', top='+yOffset+',left='+xOffset+',status=0,scrollbars=1,resizable=1,toolbar=0,menubar=0,location=0'); 
		if(newWindow == null){
			alert("打开新窗口出错，请关闭IE浏览器的探出窗口过滤功能！");
			return;
		}
	    newWindow.focus();
	    return newWindow;
	},
	changeTopLocation : function(url){
		var win = window;
		while(win.parent!=win){
			win = win.parent;
		}
		win.location.href = url;
	},
	closeWindow : function(windowReturnValue){
		var win = window;
		while(win.parent!=win){
			win = win.parent;
		}
		if(windowReturnValue){
			win.returnValue = windowReturnValue;
		}
		win.opener=null;		
		win.close();
	},
	maxWindow : function(){
		try{
			var win = window;
			/*while(win.parent!=win){
				win = win.parent;
			}*/
		    if(win.dialogLeft){
		        win.dialogLeft = "0px";
		        win.dialogTop = "0px";
				win.dialogWidth = screen.availWidth;
		        win.dialogHeight = screen.availHeight;
		    }else{
				win.moveTo(0,0);
				win.resizeTo(screen.availWidth,screen.availHeight);
		    }
	    }catch(e){};
	},
	resizeWindow : function(width, height){
		if(width==null)
			width=780;
		if(height==null)
			height=428;
		var win = window;
		/*while(win.parent!=win){
			win = win.parent;
		}*/
		if (document.all){
	    	var xMax = screen.width, yMax = screen.height;
		}
	    else if(document.layers){
	      	var xMax = window.outerWidth, yMax = window.outerHeight;
		}
	    else{
	      	var xMax = 1024, yMax=768;
		}
	    var xOffset = (xMax - width)/2, yOffset = (yMax - height)/2;
	    if(win.dialogLeft){
	        win.dialogLeft =  "" + xOffset + "px";
	        win.dialogTop =  "" + yOffset + "px";
			win.dialogWidth = "" + width + "px";
	        win.dialogHeight = "" + height + "px";
	    }else{
			win.moveTo(xOffset, yOffset);
			win.resizeTo(width, height);
	    }
	},
	empty: function(){
	},
	emptyArray: function(size){
		if(!size)
			size = 0;
		var resultArray = new Array(size);
		for(var i = 0; i<size;i++){
			resultArray[i] = i;
		}
		return resultArray;
	},
	cancelEvent: function(){
		with (window.event) {
			cancelBubble = true ;
			returnValue = false ;
		}
		return false ;
	}
}
var ne_wf_openWindow = ne_Common.openWindow;
var ne_wf_openDialog = ne_Common.openDialog;
var ne_wf_openDialogEx = ne_Common.openDialogEx;
/**************************** StringUtil ****************************/
StringUtil = {
	nullToEmpty : function(strIn){
		if(strIn)
			if(strIn != null)
				return strIn;
		return "";
	},
	emptyToNull : function(strIn){
		if(strIn){
			if(strIn == ""){
				return null;
			}else{
				return strIn;
			}
		}else{
			return null;
		}
	}
}

/*************************** common util **********************/
ne_Form = {
	requestSubmitted : false,
	checkSubmit : function(){
		if(ne_Form.requestSubmitted == true){
			alert("表单已经提交，请耐心等待！");
			return false;
		}else{
			ne_Form.requestSubmitted=true;
			return true;
		}
	},
	onFormSubmit : function(form,isCheck,mode){
		if(isCheck == null)
			isCheck = true;
		if(isCheck){
			if(!ne_Validator.Validate(form,mode)){
				return false;
			}
		}
		if(ne_Form.checkSubmit()){
			return true;
		}
		return false;
	},
	formSubmit : function(formId,elementName,elementValue){
		var form = document.getElementById(formId);
		if(form.onsubmit()){
			if(elementName){
				form.elements[elementName].value=elementValue;
			}
			form.submit();
		}
	}
}

/*************************** checkbox util **********************/
ne_Checkbox = {
	checkAllByCheckbox: function(checkName,checkbox){
		this.checkAll(checkName,$(checkbox).checked);
	},
	checkAll: function(checkName,checked){
		var checks = document.getElementsByName(checkName);
		if(checks != null){
			if(checks.length){
			    for (var i=0; i<checks.length; i++) {
			        var obj = checks.item(i);
			        if(obj.type == "checkbox"){
			        	obj.checked = checked;
			        } 
			    }
		    }else{
		        var obj = checks;
		        if(obj.type == "checkbox"){
		        	obj.checked = checked;
		        } 
		    }
		}
	},
	checkedSize: function(checkName){
		var size = 0;
		var checks = document.getElementsByName(checkName);
		if(checks != null){
			if(checks.length){
			    for (var i=0; i<checks.length; i++) {
			        var obj = checks.item(i);
			        if(obj.checked){
			        	size++;
			        } 
			    }
		    }else{
		        var obj = checks;
		        if(obj.checked){
		        	size++;
		        } 
		    }
		}
		return size;
	},
	checkByValue: function(checkName,value){
		var checks = document.getElementsByName(checkName);
		if(checks != null){
			if(checks.length){
			    for (var i=0; i<checks.length; i++) {
			        var obj = checks.item(i);
			        if(obj.type == "checkbox"){
			        	if(obj.value == value)
			        		obj.checked = true;
			        	else
			        		obj.checked = false;
				        } 
			    }
		    }else{
		        var obj = checks;
		        if(obj.type == "checkbox"){
		        	if(obj.value == value)
		        		obj.checked = true;
		        	else
		        		obj.checked = false;
		        } 
		    }
		}
	},
	checkedValue: function(checkName, splitFlag){
		if(!splitFlag)
			splitFlag = ",";
		var value = "";
		var checks = document.getElementsByName(checkName);
		if(checks != null){
			if(checks.length){
			    for (var i=0; i<checks.length; i++) {
			        var obj = checks.item(i);
			        if(obj.checked){
			        	value += obj.value + splitFlag;
			        } 
			    }
			    if(value.length >0)
			    	value = value.substring(0,value.length-1);
		    }else{
		        var obj = checks;
		        if(obj.checked){
		        	value += obj.value;
		        } 
		    }
		}
		return value;
	},
	checkedValueArray: function(checkName){
		var value = new Array();
		var checks = document.getElementsByName(checkName);
		if(checks != null){
			if(checks.length){
			    for (var i=0; i<checks.length; i++) {
			        var obj = checks.item(i);
			        if(obj.checked){
		        		value.push(obj.value);
			        } 
			    }
		    }else{
		        var obj = checks;
		        if(obj.checked){
		        	value.push(obj.value);
		        } 
		    }
		}
		return value;
	}
}
/*************************** listbox util **********************/
ne_ListBox = {
	isOptionExcute: function(oSelect,value){
  		for(var i=0; i<oSelect.options.length; i++ ){
  			if(oSelect.options[i].value == value){
  				return true;
  			}
  		}
  		return false;
	},
	isSelected: function(oSelect,value){
  		for(var i=0; i<oSelect.options.length; i++ ){
  			if(oSelect.options[i].value == value){
  				return oSelect.options[i].selected;
  			}
  		}
  		return false;
	},
	selectFirst: function(oSelect){
		oSelect = $(oSelect);
		if(oSelect.options.length>0){
			oSelect.options[0].selected = true;
		}
	},
	addOptionByForm: function(formId,checkName,value,text){
		var form = document.getElementById(formId);
		var oSelect = form.elements[checkName];
		this.addOption(oSelect,value,text);
	},
	addOptionById: function(selectId,value,text){
		var oSelect = document.getElementById(selectId);
		this.addOption(oSelect,value,text);
	},
	addOption: function(oSelect,value,text,index){
		if(this.isOptionExcute(oSelect,value))
			return null;
		var oOption = document.createElement("OPTION");
		oOption.text=text;
		oOption.value=value;
		oSelect.add(oOption,index);
		return oOption;
	},
	removeOption: function(oSelect,value){
  		for(var i=0; i<oSelect.options.length; i++ ){
  			if(oSelect.options[i].value == value){
  				oSelect.options[i] = null;
  			}
  		}
	},
	removeSelect: function(oSelect){
  		for(var i=0; i<oSelect.options.length; i++ ){
			if(oSelect.options[i].selected){
  				oSelect.options[i] = null;
  				i--;
  			}
  		}
	},
	removeSelectById: function(selectId){
	    var oSelect = document.getElementById(selectId);
	    this.removeSelect(oSelect);
	},
	removeAll: function(oSelect){
  		for(var i=0; i<oSelect.options.length; i++ ){
  			oSelect.options[i] = null;
  			i--;
  		}
	},
	removeAllById: function(selectId){
	    var oSelect = document.getElementById(selectId);
	    this.removeAll(oSelect);
	},
	isEmpty: function(oSelect){
	    if(oSelect.options.length > 0) return false;
	    return true;
	},
	isEmptyById: function(selectId){
	    var oSelect = document.getElementById(selectId);
	    return this.isEmpty(oSelect);
	},
	select: function(oSelect,value){
  		for(var i=0; i<oSelect.options.length; i++ ){
  			if(oSelect.options[i].value == value){
  				oSelect.options[i].selected = true;
  			}
  		}
	},
	selectAll: function(oSelect){
  		for(var i=0; i<oSelect.options.length; i++ ){
  			oSelect.options[i].selected = true;
  		}
	},
	unselect: function(oSelect,value){
  		for(var i=0; i<oSelect.options.length; i++ ){
  			if(oSelect.options[i].value == value){
  				oSelect.options[i].selected = false;
  			}
  		}
	},
	unselectAll: function(oSelect){
  		for(var i=0; i<oSelect.options.length; i++ ){
  			oSelect.options[i].selected = false;
  		}
	},
	copySelect: function(src, target){
  		for(var i=0; i<src.options.length; i++ ){
			var oOption = src.options[i];
			if(oOption.selected){
  				this.addOption(target,oOption.value,oOption.text);
  			}
  		}
	},
	copyAll: function(src, target){
  		for(var i=0; i<src.options.length; i++ ){
			var oOption = src.options[i];
  			this.addOption(target,oOption.value,oOption.text);
  		}
	},
	upSelectOption: function(oSelect){
		var index = oSelect.selectedIndex;
		if( index <= 0 )
			return ;
		var toMoveX = oSelect.options[ index -1 ];
		var toMoveY = oSelect.options[ index ];
		var optX = new Option( toMoveX.text, toMoveX.value, false, false );
		var optY = new Option( toMoveY.text, toMoveY.value, false, false );
		oSelect.options[index] = optX;
		oSelect.options[index-1] = optY;
		oSelect.selectedIndex = index-1;
	},
	downSelectOption: function(oSelect){
		var index = oSelect.selectedIndex;
		if( index < 0 || index>=oSelect.options.length-1)
			return ;
		var toMoveX = oSelect.options[ index ];
		var toMoveY = oSelect.options[ index + 1 ];
		var optX = new Option( toMoveX.text, toMoveX.value, false, false );
		var optY = new Option( toMoveY.text, toMoveY.value, false, false );
		oSelect.options[index] = optY;
		oSelect.options[index+1] = optX;
		oSelect.selectedIndex = index+1;
	},
	// result[0][0]=option.value ; result[0][1]=option.text ;
	getSelectedOptionArray: function(oSelect){
		var result = new Array();
		var j = 0;
  		for(var i=0; i<oSelect.options.length; i++ ){
  			if(oSelect.options[i].selected){
  				var opt = new Array();
  				opt[0]=oSelect.options[i].value;
  				opt[1]=oSelect.options[i].text;
  				result[j]=opt;
  				j++;
  			}
  		}
  		return result;
	},
	getAllOptionArray: function(oSelect){
		var result = new Array();
  		for(var i=0; i<oSelect.options.length; i++ ){
  			var opt = new Array();
  			opt[0]=oSelect.options[i].value;
  			opt[1]=oSelect.options[i].text;
  			result[i]=opt;
  		}
  		return result;
	},
	getAllTextsAsString: function(oSelect,seperator,isNotBeginEnd){
		var result = "";
		for(var i=0; i<oSelect.options.length; i++ ){
  			if (i != 0){
  				result += seperator + oSelect.options[i].text;
  			}else{
  				result = oSelect.options[i].text;
  			}

  		}
  		if (result.length > 0){ 
  			if(isNotBeginEnd == null || isNotBeginEnd == false)
	  			result = seperator + result + seperator;
  		}
  		return result;
	},		
	getAllValuesAsString: function(oSelect,seperator,isNotBeginEnd){
		var result = "";
		for(var i=0; i<oSelect.options.length; i++ ){
  			if (i != 0){
  				result += seperator + oSelect.options[i].value;
  			}else{
  				result = oSelect.options[i].value;
  			}

  		}
  		if (result.length > 0){ 
  			if(isNotBeginEnd == null || isNotBeginEnd == false)
	  			result = seperator + result + seperator;
  		}
  		return result;
	}
}
/*****************************************************************************/
ne_Cookie={
	get: function(name) { 
	   var start = document.cookie.indexOf(name+"="); 
	   var len = start+name.length+1; 
	   if ((!start) && (name != document.cookie.substring(0,name.length))) return null; 
	   if (start == -1) return null; 
	   var end = document.cookie.indexOf(";",len); 
	   if (end == -1) end = document.cookie.length; 
	   return unescape(document.cookie.substring(len,end)); 
	},
	set: function(name,value,expires,path,domain,secure) { 
		if(!expires){
			var today = new Date(); 
			var zero_date = new Date(0,0,0); 
			today.setTime(today.getTime() - zero_date.getTime()); 
			var cookie_expire_date = new Date(today.getTime() + (54 * 7 * 86400000)); 
			expires = cookie_expire_date;
		}
	    var cookieString = name + "=" +escape(value) + 
	       ( (expires) ? ";expires=" + expires.toGMTString() : "") + 
	       ( (path) ? ";path=" + path : "") + 
	       ( (domain) ? ";domain=" + domain : "") + 
	       ( (secure) ? ";secure" : ""); 
	    document.cookie = cookieString; 
	},
	del: function(name,path,domain) { 
	   if (Get_Cookie(name)) document.cookie = name + "=" + 
	      ( (path) ? ";path=" + path : "") + 
	      ( (domain) ? ";domain=" + domain : "") + 
	      ";expires=Thu, 01-Jan-70 00:00:01 GMT"; 
	}
}
/*****************************************************************************/
ne_BeanController = {
	pagingInputTest: function(inputId,max,now,nFlag){
		var inputString = $(inputId).value;
	    var p = parseInt(inputString);
	    if(nFlag == null)
	    	nFlag = 0;
	    p = p + nFlag;
	    if(!isNaN(p)){
	        if(p>=1 && p<=max && p!=now){
	            return p;
	        }   
	    }
	    $(inputId).value = now;
	    return -1;
	},
	pagingTest: function(p,max,now){
	    if(!isNaN(p)){
	        if(p>=1 && p<=max && p!=now){
	            return p;
	        }   
	    }
	    return -1;
	},
	checkCommand: function(command){
		var msg = $(command).getAttribute("msg");
		if(msg!=null && msg.length>0){
			if(!window.confirm(msg))
				return false;
		}
		return true;
	},
	checkListCommand: function(command, selectName){
		if(!selectName)
			selectName = "selectedBeanIds";
		var min = command.getAttribute("min");
		if(min!=null && min.length>0){
			if(ne_Checkbox.checkedSize(selectName)<(min/1)){
				alert("最少必须选则"+min+"条数据！");
				return false;
			}
		}
		var max = command.getAttribute("max");
		if(max!=null && max.length>0){
			if(ne_Checkbox.checkedSize(selectName)>(max/1)){
				alert("最多只能选则"+min+"条数据！");
				return false;
			}
		}
		return this.checkCommand(command);
	}
}
/*****************************************************************************/
ne_DateFormat = {
	aDay: new Array("Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"),
	aMonth: new Array("January","February","March","April","May","June","July","August","September","October","November","December"),
	formatDate: function(xdate){
		if(xdate == null || typeof(xdate) != "object")
			return "";
		var con = xdate.constructor;
		if (con != Date){
			try{
				return this.formatDate(xdate.value);
			}catch(e){
				return "";
			}
		}
		var result = "";
		result += xdate.getYear();
		result += "-";
		if(xdate.getMonth() < 9)
			result += "0";
		result += xdate.getMonth()+1;
		result += "-";
		if(xdate.getDate() < 10)
			result += "0";
		result += xdate.getDate();
		return result;
	},
	formatDateTime: function(xdate){
		if(xdate == null || typeof(xdate) != "object")
			return "";
		var con = xdate.constructor;
		if (con != Date){
			try{
				return this.formatDateTime(xdate.value);
			}catch(e){
				return "";
			}
		}
		var result = "";
		result += xdate.getYear();
		result += "-";
		if(xdate.getMonth() < 9)
			result += "0";
		result += xdate.getMonth()+1;
		result += "-";
		if(xdate.getDate() < 10)
			result += "0";
		result += xdate.getDate();
		result += " ";
		if(xdate.getHours() < 10)
			result += "0";
		result += xdate.getHours();
		result += ":";
		if(xdate.getMinutes() < 10)
			result += "0";
		result += xdate.getMinutes();
		return result;
	},
	parseDate: function(source){
		if(source == null || source.length < 7)
			return null;
		var year = parseInt(source.substr(0,4));
		var month = parseInt(source.substr(5,2));
		var day = parseInt(source.substr(8,2));
		var result = new Date(year, month-1, day);
		return result;
	},
	parseDateTime: function(source){
		if(source == null || source.length < 13)
			return null;
		var year = parseInt(source.substr(0,4));
		var month = parseInt(source.substr(5,2));
		var day = parseInt(source.substr(8,2));
		var hour = parseInt(source.substr(11,2));
		var minute = parseInt(source.substr(14,2));
		var result = new Date(year, month-1, day, hour, minute);
		return result;
	}
}
/*****************************************************************************/
/*window.onerror = function(){
	return true;
}*/
String.prototype.Trim = function(){
	return this.replace(/(^\s*)|(\s*$)/g, "");
}
String.prototype.LTrim = function(){
	return this.replace(/(^\s*)/g, "");
}
String.prototype.Rtrim = function(){
	return this.replace(/(\s*$)/g, "");
}

function trim(str){
  if(str==null) return "";
  if(str.length==0) return "";
  var i=0,j=str.length-1,c;
  for(;i<str.length;i++){
    c=str.charAt(i);
    if(c!=' ') break;

  }
  
  for(;j>-1;j--){
    c=str.charAt(j);
    if(c!=' ') break;
  }
  if(i>j) return "";
  return str.substring(i,j+1); 
}

function isEmpty(str){
	var value=trim(str);
	if(value.length !=0)return false;
	return true;
}
window.ClearEvent=function(){
	event.cancelBubble=false;
	var sSrcTagName=event.srcElement.tagName.toLowerCase();
	return (sSrcTagName=="textarea" || sSrcTagName=="input" || sSrcTagName=="select");
}
window.ClearKey=function(){
	event.cancelBubble=false;
	var iKeyCode=event.keyCode;
	if ((event.keyCode==8
		||event.keyCode==78
		||event.keyCode==37
		||event.keyCode==39
		||event.keyCode==116
		||event.keyCode==82
		||event.keyCode==121
		||event.keyCode==115)
		||(event.srcElement.tagName == "A" && event.shiftKey)){
		event.returnValue=false;
		return false;
	}
	return true;
}
with (window.document){
	//oncontextmenu=onselectstart=ondragstart=window.ClearEvent;
	//oncontextmenu=window.ClearEvent;
	//onkeydown=window.ClearKey;
}
function ne_wf_initActiveStyleSheet(){
	if(window.screen.width>900){
		var i, a, main;
		for(i=0; (a = document.getElementsByTagName('link')[i]); i++) {
	    	if(a.getAttribute('rel').indexOf('style') != -1 && a.getAttribute('href')) {
	        	if(a.getAttribute('href').indexOf("S800x600_")==0)
	        		a.disabled = true;
	    	}
	    }
	}
}

function correctPNG(){
	for(var i=0; i<document.images.length; i++){
		var img = document.images[i];
		var imgName = img.src.toUpperCase();
		if (imgName.substring(imgName.length-3, imgName.length) == "PNG"){
			var imgID = (img.id) ? "id='" + img.id + "' " : "";
			var imgClass = (img.className) ? "class='" + img.className + "' " : "";
			var imgTitle = (img.title) ? "title='" + img.title + "' " : "title='" + img.alt + "' ";
			var imgStyle = "display:inline-block;" + img.style.cssText;
			if (img.align == "left") 
				imgStyle = "float:left;" + imgStyle;
			if (img.align == "right") 
				imgStyle = "float:right;" + imgStyle;
			if (img.parentElement.href) 
				imgStyle = "cursor:hand;" + imgStyle;
			var strNewHTML = "<span " + imgID + imgClass + imgTitle 
		   		+ " style=\"" + "width:" + img.width + "px; height:" + img.height + "px;" + imgStyle + ";"
		   		+ "filter:progid:DXImageTransform.Microsoft.AlphaImageLoader"
		   		+ "(src='" + img.src + "', sizingMethod='scale');\"></span>";
	   		img.outerHTML = strNewHTML;
	   		i = i-1;
		}
	}
}
/**************************** StringUtil ****************************/
StringUtil = {
	nullToEmpty : function(strIn){
		if(strIn)
			if(strIn != null)
				return strIn;
		return "";
	},
	emptyToNull : function(strIn){
		if(strIn){
			if(strIn == ""){
				return null;
			}else{
				return strIn;
			}
		}else{
			return null;
		}
	}
}
/*************************** common util **********************/
ne_Common = {
	openDialog : function(url,param,width,height){
		if(param==null)
			param="";
		if(width==null)
			width=780;
		if(height==null)
			height=428;
		return window.showModalDialog(url,param,'dialogwidth: '+width+'px; dialogheight: '+height+'px; center: 1; status: 0; help: 0; scroll: 0; resizable: 0;');
	},
	openDialogEx : function(url,param,width,height,context){
		var iframePanel = "dialogPanel.ne?";
		if(context){
			iframePanel=context + "/" + iframePanel;
		}
		return ne_Common.openDialog(iframePanel + url,param,width,height);
	},
	openWindow : function(url,name,width,height){
		if(name==null)
			name="_blank";
		if(width==null)
			width=780;
		if(height==null)
			height=428;
		if (document.all){
	    	var xMax = screen.width, yMax = screen.height;
		}
	    else if(document.layers){
	      	var xMax = window.outerWidth, yMax = window.outerHeight;
		}
	    else{
	      	var xMax = 640, yMax=480;
		}
	    var xOffset = (xMax - width)/2, yOffset = (yMax - height)/2;
	    var newWindow = window.open(url,name,'width='+width+'px,height='+height+'px,screenX='+xOffset+',screenY='+yOffset+', top='+yOffset+',left='+xOffset+',status=0,scrollbars=1,resizable=1,toolbar=0,menubar=0,location=0'); 
		if(newWindow == null){
			alert("打开新窗口出错，请关闭IE浏览器的探出窗口过滤功能！");
			return;
		}
	    newWindow.focus();
	    return newWindow;
	},
	changeTopLocation : function(url){
		var win = window;
		while(win.parent!=win){
			win = win.parent;
		}
		win.location.href = url;
	},
	closeWindow : function(windowReturnValue){
		var win = window;
		while(win.parent!=win){
			win = win.parent;
		}
		if(windowReturnValue){
			win.returnValue = windowReturnValue;
		}
		win.opener=null;		
		win.close();
	},
	maxWindow : function(){
		var win = window;
		/*while(win.parent!=win){
			win = win.parent;
		}*/
	    if(win.dialogLeft){
	        win.dialogLeft = "0px";
	        win.dialogTop = "0px";
			win.dialogWidth = screen.availWidth;
	        win.dialogHeight = screen.availHeight;
	    }else{
			win.moveTo(0,0);
			win.resizeTo(screen.availWidth,screen.availHeight);
	    }
	},
	resizeWindow : function(width, height){
		if(width==null)
			width=780;
		if(height==null)
			height=428;
		var win = window;
		/*while(win.parent!=win){
			win = win.parent;
		}*/
		if (document.all){
	    	var xMax = screen.width, yMax = screen.height;
		}
	    else if(document.layers){
	      	var xMax = window.outerWidth, yMax = window.outerHeight;
		}
	    else{
	      	var xMax = 1024, yMax=768;
		}
	    var xOffset = (xMax - width)/2, yOffset = (yMax - height)/2;
	    if(win.dialogLeft){
	        win.dialogLeft =  "" + xOffset + "px";
	        win.dialogTop =  "" + yOffset + "px";
			win.dialogWidth = "" + width + "px";
	        win.dialogHeight = "" + height + "px";
	    }else{
			win.moveTo(xOffset, yOffset);
			win.resizeTo(width, height);
	    }
	},
	empty: function(){
	},
	emptyArray: function(size){
		if(!size)
			size = 0;
		var resultArray = new Array(size);
		for(var i = 0; i<size;i++){
			resultArray[i] = i;
		}
		return resultArray;
	},
	cancelEvent: function(){
		with (window.event) {
			cancelBubble = true ;
			returnValue = false ;
		}
		return false ;
	}
}
var ne_wf_openWindow = ne_Common.openWindow;
var ne_wf_openDialog = ne_Common.openDialog;
var ne_wf_openDialogEx = ne_Common.openDialogEx;
/**************************** StringUtil ****************************/
StringUtil = {
	nullToEmpty : function(strIn){
		if(strIn)
			if(strIn != null)
				return strIn;
		return "";
	},
	emptyToNull : function(strIn){
		if(strIn){
			if(strIn == ""){
				return null;
			}else{
				return strIn;
			}
		}else{
			return null;
		}
	}
}

/*************************** common util **********************/
ne_Form = {
	requestSubmitted : false,
	checkSubmit : function(){
		if(ne_Form.requestSubmitted == true){
			alert("表单已经提交，请耐心等待！");
			return false;
		}else{
			ne_Form.requestSubmitted=true;
			return true;
		}
	},
	onFormSubmit : function(form,isCheck,mode){
		if(isCheck == null)
			isCheck = true;
		if(isCheck){
			if(!ne_Validator.Validate(form,mode)){
				return false;
			}
		}
		if(ne_Form.checkSubmit()){
			return true;
		}
		return false;
	},
	formSubmit : function(formId,elementName,elementValue){
		var form = document.getElementById(formId);
		if(form.onsubmit()){
			if(elementName){
				form.elements[elementName].value=elementValue;
			}
			form.submit();
		}
	}
}

/*************************** checkbox util **********************/
ne_Checkbox = {
	checkAllByCheckbox: function(checkName,checkbox){
		this.checkAll(checkName,$(checkbox).checked);
	},
	checkAll: function(checkName,checked){
		var checks = document.getElementsByName(checkName);
		if(checks != null){
			if(checks.length){
			    for (var i=0; i<checks.length; i++) {
			        var obj = checks.item(i);
			        if(obj.type == "checkbox"){
			        	obj.checked = checked;
			        } 
			    }
		    }else{
		        var obj = checks;
		        if(obj.type == "checkbox"){
		        	obj.checked = checked;
		        } 
		    }
		}
	},
	checkedSize: function(checkName){
		var size = 0;
		var checks = document.getElementsByName(checkName);
		if(checks != null){
			if(checks.length){
			    for (var i=0; i<checks.length; i++) {
			        var obj = checks.item(i);
			        if(obj.checked){
			        	size++;
			        } 
			    }
		    }else{
		        var obj = checks;
		        if(obj.checked){
		        	size++;
		        } 
		    }
		}
		return size;
	},
	checkByValue: function(checkName,value){
		var checks = document.getElementsByName(checkName);
		if(checks != null){
			if(checks.length){
			    for (var i=0; i<checks.length; i++) {
			        var obj = checks.item(i);
			        if(obj.type == "checkbox"){
			        	if(obj.value == value)
			        		obj.checked = true;
			        	else
			        		obj.checked = false;
				        } 
			    }
		    }else{
		        var obj = checks;
		        if(obj.type == "checkbox"){
		        	if(obj.value == value)
		        		obj.checked = true;
		        	else
		        		obj.checked = false;
		        } 
		    }
		}
	},
	checkedValue: function(checkName, splitFlag){
		if(!splitFlag)
			splitFlag = ",";
		var value = "";
		var checks = document.getElementsByName(checkName);
		if(checks != null){
			if(checks.length){
			    for (var i=0; i<checks.length; i++) {
			        var obj = checks.item(i);
			        if(obj.checked){
			        	value += obj.value + splitFlag;
			        } 
			    }
			    if(value.length >0)
			    	value = value.substring(0,value.length-1);
		    }else{
		        var obj = checks;
		        if(obj.checked){
		        	value += obj.value;
		        } 
		    }
		}
		return value;
	},
	checkedValueArray: function(checkName){
		var value = new Array();
		var checks = document.getElementsByName(checkName);
		if(checks != null){
			if(checks.length){
			    for (var i=0; i<checks.length; i++) {
			        var obj = checks.item(i);
			        if(obj.checked){
		        		value.push(obj.value);
			        } 
			    }
		    }else{
		        var obj = checks;
		        if(obj.checked){
		        	value.push(obj.value);
		        } 
		    }
		}
		return value;
	}
}
/*************************** listbox util **********************/
ne_ListBox = {
	isOptionExcute: function(oSelect,value){
  		for(var i=0; i<oSelect.options.length; i++ ){
  			if(oSelect.options[i].value == value){
  				return true;
  			}
  		}
  		return false;
	},
	isSelected: function(oSelect,value){
  		for(var i=0; i<oSelect.options.length; i++ ){
  			if(oSelect.options[i].value == value){
  				return oSelect.options[i].selected;
  			}
  		}
  		return false;
	},
	selectFirst: function(oSelect){
		oSelect = $(oSelect);
		if(oSelect.options.length>0){
			oSelect.options[0].selected = true;
		}
	},
	addOptionByForm: function(formId,checkName,value,text){
		var form = document.getElementById(formId);
		var oSelect = form.elements[checkName];
		this.addOption(oSelect,value,text);
	},
	addOptionById: function(selectId,value,text){
		var oSelect = document.getElementById(selectId);
		this.addOption(oSelect,value,text);
	},
	addOption: function(oSelect,value,text,index){
		if(this.isOptionExcute(oSelect,value))
			return null;
		var oOption = document.createElement("OPTION");
		oOption.text=text;
		oOption.value=value;
		oSelect.add(oOption,index);
		return oOption;
	},
	removeOption: function(oSelect,value){
  		for(var i=0; i<oSelect.options.length; i++ ){
  			if(oSelect.options[i].value == value){
  				oSelect.options[i] = null;
  			}
  		}
	},
	removeSelect: function(oSelect){
  		for(var i=0; i<oSelect.options.length; i++ ){
			if(oSelect.options[i].selected){
  				oSelect.options[i] = null;
  				i--;
  			}
  		}
	},
	removeSelectById: function(selectId){
	    var oSelect = document.getElementById(selectId);
	    this.removeSelect(oSelect);
	},
	removeAll: function(oSelect){
  		for(var i=0; i<oSelect.options.length; i++ ){
  			oSelect.options[i] = null;
  			i--;
  		}
	},
	removeAllById: function(selectId){
	    var oSelect = document.getElementById(selectId);
	    this.removeAll(oSelect);
	},
	isEmpty: function(oSelect){
	    if(oSelect.options.length > 0) return false;
	    return true;
	},
	isEmptyById: function(selectId){
	    var oSelect = document.getElementById(selectId);
	    return this.isEmpty(oSelect);
	},
	select: function(oSelect,value){
  		for(var i=0; i<oSelect.options.length; i++ ){
  			if(oSelect.options[i].value == value){
  				oSelect.options[i].selected = true;
  			}
  		}
	},
	selectAll: function(oSelect){
  		for(var i=0; i<oSelect.options.length; i++ ){
  			oSelect.options[i].selected = true;
  		}
	},
	unselect: function(oSelect,value){
  		for(var i=0; i<oSelect.options.length; i++ ){
  			if(oSelect.options[i].value == value){
  				oSelect.options[i].selected = false;
  			}
  		}
	},
	unselectAll: function(oSelect){
  		for(var i=0; i<oSelect.options.length; i++ ){
  			oSelect.options[i].selected = false;
  		}
	},
	copySelect: function(src, target){
  		for(var i=0; i<src.options.length; i++ ){
			var oOption = src.options[i];
			if(oOption.selected){
  				this.addOption(target,oOption.value,oOption.text);
  			}
  		}
	},
	copyAll: function(src, target){
  		for(var i=0; i<src.options.length; i++ ){
			var oOption = src.options[i];
  			this.addOption(target,oOption.value,oOption.text);
  		}
	},
	upSelectOption: function(oSelect){
		var index = oSelect.selectedIndex;
		if( index <= 0 )
			return ;
		var toMoveX = oSelect.options[ index -1 ];
		var toMoveY = oSelect.options[ index ];
		var optX = new Option( toMoveX.text, toMoveX.value, false, false );
		var optY = new Option( toMoveY.text, toMoveY.value, false, false );
		oSelect.options[index] = optX;
		oSelect.options[index-1] = optY;
		oSelect.selectedIndex = index-1;
	},
	downSelectOption: function(oSelect){
		var index = oSelect.selectedIndex;
		if( index < 0 || index>=oSelect.options.length-1)
			return ;
		var toMoveX = oSelect.options[ index ];
		var toMoveY = oSelect.options[ index + 1 ];
		var optX = new Option( toMoveX.text, toMoveX.value, false, false );
		var optY = new Option( toMoveY.text, toMoveY.value, false, false );
		oSelect.options[index] = optY;
		oSelect.options[index+1] = optX;
		oSelect.selectedIndex = index+1;
	},
	// result[0][0]=option.value ; result[0][1]=option.text ;
	getSelectedOptionArray: function(oSelect){
		var result = new Array();
		var j = 0;
  		for(var i=0; i<oSelect.options.length; i++ ){
  			if(oSelect.options[i].selected){
  				var opt = new Array();
  				opt[0]=oSelect.options[i].value;
  				opt[1]=oSelect.options[i].text;
  				result[j]=opt;
  				j++;
  			}
  		}
  		return result;
	},
	getAllOptionArray: function(oSelect){
		var result = new Array();
  		for(var i=0; i<oSelect.options.length; i++ ){
  			var opt = new Array();
  			opt[0]=oSelect.options[i].value;
  			opt[1]=oSelect.options[i].text;
  			result[i]=opt;
  		}
  		return result;
	},
	getAllTextsAsString: function(oSelect,seperator,isNotBeginEnd){
		var result = "";
		for(var i=0; i<oSelect.options.length; i++ ){
  			if (i != 0){
  				result += seperator + oSelect.options[i].text;
  			}else{
  				result = oSelect.options[i].text;
  			}

  		}
  		if (result.length > 0){ 
  			if(isNotBeginEnd == null || isNotBeginEnd == false)
	  			result = seperator + result + seperator;
  		}
  		return result;
	},		
	getAllValuesAsString: function(oSelect,seperator,isNotBeginEnd){
		var result = "";
		for(var i=0; i<oSelect.options.length; i++ ){
  			if (i != 0){
  				result += seperator + oSelect.options[i].value;
  			}else{
  				result = oSelect.options[i].value;
  			}

  		}
  		if (result.length > 0){ 
  			if(isNotBeginEnd == null || isNotBeginEnd == false)
	  			result = seperator + result + seperator;
  		}
  		return result;
	}
}
/*****************************************************************************/
ne_Cookie={
	get: function(name) { 
	   var start = document.cookie.indexOf(name+"="); 
	   var len = start+name.length+1; 
	   if ((!start) && (name != document.cookie.substring(0,name.length))) return null; 
	   if (start == -1) return null; 
	   var end = document.cookie.indexOf(";",len); 
	   if (end == -1) end = document.cookie.length; 
	   return unescape(document.cookie.substring(len,end)); 
	},
	set: function(name,value,expires,path,domain,secure) { 
		if(!expires){
			var today = new Date(); 
			var zero_date = new Date(0,0,0); 
			today.setTime(today.getTime() - zero_date.getTime()); 
			var cookie_expire_date = new Date(today.getTime() + (54 * 7 * 86400000)); 
			expires = cookie_expire_date;
		}
	    var cookieString = name + "=" +escape(value) + 
	       ( (expires) ? ";expires=" + expires.toGMTString() : "") + 
	       ( (path) ? ";path=" + path : "") + 
	       ( (domain) ? ";domain=" + domain : "") + 
	       ( (secure) ? ";secure" : ""); 
	    document.cookie = cookieString; 
	},
	del: function(name,path,domain) { 
	   if (Get_Cookie(name)) document.cookie = name + "=" + 
	      ( (path) ? ";path=" + path : "") + 
	      ( (domain) ? ";domain=" + domain : "") + 
	      ";expires=Thu, 01-Jan-70 00:00:01 GMT"; 
	}
}
/*****************************************************************************/
ne_BeanController = {
	pagingInputTest: function(inputId,max,now,nFlag){
		var inputString = $(inputId).value;
	    var p = parseInt(inputString);
	    if(nFlag == null)
	    	nFlag = 0;
	    p = p + nFlag;
	    if(!isNaN(p)){
	        if(p>=1 && p<=max && p!=now){
	            return p;
	        }   
	    }
	    $(inputId).value = now;
	    return -1;
	},
	pagingTest: function(p,max,now){
	    if(!isNaN(p)){
	        if(p>=1 && p<=max && p!=now){
	            return p;
	        }   
	    }
	    return -1;
	},
	checkCommand: function(command){
		var msg = $(command).getAttribute("msg");
		if(msg!=null && msg.length>0){
			if(!window.confirm(msg))
				return false;
		}
		return true;
	},
	checkListCommand: function(command, selectName){
		if(!selectName)
			selectName = "selectedBeanIds";
		var min = command.getAttribute("min");
		if(min!=null && min.length>0){
			if(ne_Checkbox.checkedSize(selectName)<(min/1)){
				alert("最少必须选则"+min+"条数据！");
				return false;
			}
		}
		var max = command.getAttribute("max");
		if(max!=null && max.length>0){
			if(ne_Checkbox.checkedSize(selectName)>(max/1)){
				alert("最多只能选则"+min+"条数据！");
				return false;
			}
		}
		return this.checkCommand(command);
	}
}
/*****************************************************************************/
ne_DateFormat = {
	aDay: new Array("Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"),
	aMonth: new Array("January","February","March","April","May","June","July","August","September","October","November","December"),
	formatDate: function(xdate){
		if(xdate == null || typeof(xdate) != "object")
			return "";
		var con = xdate.constructor;
		if (con != Date){
			try{
				return this.formatDate(xdate.value);
			}catch(e){
				return "";
			}
		}
		var result = "";
		result += xdate.getYear();
		result += "-";
		if(xdate.getMonth() < 9)
			result += "0";
		result += xdate.getMonth()+1;
		result += "-";
		if(xdate.getDate() < 10)
			result += "0";
		result += xdate.getDate();
		return result;
	},
	formatDateTime: function(xdate){
		if(xdate == null || typeof(xdate) != "object")
			return "";
		var con = xdate.constructor;
		if (con != Date){
			try{
				return this.formatDateTime(xdate.value);
			}catch(e){
				return "";
			}
		}
		var result = "";
		result += xdate.getYear();
		result += "-";
		if(xdate.getMonth() < 9)
			result += "0";
		result += xdate.getMonth()+1;
		result += "-";
		if(xdate.getDate() < 10)
			result += "0";
		result += xdate.getDate();
		result += " ";
		if(xdate.getHours() < 10)
			result += "0";
		result += xdate.getHours();
		result += ":";
		if(xdate.getMinutes() < 10)
			result += "0";
		result += xdate.getMinutes();
		return result;
	},
	parseDate: function(source){
		if(source == null || source.length < 7)
			return null;
		var year = parseInt(source.substr(0,4));
		var month = parseInt(source.substr(5,1))*10 + parseInt(source.substr(6,1));
		var day = parseInt(source.substr(8,1))*10 + parseInt(source.substr(9,1));
		var result = new Date(year, month-1, day);
		return result;
	},
	parseDateTime: function(source){
		if(source == null || source.length < 13)
			return null;
		var year = parseInt(source.substr(0,4));
		var month = parseInt(source.substr(5,1))*10 + parseInt(source.substr(6,1));
		var day = parseInt(source.substr(8,1))*10 + parseInt(source.substr(9,1));
		var hour = parseInt(source.substr(11,1))*10 + parseInt(source.substr(12,1));
		var minute = parseInt(source.substr(14,1))*10 + parseInt(source.substr(15,1));
		var result = new Date(year, month-1, day, hour, minute);
		return result;
	}
}
/*****************************************************************************/
ne_base64 = {
	encodeChars: "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",
	decodeChars: new Array(
	-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
	-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
	-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 62, -1, -1, -1, 63,
	52, 53, 54, 55, 56, 57, 58, 59, 60, 61, -1, -1, -1, -1, -1, -1,
	-1,0,1,2,3, 4,5,6,7,8,9, 10, 11, 12, 13, 14,
	15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, -1, -1, -1, -1, -1,
	-1, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40,
	41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, -1, -1, -1, -1, -1),
	encode: function(str) {
	var out, i, len;
	var c1, c2, c3;
	len = str.length;
	i = 0;
	out = "";
	while(i < len) {
			c1 = str.charCodeAt(i++) & 0xff;
			if(i == len)
			{
			 out += this.encodeChars.charAt(c1 >> 2);
			 out += this.encodeChars.charAt((c1 & 0x3) << 4);
			 out += "==";
			 break;
			}
			c2 = str.charCodeAt(i++);
			if(i == len)
			{
			 out += this.encodeChars.charAt(c1 >> 2);
			 out += this.encodeChars.charAt(((c1 & 0x3)<< 4) | ((c2 & 0xF0) >> 4));
			 out += this.encodeChars.charAt((c2 & 0xF) << 2);
			 out += "=";
			 break;
			}
			c3 = str.charCodeAt(i++);
			out += this.encodeChars.charAt(c1 >> 2);
			out += this.encodeChars.charAt(((c1 & 0x3)<< 4) | ((c2 & 0xF0) >> 4));
			out += this.encodeChars.charAt(((c2 & 0xF) << 2) | ((c3 & 0xC0) >>6));
			out += this.encodeChars.charAt(c3 & 0x3F);
	}
	return out;
	},
	decode: function(str) {
	var c1, c2, c3, c4;
	var i, len, out;
	len = str.length;
	i = 0;
	out = "";
	while(i < len) {
			/* c1 */
			do {
			 c1 = this.decodeChars[str.charCodeAt(i++) & 0xff];
			} while(i < len && c1 == -1);
			if(c1 == -1)
			 break;
			/* c2 */
			do {
			 c2 = this.decodeChars[str.charCodeAt(i++) & 0xff];
			} while(i < len && c2 == -1);
			if(c2 == -1)
			 break;
			out += String.fromCharCode((c1 << 2) | ((c2 & 0x30) >> 4));
			/* c3 */
			do {
			 c3 = str.charCodeAt(i++) & 0xff;
			 if(c3 == 61)
			return out;
			 c3 = this.decodeChars[c3];
			} while(i < len && c3 == -1);
			if(c3 == -1)
			 break;
			out += String.fromCharCode(((c2 & 0XF) << 4) | ((c3 & 0x3C) >> 2));
			/* c4 */
			do {
			 c4 = str.charCodeAt(i++) & 0xff;
			 if(c4 == 61)
			return out;
			 c4 = this.decodeChars[c4];
			} while(i < len && c4 == -1);
			if(c4 == -1)
			 break;
			out += String.fromCharCode(((c3 & 0x03) << 6) | c4);
	}
	return out;
	},
	utf16to8: function(str) {
	var out, i, len, c;
	out = "";
	len = str.length;
	for(i = 0; i < len; i++) {
			c = str.charCodeAt(i);
			if ((c >= 0x0001) && (c <= 0x007F)) {
			 out += str.charAt(i);
			} else if (c > 0x07FF) {
			 out += String.fromCharCode(0xE0 | ((c >> 12) & 0x0F));
			 out += String.fromCharCode(0x80 | ((c >>6) & 0x3F));
			 out += String.fromCharCode(0x80 | ((c >>0) & 0x3F));
			} else {
			 out += String.fromCharCode(0xC0 | ((c >>6) & 0x1F));
			 out += String.fromCharCode(0x80 | ((c >>0) & 0x3F));
			}
	}
	return out;
	},
	utf8to16: function(str) {
	var out, i, len, c;
	var char2, char3;
	out = "";
	len = str.length;
	i = 0;
	while(i < len) {
			c = str.charCodeAt(i++);
			switch(c >> 4)
			{
			 case 0: case 1: case 2: case 3: case 4: case 5: case 6: case 7:
			 // 0xxxxxxx
			 out += str.charAt(i-1);
			 break;
			 case 12: case 13:
			 // 110x xxxx 10xx xxxx
			 char2 = str.charCodeAt(i++);
			 out += String.fromCharCode(((c & 0x1F) << 6) | (char2 & 0x3F));
			 break;
			 case 14:
			 // 1110 xxxx10xx xxxx10xx xxxx
			 char2 = str.charCodeAt(i++);
			 char3 = str.charCodeAt(i++);
			 out += String.fromCharCode(((c & 0x0F) << 12) |
			((char2 & 0x3F) << 6) |
			((char3 & 0x3F) << 0));
			 break;
			}
	}
	return out;
	}
}
/*****************************************************************************/

