function isArray(a) {
	return isObject(a) && a.constructor == Array;
}

function isObject(a) {
	return (a && typeof a == 'object') || isFunction(a);
}

function isFunction(a) {
	return typeof a == 'function';
}

function debug(value) {
  if(typeof console != 'undefined' && console.log) {
    console.log(value);    
  }
  else{
    alert(value);
  }
}

Array.prototype.indexOf = function(value) {
  for(var i = 0; i < this.length; i++) {
    if(this[i] == value) {
      return i;
    }
  }
  return -1;
}

String.prototype.ucfirst = function() {
  firstLetter = this.charCodeAt(0);
  if((firstLetter >= 97 && firstLetter <= 122)
     || (firstLetter >= 224 && firstLetter <= 246)
     || (firstLetter >= 249 && firstLetter <= 254))
  {
    firstLetter = firstLetter - 32;
  }
  return String.fromCharCode(firstLetter) + this.substr(1,this.length -1)
}

function getMediaPath() {
  var scriptPath = document.getElementsByTagName('script')[0].src
  return scriptPath.substring(0, scriptPath.lastIndexOf('/js/')) + '/media';
}

function getElementPosition(elem) {
  var compTop  = 0;
  var compLeft = 0;
  while (elem) {
      compLeft += elem.offsetLeft;
      compTop  += elem.offsetTop;
      elem      = elem.offsetParent;
  }
  if (navigator.userAgent.indexOf('Mac') != -1 && 
      typeof document.body.leftMargin != 'undefined') {
      compLeft += document.body.leftMargin;
      compTop  += document.body.topMargin;
  }
  return {y: compTop, x: compLeft};
}

//translates stuff
function __(key) {
  if(typeof trans == 'object') {
    return trans[key] || key;
  }
  return key;
}


/************* track outbound links in google *****************/
function trackOutbound(linkname) {
  if(typeof(pageTracker) != 'undefined' && typeof(pageTracker._trackPageview) == 'function') {
    pageTracker._trackPageview(linkname);
  }
}