// JavaScript Document
/******************************************
* Scrollable content script III- (Modified from II) © Dynamic Drive (www.dynamicdrive.com)
* Visit http://www.dynamicdrive.com/ for full source code
* This notice must stay intact for use
******************************************/

function SCWindow(name,width,height){
  this.name = name
  this.objname = name
  this.width = width
  this.height = height
  this.contentwidth = this.width - 4
  //specify speed of scroll (greater=faster)
  this.speed = 5
}

SCWindow.prototype.initialize = function(){
    var id = this.name + "content"
    var id2 = this.name + "content2"
    this.crossobj = document.getElementById? document.getElementById(id2) : document.all[id2]
    this.contentbox = document.getElementById? document.getElementById(id) : document.all[id]
    this.contentheight=this.crossobj.offsetHeight
    //this.contentwidth=this.crossobj.scrollWidth
	//this.contentwidth=1296
	this.contentwidth= document.getElementById("time").offsetWidth
	
    this.contentbox.style.height = this.contentheight + "px"
	this.contentbox.style.width = this.contentwidth + "px"
    this.limit = this.height-this.contentheight
	this.widthlimit = this.width-this.contentwidth
}

SCWindow.prototype.movedown = function (){
  var thisthis = this
  var topint = parseInt(this.crossobj.style.top)
  if (topint>=this.limit){
    this.crossobj.style.top=topint-this.speed+"px"
    this.movedownvar=setTimeout(function(){thisthis.movedown()},30)
  }
}

SCWindow.prototype.moveup = function (){
  var thisthis = this
  var topint = parseInt(this.crossobj.style.top)
  if (topint<0){
    this.crossobj.style.top=topint+this.speed+"px"
    this.moveupvar=setTimeout(function(){thisthis.moveup()},30)
  }
}

SCWindow.prototype.pagedown = function (){
  var thisthis = this
  var topint = parseInt(this.crossobj.style.top)
  if (topint >= (this.limit + 110)){
    var val = topint - 110
    if (val < this.limit){val=this.limit}
    this.crossobj.style.top=val+"px"
  }
}

SCWindow.prototype.pageup = function (){
  var thisthis = this
  var topint = parseInt(this.crossobj.style.top)
  if (topint<0){
    var val = topint + 110
    if(val > 0){val = 0}
    this.crossobj.style.top=val+"px"
  }
}

SCWindow.prototype.pageright = function (){
  var thisthis = this
  var leftint = parseInt(this.crossobj.style.left)
  var timeline = document.getElementById("time")

  if (leftint>=this.widthlimit){
    var val = leftint - 108
    if (val<this.widthlimit){val=this.widthlimit}
	  //alert(leftint + ":" + val)
    this.crossobj.style.left=val+"px" 
	timeline.style.left=val+"px"
  }
}

SCWindow.prototype.pageleft = function (){
  var thisthis = this
  var leftint = parseInt(this.crossobj.style.left)
  var timeline = document.getElementById("time")
  
  if (leftint<0){
    var val = leftint + 108
    if(val > 0){val = 0}
    this.crossobj.style.left=val+"px"
	timeline.style.left=val+"px"
  }
}

SCWindow.prototype.stop = function (){
  clearTimeout(this.moveupvar)
  clearTimeout(this.movedownvar)
}

SCWindow.prototype.control = function(cont){
  this.stop()
  switch (cont) {
    case "up"     : this.moveup(); break;
    case "down"   : this.movedown(); break;
    case "pgup"   : this.pageup(); break;
    case "pgdn"   : this.pagedown(); break;
	case "pgleft" : this.pageleft(); break;
	case "pgright": this.pageright(); break;
    case "play"   : this.movedown(); break;
    case "reverse": this.moveup();
  }
}

SCWindow.prototype.startblock = function (contentstyle){
  var s = ""
  if(contentstyle){s = contentstyle}
  document.write('<div class="scwd1" id="' + this.name + 'container" style="width: ' + this.width + 'px; height: ' + this.height + 'px;">')
  document.write('<div class="scwd2" id="' + this.name + 'content2" style="width: ' + this.width + 'px; left: 0pt; top: 0px;">')
  document.write('<div class="scwd3" id="' + this.name + 'content" style="width: ' + this.contentwidth + 'px; clip: rect(0pt, 0pt, ' + this.width + 'px, ' + this.height + 'px);' + s + '">')
}

SCWindow.prototype.endblock = function (){
  document.write('</div></div></div>')
}

SCWindow.prototype.makecontrols = function (upimage,downimage){
  document.write('<div class="scwscrollcontrol" id="' + this.name + 'scroll">')
  document.write('<a class="scwbuttons" href="#" onClick="return false" onmouseover="' + this.objname + '.control(\'up\')" onmouseout="' + this.objname + '.stop()">')
  if(upimage){document.write('<img src="' + upimage + '" border="0" alt="/\\ ">')}else{document.write('/\\ ')}
  document.write('<a class="scwbuttons" href="#" onClick="return false" onmouseover="' + this.objname + '.control(\'down\')" onmouseout="' + this.objname + '.stop()">')
  if(downimage){document.write('<img src="' + downimage + '" border="0">')}else{document.write('\\/')}
  document.write('</a></div>')
}

SCWindow.prototype.makepagecontrols = function (upimage,downimage){
  document.write('<div class="scwpagecontrol" id="' + this.name + 'page">')
  document.write('<div id="bigup"><a class="scwbuttons" href="javascript: ' + this.objname + '.control(\'pgup\')">')
  if(upimage){document.write(upimage)}else{document.write('//\\\\ ')}
  document.write('</a></div><div id="bigdown"><a class="scwbuttons" href="javascript: ' + this.objname + '.control(\'pgdn\')">')
  if(downimage){document.write(downimage)}else{document.write('\\\\//')}
  document.write('</a></div></div>')

}

/*SCWindow.prototype.makecontrols = function (leftimage,rightimage){
  document.write('<div class="scwscrollcontrol" id="' + this.name + 'scroll">')
  document.write('<a class="scwbuttons" href="#" onClick="return false" onmouseover="' + this.objname + '.control(\'pgleft\')" onmouseout="' + this.objname + '.stop()">')
  if(leftimage){document.write('' + leftimage + '')}else{document.write('/\\ ')}
  document.write('<a class="scwbuttons" href="#" onClick="return false" onmouseover="' + this.objname + '.control(\'pgright\')" onmouseout="' + this.objname + '.stop()">')
  if(rightimage){document.write('' + rightimage + '')}else{document.write('\\/')}
  document.write('</a></div>')
}*/

SCWindow.prototype.makepagecontrols2 = function (leftimage,rightimage){
  document.write('<div class="scwpagecontrol" id="' + this.name + 'page">')
  document.write('<div id="bigprev"><a class="scwbuttons" href="javascript: ' + this.objname + '.control(\'pgleft\')">')
  if(leftimage){document.write(leftimage)}else{document.write('//\\\\ ')}
  document.write('</a></div><div id="bignext"><a class="scwbuttons" href="javascript: ' + this.objname + '.control(\'pgright\')">')
  if(rightimage){document.write(rightimage)}else{document.write('\\\\//')}
  document.write('</a></div></div>')

}

SCWindow.prototype.makeplaycontrols = function (stopimage,playimage,reverseimage){
  document.write('<div class="scwplaycontrol" id="' + this.name + 'play">')
  document.write('<a class="scwbuttons" href="javascript: ' + this.objname + '.control(\'reverse\')">')
  if(reverseimage){document.write('<img src="' + reverseimage + '" border="0">')}else{document.write('< ')}
  document.write('</a><a class="scwbuttons" href="javascript: ' + this.objname + '.stop()">')
  if(stopimage){document.write('<img src="' + stopimage + '" border="0">')}else{document.write('0')}
  document.write('</a><a class="scwbuttons" href="javascript: ' + this.objname + '.control(\'play\')">')
  if(playimage){document.write('<img src="' + playimage + '" border="0">')}else{document.write(' >')}
  document.write('</a></div>')

}
