function TabbedPanelsCycler(tp)
{
this.tp = tp;
this.timerID = 0;
this.interval = 5000; // Milliseconds
}

TabbedPanelsCycler.prototype.start = function()
{
this.stop();
var self = this;
this.timerID = setTimeout(function() { self.next(); }, this.interval);
};

TabbedPanelsCycler.prototype.stop = function()
{
if (this.timerID)
clearTimeout(this.timerID);
this.timerID = 0;
};

TabbedPanelsCycler.prototype.next = function()
{
var tp = this.tp;
Spry.Effect.DoFade('panel_content' + (tp.getCurrentTabIndex()+1) % tp.getTabbedPanelCount(), {duration: 500, from: 100, to: 0, toggle: false, finish: function(){
var el = document.getElementById('panel_content' + ((tp.getCurrentTabIndex() + 2) % tp.getTabbedPanelCount()));
tp.showPanel((tp.getCurrentTabIndex()+1) % tp.getTabbedPanelCount()); // 1, 2, 3, 4, 0 ... loop
Spry.Effect.DoFade('panel_content' + (tp.getCurrentTabIndex() + 1) % tp.getTabbedPanelCount(), {duration: 500, from: 0, to: 100, toggle: false});
}
});
if (this.timerID)
this.start();
};

TabbedPanelsCycler.prototype.previous = function()
{
var tp = this.tp;
var curIndex = tp.getCurrentTabIndex();
tp.showPanel(((curIndex < 1) ? tp.getTabbedPanelCount() : curIndex) - 1);
if (this.timerID)
this.start();
};

function MM_effectAppearFade(targetElement, duration, from, to, toggle)
{
Spry.Effect.DoFade(targetElement, {duration: duration, from: from, to: to, toggle: toggle});
};

var dsFeaturebox1 = new Spry.Data.XMLDataSet("assets/xml/featurebox_data.xml", "featurebox/feature1");
var dsFeaturebox2 = new Spry.Data.XMLDataSet("assets/xml/featurebox_data.xml", "featurebox/feature2");
var dsFeaturebox3 = new Spry.Data.XMLDataSet("assets/xml/featurebox_data.xml", "featurebox/feature3");
var dsFeaturebox4 = new Spry.Data.XMLDataSet("assets/xml/featurebox_data.xml", "featurebox/feature4");
var dsFeaturebox5 = new Spry.Data.XMLDataSet("assets/xml/featurebox_data.xml", "featurebox/feature5");
var dsFeaturebox1fra = new Spry.Data.XMLDataSet("assets/xml/featurebox_data.xml", "featurebox/feature1fra");
var dsFeaturebox2fra = new Spry.Data.XMLDataSet("assets/xml/featurebox_data.xml", "featurebox/feature2fra");
var dsFeaturebox3fra = new Spry.Data.XMLDataSet("assets/xml/featurebox_data.xml", "featurebox/feature3fra");
var dsFeaturebox4fra = new Spry.Data.XMLDataSet("assets/xml/featurebox_data.xml", "featurebox/feature4fra");
var dsFeaturebox5fra = new Spry.Data.XMLDataSet("assets/xml/featurebox_data.xml", "featurebox/feature5fra");

function MM_CheckFlashVersion(reqVerStr,msg){
  with(navigator){
    var isIE  = (appVersion.indexOf("MSIE") != -1 && userAgent.indexOf("Opera") == -1);
    var isWin = (appVersion.toLowerCase().indexOf("win") != -1);
    if (!isIE || !isWin){  
      var flashVer = -1;
      if (plugins && plugins.length > 0){
        var desc = plugins["Shockwave Flash"] ? plugins["Shockwave Flash"].description : "";
        desc = plugins["Shockwave Flash 2.0"] ? plugins["Shockwave Flash 2.0"].description : desc;
        if (desc == "") flashVer = -1;
        else{
          var descArr = desc.split(" ");
          var tempArrMajor = descArr[2].split(".");
          var verMajor = tempArrMajor[0];
          var tempArrMinor = (descArr[3] != "") ? descArr[3].split("r") : descArr[4].split("r");
          var verMinor = (tempArrMinor[1] > 0) ? tempArrMinor[1] : 0;
          flashVer =  parseFloat(verMajor + "." + verMinor);
        }
      }
      // WebTV has Flash Player 4 or lower -- too low for video
      else if (userAgent.toLowerCase().indexOf("webtv") != -1) flashVer = 4.0;

      var verArr = reqVerStr.split(",");
      var reqVer = parseFloat(verArr[0] + "." + verArr[2]);
  
      if (flashVer < reqVer){
        if (confirm(msg))
          window.location = "http://www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash";
      }
    }
  } 
}
window.onload = function(){
cycler.start();
}
