/***********************************************
* Cross browser Marquee II- © Dynamic Drive (www.dynamicdrive.com)
* This notice MUST stay intact for legal use
* Visit http://www.dynamicdrive.com/ for this script and 100s more.
***********************************************/
/**
* Edited by martin@nestdesign.com
* In begining it will duplicate all content of marqueed object and then it is moving that object.
*/
var delayb4scroll=1000 //Specify initial delay before marquee starts to scroll on page (2000=2 seconds)
var marqueespeed=4 //Specify marquee scroll speed (larger is faster 1-10)
var pauseit=0 //Pause marquee onMousever (0=no. 1=yes)?
var marqueescroll=80 //Delay to next scroll (in ms 10 - 100)

////NO NEED TO EDIT BELOW THIS LINE////////////

var copyspeed=marqueespeed
var pausespeed=(pauseit==0)? copyspeed: 0
var actualwidth=''

function scrollmarquee(){
  objLeft=parseInt(cross_marquee.style.left);
  if (objLeft>(actualwidth*(-1)+8))
    cross_marquee.style.left=objLeft-copyspeed+"px";
  else
    cross_marquee.style.left=parseInt(cross_marquee.style.left)+(actualwidth)+copyspeed+"px";
}
var i = 0;

/**
  find object, which is some of child names as objTagName
*/
function getValidChild(parentObj, objTagName){
  parentObj = parentObj.firstChild
  i ++;
  if (i > 20)return ;
  while (parentObj){
    if (parentObj.tagName){
      if (parentObj.tagName == objTagName.toUpperCase()){
        return parentObj;
      } else {
        obj = getValidChild(parentObj, objTagName);
        if (typeof(obj) == "object")
          return obj;
      }
    }
    parentObj = parentObj.nextSibling;
  }
}

function initializemarquee(){
  cross_marquee=document.getElementById("vmarquee") // P
  if(!cross_marquee) 
    return
  actualwidth=parseInt(getValidChild(cross_marquee, "span").offsetWidth) // gets all images width
  /*    MICHAL CHANGES    */
  if(getValidChild(cross_marquee, "img")){// change the height of div#vmarquee to img height only if there are images in div#vmarquee
    cross_marquee.parentNode.style.height = parseInt(getValidChild(cross_marquee, "img").offsetHeight)+"px" // sets displayed height
  }
  /*    MICHAL CHANGES END    */
  cross_marquee.innerHTML = cross_marquee.innerHTML+cross_marquee.innerHTML+cross_marquee.innerHTML; // copy content
  cross_marquee.style.width = parseInt(getValidChild(cross_marquee, "span").offsetWidth)*3+"px"; // sets marqueed object width
  cross_marquee.style.left = 0
  marqueewidth=parseInt(document.getElementById("marqueecontainer").offsetWidth) // gets displayed width
  if (window.opera || navigator.userAgent.indexOf("Netscape/7")!=-1){ //if Opera or Netscape 7x, add scrollbars to scroll and exit
    cross_marquee.style.width=marqueewidth+"px"
    cross_marquee.style.overflow="scroll"
    return
  }
  setTimeout('lefttime=setInterval("scrollmarquee()",marqueescroll)', delayb4scroll)
}

if (window.addEventListener)
  window.addEventListener("load", initializemarquee, false)
else if (window.attachEvent)
  window.attachEvent("onload", initializemarquee)
else if (document.getElementById)
  window.onload=initializemarquee

function mydebug(mytext){
  debugdiv = document.getElementById('debug');
  if(debugdiv)
    debugdiv.innerHTML += mytext + ' ';
  else
    alert(mytext);
}
