var userAgent = navigator.userAgent.toLowerCase();
var is_webtv = userAgent.indexOf('webtv') != -1;
var is_kon = userAgent.indexOf('konqueror') != -1;
var is_mac = userAgent.indexOf('mac') != -1;
var is_saf = userAgent.indexOf('applewebkit') != -1 || navigator.vendor == 'Apple Computer, Inc.';
var is_opera = userAgent.indexOf('opera') != -1 && opera.version();
var is_moz = (navigator.product == 'Gecko' && !is_saf) && userAgent.substr(userAgent.indexOf('firefox') + 8, 3);
var is_ns = userAgent.indexOf('compatible') == -1 && userAgent.indexOf('mozilla') != -1 && !is_opera && !is_webtv && !is_saf;
var is_ie = (userAgent.indexOf('msie') != -1 && !is_opera && !is_saf && !is_webtv) && userAgent.substr(userAgent.indexOf('msie') + 5, 3);
function $(id) {
	return document.getElementById(id);
}
function in_array(needle, haystack) {
	if(typeof needle == 'string') {
		for(var i in haystack) {
			if(haystack[i] == needle) {
					return true;
			}
		}
	}
	return false;
}
function thumbImg(w , thumbwidth, h, thumbheight) {
var x_ratio = thumbwidth / w;
var y_ratio = thumbheight / h;
var wh = new Array();

if((x_ratio * h) < thumbheight) {
wh['h'] = Math.ceil(x_ratio * h);
wh['w'] = thumbwidth;
} else {
wh['w'] = Math.ceil(y_ratio * w);
wh['h'] = thumbheight;
}
return wh;
}

function imgOpacity(str,opValue,speed,Value,toValue){var myOpacity,Optemp=parseInt(is_ie?str.filters.alpha.opacity:document.defaultView.getComputedStyle(str,null).getPropertyValue('opacity')*100);clearInterval(myOpacity);myOpacity=setInterval(function(){if(Value<100){Optemp-=opValue}else if(Value==100){Optemp+=opValue}if((Value<100&&Optemp<=Value)||(Value==100&&Optemp>=Value)){if(is_ie){str.filters.alpha.opacity=Value}else{str.style.opacity=Value/100}clearInterval(myOpacity);return}if(is_ie){str.filters.alpha.opacity=Optemp}else{str.style.opacity=Optemp/100}},speed);str.onmouseout=function(){clearInterval(myOpacity);if(toValue==undefined){Value=100}else{Value=toValue}imgOpacity(this,opValue,speed,Value)}}

function Trim(str){return str.replace(/(^\s*)|(\s*$)/g, "")}
function LTrim(str){return str.replace(/(^\s*)/g,  "")}
function RTrim(str){return str.replace(/(\s*$)/g,  "")}
function AllTrim(str){return str.replace(/\s*/g,'')}

function GetMessageLength()
{
	var oEditor = FCKeditorAPI.GetInstance('Content') ;
	var oDOM = oEditor.EditorDocument ;
	var iLength ;

	if ( document.all )		// If Internet Explorer.
	{
		iLength = oDOM.body.innerText.length ;
	}
	else					// If Gecko.
	{
		var r = oDOM.createRange() ;
		r.selectNodeContents( oDOM.body ) ;
		iLength = r.toString().length ;
	}
//	oEditor.InsertHtml('')
return iLength
}	

function ToNum(strValue,strInteger,goValue){
var str = strValue.value; 
    str = str.replace(/\１/g, "1");  
    str = str.replace(/\２/g, "2");  
    str = str.replace(/\３/g, "3");  
    str = str.replace(/\４/g, "4");  
    str = str.replace(/\５/g, "5");  
    str = str.replace(/\６/g, "6");  
    str = str.replace(/\７/g, "7");  
    str = str.replace(/\８/g, "8");  
    str = str.replace(/\９/g, "9");  
    str = str.replace(/\０/g, "0");  
    str = str.replace(/\一/g, "1");  
    str = str.replace(/\二/g, "2");  
    str = str.replace(/\三/g, "3");  
    str = str.replace(/\四/g, "4");  
    str = str.replace(/\五/g, "5");  
    str = str.replace(/\六/g, "6");  
    str = str.replace(/\七/g, "7");  
    str = str.replace(/\八/g, "8");  
    str = str.replace(/\九/g, "9");  
    str = str.replace(/\壹/g, "1");  
    str = str.replace(/\贰/g, "2");  
    str = str.replace(/\叁/g, "3");  
    str = str.replace(/\肆/g, "4");  
    str = str.replace(/\伍/g, "5");  
    str = str.replace(/\陆/g, "6");  
    str = str.replace(/\柒/g, "7");  
    str = str.replace(/\捌/g, "8");  
    str = str.replace(/\玖/g, "9");  
    str = str.replace(/\零/g, "0");  
    str = str.replace(/\。/g, ".");  
if (strInteger){str = str.replace(/\./g, '');}
if (isNaN(str)){alert('应用半角数字！');strValue.focus();return str=goValue;}
    return str; 
}

function Fgf(str){  
    str = str.replace(/\ /g, "|");  
    str = str.replace(/\　/g, "|");  
    str = str.replace(/\//g, "|");  
    str = str.replace(/\\/g, "|");  
    str = str.replace(/\，/g, "|");  
    str = str.replace(/\,/g, "|");   
    str = str.replace(/\。/g, "|");  
    str = str.replace(/\、/g, "|");   
    str = str.replace(/\./g, "|");
    str = str.replace(/\｜/g, "|"); 
    return str;  
}