/* CopyrightTag: Copyright (c) 2004-2008 Satmetrix Systems, Inc. All Rights Reserved. */
/* $Id: spinner.js,v 1.3 2008/01/08 23:54:14 build Exp $ */
var inf_filters = (is_ie5_5up && is_win) ? true : false;   //Are filters supported? Comes from browserCheck.js above

var inf_spinnerCollection = new Array();

infSpinner_existingOnload = (window.onload) ? window.onload : new Function;
window.onload = inf_initSpinners;





/****** FILTERS ******/

var filterList = new Array();



filterList[filterList.length] = 'progid:DXImageTransform.Microsoft.Barn( motion=out,orientation=vertical)';

filterList[filterList.length] = 'progid:DXImageTransform.Microsoft.Fade(Overlap=1.00)';

filterList[filterList.length] = 'progid:DXImageTransform.Microsoft.GradientWipe(GradientSize=0.25,wipestyle=0,motion=forward)';

filterList[filterList.length] = 'progid:DXImageTransform.Microsoft.GradientWipe(GradientSize=0.25,wipestyle=0,motion=reverse)';

filterList[filterList.length] = 'progid:DXImageTransform.Microsoft.Iris(irisstyle=CIRCLE,motion=out)';

filterList[filterList.length] = 'progid:DXImageTransform.Microsoft.Pixelate(duration=2,maxSquare=30)';

filterList[filterList.length] = 'progid:DXImageTransform.Microsoft.RandomDissolve()';

filterList[filterList.length] = 'progid:DXImageTransform.Microsoft.Slide(slidestyle=PUSH,Bands=1)';

filterList[filterList.length] = 'progid:DXImageTransform.Microsoft.Stretch(stretchstyle=PUSH)';

filterList[filterList.length] = 'progid:DXImageTransform.Microsoft.Strips(motion=leftdown)';

filterList[filterList.length] = 'progid:DXImageTransform.Microsoft.Wheel(spokes=6)';

filterList[filterList.length] = 'progid:DXImageTransform.Microsoft.Blinds( Bands=10,direction=up);';

filterList[filterList.length] = 'progid:DXImageTransform.Microsoft.Inset();'

filterList[filterList.length] = 'progid:DXImageTransform.Microsoft.RadialWipe(wipestyle=CLOCK);'

filterList[filterList.length] = 'FILTER: progid:DXImageTransform.Microsoft.Slide(slidestyle=SWAP,Bands=1);'



/****** CONSTRUCTORS ******/

function inf_spinner(name) { 

    this.name = name;
    this.layerId = "inf_spinner_" + name;
    this.delay = "";
    this.style1 = "commentSpinnerOddComments";
    this.style2 = "commentSpinnerEvenComments";
    this.filterType = "";
    this.height = "150";
    this.content = new Array();
    this.target = null;

	//methods
    this.paint = inf_paintSpinner;
    this.getObjStr = inf_getObjStr;

}



/****** METHODS ******/

function inf_paintSpinner() {

  if (is_nav4) {

    var h = (this.height == undefined) ? "150" : this.height;

    document.write ('<ilayer id="' + this.layerId + '_nsOutter" width="100%" height="' + h + '">');

    document.write ('<layer id="' + this.layerId + '_nsInner" height="100%"></layer>');

    document.write ('</ilayer>');

  }

  else {

    document.write ('<div class="commentSpinner" id="' + this.layerId + '" ');

    document.write ('</div>');

  }

}



function inf_getObjStr () {

    var str,obj;

    

    if (is_nav4) {

        str = "document." + this.layerId + "_nsOutter.document." + this.layerId + "_nsInner.document";

    }

    else if (is_ie4) str = "document.all." + this.layerId;

    else str = "document.getElementById('"+ this.layerId + "')";

    obj = eval(str);

    

    return obj;

}



/****** FUNCTIONS ******/

function inf_initSpinners() {

  // First call the cached existing onload function, if any
  infSpinner_existingOnload();
  
  var spinner,myTarget;

  

  for(i=0; i<inf_spinnerCollection.length; i++) {              // for each spinner 

    spinner = inf_spinnerCollection[i];

    spinner.target = eval(spinner.getObjStr());

    var j = 0;

     inf_changeContent(spinner);

  }

}



function inf_changeContent(spinner, spinnerCount){

  var spinnerCount = (!spinnerCount || spinnerCount >= spinner.content.length) ? 0 : spinnerCount;

  

  if (inf_filters) {

    var target = spinner.target.parentElement;

    

    var spinnerIndex = (spinner.filterType == "*") ? Math.floor(Math.random()*(filterList.length)) : spinner.filterType;

    target.style.filter = filterList[spinnerIndex];

    target.filters[0].apply();

    var newStyle = (target.className == spinner.style1) ? spinner.style2 : spinner.style1;


    //target.style.backgroundColor = newColor;
    target.className = newStyle;
    

    inf_writeContent(spinner,spinner.content[spinnerCount]);

    target.filters[0].play();

  }

  else inf_writeContent(spinner,spinner.content[spinnerCount]);

  

  spinnerCount++;

  var evalStr = 'inf_changeContent(' + spinner.name + ',' + spinnerCount +')';

  setTimeout(evalStr,spinner.delay);

}

