   var _notify = new Array();
   var _nofify_exp=5000;
   var _error = new Array();

  /*
   *  方法:Array.remove(dx)
   *  功能:删除数组元素.
   *  参数:dx删除元素值.
   *  返回:在原数组上修改数组.
   */
   Array.prototype.remove = function(obj){
	   for ( var i=0 ; i < this.length ;i++){
	        if ( this[i] == obj )
	        {
	            this.splice(i, 1); 
	            break;
	        }
	    }
	}
  function escapeHTML(content){
    if(content && content!= ''){
    	content =  content.replace(/<(.*?)>/g, "");
    }
  	return content;
  }

   /**
     _ele: <sleect> id;
     data: 数组对象
     _value : option value
     _text: option text
   **/
   function addOptions( _ele, data,_value,_text,defaultSelected){
     var ele = document.getElementById(_ele);
     if(ele && ele!=null){
       if (navigator.appName.indexOf("Microsoft") != -1) {
 	      for (var i = 0; i < data.length; i++) {
	        value = data[i][_value];
	        ele.options[ele.options.length] = new Option(data[i][_text], value);
	   	  }
	   	  if(defaultSelected){
			  for (var i=0; i<ele.options.length; i++){
				  if(ele.options[i].value==defaultSelected){
				      ele.options[i].selected = true;
				      break;
				   }
			  }
		  }
       }else{
	      for (var i = 0; i < data.length; i++) {
	           value = data[i][_value];
	           if(defaultSelected && value==defaultSelected){
	           	ele.options[ele.options.length] = new Option(data[i][_text], value, true);
	           }else{
	   		 	ele.options[ele.options.length] = new Option(data[i][_text], value);
	   		   }
	   	  }
       }
    }
  } 
 
 
/**edit by terry**/
function getUserManageDiv(id,url){
    showLoading();
    url += (url.indexOf("?")==-1?"?":"&") + "timestamp=" + new Date().getTime();
	new Ajax.Request(url, {
	  method: 'get',
	  onSuccess: function(transport) {
	     hiddenLoading();
	     document.getElementById(id).innerHTML =transport.responseText;
	  }
	
	});
}


function getHtmlByAjax(id,url,pars){
        document.getElementById(id).innerHTML ='<img src="../images/progress.gif" />';
        var myAjax = new Ajax.Updater( 
        id, 
        url, { 
	        method: 'get', 
	        parameters: pars,
	        onFailure: reportError
         });
}
	
function reportError(request){
alert('Sorry. There was an error.');
}	
	
function getHtmlByAjaxAndScrollTop(id,url,pars){
		document.getElementById(id).innerHTML ='<img src="../images/progress.gif" />';
        var myAjax = new Ajax.Updater( 
        id, 
        url, { 
	        method: 'get', 
	        parameters: pars
	        
         });
        window.scrollTo(1,80);
}

function showLoading(){
        var loadingBoxId= document.getElementById('loadingBox');
        if (loadingBoxId && loadingBoxId != null) {
        		loadingBoxId.style.display='';
        		hiddenAllBox();
        }
}
function hiddenLoading(){
        var loadingBoxId= document.getElementById('loadingBox');
        if (loadingBoxId && loadingBoxId != null) {
        		loadingBoxId.style.display='none';
        }
}

function logOut(contextPath){
    url = contextPath +"/web/logout?timestamp=" + new Date().getTime();
	new Ajax.Request(url, {
	  method: 'get',
	  onSuccess: function(transport) {
	     window.location.href='/';
	  }
	});
    //UserMain.logOut(responseLogOut);
}




function hiddenAllBox(){
    box1="successBox";
    box2="errorsBox";
    if(box1 && box1!=null){
    	if(document.getElementById(box1) &&  document.getElementById(box1) != null){
    	document.getElementById(box1).style.display='none';
    	}
    }
    if(box2 && box2!=null){
    	if(document.getElementById(box2) &&  document.getElementById(box2) != null){
    	document.getElementById(box2).style.display='none';
    	}
    }
}

   /**
   * Handle infomation messages.
   * @param  messages.
   */
  function jcv_handleMsg(messages) {
 	  //hiddenErrorsBox();
  	   hiddenLoading();
  	   	$('notification').show();
  	   	/*
		var d = new Date();
	    var t =d.getUTCMilliseconds();
		_notify.push(t);
		*/
	    var div ='<div  class="entry notify">'+messages+'</div>';
	    $('notification').update(div);
		//var ff = new Insertion.Top('notification', div);
		// keep the height of doc
		$('notification').setStyle({'height':$('notification').getHeight() + 'px'});
		//fade out effect
		//new GTFade("t"+t,{opacity:0.2,delay:3});
//		window.setTimeout("_removeDiv('"+t+"')",_nofify_exp);  	
		window.scrollTo(1,80);
  }
 
   /**
   * Handle error messages.
   * @param messages Array of error messages.
   * @param focusField Field to set focus on.
   */
  function jcv_handleError(messages, focusField) {
      hiddenLoading();
      $('notification').show();
      if (focusField && focusField != null) {
          var doFocus = true;
          if (focusField.disabled || focusField.type == 'hidden') {
              doFocus = false;
          }
          if (doFocus && 
              focusField.style && 
              focusField.style.visibility &&
              focusField.style.visibility == 'hidden') {
              doFocus = false;
          }
          if (doFocus) {
              focusField.focus();
//              Element.extend(focusField).setStyle({'background':'#FFCCCC'});
          }
      }else{
      	 //window.scrollTo(1,80);
      }
      
		//var d = new Date();
	    //var t =d.getUTCMilliseconds();
		//_notify.push(t);
	    var div ='<div class="entry error"><li>'+messages+'</li></div>';
	    $('notification').show();
	    $('notification').update(div);
		//var ff = new Insertion.Top('notification', div);
		//fade out effect
		//window.setTimeout("_removeDiv('"+t+"')",_nofify_exp);  	
		window.scrollTo(1,80);
  }

   /**
   * Handle error messages.
   * @param messages Array of error messages.
   * @param focusField Field to set focus on.
   */
  function jcv_handleErrors(messages, focusField) {
       hiddenLoading();
       $('notification').show();
      if (focusField && focusField != null) {
          var doFocus = true;
          if (focusField.disabled || focusField.type == 'hidden') {
              doFocus = false;
          }
          if (doFocus && 
              focusField.style && 
              focusField.style.visibility &&
              focusField.style.visibility == 'hidden') {
              doFocus = false;
          }
          if (doFocus) {
              focusField.focus();
//              Element.extend(focusField).setStyle({'background':'#FFCCCC'});
          }
      }else{
      	 //window.scrollTo(1,80);
      }
 
		//var d = new Date();
	    //var t =d.getUTCMilliseconds();
        var html='<div class="entry error">';
      	//display errors message
		for ( var i=0 ; i < messages.length ; i++ ){
			//_notify.push(t);
		    var div ='<li>'+messages[i]+'</li>';
		    html = html + div;
			//var ff = new Insertion.Top('notification', div);
			//fade out effect
			//new GTFade("t"+t,{opacity:0.2,delay:3});
//			window.setTimeout("_removeDiv('"+t+"')",_nofify_exp);  	
			//t++;
		}
		html = html + "</div>";
		$('notification').show();
		$('notification').update(html);
		window.scrollTo(1,80);
  }

	function _removeDiv(item){
			 $('t'+item).remove();
			 _notify.splice(item,1);
	}
