// Use Freely as long as following disclaimer is intact ::
//---------------------------------------------------------------
// Cross Browser Multi-Directional Scroller v1.0 24th August 2004
// This script written by Rik Comery. www.ricom.co.uk
// For support, visit the "Resources" section at www.ricom.co.uk
// All rights reserved.
// Featured in the SimplytheBest DHTML Scripts Library at http://simplythebest.net/scripts/

/* 		SCROLLER CONFIGURATION 		*/

orientation = "vertical";        // Orientation of scroller (Horizontal or vertical)
scrollerWidth = "250px";             // Width of entire scroller.
scrollerHeight = "20px";             // Height of Scroller.
borderWidth = "1";                   // Width of border. (use 0 for no border).
borderColour = "#CCCCCC";          // Colour of scroller border. (Use either hexadecimal or text values. e.g. "#FF0000" or "Red")
backColour = "transparent";              // Colour of scroller background. (Use either hexadecimal or text values. e.g. "#FF0000" or "Red")
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)
delay = new Array(340,260); //tecrif :: ms delay
step = 1;    //tecrif :: pixels scrolling at one step

var timer2 = new Array();
var status2 = new Array(true,true,true);

////// DO NOT EDIT BELOW THIS LINE  ///////////////////////////////////////////////////////////////////

//Browser Sniffer
var isIE 	= (document.getElementById && document.all)?true:false;
var isNS6 	= (document.getElementById && !document.all)?true:false;

document.write('<div id="chartDisplay" style="position:absolute; z-index:100; visibility:hidden;"></div>');
function buildScroller(scroller_id)
{
    document.write('<div id="chartDisplay" style="position:absolute; z-index:100; visibility:hidden;"></div>');
    scroller='<table border="0" cellpadding="0" cellspacing="0" style="width:'+scrollerWidth+';height:'+scrollerHeight+';border:'+borderWidth+'px solid '+borderColour+';background-color:'+backColour+'">';
    scroller+='<tr valign="middle"><td><div id="div'+scroller_id+'" style="';
    if(orientation.toLowerCase()=="vertical"){scroller+='height:'+scrollerHeight+';';}
    scroller+='width:'+scrollerWidth+'; position:relative; background-color:'+backColour+'; overflow:hidden;">';
    scroller+='<div id="scroller'+scroller_id+'" style="position:relative; left:0; z-index:1;"';
    if(stopScroll==1){
        scroller+=' onMouseOver="stopScroller('+scroller_id+');" onMouseOut="setWidth('+scroller_id+')"';}
    scroller+='><table cellpadding="0" cellspacing="0"  border="0" name="table" id="scrollerTable'+scroller_id+'"';
    if(orientation.toLowerCase()=="vertical"){scroller+='style="width:'+scrollerWidth+'"';}
    scroller+='><tr><td id="tickerContent2-'+scroller_id+'">';
    scroller+='<\/td><\/tr><\/table><\/div><\/div><\/td><\/tr><\/table>';
    document.writeln(scroller);
}

// Ensure the width of the scroller is divisible by 2. This allows smooth flowing of the scrolled content
function setWidth(scroller_id) {
  tableObj=(isIE)?eval("document.all.scrollerTable"+scroller_id):document.getElementById("scrollerTable"+scroller_id);
  obj=(isIE)?eval("document.all.scroller"+scroller_id):document.getElementById("scroller"+scroller_id);
  objWidth=(orientation.toLowerCase()=="horizontal")?getOffset(tableObj,"width"):getOffset(tableObj,"height");
  newWidth = (Math.floor(objWidth/2)*2)+2;
  obj.style.width=newWidth;
  moveLayer(scroller_id, newWidth);
}

// Move the layer by <step> pixels to the left
function moveLayer(scroller_id, width) {
  target = 'scroller'+scroller_id;
  obj=(isIE)?eval('document.all.'+target):document.getElementById(target);
  if(obj.style.left=="") obj.style.left=0;
  if(obj.style.top=="") obj.style.top=0;
  limit = -width + step;
  switch(orientation.toLowerCase()) {
    case "horizontal":
       value = parseInt(obj.style.left);
       obj.style.left = eval((value <= limit )?5*step:value - step)+'px';
       break;
    case "vertical":
       value = parseInt(obj.style.top);
       obj.style.top = eval((value <= limit)?5*step:value - step)+'px';
       break;
  }
  timer2['scroller'+scroller_id] = setTimeout ('moveLayer('+scroller_id+', '+width+');', delay[scroller_id-1]);
  status2[scroller_id-1] = true;
}

// Get width and height of layer
function getOffset(obj, dim) {
  if(dim=="width")
  {
    oWidth = obj.offsetWidth
    return oWidth
  }
  else if(dim=="height")
  {
    oHeight = obj.offsetHeight
    return oHeight
  }
}

function stopScroller(scroller_id) {
  if(timer2['scroller'+scroller_id]) {
    status2[scroller_id-1] = false;
    clearTimeout(timer2['scroller'+scroller_id]);
  }
}

function runScroller(scroller_id) {
  stopScroller(scroller_id);
  setWidth(scroller_id);
  status2[scroller_id-1] = true;
}

    var timeOuts2 = new Array();
    var tickers2 = new Array(1,0);
    var itemIndex2 = 0;
    var completed2 = false;
    var loading2 = false;

	function processAnswer2(item) {
 	      if (xmlhttp.readyState==4) {
             if (xmlhttp.status==200) {
			         target = 'tickerContent2-'+item;
				     document.getElementById(target).innerHTML = xmlhttp.responseText;
			         document.getElementById('statusTicker2-'+item).src="http://www.bessette-assurances.com//modules/mod_WISroYahooQuotes/WISroYahooQuotes/online.jpg";
                   loading2 = false;
                   			       if(itemIndex2 < tickers2.length-2) {
			       	itemIndex2++;
                            	time = 100; //+50*2;
				}
				else {
	                            //document.getElementById('loader').innerHTML += '>OK ... completed list <br />';
	                            itemIndex2 = 0;
	                            time = 20000;
				       completed2 = true;
				}
		             if(!loading2 && time > 0) {
		              timeOuts2['tickers'] = setTimeout("loadData2()",  time);
		             }
		        }
           }
	}
    function initData2() {
	//alert('2');
        itemIndex2 = 0;
        completed2 = false;
        loading2 = false;
    }
    function loadData2() {
        theItem = tickers2[itemIndex2];
        pURL = 'http://www.bessette-assurances.com//modules/mod_WISroYahooQuotes/mod_WISroYahooQuotes_htm.php?access=WISroYQ&nocaching='+ Math.floor(Math.random()*1000)+'&UniqueID=2&Ajax=20&timeout=15&DisplayDate=1&DisplayName=1&MinichartSource=ichart.finance.yahoo.com&DisplayChange=1&BackColor=transparent&BorderSize=1&BorderColor=%23CCCCCC&Color1=%23EFEFEF&Color2=%23FFFFFF&TickerOrientation=vertical&Ticker1Name=Ticker+%231&Ticker1=%5EGSPC%2C%5EGSPTSE%2C%5ENYA&Ticker2Name=Ticker+%232&Ticker2=%5EFTSE%2C%5EGDAXI&Ticker3Name=Ticker+%233&Tickers=1&TickerDelays=340%2C260&DisplayReload=1&ScrollBehaviour=1&ScrollWidth=250px&ScrollHeight=20px&ScrollAmount=1&ScrollSpaceChar=%7C&TickerDesc1=%2C%2C&TickerDesc2=%2C&TickerDesc3=&joomla_version=1.5&inc=/var/www/vhosts/bessette-assurances.com/httpdocs&id='+theItem;
	 var flag = false;
        if (window.XMLHttpRequest) { // code for Mozilla, Safari, etc
		xmlhttp = new XMLHttpRequest();
            flag = true;
	  } else if (window.ActiveXObject) { //IE
			xmlhttp = new ActiveXObject('Microsoft.XMLHTTP');
			if (xmlhttp) {
				flag = true;
			}
        }
        if (flag && !loading2) {
            completed2 = false;
             document.getElementById('statusTicker2-'+theItem).src="http://www.bessette-assurances.com//modules/mod_WISroYahooQuotes/WISroYahooQuotes/offline.jpg";
                   		stopScroller(theItem);
            xmlhttp.onreadystatechange = function(rtn) { processAnswer2(theItem); };
	        xmlhttp.open('GET', pURL, true);   // leave true for Gecko
	        xmlhttp.send(null);
            loading2 = true;
	    };
}
