/*======================================================================*
 *			 Prototype 1.4.0 Start				*/

var Class = {
  create: function() {
    return function() {
      this.initialize.apply(this, arguments);
    }
  }
}

var Abstract = new Object();

Object.extend = function(destination, source) {
  for (property in source) {
    destination[property] = source[property];
  }
  return destination;
}

Object.inspect = function(object) {
  try {
    if (object == undefined) return 'undefined';
    if (object == null) return 'null';
    return object.inspect ? object.inspect() : object.toString();
  } catch (e) {
    if (e instanceof RangeError) return '...';
    throw e;
  }
}

Function.prototype.bind = function() {
  var __method = this, args = $A(arguments), object = args.shift();
  return function() {
    return __method.apply(object, args.concat($A(arguments)));
  }
}

Function.prototype.bindAsEventListener = function(object) {
  var __method = this;
  return function(event) {
    return __method.call(object, event || window.event);
  }
}

function $() {
  var elements = new Array();
  for (var i = 0; i < arguments.length; i++) {
    var element = arguments[i];
    if (typeof element == 'string')
      element = document.getElementById(element);
    if (arguments.length == 1)
      return element;
    elements.push(element);
  }
  return elements;
}

var $A = Array.from = function(iterable) {
  if (!iterable) return [];
  if (iterable.toArray) {
    return iterable.toArray();
  } else {
    var results = [];
    for (var i = 0; i < iterable.length; i++)
      results.push(iterable[i]);
    return results;
  }
}
/*			   Prototype 1.4.0 End				*/
/*======================================================================*/

// 等比缩小图片
function changeImg( obj, width, height ) {
  if ( obj.width > width || obj.height > height ) {
    var scale;
    var scale1 = obj.width / width;
    var scale2 = obj.height / height;
    if(scale1 > scale2){ scale = scale1;
    }else{ scale = scale2; }
    obj.height = obj.height / scale;
  }
}

// 处理 文本框 水印
function wmBlur( input ){
  input.ct = input.value;
  if( input.ct=='' ){
    input.style.color = 'Silver';
    input.value = input.wm;
  } else{
    input.style.color = 'Black';
    input.value = input.ct;
  }
}
function wmFocus( input ){
  input.style.color = 'Black';
  if( input.value != input.ct )
    input.value = input.ct;
}
