
    //切换控件的可视状态
	function setVisibleChange(rsControlName) {
		tblList = document.getElementById(rsControlName);
		if ('' == tblList.style.display) {
			tblList.style.display = 'none';
		} else {
			tblList.style.display = '';
		}
	}

	//切换check的选中状态（当是多个控件时，如果有一个当前为选中状态，则将所有状态置为‘非选中’）
	function setCheckedChange(rsCheckName) {
		var oCheck;

		oCheck = document.all[rsCheckName];
		if (oCheck == '[object]') {
			if(!oCheck.length){
				//单个控件时直接反转其选中状态即可
				oCheck.checked = !oCheck.checked;
				return;
			}
			else{   
				//多控件时，如果有一个当前为选中状态，则将所有状态置为‘非选中’
				for (i=0; i<oCheck.length; i++) {
					//当有一个控件为选中时，则将所有CHECKBOX设为非选中状态
					if (oCheck[i].checked) {
						clearAllChecked(rsCheckName);
						return;
					}
				}
				//多控件时，所有checkbox均为非选中时，设置为选中
				selectAllChecked(rsCheckName);
				return;
			}
		}
	}

	//取消checkbox的选中状态
	function clearAllChecked(rsCheckName){
		var oCheck;

		oCheck = document.all[rsCheckName];
		if (oCheck != '[object]' && oCheck != '[object HTMLCollection]') {
            return;
        }
		if(!oCheck.length){
			oCheck.checked = false;
		}
		else{    
			for (i=0; i<oCheck.length; i++) {
				oCheck[i].checked = false;
			}
		}
	}

	//设置checkbox为选中状态
	function selectAllChecked(rsCheckName){
		var oCheck;

		oCheck = document.all[rsCheckName];
		if (oCheck != '[object]' && oCheck != '[object HTMLCollection]') {
            return;
        }
		if(!oCheck.length){
			oCheck.checked = true;
		}
		else{    
			for (i=0; i<oCheck.length; i++) {
				oCheck[i].checked = true;
			}
		}
	}

	//取Checkbox控件的值,多个同名控件以','分割
	function getValuesWithComma(rsControlName, rbCheck, rsSplit) {
		var oControl;
		var sRtn;
		
		//取选中值还是非选中值
		var bCheck = true; //缺省取选中值
		if (!('undefined' == typeof(rbCheck))) {
			if (!rbCheck) {
				bCheck = false;
			}
		}
		
		//取分隔符
		var sSplit = ','; //缺省分隔符
		if (!('undefined' == typeof(rsSplit))) {
			sSplit = rsSplit;
		}

		sRtn = "";
		oControl = document.getElementsByName(rsControlName);
		if (typeof(oControl) == 'object') {
			if(!oControl.length){
				//单个控件时
				if (oControl.checked && bCheck) {
					sRtn = oControl.value;
				} else if (!oControl.checked && !bCheck) {
					sRtn = oControl.value;
				}
			}
			else{
				//多个同名控件时
				for (i=0; i<oControl.length; i++) {
					//当有控件选中时，取出该控件的值
					if (oControl[i].checked && bCheck) {
						sRtn += oControl[i].value + sSplit;
					} else if (!oControl[i].checked && !bCheck) {
						sRtn += oControl[i].value + sSplit;
					}
				}
				sRtn = sRtn.substr(0, sRtn.length - 1);
			}
		}
		return sRtn;
	}
    
    //定时滚动使用的句柄
    var iHandleInterval;

    /*
    功能：	设置自动滚动
    参数：	sType:滚动类型（upstart向上滚动;downstart向下滚动;leftstart:向左滚动;rightstart向右滚动;）；
            sDivName:Div名称；
            nRecordSpace:记录间隔；
            nInterval:定时滚动的间隔执行时间（缺省为80毫秒）；
            nScrollStep:每次滚动距离（缺省为1px）；
    备注：   左右自动滚动需要设置第一个HTML对象的排列方式为左对齐，比如左右滚动的TABLE需要设置align=left
    返回值： 无
    */
	function setAutoScroll(sType, sDivName, nRecordSpace, nInterval, nScrollStep) {
		sScrollType = sType;
		var divList = document.getElementById(sDivName);

        if(null == divList || 'undefined' == typeof(divList)){
			return;
        }
		if (('undefined' == typeof(divList))) {
			return;
		}
		if (('undefined' == typeof(nInterval))) {
			nInterval = 80
		}
		if (('undefined' == typeof(nScrollStep))) {
			nScrollStep = 1
		}
        
        //设置鼠标移入DIV和移出DIV时触发的事件
        divList.onmouseover=function() {clearInterval(iHandleInterval);} 
        divList.onmouseout=function() {iHandleInterval = setInterval("scrollTimer('" + sDivName + "'," + nScrollStep + ", true, " + nRecordSpace + ")", nInterval);} 

        //自动滚动需要增加后续的滚动内容
        divList.innerHTML = divList.innerHTML + divList.innerHTML;
 		
        //向右和向下滚动需要设置滚动的初始位置
        switch (sType) {
			case "leftstart":	
				break;
			case "upstart":	
				break;
			case "rightstart":
                divList.scrollLeft = nRecordSpace;
				break;
			case "downstart":
                divList.scrollTop = nRecordSpace;
				break;
			default:
				clearInterval(iHandleInterval);
                return;
				break;
		}
        iHandleInterval = setInterval("scrollTimer('" + sDivName + "'," + nScrollStep + ", true, " + nRecordSpace + ")", nInterval);
    }

    /*
    功能：	设置滚动开始或结束
    参数：	sType:滚动类型（upstart:向上滚动开始;upend:向上滚动结束;downstart:向下滚动开始;downend:向下滚动结束）；
            sDivName:Div名称；
            nInterval:定时滚动的间隔执行实际（缺省为30毫秒）；
            nScrollStep:每次滚动距离（缺省为1）；
    返回值： 无
    */
	function setScroll(sType, sDivName, nInterval, nScrollStep) {
		sScrollType = sType;
		var divList = document.getElementById(sDivName);
		if (('undefined' == typeof(divList))) {
			return;
		}
		if (('undefined' == typeof(nInterval))) {
			nInterval = 30
		}
		if (('undefined' == typeof(nScrollStep))) {
			nScrollStep = 1
		}
		switch (sType) {
			case "leftstart":	
				iHandleInterval = setInterval("scrollTimer('" + sDivName + "'," + nScrollStep + ")", nInterval);
				break;
			case "upstart":	
				iHandleInterval = setInterval("scrollTimer('" + sDivName + "'," + nScrollStep + ")", nInterval);
				break;
			case "upend":
				clearInterval(iHandleInterval);
				break;
			case "rightstart":
				iHandleInterval = setInterval("scrollTimer('" + sDivName + "'," + nScrollStep + ")", nInterval);
				break;
			case "downstart":
				iHandleInterval = setInterval("scrollTimer('" + sDivName + "'," + nScrollStep + ")", nInterval);
				break;
			case "downend":
				clearInterval(iHandleInterval);
				break;
			case "end":
				clearInterval(iHandleInterval);
				break;
			default:
				clearInterval(iHandleInterval);
				break;
		}
	}

	//滚动开始或结束（定时器）
	function scrollTimer(sDivName, nScrollStep, bAuto, nRecordSpace) {
		if (('undefined' == typeof(bAuto))) {
			bAuto = false;
		}
		var divList = document.getElementById(sDivName);
		if(null!=divList){
			if (!('undefined' == typeof(divList))) {
				switch (sScrollType) {
					case "leftstart":
						//向左滚动
                		if ( bAuto ) {
                            //自动滚动
                            if (divList.scrollLeft >= nRecordSpace) {
                                divList.scrollLeft = 0;
                            } else {
                                divList.scrollLeft = divList.scrollLeft + nScrollStep;
                            }
                        } else {
    						divList.scrollLeft = divList.scrollLeft - nScrollStep;
                        }
						break;
					case "upstart":
						//向上滚动
                		if ( bAuto ) {
                            //自动滚动
                            if (divList.scrollTop >= nRecordSpace) {
                                divList.scrollTop = 0;
                            } else {
                                divList.scrollTop = divList.scrollTop + nScrollStep;
                            }
                        } else {
    						divList.scrollTop = divList.scrollTop - nScrollStep;
                        }
						break;
					case "upend":
						break;
					case "rightstart":
						//向右滚动
                		if ( bAuto ) {
                            //自动滚动
                            if (divList.scrollLeft <= 0) {
                                divList.scrollLeft = nRecordSpace;
                            } else {
                                divList.scrollLeft = divList.scrollLeft - nScrollStep;
                            }
                        } else {
                            divList.scrollLeft = parseInt(divList.scrollLeft) + nScrollStep;
                        }
						break;
					case "downstart":
						//向下滚动
                		if ( bAuto ) {
                            //自动滚动
                            if (divList.scrollTop <= 0) {
                                divList.scrollTop = nRecordSpace;
                            } else {
                                divList.scrollTop = divList.scrollTop - nScrollStep;
                            }
                        } else {
    						divList.scrollTop = parseInt(divList.scrollTop) + nScrollStep;
                        }
						break;
					case "downend":
						break;
					case "end":
						break;
                    default:
                        break;
				}
			}
		}
	}
    
	function openUserView(nUserID) {
		if (typeof(nUserID) != 'undefined') {
			openLittleBook(nUserID);
		}
	}


	function AllTrim(str) {
        if(str == null || str == "") {
            return "";
        }
		 
        lIdx = 0;
        rIdx = str.length;
        if (AllTrim.arguments.length == 2) {
            act = AllTrim.arguments[1].toLowerCase();
        } else {
            act = "all";
        }
        for(var i=0; i<str.length; i++){
            thelStr = str.substring(lIdx, lIdx + 1);
            therStr = str.substring(rIdx, rIdx - 1);
            if ((act=="all" || act=="left") && thelStr==" "){
                lIdx++;
            }
            if ((act=="all" || act=="right") && therStr==" "){
                rIdx--;
            }
        }
        str = str.slice(lIdx,rIdx);
        return str;
	}

    //字符串超长，截断后尾部加省略号
	/*
	功能：	字符串超长，截断后尾部加省略号
	参数：	sStr: 要处理的字符串；
            nLen: 截取的长度；
            sTail: 截取后在返回字符串后面加省略号
	返回值： 截取的字符串
	*/
    function cutString(sStr, nLen, sTail){
        var value;
        var sChar;
        
        //未指定参数，则设置其缺省值
        if (('undefined' == typeof(nLen)) ) {
            nLen = 0;
        }
        if (('undefined' == typeof(sTail)) ) {
            sTail = " ...";
        }
        
        sRtn = "";
        n = 0;
        for(var i=0;i<sStr.length;i++) {
            sChar = sStr.charAt(i);
            value = String(escape(String(sChar))) ; 
            if(value.length>3) {
                //一个汉字做为两个字符长度处理
                n += 2 ; 
            } else { 
                n += 1 ; 
            }
            sRtn += sChar;
            if ((n + sTail.length >= nLen) && (i != sStr.length-1)) {
                //字符串的长度超过了给定长度
                return sRtn + sTail;
            }
        } 
        return sRtn;
    }
    
    //取字符串长度
    function getStrLen(sStr) { 
        var nLen = 0; 

        for(var i=0;i<sStr.length;i++) {
            var value = String(escape(String(sStr.charAt(i)))) ; 
            if(value.length>3) {
                nLen += 2 ; 
            } else { 
                nLen += 1 ; 
            } 
        } 
        return nLen ; 
    }
    
    //和讯网摘 365Key 天极网摘 都市网摘  YouNote 加加  博采  你好BLOG   天下图摘 我摘 POCO 搜狐 ViVi
    //添加‘网摘代码’
    function outputWebDocLink() { 
        sHtml = "<font style=\"color:#1981DD\">收藏此页到：</font>";
        sHtml += "<a title=\"功能强大的网络收藏夹，一秒钟操作就可以轻松实现保存带来的价值、分享带来的快乐\" href=\"javascript:t=document.title;u=location.href;e=document.selection?(document.selection.type!='None'?document.selection.createRange().text:''):(document.getSelection?document.getSelection():'');void(open('http://bookmark.hexun.com/post.aspx?title='+escape(t)+'&url='+escape(u)+'&excerpt='+escape(e),'HexunBookmark','scrollbars=no,width=600,height=450,left=80,top=80,status=no,resizable=yes'));\"><font style=\"color:#1981DD\">[和讯]</font></a>";
        sHtml += "<a title=\"功能强大的网络收藏夹，一秒钟操作就可以轻松实现保存带来的价值、分享带来的快乐\" href=\"javascript:d=document;t=d.selection?(d.selection.type!='None'?d.selection.createRange().text:''):(d.getSelection?d.getSelection():'');void(keyit=window.open('http://www.365key.com/storeit.aspx?t='+escape(d.title)+'&u='+escape(d.location.href)+'&c='+escape(t),'keyit','scrollbars=no,width=475,height=575,left=75,top=20,status=no,resizable=yes'));keyit.focus();\"><font style=\"color:#1981DD\">[365Key]</font></a>";
        sHtml += "<a title=\"功能强大的网络收藏夹，一秒钟操作就可以轻松实现保存带来的价值、分享带来的快乐\" href=\"javascript:d=document;t=d.selection?(d.selection.type!='None'?d.selection.createRange().text:''):(d.getSelection?d.getSelection():'');void(yesky=window.open('http://hot.yesky.com/dp.aspx?t='+escape(d.title)+'&u='+escape(d.location.href)+'&c='+escape(t)+'&st=2','yesky','scrollbars=no,width=400,height=480,left=75,top=20,status=no,resizable=yes'));yesky.focus();\"><font style=\"color:#1981DD\">[天极]</font></a>";
        sHtml += "<a title=\"功能强大的网络收藏夹，一秒钟操作就可以轻松实现保存带来的价值、分享带来的快乐\" href=\"javascript:d=document;t=d.selection?(d.selection.type!='None'?d.selection.createRange().text:''):(d.getSelection?d.getSelection():'');void(postkey=window.open('http://key.zj.com/member/store.cgi?t='+escape(d.title)+'&u='+escape(d.location.href)+'&c='+escape(t),'postkey','scrollbars=no,width=548,height=420,left=80,top=80,status=no,resizable=no'));postkey.focus();\"><font style=\"color:#1981DD\">[都市]</font></a>";
        sHtml += "<a title=\"功能强大的网络收藏夹，一秒钟操作就可以轻松实现保存带来的价值、分享带来的快乐\" href=\"javascript:d=document;t=d.selection?(d.selection.type!='None'?d.selection.createRange().text:''):(d.getSelection?d.getSelection():'');void(keyit=window.open('http://www.younote.com/Noteit.aspx?t='+escape(d.title)+'&u='+escape(d.location.href)+'&c='+escape(t),'keyit','scrollbars=no,width=475,height=575,left=75,top=20,status=no,resizable=yes'));keyit.focus();\"><font style=\"color:#1981DD\">[YouNote]</font></a>";
        sHtml += "<a title=\"将此文加入博客中国博采\" href=\"javascript:d=document;t=d.selection?(d.selection.type!='None'?d.selection.createRange().text:''):(d.getSelection?d.getSelection():'');void(keyit=window.open('http://blogmark.blogchina.com/jsp/key/quickaddkey.jsp?k='+encodeURI(d.title)+'&u='+encodeURI(d.location.href)+'&c='+encodeURI(t),'keyit','scrollbars=no,width=500,height=430,status=no,resizable=yes'));keyit.focus();\"><font style=\"color:#1981DD\">[博采]</font></a>";
        sHtml += "<a title=\"将此文加入天下图摘\" href=\"javascript:d=document;t=d.selection?(d.selection.type!='None'?d.selection.createRange().text:''):(d.getSelection?d.getSelection():'');void(keyit=window.open('http://www.cn3.cn/user/addurl.asp?t='+escape(d.title)+'&u='+escape(d.location.href)+'&c='+escape(t),'keyit','scrollbars=no,width=490,height=450,left=120,top=50,status=no,resizable=yes'));keyit.focus();\"><font style=\"color:#1981DD\">[天下图摘]</font></a>";
        sHtml += "<a title=\"将此文加入我摘\" href=\"javascript:d=document;t=d.selection?(d.selection.type!='None'?d.selection.createRange().text:''):(d.getSelection?d.getSelection():'');void(vivi=window.open('http://my.poco.cn/fav/storeIt.php?t='+escape(d.title)+'&u='+escape(d.location.href)+'&c='+escape(t),'_blank','scrollbars=no,width=475,height=575,left=75,top=20,status=no,resizable=yes'));\"><font style=\"color:#1981DD\">[POCO]</font></a>";
        sHtml += "<a title=\"将此文加入搜狐\" href=\"javascript:d=document;t=d.selection?(d.selection.type!='None'?d.selection.createRange().text:''):(d.getSelection?d.getSelection():'');void(keyit=window.open('http://z.sohu.com/storeit.do?t='+escape(d.title)+'&u='+escape(d.location.href)+'&c='+escape(t),'keyit','scrollbars=no,width=475,height=575,left=75,top=20,status=no,resizable=yes'));keyit.focus();\"><font style=\"color:#1981DD\">[狐摘]</font></a>";
        sHtml += "<a title=\"将此文加入新浪vivi\" href=\"javascript:d=document;t=d.selection?(d.selection.type!='None'?d.selection.createRange().text:''):(d.getSelection?d.getSelection():'');void(vivi=window.open('http://vivi.sina.com.cn/collect/icollect.php?pid=2008&title='+escape(d.title)+'&url='+escape(d.location.href)+'&desc='+escape(t),'vivi','scrollbars=no,width=480,height=480,left=75,top=20,status=no,resizable=yes'));vivi.focus();\"><font style=\"color:#1981DD\">[vivi]</font></a>";
        sHtml += "";
        document.write(sHtml);
    }

    function ShowTitle(objCut, strName){
        var objTitle = document.getElementById(strName);
        if ((objCut.offsetWidth-15)<objTitle.offsetWidth){
        	if (isIE) {
                objCut.title = objTitle.innerText;
            } else {
                objCut.title = objTitle.textContent;
            }
        }else{
            objCut.title = '';
        }
    }

//---------------翁世梁-------------------------------------------
	/*功能，多选项设置全选，不选，反选功能
	  参数:obj,strAct
	  strAct:
		select:全选
		clear:全 不选
		reverse:反选
	 返回值：用,分割的obj对应值的字符串
	  使用例子：
		ResetCheckBox(document.delSoho.id,'select')
	*/

	function ResetCheckBox(obj, strAct){
		if (null == obj) {
			return false;
		}
		var values = '';
		if(obj.length > 0) {  //checkbox is array
			//set status one by one
			var eval_str = '';
			switch (strAct){
				case 'select':
					eval_str = ' if(obj[i].disabled==false){ obj[i].checked = true; } ';
					break;
				case 'clear':
					eval_str = ' if(obj[i].disabled==false){ obj[i].checked = false; } ';
					break;
				case 'reverse':
					eval_str = ' if(obj[i].disabled==false){ if(obj[i].checked==true){ obj[i].checked = false; }else{ obj[i].checked = true;} } ';
					break;
			}
			if (eval_str!=''){ eval('for(var i=0; i<obj.length; i++){'+eval_str+'}'); }
			//get values
			var array_id =new Array();
			var j = 0;
			for(var i=0; i<obj.length; i++) {
				if(obj[i].checked) {
					array_id[j] = obj[i].value;
					j++;
				}
			}
			values = array_id.join(',');
		}else if(obj.disabled==false) {  //checkbox is a single element
			switch (strAct){
				case 'select':
					obj.checked = true;
					break;
				case 'clear':
					obj.checked = false;
					break;
				case 'reverse':
					if(obj.checked==true){ obj.checked = false; }else{ obj.checked = true; }
					break;
			}
			if (obj.checked==true){
				values = obj.value;
			}else{
				values = '';
			}
		}
		return values;
	}
	/*
	功能: 获取ID的值，并且用各个ID用相应的字符隔开
	参数：ID对象
	*/
	function getIdValueStr(obj){
		var values = '';
		if(obj.length>0){
			var array_id =new Array();
			var j = 0;
			for(var i=0; i<obj.length; i++) {
				if(obj[i].checked) {
					array_id[j] = obj[i].value;
					j++;
				}
			}
			values = array_id.join(',');
		}else if(obj.disabled==false) {  //checkbox is a single element
			if (obj.checked==true){
				values = obj.value;
			}else{
				values = '';
			}
		}
		return values;
	}

//以下函数从原有系统中的utils.js中拷贝而来-------------------------------------------------------
    //检查输入的数据类型
    
    function checkPositiveInteger(pint1)
    {
        pint1 += ""
        return checkInteger(pint1) && pint1.indexOf('-')==-1
    }

    function checkInteger(int1) 
    {
        int1 += ""
        return checkFloat(int1+"") && Math.floor(int1)==int1 && int1.indexOf(".")==-1
    }

    // These function will check number format, 
    // note it will exclude numbers in special format ,
    // for example: 4.5E6
    function checkFloat(float1) 
    {
        regExp1  = /[^-?\d\.]/
        regExp2 = /^-?\.\d*$/
        regExp3 = /^-?\d*\.$/
        if(isNaN(float1) ||
            regExp1.exec(float1) ||
            regExp2.exec(float1) ||
            regExp3.exec(float1))
            return false
        return true
        
    }
//----------------------------------------------------------------------------------------------


function getImageObject(url){
	var objimg = new Image();
	objimg.src = url;
	return objimg;
}

function popImage(strUrl){
	var oImg = getImageObject(strUrl);
	var imgWidth = oImg.width;
	var imgHeight = oImg.height;
	var maxWidth = window.screen.availWidth;
	var maxHeight = window.screen.availHeight;
	var winWidth, winHeight, winStr = 'scrollbars=yes';
	if(imgWidth > (maxWidth-4) && imgHeight > (maxHeight-4)){
		winWidth = maxWidth + 20 - 4;
		winHeight = maxHeight + 15 - 4;
	}else if (imgWidth>(maxWidth - 4)){
		winHeight = imgHeight + 15 - 4;
		winWidth = maxWidth - 4;
	}else if(imgHeight>(maxHeight - 4)){
		winHeight=maxHeight - 4;
		winWidth=imgWidth + 20 - 4;
	}else{
		winWidth = imgWidth;
		winHeight = imgHeight;
		winStr = 'scrollbars=no';
	}
	winStr += ',toolbar=no,location=no,directories=no,status=no,menubar=no,resizable=0,left=0,top=0,width='+winWidth+',height='+winHeight;
	var imgWin = window.open('about:blank','',winStr);
	with (imgWin.document){
		writeln('<html><head><title>中国缘 -- 图片浏览</title><style>body{margin:0px; padding:0px; border:0px none;}</style>');
		writeln('</head><body bgcolor="#D4D0C8" onload="self.focus()">');
		writeln('<table border="0" cellspacing="0" cellpadding="0" width="100%" height="100%"><tr><td align="center">');
		writeln('<img id="DersonImage" name="DersonImage" src="'+strUrl+'" style="margin:0px; padding:0px; border:0px none;display:block">');
		writeln('</td></tr></table></body></html>');
		close();
	}
}

/* Arg1: image object; Arg2: image width resize to; Arg3: image height resize to; */
function resizeImg(){
    var aArg = resizeImg.arguments;  
    var nArg = aArg.length;
    if (nArg == 0){ return; }
    
    var objImage = aArg[0];
    var objTmpImage = getImageObject(objImage.src);
    var nOldWidth = objTmpImage.width;
    var nOldHeight = objTmpImage.height;
    if(nOldWidth == 0 || nOldHeight == 0){ return; }

    if(nArg > 1){
        nNewWidth = parseInt(aArg[1]);
    }else{
        nNewWidth = objImage.width;
    }
    if(nArg > 2){
        nNewHeight = parseInt(aArg[2]);
    }else{
        nNewHeight = objImage.height;
    }
    var nTmpWidth = nOldWidth * nNewHeight / nOldHeight;
    var nTmpHeight = nOldHeight * nNewWidth / nOldWidth;

    if(nNewWidth == 0){
        nNewWidth = nTmpWidth;
    }
    if(nNewHeight == 0){
        nNewHeight = nTmpHeight;
    }
    if(nOldWidth > nNewWidth){
        if(nOldHeight > nNewHeight){
            if ((nOldWidth / nOldHeight) > (nNewWidth / nNewHeight)){
                nNewHeight = nTmpHeight;
            }else{
                nNewWidth = nTmpWidth;
            }
        }else{
            nNewHeight = nTmpHeight;
        }
    }else{
        if(nOldHeight > nNewHeight){
            nNewWidth = nTmpWidth;
        }else{
            if(nArg >3){
                var enlarge = aArg[3];
            }else{
                var enlarge = false;
            }
            if(enlarge){
                if((nOldWidth / nOldHeight) > (nNewWidth / nNewHeight)){
                    nNewHeight = nTmpHeight;
                }else{
                    nNewWidth = nTmpWidth;
                }
            }else{
                nNewWidth = nOldWidth;
                nNewHeight = nOldHeight;
            }
        }
    }
    objImage.width = Math.round(nNewWidth);
    objImage.height = Math.round(nNewHeight);
}

//alt 显示图片的文件大小和原始尺寸信息
function getImgInfo(strURL){
    var objTmpImage = getImageObject(strURL);
    var nOldWidth = objTmpImage.width;
    var nOldHeight = objTmpImage.height;
    var nOldSize = objTmpImage.fileSize;
    if(nOldSize>0){
        var sImgBytes = FormatNumber(Math.ceil(nOldSize), 0, 0, 0, -1) + ' 字节';
    }else {
        var sImgBytes = '（未知）';
    }
    var sRtn = '文件大小：' + sImgBytes + '\n实际尺寸：' + nOldWidth + '×' + nOldHeight + ' 像素';
    return sRtn;
}

//	
//	参数 : emails  ,可以使 email 串 ,或者是 text 控件
//		   nLimitEmailNum 限制 email 数量 -1,缺省 代表 不限制
//				
function checkEmail(emails,nLimitEmailNum){
	var sEmails = "";
	var sEmail = "";
	var nCount = 0;
	var array_id =new Array();
	
	//	判断 emails 参数是否合法
	if ('undefined' == typeof(emails)) {
		alert("email 检测函数的参数没有定义!");
		return -1;
	}
	//  判断 nLimitEmailNum 值
	//	没定义或者小于0 则 nLimitEmailNum = -1;
	//	其他不变
	if ('undefined' == typeof(nLimitEmailNum)) {
		nLimitEmailNum = -1;
	}

	//判断 emails 是对象还是字符串
	if("string"==typeof(emails)){
		sEmails = emails;
	}else if("object"==typeof(emails)){
		sEmails = emails.value;
	}
	
	aEmails = sEmails.split(",");
	nCount = aEmails.length;
	if(-1 != nLimitEmailNum && nCount > nLimitEmailNum){
		alert("你设置的 email 数量超过了 " + nLimitEmailNum + " 个!");
		return -1;
	}
	for(var i =0 ; i < nCount ; i++){
		sEmail = aEmails[i];
		if(!isEmail(sEmail)){
			var sMsg = "";
			if(""==sEmail){
				sMsg = "严格的要求使用1个 ',' 分隔 Email!";
				sMsg = sMsg + "\n";
				sMsg = sMsg + "前后没有 Email 请不要使用 ',' ";
			}else{
				sMsg = "< " + sEmail + " > ";
				sMsg = sMsg + "\n";
				sMsg = sMsg + "不是合法的 Emial 格式!";
			}
			alert(sMsg);
			return -1;
		}
	}
	return nCount;
}

function isEmail(regexpValue){
	if ('undefined' == typeof(regexpValue)) {
		return false;
	}
	var email_regexp=/^[^\s].*@(\w*\-*\w*)+\.\w+/;
	var get_data = regexpValue;
	var result=get_data.match(email_regexp);
	if(result!=null){
		if(!get_data.match(/.*@.*@.*/))
			return true;
		return false;
	}
	return false;
}

//从本机导入EMAIL（需要定义非IE浏览器的接口函数：setEmailList(sMail)，其中sMail为选中的MAIL地址）
//ie浏览器直接返回选中的MAIL地址
function importMail() { 
	var sUrl = 'http://www.' + CC_DOMAIN + '/php/common/com_import_mail_load.php';
	if (isIE) {
		//IE时用模态框的方式打开
		var sParam = "";
		var sProperty = "dialogWidth:608px; dialogHeight:320px";
		var oRet = window.showModalDialog(sUrl, sParam, sProperty);
		if(null != oRet && "string" == typeof(oRet)) {
			sRtn = oRet;
		} else {
			sRtn = "";
		}
	} else {
		var sWinName = "importMail";
		var sProperty = "toolbar=no,location=no,width=608px,height=320px,scrollbars=no";
		var oWin = window.open(sUrl, sWinName, sProperty);
		if (!oWin.opener ) {
			oWin.opener = window ;
		}
		oWin.focus();
		sRtn = "";
	}
	return sRtn;
}

//导入一级好友
//需要在窗口中定义接口函数：setFriendList(sFriend)，其中sFriend为选中的好友名称）
function importFriend() { 
	var sUrl = 'http://www.' + CC_DOMAIN + '/php/common/com_import_friend.php';
	/*if (isIE) {
		var sParam = "";
		var sProperty = "dialogWidth:608px; dialogHeight:470px";
		var oRet = window.showModalDialog(sUrl, sParam, sProperty);
		if(null != oRet && "string" == typeof(oRet)) {
			sRtn = oRet;
		} else {
			sRtn = "";
		}
	} else {//*/
		var sWinName = "importFriend";
		var sProperty = "toolbar=no,location=no,width=608px,height=600px,scrollbars=yes";
		var oWin = window.open(sUrl, sWinName, sProperty);
		if (!oWin.opener ) {
			oWin.opener = window ;
		}
		oWin.focus();
		sRtn = "";
	//}
	return sRtn;
}

/* the following function copied from:
   http://www.4guysfromrolla.com/webtech/code/FormatNumber.shtml
*/
function FormatNumber(num,decimalNum,bolLeadingZero,bolParens,bolCommas)
/**********************************************************************
	IN:
		NUM - the number to format
		decimalNum - the number of decimal places to format the number to
		bolLeadingZero - true / false - display a leading zero for
										numbers between -1 and 1
		bolParens - true / false - use parenthesis around negative numbers
		bolCommas - put commas as number separators.
 
	RETVAL:
		The formatted number!
 **********************************************************************/
{ 
        if (isNaN(parseInt(num))) return 'NaN';

	var tmpNum = num;
	var iSign = num < 0 ? -1 : 1;		// Get sign of number
	
	// Adjust number so only the specified number of numbers after
	// the decimal point are shown.
	tmpNum *= Math.pow(10,decimalNum);
	tmpNum = Math.round(Math.abs(tmpNum))
	tmpNum /= Math.pow(10,decimalNum);
	tmpNum *= iSign;					// Readjust for sign
	
	
	// Create a string object to do our formatting on
	var tmpNumStr = new String(tmpNum);

	// See if we need to strip out the leading zero or not.
	if (!bolLeadingZero && num < 1 && num > -1 && num != 0)
		if (num > 0)
			tmpNumStr = tmpNumStr.substring(1,tmpNumStr.length);
		else
			tmpNumStr = '-' + tmpNumStr.substring(2,tmpNumStr.length);
		
	// See if we need to put in the commas
	if (bolCommas && (num >= 1000 || num <= -1000)) {
		var iStart = tmpNumStr.indexOf('.');
		if (iStart < 0)
			iStart = tmpNumStr.length;

		iStart -= 3;
		while (iStart >= 1) {
			tmpNumStr = tmpNumStr.substring(0,iStart) + ',' + tmpNumStr.substring(iStart,tmpNumStr.length)
			iStart -= 3;
		}		
	}

	// See if we need to use parenthesis
	if (bolParens && num < 0)
		tmpNumStr = '(' + tmpNumStr.substring(1,tmpNumStr.length) + ')';

	return tmpNumStr;		// Return our formatted string!
}

//弹出小窗口
function popupSmallWindow(){
    var aArg = popupSmallWindow.arguments;
    var nArg = aArg.length;
    if(nArg == 0){ return false; }

    var sUrl = aArg[0];
    if(nArg > 1){
        nWidth = aArg[1];
        if(nWidth > screen.availWidth){
            nWidth = screen.availWidth;
        }
    }else{
        nWidth = 480;
    }
    if(nArg > 2){
        nHeight = aArg[2];
        if(nHeight > screen.availHeight){
            nHeight = screen.availHeight;
        }
    }else{
        nHeight = 360;
    }

    nLeft = Math.ceil((screen.width - nWidth)/2);
    if(nLeft < 0){ nLeft = 0; }

    nTop = Math.ceil((screen.height - nHeight)/2);
    if(nTop < 0){ nTop = 0; }

    if(isIE){
        sProperties = 'dialogTop:'+nTop+'px;';
        sProperties += 'dialogLeft:'+nLeft+'px;';
        sProperties += 'dialogWidth:'+nWidth+'px;';
        sProperties += 'dialogHeight:'+nHeight+'px;';
        sProperties += 'help:no; resizable:no; scroll:yes; status:no';
        window.showModalDialog(sUrl, window, sProperties);
    }else{
        sProperties = 'top='+nTop+',';
        sProperties += 'left='+nLeft+',';
        sProperties += 'width='+nWidth+',';
        sProperties += 'height='+nHeight+',';
        sProperties += 'menubar=no, toolbar=no, resizable=no, scrollbars=yes, status=no';
        objWindow = window.open(sUrl, '', sProperties);
        objWindow.focus();
    }
}

//显示弹出信息
function popupMessage(sMessage){
    /*
    if(isIE){
        nWidth = 100;
        nHeight = Math.ceil((getStrLen(sMessage)*12) /nWidth);
        sProperties = 'center:yes; help:no; resizable:no; scroll:no; status:no';
        sProperties += 'dialogWidth:'+nWidth+'px;';
        sProperties += 'dialogHeight:'+nHeight+'px;';
        window.showModelessDialog('/common/inModalDialog.html', sMessage, sProperties);
        window.alert(sMessage);
    }else{
        window.alert(sMessage);
    }
    */
    window.alert(sMessage);
}

function inArray(rnID, raArray) {
    for(var i=0; i<raArray.length; i++) {
        if(rnID==raArray[i]) {
            return true;
        }
    }
	return false;
}

//会员登录时间的描述
function showLoginTimeDesc(rnTime){

}
