(function($){
     $.fn.extend({
          centerxy: function (options) {
               var options =  $.extend({ // Default values
                    inside:window, // element, center into window
                    transition: 0, // millisecond, transition time
                    minX:0, // pixel, minimum left element value
                    minY:0, // pixel, minimum top element value
                    vertical:true, // booleen, center vertical
                    withScrolling:true, // booleen, take care of element inside scrollTop when minX < 0 and window is small or when window is big
                    horizontal:true // booleen, center horizontal
               }, options);
               return this.each(function() {
                    var props = {position:'absolute'};
                    if (options.vertical) {
                         var top = ($(options.inside).height() - $(this).outerHeight()) / 2;
                         if (options.withScrolling) top += $(options.inside).scrollTop() || 0;
                         top = (top > options.minY ? top : options.minY);
                         $.extend(props, {top: top+'px'});
                    }
                    if (options.horizontal) {
                          var left = ($(options.inside).width() - $(this).outerWidth()) / 2;
                          if (options.withScrolling) left += $(options.inside).scrollLeft() || 0;
                          left = (left > options.minX ? left : options.minX);
                          $.extend(props, {left: left+'px'});
                    }
                    if (options.transition > 0) $(this).animate(props, options.transition);
                    else $(this).css(props);
                    return $(this);
               });
          }
     });
})(jQuery);

(function($){
     $.fn.extend({
          center: function () {
                return this.each(function() {
                        var top = ($(window).height() - $(this).outerHeight()) / 2;
                        var left = ($(window).width() - $(this).outerWidth()) / 2;
                        $(this).css({position:'absolute', margin:0, top: (top > 0 ? top : 0)+'px', left: (left > 0 ? left : 0)+'px'});
                });
        }
     });
     $.fn.extend({
          centerx: function (xsize) {
                return this.each(function() {
                        var left = ($(window).width() - xsize) / 2;
                        $(this).css({position:'absolute', margin:0, left: (left > 0 ? left : 0)+'px'});
                });
        }
     });

//Sample Encoding:
//alert(  $.URLEncode("This is a \"test\"; or (if you like) an example...");
//This%20is%20a%20%22test%22%3B%20or%20%28if%20you%20like%29%20an%20example...
//Sample Decoding:
//alert(  $.URLDecode("Is%20it%20what%20it%20is%3F");

$.extend(
{URLEncode:
  function(c) {
    var o='';
    var x=0;
    c=c.toString();
    var r=/(^[a-zA-Z0-9_.]*)/;
    while(x<c.length){
      var m=r.exec(c.substr(x));
      if(m!=null && m.length>1 && m[1]!=''){
        o+=m[1];x+=m[1].length;
      } else{
        if(c[x]==' ') o+='+'; 
        else {
          var d=c.charCodeAt(x);
          var h=d.toString(16);
            o+='%'+(h.length<2?'0':'')+h.toUpperCase();}x++;}}return o;
            },
URLDecode:function(s){var o=s;var binVal,t;var r=/(%[^%]{2})/;
  while((m=r.exec(o))!=null && m.length>1 && m[1]!=''){b=parseInt(m[1].substr(1),16);
  t=String.fromCharCode(b);o=o.replace(m[1],t);}return o;}
});

})(jQuery);

function ismaxlength(obj){
var mlength=obj.getAttribute? parseInt(obj.getAttribute("maxlength")) : ""
if (obj.getAttribute && obj.value.length>mlength)
obj.value=obj.value.substring(0,mlength)
}
