var w3c = (document.getElementById) ? 1:0 
var ns4 = (document.layers) ? 1:0 ;
var ie4 = (document.all) ? 1:0 
var saf = (navigator.userAgent.indexOf('KHTML')!=-1)?true:false;

if (ie4) { w3c = ns4 = saf = 0; }
if (saf) { w3c = ns4 = ie4 = 0; }

var range = ""; 
var cap = ""; 
var mutex = 0; 
var xplace = 0; 
var yplace = 0;
var xmax = 0; 
var xmin = 0;
var ymin = 0;
var ymax = 0;
var newsWidth = 0; 
var newsHeight = 0; 
var jumpDistance = 300;


var speed = 4; 

var showroomId = "tradition"; 
var showroomClipId = "main"; 

function redrawScreen() { 
location.reload(); 
return false 
} 

function shiftTo(obj, x, y) {
if (w3c || saf) { 
obj.style.left = x + "px"; 
obj.style.top = y + "px"; 
//obj.x = x;
//obj.y = y;
} 
else if (ns4) { 
obj.moveTo(x,y); 
} 
else if (ie4) { 
obj.style.pixelLeft = x; 
obj.style.pixelTop = y; 
} 
} 

function getObject(obj) { 
var theObj = eval("document." + range + obj + cap); 
return theObj; 
} 

function scrollRight() {

if (mutex == 1){
var theObj = getObject(showroomId); 

if (xplace < xmax) {
xplace = xplace + speed; 
if (xplace > xmax) {
xplace = xmax;
}

shiftTo(theObj, xplace, yplace); 
setTimeout("scrollRight()",25); 
} 
} 
} 

function scrollLeft() 
{
  if (mutex == 2)
  { 
    var theObj = getObject(showroomId); 

    if (xplace >= xmin) 
    { 
      xplace = xplace - speed; 
      if (xplace < xmin) 
      {
        xplace = xmin;
      }

      shiftTo(theObj, xplace, yplace); 
      setTimeout("scrollLeft()",25); 
    } 
  } 
} 

function scrollDown() {
if (mutex == 3){
var theObj = getObject(showroomId); 
if (yplace > ymin) {
yplace = yplace - speed; 
if (yplace < ymin) {
yplace = ymin;
}
shiftTo(theObj, xplace, yplace); 
setTimeout("scrollDown()",25); 
} 
} 
} 

function scrollUp() {
if (mutex == 4){
var theObj = getObject(showroomId); 
if (yplace < ymax) {
yplace = yplace + speed; 
if (yplace > ymax) {
yplace = ymax;
}
shiftTo(theObj, xplace, yplace); 
setTimeout("scrollUp()",25); 
} 
} 
} 

function jumpLeft() {
if (mutex == 8){ 
var theObj = getObject(showroomId); 

if (xplace > xmin) { 
xplace = xplace - jumpDistance; 
if (xplace < xmin) {
xplace = xmin;
}
shiftTo(theObj, xplace, yplace); 
mutex = 2;
} 
} 	
}

function jumpRight() {

  if (mutex == 9)
  {
    var theObj = getObject(showroomId); 
    if (xplace < xmax) 
    {
      xplace = xplace + jumpDistance; 
      if (xplace > xmax) 
      {
        xplace = xmax;
      }

      shiftTo(theObj, xplace, yplace); 
      mutex = 1;
    } 
  } 

} 



function scrollIt(msg, dir) {
window.status = msg; 
mutex = dir; 

if (mutex == 1) scrollRight();
else if (mutex == 2) scrollLeft();
else if (mutex == 3) scrollDown();
else if (mutex == 4) scrollUp();
else if (mutex == 8) jumpLeft();
else if (mutex == 9) jumpRight();
} 

function init() { 
if (w3c) { 
range = "getElementById(\""; 
cap = "\")"; 
theObj = getObject(showroomClipId); 
newsWidth = theObj.offsetWidth; 
newsHeight = theObj.offsetHeight; 
theObj = getObject(showroomId); 
if (theObj.offsetWidth == newsWidth) {
  var widthFromHook = document.getElementById('widthHook').style.width;
  var myWidth = parseInt(widthFromHook.substring(0,widthFromHook.indexOf('px')));
} else {
  var myWidth = theObj.offsetWidth
}
xmin = (myWidth - newsWidth) * -1; 
ymin = (theObj.offsetHeight - newsHeight) * -1; 

} 
else if (ns4) { 
window.captureEvents(Event.RESIZE); 
window.onresize = redrawScreen; 
theObj = getObject(showroomClipId); 
newsWidth = theObj.clip.width; 
newsHeight = theObj.clip.height; 
showroomId = showroomClipId + ".document." + showroomId; 
theObj = getObject(showroomId); 
xmin = (theObj.clip.width - newsWidth) * -1; 
ymin = (theObj.clip.height - newsHeight) * -1; 
} 
else if (ie4) { 
range = "all."; 
theObj = getObject(showroomClipId); 
newsWidth = theObj.offsetWidth; 
newsHeight = theObj.offsetHeight; 
theObj = getObject(showroomId); 
xmin = (theObj.offsetWidth - newsWidth) * -1; 
ymin = (theObj.offsetHeight - newsHeight) * -1; 
} 
else if (saf) { 
range = "getElementById(\""; 
cap = "\")"; 
newsWidth = 990; 
var widthFromHook = document.getElementById('widthHook').style.width;
var safariWidth = parseInt(widthFromHook.substring(0,widthFromHook.indexOf('px')));
xmin = (safariWidth - newsWidth) * -1;
getObject(showroomClipId).style.overflow = 'hidden';
}

} 

