/* shobject 1.0, copyright(c) 2009 inventive designs <www.inventivedesigns.cz>
   ! - requires AddEvent() and removeEvent() functions defined below.
*/
var d = document;
var w = window;

function shobject(settings,id) {
  for (var i in settings) this[i] = settings[i];
  if (id) this.init(id);
}
shobject.prototype = {
  a_shown:100,
  a_hidden:0,
  dur_setNextAlpha:60,
  step:15,
  init:function(id) {
    this.id = id;
    this.a = this.a_hidden;
    this.setAlpha(this.a);
  },
  setAlpha:function(a,id) {
    if (!id) {
      var id = this.id;
      this.a = a;
      clearInterval(this.int_setAlpha);
    }
    var s = d.getElementById(id).style;
    s.opacity = (a/100);
    s.MozOpacity = (a/100);
    s.KhtmlOpacity = (a/100);
    s.filter = 'Alpha(opacity='+a+')';
    s.visibility = 'visible';
  },
  setNextAlpha:function(sh,a_end) {
    if (sh.sign*sh.a<a_end) {
      sh.a += sh.step*sh.sign;
    } else {
      sh.a = a_end;
      clearInterval(sh.int_setAlpha);
    }
    sh.setAlpha(sh.a,sh.id)
  },
  show:function() {
    clearInterval(this.int_setAlpha);
    var t = this;
    this.sign = 1;
    this.int_setAlpha = w.setInterval(function(){shobject.prototype.setNextAlpha(t,t.a_shown)},t.dur_setNextAlpha);
  },
  hide:function() {
    clearInterval(this.int_setAlpha);
    var t = this;
    this.sign = -1;
    this.int_setAlpha = w.setInterval(function(){shobject.prototype.setNextAlpha(t,t.a_hidden)},t.dur_setNextAlpha);
  }
}
// ^ end of shobject
function changeImg(id_img,url) {
  d.getElementById(id_img).src = url;
}
function setClass(id,c) {
  d.getElementById(id).className = c;
}
function setMouseOverOut(id,fncOver,fncOut) {
  var el = d.getElementById(id);
  el.style.cursor = 'pointer';
  if (fncOver) addEvent(el,'mouseover',function(){eval(fncOver)});
  if (fncOut) addEvent(el,'mouseout',function(){eval(fncOut)});
}
// unification of browsers's functions
function addEvent(o,eventName,fnc) {
  if(o.addEventListener) {
    o.addEventListener(eventName,fnc,true);
    return true;
  } else if (o.attachEvent) {
    var r = o.attachEvent('on'+eventName,fnc);
    return r;
  } else {
    return false;
  }
}
function removeEvent(o,eventName,fnc) {
  if(o.removeEventListener) {
    o.removeEventListener(eventName,fnc,true);
    return true;
  } else if (o.detachEvent) {
    var r = o.detachEvent('on'+eventName,fnc);
    return r;
  } else {
    return false;
  }
}