		function $(id){
			return document.getElementById(id);
		}

function JHshStrLen(sString)
{
   var sStr,iCount,i,strTemp ;

   iCount = 0 ;
   sStr = sString.split("");
    for (i = 0 ; i < sStr.length ; i ++)
     {
         strTemp = escape(sStr[i]);
          if (strTemp.indexOf("%u",0) == -1)
          {
              iCount = iCount + 1 ;
          }
          else
          {
              iCount = iCount + 2 ;
          }
      }

      return iCount ;
}

function   azshu(string_value) 
{ 
var   type= "/^[0-9]*[1-9][0-9]*$/"; 
var   re   = new  RegExp(type); 
if(string_value.match(/^[0-9]*[1-9][0-9]*$/)!=null) 
{ 
return true ;
} 
else 
{ 
return false ;
} 
}
function toBin(intNum)
{
 var answer = "";
 if(/\d+/.test(intNum))
 {
  while(intNum != 0)
  {
   answer = Math.abs(intNum%2)+answer;
   intNum = parseInt(intNum/2);
  }
  if(answer.length == 0)
   answer = "0";
  return answer; 
 }
}


function stringRevert(ssm){
	var aa= ssm.replace(/\[blank\]/g,' ');
	var nn= aa.replace(/\[return\]/g,'\n');
	return nn;
}
function stringReplace(ssm){
	var nn= ssm.replace(/ /g,'[blank]');
	var aa= nn.replace(/\n/g,'[return]');
	var tt= aa.replace(/\r/g,'');
	return tt;
}


 function IsURL(str_url){
  var strRegex = "^((https|http|ftp|rtsp|mms)?://)" 
  + "?(([0-9a-z_!~*'().&=+$%-]+: )?[0-9a-zA-Z_!~*'().&=+$%-]+@)?" //ftpuser@ 
        + "(([0-9]{1,3}\.){3}[0-9]{1,3}" // IPʽURL- 199.194.52.184 
        + "|" // IPDOMAIN
        + "([0-9a-zA-Z_!~*'()-]+\.)*" // - www. 
        + "([0-9a-zA-Z][0-9a-zA-Z-]{0,61})?[0-9a-zA-Z]\." //  
        + "[a-zA-Z]{2,6})" // first level domain- .com or .museum 
        + "(:[0-9]{1,4})?" // ˿- :80 
        + "((/?)|" // a slash isn't required if there is no file name 
        + "(/[0-9a-zA-Z_!~*'().;?:@&=+$,%#-]+)+/?)$";
        var re=new RegExp(strRegex); 
  //re.test()
        if (re.test(str_url)){
            return (true); 
        }else{ 
            return (false); 
        }
    }
String.prototype.samll = function () {
       if(this.length<=7){
       		return this;
       }else{
       		return this.slice(0,7)+'...';
	   }
};
String.prototype.trim= function()  
{  
    // ʽǰո  
    // ÿַ  
    return this.replace(/(^\s*)|(\s*$)/g, '');  
}
////////////////////////////////////////////////////////////////////////////////////////////////////////
//Array extend
Array.prototype.indexof = function (obj) {
	var result = -1;
	for (var i = 0; i < this.length; i++) {
		if (this[i] == obj) {
			result = i;
			break;
		}
	}
	return result;
}
Array.prototype.contains = function (obj) {
	return (this.indexof(obj) >= 0);
}
Array.prototype.append = function (obj, nodup) {
	if (!(nodup && this.contains(obj))) {
		this[this.length] = obj;
	}
}
Array.prototype.insert = function (obj,index) {
	var front = this.slice(0,index);
	var back = this.slice(index);
	front.append(obj,false);
	var newone = front.concat(back);
	return newone;
};

Array.prototype.unshiftZOOVE = function (obj, nodup) {
	if (!(nodup && this.contains(obj))) {
		this.unshift(obj);
	}
}

Array.prototype.remove = function (index) {
	if (index >= 0 && index < this.length) {
		this.splice(index, 1);
	}
}

Array.prototype.removeModel = function (model){
	for (var i=0; i<this.length; i++) {
		if(this[i] == model){
			this.splice(i, 1);
			break;
		}
	}
	
};

Array.prototype.clear = function () {
	this.splice(0, this.length);
}

////////////////////////////////////////////////////////////////////////////////////////////////////////
// Event Call 
var jsEvent = new Array();
jsEvent.EventRouter = function (element, eventType) {
	this.listeners = new Array();
	this.element = element;
	element.eventRouter = this;
	element[eventType] = jsEvent.EventRouter.callback;
}
jsEvent.EventRouter.prototype.addListener = function (listener) {
	this.listeners.append(listener, true);
}
jsEvent.EventRouter.prototype.removeListener = function (listener) {
	this.listeners.remove(listener);
}
jsEvent.EventRouter.prototype.notify = function (e) {
	var listeners = this.listeners;
	for (var i = 0; i < listeners.length; i++) {
		var listener = listeners[i];
		listener.call(this, e);
	}
}
jsEvent.EventRouter.callback = function (event) {
	var e = (event) ? event : window.event;
	if (window.event) {
		e.cancelBubble = true;
	} else {
		e.stopPropagation();
	}
	var router = this.eventRouter;
	router.notify(e);
}

////////////////////////////////////////////////////////////////////////////////////////////////////////
// Object clone 
Object.prototype.clone = function () {
	var newObj = new Object();
	for (elements in this) {
		newObj[elements] = this[elements];
	}
	return newObj;
}
Object.prototype.cloneAll = function () {
	function clonePrototype() {
	}
	clonePrototype.prototype = this;
	var obj = new clonePrototype();
	for (var ele in obj) {
		if (typeof (obj[ele]) == "object") {
			obj[ele] = obj[ele].cloneAll();
		}
	}
	return obj;
}
/////////////////////////////////////////////////////////
/// colour
function addcolour(dom){
	dom.style.background= '#FFFFCC';
}
function dropcolour(dom){
	dom.style.background= '#FFFFFF' ;
}

