function countdownObject(id, td, ca, cs,lz,df,fm) {
  this.CountID = id;
  this.TargetDate = td;
  this.CountActive = ca;
  this.CountStepper = cs;
  this.LeadingZero = lz;
  this.DisplayFormat = df;
  this.FinishMessage = fm;

  this.SetTimeOutPeriod;
  this.secs;

  this.t;

  this.runme = run;
  this.CountMeBack = CountBack;

  function calcage(secs, num1, num2) {
    s = ((Math.floor(secs/num1))%num2).toString();
    if (this.LeadingZero && s.length < 2) {
      s = "0" + s;
    }
    return "<b>" + s + "</b>";
  }

  function CountBack() {
    if (this.secs < 0) {
      document.getElementById(this.CountID).innerHTML = this.FinishMessage;
      return;
    }
    DisplayStr = this.DisplayFormat.replace(/%%D%%/g, calcage(this.secs,86400,100000));
    DisplayStr = DisplayStr.replace(/%%H%%/g, calcage(this.secs,3600,24));
    DisplayStr = DisplayStr.replace(/%%M%%/g, calcage(this.secs,60,60));
    DisplayStr = DisplayStr.replace(/%%S%%/g, calcage(this.secs,1,60));

    document.getElementById(this.CountID).innerHTML = DisplayStr;
//alert("test");
    if (this.CountActive) {
	  this.secs = this.secs + this.CountStepper;
	}
  }

  function run() {
    this.CountStepper = Math.ceil(this.CountStepper);
    if (this.CountStepper == 0) {
      this.CountActive = false;
    }
    this.SetTimeOutPeriod = (Math.abs(this.CountStepper)-1)*1000 + 990;
    var dthen = new Date(this.TargetDate);
    var dnow = new Date();
    if(this.CountStepper > 0) {
      ddiff = new Date(dnow-dthen);
    } else {
      ddiff = new Date(dthen-dnow);
    }
    this.secs = Math.floor(ddiff.valueOf()/1000);
    if (this.CountActive) {
      setInterval(""+this.CountMeBack()+"", this.SetTimeOutPeriod);
	} else {
      this.CountMeBack();
	}
  }
}

function start_slideshow(start_frame, end_frame, delay) {
    setTimeout(switch_slides(start_frame, start_frame, end_frame, delay), delay);
}

function switch_slides(frame, start_frame, end_frame, delay) {
    return (function() {
        Effect.Fade('mk' + frame + 'top');
        if (frame == end_frame) { frame = start_frame; } else { frame = frame + 2; }
        Effect.Appear('mk' + frame + 'top');
        setTimeout(switch_slides(frame, start_frame, end_frame, delay), delay + 850);
   })
}


function opentime(pageToOpen)
{
  var width  = 800;
  var height = 600;
  var left   = (screen.width  - width)/2;
  var top    = (screen.height - height)/2;
  var params = 'width='+width+', height='+height;
  params += ', top='+top+', left='+left;
  params += ', directories=no';
  params += ', location=no';
  params += ', menubar=no';
  params += ', resizable=no';
  params += ', scrollbars=yes';
  params += ', status=no';
  params += ', toolbar=no';
  newwin=window.open(pageToOpen,'', params);
}

function opentimew(pageToOpen, width)
{
  var width  = width;
  var height = 600;
  var left   = (screen.width  - width)/2;
  var top    = (screen.height - height)/2;
  var params = 'width='+width+', height='+height;
  params += ', top='+top+', left='+left;
  params += ', directories=no';
  params += ', location=no';
  params += ', menubar=no';
  params += ', resizable=no';
  params += ', scrollbars=yes';
  params += ', status=no';
  params += ', toolbar=no';
  newwin=window.open(pageToOpen,'', params);
}

function opentimewh(pageToOpen, width, height)
{
  var width  = width;
  var height = height;
  var left   = (screen.width  - width)/2;
  var top    = (screen.height - height)/2;
  var params = 'width='+width+', height='+height;
  params += ', top='+top+', left='+left;
  params += ', directories=no';
  params += ', location=no';
  params += ', menubar=no';
  params += ', resizable=no';
  params += ', scrollbars=yes';
  params += ', status=no';
  params += ', toolbar=no';
  newwin=window.open(pageToOpen,'', params);
}

function opentime2(pageToOpen)
{
  var width  = screen.width;
  var height = screen.width;
  var left   = 0;
  var top    = 0;
  var params = 'width='+width+', height='+height;
  params += ', top='+top+', left='+left;
  params += ', directories=no';
  params += ', location=no';
  params += ', menubar=no';
  params += ', resizable=yes';
  params += ', scrollbars=yes';
  params += ', status=no';
  params += ', toolbar=no';
  newwin=window.open(pageToOpen,'', params);
}

function opentime3(pageToOpen)
{
  var width  = screen.width;
  var height = screen.width;
  var left   = 0;
  var top    = 0;
  var params = 'width='+width+', height='+height;
  params += ', top='+top+', left='+left;
  newwin=window.open(pageToOpen,'', params);
}

