function findPos(el) {
        x = 0; y = 0; var temp
        if(el.offsetParent) {
              temp = el
              while(temp.offsetParent) {
                    temp = temp.offsetParent;
                    x += temp.offsetLeft
                    y += temp.offsetTop;
              }
        }
        x += el.offsetLeft
        y += el.offsetTop
        return [x, y, el.offsetWidth]
}

readURL = function(obj, url, params, func) {
      http = null;
      if(window.XMLHttpRequest) {// code for Firefox, Mozilla, IE7, etc.
            http=new XMLHttpRequest();
      } else if (window.ActiveXObject) {// code for IE6, IE5
            http=new ActiveXObject("Microsoft.XMLHTTP");
      }
      
      http.abort();
      http.onreadystatechange = function() {
            if(http.readyState == 4 && http.status == 200) {
                  
                  var _text = http.responseText;
                  document.getElementById(obj).innerHTML = _text;
                  if(func) eval(func);
            }
      }
      
      http.open("GET", url + '?' + params, true);  
      http.send(null);
}

function showTextBox(obj, txt) {
      if(!txt) txt = obj.title;
      document.getElementById('textpoptxt').innerHTML = txt;
      textpop.style.display = 'block';
      pos = findPos(obj);
      textpop.style.left = (pos[0] - 60) + 'px';
      textpop.style.top = (pos[1] - textpop.offsetHeight) + 'px';
}  

function addAction(id) {
      pos = findPos(document.getElementById(id));
      var d = document.createElement('div');
      d.className = 'divAction';
      pp = parseInt(document.getElementById(id).style.width) - pos[2]; 
      d.style.left = (pos[0] + pp) + 'px';
      d.style.top = (pos[1] + pp) + 'px';
      document.getElementById('bs').appendChild(d);
}

function new_window(url,wi,hi) {
link =
window.open(url,"Link","toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=1,resizable=1,width="+wi+",height="+hi+",left=0,top=0");
};

function new_window_stat(url,wi,hi) {
links =
window.open(url,"Links","toolbar=0,location=0,directories=0,status=1,menubar=0,scrollbars=0,resizable=0,width="+wi+",height="+hi+",left=0,top=0");
};

function nextProd(p) {
      clearTimeout(t);
      prod++;
      if(!sArr[prod]) prod = 0;
      ss = ss == 1 ? 2 : 1;
      var img = new Image();
      img.onload = function() {
            img.onload = null;
            s[ss].style.backgroundImage = "url('/bildes/sakums/" + sArr[prod] + "')";
            s[ss].style.visibility = 'visible';
            s[ss].style.opacity = 0;
            s[ss].style.filter = 'alpha(opacity:0)';
            s[ss].style.zIndex = 1000;
            s[ss == 1 ? 2 : 1].style.zIndex = 999;
            swapProd();
      }
      img.src = '/bildes/sakums/' + sArr[prod];

}

function swapProd() {
      a += 10;
      s[ss].style.opacity = a / 100;
      s[ss].style.filter = 'alpha(opacity:' + a +')';
      
      if(a < 100) {
            setTimeout('swapProd()', 50);
      } else {
            a = 0;
            t = setTimeout('nextProd()', 5000);
      }           
}

