/* - - - - - - - - - - - - - - - - - - - - - - -
 JavaScript
 29 ianuarie 2010 20:37:20
 HAPedit 3.1.11.111
 - - - - - - - - - - - - - - - - - - - - - - - */

if(!window.JSN)
{/*** Include Library Code ***/

JSN = new Object();

JSN.objNo = 0;
JSN.getObjId = function(){return "JSN_obj" + JSN.objNo++;}
// identificare body
JSN.trueBody = function(){
   return (document.compatMode && document.compatMode!="BackCompat")? document.documentElement : document.body
}
// latimea documentului
JSN.getDocWidth = function()
{
   return (document.all && !window.opera)? JSN.trueBody().clientWidth : (navigator.appName=="Netscape")? JSN.trueBody().clientWidth : window.innerWidth;
}
// scroll left
JSN.getScrollLeft = function()
{
   return (document.all && !window.opera)? JSN.trueBody().scrollLeft : window.pageXOffset
}
// inaltimea documentului
JSN.getDocHeight = function()
{
   return (document.all && !window.opera)? JSN.trueBody().clientHeight : window.innerHeight;
}
// scroll top
JSN.getScrollTop = function()
{
   return (document.all && !window.opera)? JSN.trueBody().scrollTop : window.pageYOffset
}
// pozitia X de start/sfarsit a animatiei
JSN.randomX = function(imgwidth, docwidth){return parseInt(Math.random() * (docwidth - imgwidth));}

// intoarce un tablou de denumiri
JSN.arrayImgs = function(paramArray)
{
   ret = new Array();
   for (var i=0; i<paramArray.no; i++)
   {
       ret[i] = paramArray.path + i + paramArray.type;
   }
   return ret;
}

// seteaza proprietatea style.clip cu datele din proprietatea clip a obiectului
JSN.setClip = function(object) {
    object.style.clip = "rect(" + object.clip.top + "px " + object.clip.right + "px "
                                + object.clip.bottom + "px " + object.clip.left + "px)";
}

// http://www.phpied.com/dynamic-script-and-style-elements-in-ie/
JSN.addStyles = function(styles) {
    style = document.createElement("style");
    style.type = "text/css";

    if (style.styleSheet) { // IE
            style.styleSheet.cssText = styles;
    } else { // others
            var tt1 = document.createTextNode(styles);
            style.appendChild(tt1);
    }

    document.getElementsByTagName("head")[0].appendChild(style);
}

// http://www.onlinetools.org/articles/unobtrusivejavascript/cssjsseparation.html
function jscss(a, o, c1, c2) {
  switch (a){
    case 'swap':
      o.className = !jscss('check', o, c1)? o.className.replace(c2, c1) : o.className.replace(c1, c2);
    break;
    case 'add':
      if (!jscss('check', o, c1)) {o.className += o.className? ' '+c1 : c1;}
    break;
    case 'remove':
      var rep = o.className.match(' '+c1)? ' '+c1 : c1;
      o.className = o.className.replace(rep, '');
    break;
    case 'check':
      return new RegExp('\\b'+c1+'\\b').test(o.className)
    break;
  }
}

// intoarce o functie daca valoarea nu este functie; altfel intoarce valoarea
JSN.Functie = function(value) {
    if (value instanceof Function) return value;
    return function() {return value};
}

// intoarce functia de animatie pt. "wobno" schimbari de directie
JSN.wobbles = function(wobno)
{
   return function(pos){
              var t = (wobno * pos) % 2;
              if (t<1) return t; else return 2 - t;
          }
}
// intoarce functia de animatie pt. "wobno" schimbari de directie amortizate
JSN.wobblesa = function(wobno)
{
   return function(pos){
              return (1 - Math.cos(Math.PI * wobno * pos)) / 2;
          }
}
// intoarce functia de animatie pt. parabola (ecuatie de gradul 2: -x**2 + (b/a)*x)
JSN.parabola = function(restr, wobno, wobfct)
{
   // var x1 = 0; x1, x2 = radacinile ecuatiei
   var x2 = 1 + restr;
   var prop = 1 / (restr * wobno);

   return function(pos) {
              if (pos==0) return 0;
              var x = wobfct(pos);
              var wobcrt = Math.ceil(pos * wobno);
              if (wobcrt % 2 == 0) x = 1 - x;
              return prop * x * (x2 - x) + (wobcrt-1) / wobno;
          }
}

}

