var DIR_LEFT = 0;
var DIR_RIGHT = 1;

Item = new Array;
i=0;

/* DEFINE SCROLLER ELEMENTS
  Define new scroller elements here in the following format.
  Item[i] = new Array ("display text", "URL", "frame target to load link in");i++  
  Note: If you do not want the item to be a link, change the URL value to "none".
*/
  Item[i] = new Array ("<img src=\"img/flags/1.jpg\" alt=\"English - US\" border=\"0\" width=\"106\" height=\"53\"/>", "#", "_self");i++  
  Item[i] = new Array ("<img src=\"img/flags/2.jpg\" border=\"0\" width=\"106\" height=\"53\" alt=\"\" />", "#", "");i++
  Item[i] = new Array ("<img src=\"img/flags/3.jpg\" border=\"0\" width=\"106\" height=\"53\" alt=\"\" />", "#", "");i++
  Item[i] = new Array ("<img src=\"img/flags/4.jpg\" border=\"0\" width=\"106\" height=\"53\" alt=\"\" />", "#", "");i++
  Item[i] = new Array ("<img src=\"img/flags/5.jpg\" border=\"0\" width=\"106\" height=\"53\" alt=\"\" />", "#", "");i++
  Item[i] = new Array ("<img src=\"img/flags/6.jpg\" border=\"0\" width=\"106\" height=\"53\" alt=\"\" />", "#", "");i++
  Item[i] = new Array ("<img src=\"img/flags/7.jpg\" border=\"0\" width=\"106\" height=\"53\" alt=\"\" />", "#", "");i++
  Item[i] = new Array ("<img src=\"img/flags/8.jpg\" border=\"0\" width=\"106\" height=\"53\" alt=\"\" />", "#", "");i++
  
////// SCROLLER CONFIGURATION ///////////////////////////////////////////////////////////////////  

scrollerWidth = "475"             // Width of entire scroller.
scrollerHeight = "53"             // Height of Scroller.
borderWidth = 0                   // Width of border. (use 0 for no border).
borderColour = "#000000"          // Colour of scroller border. (Use either hexadecimal or text values. e.g. "#FF0000" or "Red") 
backColour = "#013b28"              // Colour of scroller background. (Use either hexadecimal or text values. e.g. "#FF0000" or "Red") 
staticColour = "#000000"          // Colour of scroller items that are NOT a link. (including scrollerDivider characters)
stopScroll = 1                    // Pause the scroller on mouseOver. (use 0 for no.)
textAlignment="left"				// Alignment of each scroller item.  Only really makes a difference on vertical scroller
                                  // (center, left, right, justify)

// Scroller Links
linkFont = "arial"                // Font of scroller links;
linkWeight = "normal"             // Weight of scroller links;
linkColour = "#000080"            // Colour of scroller links
linkSize = "10"                   // Size of links (in points)
linkDecoration = "none"           // Decoration of links. (underline, overline, none)

// Scroller Links On MouseOver
slinkFont = "arial"               // Font of scroller links;
slinkWeight = "normal"            // Weight of scroller links;
slinkColour = "#cc3333"           // Colour of scroller links
slinkSize = "10"                  // Size of links (in points)
slinkDecoration = "underline"     // Decoration of links. (underline, overline, none)

scrollerDivider = "<span style=\"width:10px;\">&nbsp;</span>" // Character to place between each scroller item. 
                                  // <img> tags can be used if an image is required. 
                                  // Use "0" for nothing.  For Vertical scrollers, it is best to use "<br>"

/* 
  Because Netscape version 4 does not support this scroller, configure the values below so NS4 users do not see an erro	r. 
  In the scroller's place will be a static title which can be a link if require.  The appearance of the static text (colour, scroller border etc)
  will be exactly the same as for the working version in other browsers.
*/
ns4Text = "";  // Alternative text to display in Netscape 4.
ns4URL = "";            // URL of link in NS4. If no URL is required, enter "none"
ns4Target = "";                           // Frame target for link in NS4

////// DO NOT EDIT BELOW THIS LINE  ///////////////////////////////////////////////////////////////////

//Browser Sniffer
var isIE = (document.getElementById && document.all)?true:false;
var isNS4 = (document.layers)?true:false;
var isNS6 = (document.getElementById && !document.all)?true:false;

if(!isIE)
	scrollerWidth = "160";
	
// Build the scroller and place it on the page
function buildScroller()
{
	htm = "";
	
  if(isNS4){
    htm +='<table border="0" cellpadding="0" cellspacing="0" width="'+scrollerWidth+'"><tr><td>'
    htm +='<table border="0" cellpadding="3" cellspacing="1" width="100%" height="'+scrollerHeight+'"><tr><td align="center" nowrap><p>';
    if(ns4URL.toLowerCase()!="none"){htm+='<a href="'+ns4URL+'" target="'+ns4Target+'">'+ns4Text+'</a>';}
    else{htm+=ns4Text;} 
    htm+='</p></td></tr></table></td></tr></table>'   
  }else{
    htm='<table border="0" cellpadding="0" cellspacing="0" style="width:'+scrollerWidth+';height:'+scrollerHeight+';border:'+borderWidth+'px solid '+borderColour+';background-color:'+backColour+'">';
    htm+='<tr valign="middle"><td><div id="div" style="';
    htm+='width:'+scrollerWidth+'; position:relative; background-color:'+backColour+'; overflow:hidden">';
    htm+='<div id="div1" style="position:relative; left:0; right:0; z-index:1">';
    htm+='<table border="0" name="table" id="table"';
    htm+='><tr>';
    
    y=0;
    
    while (y<4)
    {
      for (x=0; x<(Item.length); x++)
      {
        htm+='<td ';
        
        htm+='nowrap';
		
		if(stopScroll==1){
			htm+=' onMouseOver="stopScroller();" onMouseOut="setWidth()"';
		}
        
        htm+='><p>';
        
        if(Item[x][1].toLowerCase()!="none"){
			htm+='<a class="rcScroller" href="'+Item[x][1]+'" target="'+Item[x][2]+'" >'+Item[x][0]+'<\/a>';
        }
        else{
			htm+=Item[x][0];
		}          
        
        htm+='</p><\/td>';
        
        if(scrollerDivider.toLowerCase() != "none"){
			htm+='<td nowrap><p>'+scrollerDivider+'<\/p><\/td>';
		}
      }
      y++
    }
    htm+='<\/tr><\/table><\/div><\/div><\/td><\/tr><\/table>';  
  }
  document.writeln(htm);
}

// Ensure the width of the scroller is divisible by 2. This allows smooth flowing of the scrolled content
function setWidth(dir)
{ 
  tableObj = (isIE) ? document.all("table") : document.getElementById("table"); 
  obj = (isIE) ? document.all.div1 : document.getElementById("div1");   
  objWidth = tableObj.offsetWidth;
  HalfWidth = Math.floor(objWidth/2);
  
  newWidth = (HalfWidth*2)+2;
  
  obj.style.width = newWidth;
  
  if(dir == DIR_LEFT)
	moveLayerLeft(obj, newWidth);
	
  if(dir == DIR_RIGHT) {
  if(isFirstLoad)
		obj.style.left = ((0-(newWidth/2))/2)
	moveLayerRight(obj, newWidth);
  }
}

var timer;

function moveLayerLeft(obj, width)
{
	var st = "";
	maxLeft = (0-(width/2)+2)/2;
	obj.style.left=(parseInt(obj.style.left) <= maxLeft)? 0 : parseInt(obj.style.left)-1;
	st+=obj.style.left;
	timer = setTimeout("moveLayerLeft(obj, "+width+");", 10); 
}

function moveLayerRight(obj, width)
{
	var st = "";
	maxRight = ((0-(width/2))/2)*-1;
	obj.style.left = (parseInt(obj.style.left) <= 0) ? parseInt(obj.style.left)+1 : maxRight*-1;
	st+=obj.style.left;
	timer = setTimeout("moveLayerRight(obj, "+width+");", 10);
}

function stopScroller()
{
  clearTimeout(timer);  
}

function runScroller(dir){
	isFirstLoad = false;
	if(!isNS4){
		setWidth(dir);
	}
}

function loadScroller() {
	
}
var isFirstLoad = true;

