/*  Prototype JavaScript framework, version 1.4.0
 *  (c) 2005 Sam Stephenson <sam@conio.net>
 *
 *  Prototype is freely distributable under the terms of an MIT-style license.
 *  For details, see the Prototype web site: http://prototype.conio.net/
 *
/*--------------------------------------------------------------------------*/

// I am using a very tiny part of prototype...



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;
}



function toggle(element) {
  element = $(element);
  if(element.style.display == 'none') { 
	  show(element);
  } else { 
	  hide(element);
  }
}

function hide(element) {
  element = $(element);
  element.style.display = 'none';
}

function show(element) {
  element = $(element);
  element.style.display = 'block';
}


//modified prototype function
function scrollTo(element) {
  element = $(element);
  var x = findPosX(element),
      y = findPosY(element);
  window.scroll(x, y);
}



//add a trim function to String objects
String.prototype.trim = function() {
	return this.replace(/^\s+|\s+$/g, '');
}



//these are not part of prototype.... they were found elsewhere and are usuable in any project for free

function findPosX(obj) {
  var curleft = 0;
  if (obj.offsetParent) {
    while (1) {
      curleft+=obj.offsetLeft;
      if (!obj.offsetParent) {
        break;
      }
      obj=obj.offsetParent;
    }
  } else if (obj.x) {
    curleft+=obj.x;
  }
  return curleft;
}


function findPosY(obj) {
  var curtop = 0;
  if (obj.offsetParent) {
    while (1) {
      curtop+=obj.offsetTop;
      if (!obj.offsetParent) {
        break;
      }
      obj=obj.offsetParent;
    }
  } else if (obj.y) {
    curtop+=obj.y;
  }
  return curtop;
}



