function Is() {
    var agent = navigator.userAgent.toLowerCase();
    this.major = parseInt(navigator.appVersion);
    this.minor = parseFloat(navigator.appVersion);
    this.ns  = ((agent.indexOf('mozilla')!=-1) && ((agent.indexOf('spoofer')==-1) && (agent.indexOf('compatible') == -1)));
    this.ns2 = (this.ns && (this.major == 2));
    this.ns3 = (this.ns && (this.major == 3));
    this.ns4b = (this.ns && (this.minor < 4.04));
    this.ns4 = (this.ns && (this.major >= 4));
    this.ie   = (agent.indexOf("msie") != -1);
    this.ie3  = (this.ie && (this.major == 2));
    this.ie4  = (this.ie && (this.major >= 4));
    this.op3 = (agent.indexOf("opera") != -1);
    this.win   = (agent.indexOf("win")!=-1);
    this.mac   = (agent.indexOf("mac")!=-1);
    this.unix  = (agent.indexOf("x11")!=-1);
}

var is = new Is();

  function getCookie(name) { // use: getCookie("name");
    var cook_multi = document.cookie;
	var index = cook_multi.indexOf(name + "=");
    if (index == -1) return null;
    index = cook_multi.indexOf("=", index) + 1;
    var endstr = cook_multi.indexOf(";", index);
    if (endstr == -1) endstr = cook_multi.length;

	return unescape(cook_multi.substring(index, endstr));
  }

  var today = new Date();
  var expiry = new Date(today.getTime() + 28 * 24 * 60 * 60 * 1000);

  function setCookie(name,value,path) {
    if (value != null && value != "")
      document.cookie=name+"=" + escape (value) +((path)?";path=" + path:"");
      //document.cookie=name + "=" + escape(value) //+"; path=/"	//+"; expires=" + expiry.toGMTString();
  }

  function deleteCookie(name,path)
  {
	expiryDate=new Date(today.getTime() - 28 * 24 * 60 * 60 * 1);
	document.cookie=name+"=" + ((path)?";path=" + path:""+";expires="+expiryDate.toGMTString());
  }

function _setCookie (name,value,path,domain,secure) {
	//document.cookie=name+"=" + escape (value) +((expires)?";expires="+expires.toGMTString():"") +((path)?";path=" + path:"") +((domain)?"; domain="+ domain:"") +((secure)?";secure":"");
	document.cookie=name+"=" + escape (value) +";expires="+expiry.toGMTString() +((path)?";path=" + path:"/") +((domain)?"; domain="+ domain:"http://sqlsrv") // +((secure)?";secure":"");
	
}

  function blankArray(len) { // create blank array
    for (var i=0; i < len; i++)
      this[i] = "";
    this.length = len;
  }

  function defineCookie(arr_name,newData) { // convert array to string separated by '!'
    userData = newData[0];
    for (var i=1; i < newData.length; i++)
      userData += "!" + newData[i];
    setCookie(arr_name, userData);
    //history.go(0);
  }

// DEFINITIONS
// data[0] = bgcolour; data[1] = userName; data[2] = headCount;
// userData = data[0]+ "!" + data[1] + "!" + data[2];

  var userData = getCookie("userData") || "white!Visitor!1";

// Count number of cookie variables
  var numVars = 1;
  var start = userData.indexOf("!") + 1;
  while (start != 0 && start < userData.length) {
    numVars++;
    start = userData.indexOf("!", start) + 1;
  }

// Initialise array and retrieve values
  var data = new blankArray(numVars);
  for (var i=0, start=0; i < data.length; i++) {
    var end = userData.indexOf("!", start);
    if (end == -1) end = userData.length;
    data[i] = userData.substring(start, end); // store value in array
    start = end + 1;
  }
  
function popUpWin(url,w,h,l_bol_scroll,bStatus,sWinName) {
	var iwidth=w, iheight=h,a,b
	var screen_width=screen.width,screen_height=screen.height;
	//center the window
	a=(screen_width-w)/2
		b=(screen_height-h)/2      

	if (null==l_bol_scroll) l_bol_scroll=0
	if (null==bStatus) bStatus=1

		
	window.open(url,sWinName,'top='+b+',left='+a+',toolbar=0,location=0,directories=0,status='+bStatus+',menubar=0,scrollbars='+l_bol_scroll+',resizable=1,width='+(iwidth)+',height='+(iheight));
  return false;
}  

function stripTag(strHTML,strType){
  var arysplit, i, j, strOutput,strTagContent="",strTag,strClass
  if(1==strType){
	strTag="b"
	strClass="news_title"
  }
  else{
	strTag="P"	
	strClass="news_content"
  }

  arysplit=strHTML.split("<")
 
  if(arysplit.length > 0)
	j = 1
  else 
	j = 0

  //Loop through each instance of the array
  for(i=j;i<arysplit.length;i++){
     //Do we find a matching > sign?
     if(findIt(arysplit[i], ">")){
       //If so, snip out all the text between the start of the string
       //and the > sign
	   if(findIt(arysplit[i],strClass)) strTagContent=strTagContent+"<"+strTag+">"+arysplit[i].substr(locateIt(arysplit[i], ">") + 1)+"</"+strTag+">"
       arysplit[i]=arysplit[i].substr(locateIt(arysplit[i], ">") + 1)
     }
     else
       //Ah, the < was was nonmatching
       arysplit[i] = "<" + arysplit[i]
  }

  return strTagContent
}

function findIt(str1,str2) {
	var re = new RegExp(str2)
	var input = str1
	if (input.search(re) != -1) {
		return true
	}else{
		return false
	}
}

function locateIt(str1,str2) {
	var re = new RegExp(str2)
	var input = str1
	return input.search(re)
}

function getSoHuADClick(obj){
	if (is.ie){
		if(event.offsetY>27){
			setCookie("SoHuADClick",1,"/");	
		}
	}
}

function setMail(sWho,sAt,sTxt){
	if(null==sTxt) sTxt=sWho+'@'+sAt
	document.write('<a href="mail'+'to:'+sWho+'@'+sAt+'" class="eng">'+sTxt+'</a>')
}

function isBig5()
{
  var isBig5Version=(window.location.href.indexOf('8080')<0)
  if (isBig5Version)
  {
    return true;
  }
  else
  {
    return false;
  }
}

function countWord(obj)
{
  var nWord=document.getElementById("WordCount")
  nWord.innerText="已输入字数:"+obj.value.length
}

function deleteRecord(url)
{
  if (confirm("确认删除记录吗？"))
  {
     window.location=url;
	 return false;
  }
  else
  {
     return false;
  }
}

function initSelectBox(obj,sTxt)
{
  obj.value=sTxt;
}

function setRichContent(sTarget)
{
  var oNewsForm=document.forms[0]
  var oTxt=eval("oNewsForm."+sTarget)
  var oDoc=oNewsForm.doc_html
  oTxt.value=oDoc.value
}

function getRichContent(sTarget)
{
  var oNewsForm=document.forms[0]
  var oTxt=eval("oNewsForm."+sTarget)
  var oDoc=oNewsForm.doc_html
  oDoc.value=oTxt.value
}

function isEmpty(el)
{
  return eval("document.forms[0]."+el+".value.replace(/ /ig,'').length==0");
}