﻿<!--
var navString = window.navigator.userAgent.toLowerCase();
isIE = (navString.indexOf("msie") != -1);

//********************************************************//
//根据Ｉｄ得到对象
//********************************************************//
function $(element)
{
	if(typeof element == 'string')
		return document.getElementById(element) || document.all(element) || document.forms(0).all(element);
	else
		return null;
}

function ValObj(obj)
{
	if (isNaN(obj))return false;
	if (typeof obj == 'object')
		return true;
	else
		return false;
}

//********************************************************//
//根据Name得到对象
//********************************************************//
function $Name(ele)
{
	if(typeof ele == 'string')
		return document.getElementsByName(ele);
	else
		return ele;
}

//********************************************************//
//得到表单对象
//********************************************************//
function GetFormElement(formid)
{
	var formObj = document.forms[0];
	for(var i=0;i<formObj.elements.length;i++)
	{
		var e = formObj.elements[i];
		if(e.id.indexOf(formid)!=-1)
			return e;
	}
}

//********************************************************//
//是否为数字
//********************************************************//
function IsNumeric(val)
{
	var re=new RegExp("^[0-9]+$");
	if (val.toString().match(re))
		return true;
	else
		return false;
}

//********************************************************//
//查看是否为空值
//********************************************************//
function IsNullOrEmpty(val) {
	if ( val== "" || val == null)
		return true;
	else return false;
}

//********************************************************//
//得到文本的总字符数一个汉字为两个字符
//********************************************************//
function GetLength(str)
{
	return str.replace(/[^\x00-\xff]/g,"**").length;
}

//********************************************************//
//得到坐标
//********************************************************//
function getposOffset(what, offsettype)
{
  var totaloffset=(offsettype=="left")? what.offsetLeft : what.offsetTop;
  var parentEl=what.offsetParent;
  while (parentEl!=null)
  {
    totaloffset=(offsettype=="left")? totaloffset+parentEl.offsetLeft : totaloffset+parentEl.offsetTop;
    parentEl=parentEl.offsetParent;
  }
  return totaloffset;
}

//********************************************************//
//复制地址
//********************************************************//
function CopyUrl()
{
	if (isIE)
	{
		window.clipboardData.setData("Text",thisUrl);
		window.alert( '本帖地址已复制到剪贴板，您可按下 Ctrl+V 在任何软件如：QQ、MSN中进行粘贴发送给好友');
	}
	else
	{
		alert("请用Ctrl+C将本帖地址复制到剪贴板");
	}
}

function WindowReload(){window.location.reload();}
//********************************************************//
//验证Url是否存在
//********************************************************//
function IsExistUrl(sURL) 
{
  var xmlHttp;
  if (window.ActiveXObject){
      xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
  }else{
      xmlHttp=new XMLHttpRequest();
  }
  xmlHttp.open("GET", sURL, true);
	xmlHttp.onreadystatechange=function() {
  if (xmlHttp.readyState==4) {
		alert(xmlHttp.status);
      if (xmlHttp.status==200)
          return true;
      else if (xmlHttp.status==404)
          return false;
      else if (xmlHttp.status==500)
				return false;
	  else
				return false;
  }
  }
  xmlHttp.send();
}

String.prototype.trim=Trim;  //去除前后空白的值
String.prototype.ltrim=Ltrim;  //去除左边空白的值
String.prototype.rtrim=Rtrim;  //去除右边空白的值
function Trim() { return this.replace(/^\s+|\s+$/g, "");}
function Ltrim() {return this.replace(/(^\s*)/g, "");}
function Rtrim() { return this.replace(/(\s*$)/g, "");}

//-->