// JavaScript Document
String.prototype.trim = function() {	return (this.replace(/^\s+|\s+$/g,""));}; 
String.prototype.ltrim = function() {	return (this.replace(/^\s*/,""));};
String.prototype.rtrim = function() {	return (this.replace(/\s*$/,""));};
if (!Array.prototype.pop) {
 Array.prototype.pop = function() {
  var lastElement = this[this.length-1];
  this.length = Math.max(this.length-1,0);
  return lastElement;
 }
}
if (!Array.prototype.push) {
 Array.prototype.push = function() {
  for(var i=0;i<arguments.length;i++) {
   this[this.length]=arguments[i];
  }
  return this.length;
 }
}
if (!Array.prototype.shift) {
 Array.prototype.shift = function() {
  var firstElement = this[0];
  this.reverse();
  this.pop();
  this.reverse();
  return firstElement;
 }
}
if (!Array.prototype.splice) {
 Array.prototype.splice = function() {
  var start = arguments[0];
  var deleteCount = start+arguments[1];
  var deleteItem = this.slice(start,deleteCount);
  var beforeItem = this.slice(0,start);
  var afterItem = this.slice(deleteCount);
  this.length=beforeItem.length;
  var i;
  for (i=2;i<arguments.length;this[this.length]=arguments[i++]);
  for (i=0;i<afterItem.length;this[this.length]=afterItem[i++]);
  return deleteItem;
 }
}
if (!Array.prototype.unshift) {
 Array.prototype.unshift = function() {
  var arr = new Array();
  for (var i=0;i<arguments.length;arr[i]=arguments[i++]);
  arr = arr.concat(this);
  this.length = 0;
  for (i=0;i<arr.length;this[i]=arr[i++]);
 }
}

Array.prototype.del=function(n) {  //n is begin as 0
  if(n<0)
    return this;
  else
    return this.slice(0,n).concat(this.slice(n+1,this.length));
}
Array.prototype.search = function(value) {  //数组元素不能包含 ,┢
  re = new RegExp(value,[""]);
  return (this.toString().replace(re,"┢").replace(/[^,┢]/g,"")).indexOf("┢");
}

String.prototype.trim=function() {
	return this.replace(/(^\s*)|(\s*$)/g, "");
}
Object.extend = function(destination, source) {
  for (var property in source) {
    destination[property] = source[property];
  }
  return destination;
}
var Class = function(properties) {
            var _class = function() {
                return (arguments[0] !== null && this.initialize && typeof (this.initialize) == 'function') ? this.initialize.apply(this, arguments) : this; 
            };
            _class.prototype = properties;
            return _class;
        };
function goToURL(win,url) {
	if(url.trim()==''){return}
	try{
      var w=eval(win);
	  w.location=url;
	  return false;
	}catch(e){
		window.location=url;
		return false;
		}
}

function cyweb$(obj){	
var o = typeof(obj)=="object" ? obj : document.getElementById(obj);
return o;	
};

function cyweb_$(obj){	
var o = typeof(obj)=="object" ? obj : document.getElementsByName(obj);
return o;	
};

function checkEmail(strEmail) {
	  if (strEmail.search(/^\w+((-\w+)|(\.\w+))*\@[A-Za-z0-9]+((\.|-)[A-Za-z0-9]+)*\.[A-Za-z0-9]+$/) != -1){
		  if(isEmail(strEmail)){
			  return true;
			  }else{
				  return false;
				  }
		  }
	  else {return false};
	  }

function checkUser(s) {
	  var re = new RegExp("[A-Z_a-z0-9]{4,32}","ig");
	  return re.test(s);
	  }

function isEmail(email)
	{
	var invalidChars = " /;,:{}[]|*%$#!()`<>?";
	if (email == "")
	{
	return false;
	}
	for (i=0; i< invalidChars.length; i++)
	{
	var badChar = invalidChars.charAt(i)
	if (email.indexOf(badChar,0) > -1) {
	return false;
	}
	}
	var atPos = email.indexOf("@",1)
	if (atPos == -1) {return false; }
	if (email.indexOf("@", atPos+1) != -1) {   return false; }
	var periodPos = email.indexOf(".",atPos)
	if(periodPos == -1) {
	return false; // and at least one "." after the "@"
	}
	if ( atPos +2 > periodPos) {
	return false; // and at least one character between "@" and "."
	}
	if ( periodPos +3 > email.length) {return false;}
	return true;
}

function   IsDate(mystring)   {   
      var   reg   =   /^(\d{4})[-|\/](\d{2})[-|\/](\d{2})$/;   
      var   str   =   mystring;   
      var   arr   =   reg.exec(str);  
      if   (!reg.test(str)&&RegExp.$2<=12&&RegExp.$3<=31){     
        return false;   
        }   
        return   true;
    }

function goToURL(win,url) {
	if(url.trim()==''){return}
	try{
      var w=eval(win);
	  w.location=url;
	  return false;
	}catch(e){
		window.location=url;
		return false;
		}
}

function CheckKey(){
	//var e=event||window.event;
	var e=Object.reEvent();
	if((e.keyCode>=48&&e.keyCode<=57)||e.keyCode==8||(e.keyCode>=96&&e.keyCode<=105)){
		//updateOCount(e.srcElement);
		//window.oldCount=parseInt(e.srcElement.value);
		//if(isNaN(window.oldCount)){window.oldCount=0}
		}else{
			if(window.event){
			   e.returnValue=false;
			}else{
				e.stopPropagation();
		        e.preventDefault();
				}
			}
			
	}

Object.reEvent = function () {
	//获取Event
	return window.event ? window.event : (function (o) {
		do {
			o = o.caller;
		} while (o && !/^\[object[ A-Za-z]*Event\]$/.test(o.arguments[0]));
		return o.arguments[0];
	})(this.reEvent);
};
