//<![CDATA[

var Util = {

    addLoadEvent: function(func) {
    var oldonload = window.onload;
        if (typeof window.onload != 'function') {
            window.onload = func;
            } else {
            window.onload = function() {
            oldonload();
            func();
            }
        }
    },
    
    getCurrentId: function(){
    //alert($('id').value);
        return parseInt($('id').value);
    },
    
    setCurrentId: function(id){
        $('id').value = id;
    },
    
    readCookie: function(){
        function readCookie(name)
        {
	        var nameEQ = name + "=";
	        var ca = document.cookie.split(';');
	        for(var i=0;i < ca.length;i++)
	        {
		        var c = ca[i];
		        while (c.charAt(0)==' ') c = c.substring(1,c.length);
		        if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
	        }
	        return null;
        }
        var x = readCookie('cc')
        if (x)
        {
	        return x;
        }      
    },
    
    trim: function(str){
        return str.replace(/^\s*|\s*$/g,"");
    },

    //My JavaScript Collection Object
    JCollection: function() {
    /* --CCollection object-- */
     var lsize = 0;

     this.add = _add;
     this.remove = _remove;
     this.isEmpty = _isEmpty;
     this.size = _size;
     this.clear = _clear;
     this.clone = _clone;

     function _add(newItem) {
     /* --adds a new item to the collection-- */
          if (newItem == null) return;

          lsize++;
          this[(lsize - 1)] = newItem;
     }

     function _remove(index) {
     /* --removes the item at the specified index-- */
          if (index < 0 || index > this.length - 1) return;
          this[index] = null;

          /* --reindex collection-- */
          for (var i = index; i <= lsize; i++)
               this[i] = this[i + 1];

          lsize--;
     }

     function _isEmpty() { return lsize == 0 }     /* --returns boolean if collection is/isn't empty-- */

     function _size() { return lsize }     /* --returns the size of the collection-- */

     function _clear() {
     /* --clears the collection-- */
          for (var i = 0; i < lsize; i++)
               this[i] = null;

          lsize = 0;
     }

     function _clone() {
     /* --returns a copy of the collection-- */
          var c = new CCollection();

          for (var i = 0; i < lsize; i++)
               c.add(this[i]);

          return c;
     }
    }
}

    //]]>
