/*
==========================================
 MPG News Scroller 18/12/05
 Removed control panel for guest book 
==========================================
*/
	
 var dn_startpos=120;     // initial position (height of news div) 			
 var dn_speed=30;         // Speed of scroller higher number = slower scroller 				
 var dn_newsID='news';    // ID of the news box (div)			
 var dn_classAdd='hasJS'; // class to add when JS is available		

  var dn_endpos=-272;      // end position -(element height - startpos) 			
  var dn_main2='main2'     // ID of news table
  var dn_main3='main3'     // ID of span tage placed at bottom of table
  var dn_direction = "up"  // Direction of scroll text 
//== Initialise scroller when window loads runs other obload functions 
 window.onload=function(){
   if(!document.getElementById) {return;} // check for DOM
   initDOMnews();                         // add more functions as needed
 }
//== Stop scroller when window is closed 
  window.onunload=function(){clearInterval(dn_interval);}

//== This is the functional bit
  var dn_scrollpos=dn_startpos;
/* Initialise scroller */
 function initDOMnews()	{
   var n=document.getElementById(dn_newsID);            // get element
   if(!n){return;}                                      // not found give up
   n.className=dn_classAdd;                             // add class to news div
   dn_interval=setInterval('scrollDOMnews()',dn_speed); // start timer
     n.onmouseover=function(){                          // div mouse over		
      clearInterval(dn_interval);                       // stop timer
     }
     n.onmouseout=function(){                           // div mouse out
       dn_interval=setInterval('scrollDOMnews()',dn_speed); //start timer
     }
 }

//== Move Div element
  function scrollDOMnews(){
   var newsTop    =  getPosition('main2');       // get news top y co-ord
   var newsBottom =  getPosition('main3');       // get news bottom y co-ord
   var newsHeight =  newsBottom.y - newsTop.y    // news true height
   var n=document.getElementById(dn_newsID).getElementsByTagName('div')[0];

    dn_endpos= -newsHeight ;         // display all news - element height  			
    n.style.top=dn_scrollpos+'px';   // move news to new scrollpos 
    if(dn_scrollpos==dn_endpos){dn_scrollpos=dn_startpos;} 
    dn_scrollpos--;                 // new scrollpos

  }

function getPosition(id){              // get position of any tag
   var coordinates=new Object();       // object to hold x and y
   var x=0,y=0;                        // init x and y
   var p=document.getElementById(id);  // get handel
   var t=p;                            // duplicate handle

    x=p.offsetLeft;                    // get offset to parent
    while((p=p.offsetParent) != null){ // get next parent
      x += p.offsetLeft;               // add up all offsets
    }
    y=t.offsetTop;                     // repeat above for y
    while((t=t.offsetParent) != null){
     y += t.offsetTop;
    }
    coordinates.x=x;                   // set object x value
    coordinates.y=y;
    return coordinates;                // return object with x and y
 }
 
// Control panel
function dnNewsStop(){           // mouse over stop scrolling
  clearInterval(dn_interval);    // stop timer
}

function dnNewsStart(){          // mouse out start scrolling
   dn_interval=setInterval('scrollDOMnews()',dn_speed); //start timer
}


