

/*************************************************************************
  dw_lib.js - used with dw_glide.js, dw_glider.js, ...
  document.getElementById and document.all compatible (not ns4)
  version date September 2003
  
  This code is from Dynamic Web Coding 
  at http://www.dyn-web.com/
  Copyright 2003 by Sharon Paine 
  See Terms of Use at http://www.dyn-web.com/bus/terms.html
  Permission granted to use this code 
  as long as this entire notice is included.
*************************************************************************/

dynObj2.holder = {}; 
// constructor
function dynObj2(id,x,y,w,h) {
  this.el = dynObj2.getElemRef(id);
  if (!this.el) return;  this.id = id; 
  dynObj2.holder[this.id] = this; this.animString = "dynObj2.holder." + this.id;
  var px = window.opera? 0: "px";
	this.x = x || 0;	if (x) this.el.style.right = this.x + px;
	this.y = y || 0;	if (y) this.el.style.top = this.y + px;
	this.w = w || this.el.offsetWidth || 0;	this.h = h || this.el.offsetHeight || 0;
	// if w/h passed, set style width/height
	if (w) this.el.style.width = w + px; if (h) this.el.style.height = h + px;
  // methods (ref's)
  this.shiftTo = dw_shiftTo;  
  this.shiftBy = dw_shiftBy;
  this.show = dw_show;  
  this.hide = dw_hide;  
}

// ref can be discarded (with other prop's retained) and re-obtained using getInstance
dynObj2.getElemRef = function(id) { 
  var el = document.getElementById? document.getElementById(id): document.all? document.all[id]: null;
  return el;
} 

dynObj2.getInstance = function(id) {
  var obj = dynObj2.holder[id];
  if (!obj) obj = new dynObj2(id);
  else if (!obj.el) obj.el = dynObj2.getElemRef(id);
  return obj;
}

function dw_shiftTo(x,y) {
  if (x != null) this.el.style.right = (this.x = x) + "px";
  if (y != null) this.el.style.top = (this.y = y) + "px";
}

function dw_shiftBy(x,y) { this.shiftTo(this.x+x, this.y+y); }
function dw_show() { this.el.style.visibility = "visible"; }
function dw_hide() { this.el.style.visibility = "hidden"; }  


// for time-based animations
// resources: www.13thparallel.org and www.youngpup.net (accelimation)
var dw_Bezier = {
  B1: function (t) { return t*t*t },
  B2: function (t) { return 3*t*t*(1-t) },
  B3: function (t) { return 3*t*(1-t)*(1-t) },
  B4: function (t) { return (1-t)*(1-t)*(1-t) },
  // returns current value based on percentage of time passed
  getValue: function (percent,startVal,endVal,c1,c2) {
    return endVal * this.B1(percent) + c2 * this.B2(percent) + c1 * this.B3(percent) + startVal * this.B4(percent);
  }
}

// adapted from accelimation.js by Aaron Boodman of www.youngpup.net
dw_Animation = {
  instances: [],
  add: function(fp) {
    this.instances[this.instances.length] = fp;
  	if (this.instances.length == 1) this.timerID = window.setInterval("dw_Animation.control()", 20);
  },
  
  remove: function(fp) {
    for (var i = 0; i < this.instances.length; i++) {
  		if (fp == this.instances[i]) {
  			this.instances = this.instances.slice(0,i).concat( this.instances.slice(i+1) );
  			break;
  		}
  	}
  	if (this.instances.length == 0) {
  		window.clearInterval(this.timerID);	this.timerID = null;
  	}
  },
  
  control: function() {
    for (var i = 0; i < this.instances.length; i++) {
  		if (typeof this.instances[i] == "function" ) this.instances[i]();
      else eval(this.instances[i]);
    }
  }
}

/*
		dw_glider.js - requires dw_lib.js
		glide to maintain window location on scroll
		version date: September 2003 

		This code is from Dynamic Web Coding 
    at http://www.dyn-web.com/
    See Terms of Use at http://www.dyn-web.com/bus/terms.html
    Permission granted to use this code 
    as long as this entire notice is included.	
    
    Resources: ypChaser by Aaron Boodman (www.youngpup.net)
    DHTML chaser tutorial at DHTML Lab - www.webreference.com/dhtml		
*/

Glider.holder = [];
function Glider(id,x,y,w,h,d,ac) {
	this.glideDur = d || 1000; 
	this.origX = x; 
	this.origY = y; 
	this.ac = -ac || 0;
	this.baseObj = dynObj2;
	this.baseObj(id,x,y,w,h);
  Glider.holder[Glider.holder.length] = this;
  if (!Glider.winHt) Glider.winHt = getWinHeight();
}
Glider.prototype = new dynObj2;
Glider.prototype.onGlideInit = function () {}

Glider.prototype.checkGlider = function() {
	var destY;
	if (getScrollY() > 70) destY = getScrollY() + 10;
	else destY = getScrollY() + this.origY;
	//var destY = getScrollY() + this.origY;
	if (destY != this.y) {
		//if scroll y has changed
		if (destY != this.dy) {
			//it's a new move
			this.dy = destY;
			this.glideInit();
      	this.onGlideInit();
		} 
		if (Glider.winHt > 490){
			this.glide();
		}
	}
}

Glider.prototype.glideInit = function() {
	this.gt = new Date().getTime();
	var distY = this.dy - this.y;
	if ( Math.abs(distY) > Glider.winHt ) {	// distance greater than window height?
		this.gsy = (distY > 0)? this.dy - Glider.winHt: this.dy + Glider.winHt;
	} 
	else this.gsy = this.y;
	this.g_yc1 = this.gsy + ( (1+this.ac) * (this.dy - this.gsy)/3 );
	this.g_yc2 = this.gsy + ( (2+this.ac) * (this.dy - this.gsy)/3 );
}

Glider.prototype.glide = function() {
	var elapsed = new Date().getTime() - this.gt;
	if (elapsed < this.glideDur) {
		var y = dw_Bezier.getValue( elapsed/this.glideDur, this.gsy, this.dy, this.g_yc1, this.g_yc2 );
		this.shiftTo(null,y);
	} 
	else this.shiftTo(null,this.dy);
}

Glider.control = function() {
  for (var i=0; i<Glider.holder.length; i++) {
    var curObj = Glider.holder[i];
    if (curObj) curObj.checkGlider();
  }
}
//Glider.timer = setInterval("Glider.control()",20);
dw_Animation.add(Glider.control);

// returns height of window
function getWinHeight() {
	var winHt = 0;
	if (window.innerHeight) winHt = window.innerHeight-18;
	else if (document.documentElement && document.documentElement.clientHeight) 
		winHt = document.documentElement.clientHeight;
	else if (document.body && document.body.clientHeight) 
		winHt = document.body.clientHeight;
	return winHt;
}	

// returns amount of vertical scroll
function getScrollY() {
	var sy = 0;
	if (document.documentElement && document.documentElement.scrollTop)
		sy = document.documentElement.scrollTop;
	else if (document.body && document.body.scrollTop) 
		sy = document.body.scrollTop; 
	else if (window.pageYOffset)
		sy = window.pageYOffset;
	else if (window.scrollY)
		sy = window.scrollY;
	return sy;
}

// onresize, get window height
if (window.addEventListener)
	//Mozilla
	window.addEventListener("resize", function(){ Glider.winHt = getWinHeight(); }, "false");
else if (window.attachEvent)
	//IE
	window.attachEvent("onresize", function(){ Glider.winHt = getWinHeight(); } );
  

function initStatLyr() {
	// args: id, right, top, w, h, duration of glide to location onscroll, acceleration factor
  // acceleration factor should be -1 to 1. -1 is full deceleration
	var statLyr = new Glider("right_col",2,10,null,null,1000,-1.2);
  statLyr.show();
}


function getImageToDisplay(fileName, Name, Id, FileNameLocation){
	returnFile = '<a STYLE="color:white;" HREF="/play/?id=' + Id + '">' + Name + '</a><BR>';
	returnFile = returnFile + '<a HREF="' + FileNameLocation +'"><IMG SRC="http://online.casinocity.com/PropertyImages/md/'+fileName+'" height=149 width=200 alt="Click to See the Details!" BORDER="0" title="Click to See the Details!"></A>';
	return returnFile;
}

//initialize on load
if (document.getElementById) window.onload = initStatLyr;



