
var tObj = new Array();
var tObjIndex = 0;
var colorarray = new Array();
colorarray[0] = "#0000ff";
colorarray[1] = "#00ff00";
colorarray[2] = "#ff0000";
colorarray[3] = "#00ffff";
colorarray[4] = "#ff00ff";
colorarray[5] = "#ccff00";
colorarray[6] = "#66cccc";
colorarray[7] = "#ffffaa";
colorarray[8] = "#ffaaff";
colorarray[9] = "#aaffff";
colorarray[10] = "#ffffff";

function mediatrans(ob,time)
{
	this.childmax = (document.getElementById(ob).getElementsByTagName("div").length)-1;
	this.childarray = document.getElementById(ob).getElementsByTagName("div");
	this.interval=time;
	tObjIndex++;
	this.index = tObjIndex;
	tObj[this.index] = this;
	this.currentchild=0;
	this.direction=1;
	this.count=0;
	this.status=1;
	this.outchild=0;
	this.obj = ob;
	this.fadetimer=0;
	this.timer=0;
	this.start = function()
		{
			if(this.status)
			{
				if(this.childmax)
					{
						this.timer = setInterval("tObj["+this.index+"].cycle()",this.interval);
					}
				else
					{
						this.status=0;
					}
			}
		};
	this.cycle = function()
		{
			this.count=0;
			this.outchild = this.currentchild;
			if(this.direction)
				{
					this.currentchild++;
					if (this.currentchild > this.childmax)
						{
							this.currentchild=0;
						}
				}
			else
				{
					this.currentchild = this.currentchild -1;
					if (this.currentchild < 0)
						{
							this.currentchild = this.childmax;
						}
				}
			this.fadetimer = setInterval("tObj["+this.index+"].fader()",5);
		};
	this.fader = function()
		{
			if (this.count == 0)
				{
					this.childarray[this.currentchild].style.display = "block";
				}
			if (this.count > 100)
				{
					clearInterval(this.fadetimer);
					this.childarray[this.outchild].style.display="none";
				}
			else
				{
					this.childarray[this.outchild].style.opacity = ((101-this.count)*0.01);
					this.childarray[this.outchild].style.filter= "alpha(opacity="+(101-this.count)+")";
					this.childarray[this.currentchild].style.opacity = ((this.count)*0.01);
					this.childarray[this.currentchild].style.filter= "alpha(opacity="+this.count+")";
					this.count=this.count+10;
				}
		};
	this.stop = function()
		{
			clearInterval(this.timer);
			clearInterval(this.fadetimer);
			this.childarray[this.outchild].style.opacity = 0;
			this.childarray[this.outchild].style.filter= "alpha(opacity=0)";
			this.childarray[this.currentchild].style.opacity = 1;
			this.childarray[this.currentchild].style.filter= "alpha(opacity=100)";
		};
	this.big = function()
		{
			this.stop();
			controlimg = "<img src='img/zoomback.png' ";
			controlimg += "style='position:absolute;left:10px;top:10px;z-index:120;cursor:pointer' ";
			controlimg += "title='click to close image' "; 
			controlimg += "onclick='hidemodal();tObj["+this.index+"].status=1;tObj["+this.index+"].start()' />";
picdiv = "<div id='bigpic' style='text-align:center;width:640px;height:480px;overflow:hidden;background-color:#000000;display:table-cell;vertical-align: middle' ></div>";
			document.getElementById('modal').innerHTML=controlimg+picdiv;
			var x = this.childarray[this.currentchild].getElementsByTagName("img");
			document.getElementById('bigpic').innerHTML = "<img src='"+x[0].src+"' style='max-height:480px' />";
			displaymodal();
		};
}




function phrasefade(contain,long)
{
	if(long){this.interval=15000;}else{this.interval=7500;}
	tObjIndex++;
	this.index = tObjIndex;
	tObj[this.index] = this;
	container = document.getElementById(contain);
	this.childarray = container.getElementsByTagName("div");
	this.maxchild = this.childarray.length;
	this.currentchild = 0;
	this.brightening = 0;
	this.fadeout = 100;
	this.start = function()
		{
			this.changinterval = setInterval("tObj["+this.index+"].changeimage()",this.interval)
		}
	this.changeimage = function()
		{
			this.fading = this.childarray[this.currentchild];
			this.fadeinterval = setInterval("tObj["+this.index+"].fadeimage()",300);
			this.currentchild++;
			if (this.currentchild == this.maxchild){this.currentchild = 0;}
			this.brighteningchild = this.childarray[this.currentchild];
			this.brightinterval = setInterval("tObj["+this.index+"].brightimage()",200);
		}
	this.brightimage = function()
		{
			if (this.brightening > 100)
				{
					clearInterval(this.brightinterval);
					this.brightening = 0;
				}
			else
				{
					var bchildren = this.brighteningchild.getElementsByTagName("span");
					for(i=0;i<bchildren.length;i++)
						{
							bchildren[i].style.filter = "alpha(opacity="+this.brightening+")";
							bchildren[i].style.opacity = (this.brightening*0.01);
						}
					if(this.interval == 15000)
						{
							this.brightening += 25;
						}
					this.brightening += 25;	
				}
		}
	this.fadeimage = function()
		{
			if (this.fadeout < 0)
				{
					clearInterval(this.fadeinterval);
					this.fadeout = 100;
				}
			else
				{
					var fchildren = this.fading.getElementsByTagName("span");
					for(i=0;i<fchildren.length;i++)
						{
							fchildren[i].style.filter = "alpha(opacity="+this.fadeout+")";
							fchildren[i].style.opacity = (this.fadeout*0.01);
						}
					if(this.interval == 15000)
						{
							this.fadeout -= 25;
						}
					this.fadeout -= 25;
				}
		}
}

function floater(floatdiv,changeinterval)
{
	this.acc = 1;
	this.divid=document.getElementById(floatdiv);
	tObjIndex++;
	this.mask = floatdiv + "m";
	this.cinterval = changeinterval;
	
	this.index = tObjIndex;
	tObj[this.index] = this;
	this.childarray = this.divid.getElementsByTagName("img");
	this.maxchild = this.childarray.length;
	this.currentchild = 0;
	this.brightening = 0;
	this.fadeout = 100;
	this.initialize = function()
		{
			for (var i=0;i < this.childarray.length;i++)
				{
					if(this.childarray[i].offsetWidth < 260)
						{
							this.childarray[i].style.left = ((260-(this.childarray[i].offsetWidth))/2)+"px";
						}
					if(this.childarray[i].offsetHeight < 280)
						{
							this.childarray[i].style.top = ((280-(this.childarray[i].offsetHeight))/2)+"px";
						}
				}
			if (this.acc == this.maxchild)
				{
					this.start();
				}
			else
				{
					setTimeout("tObj["+this.index+"].initialize()",2000);
				}
		}
	this.start = function()
		{
			
			if(Math.round(Math.random())){this.step = 4;}else{this.step = 2;}		
			if (this.divid.offsetTop < 150)
				{
					this.directiony=this.step;
				}
			else
				{
					this.directiony=(0-this.step);
				}
			if (this.divid.offsetLeft < 300)
				{
					this.directionx=this.step;
				}
			else
				{
					this.directionx=(0-this.step);
				}	
			this.controlinterval = setInterval("tObj["+this.index+"].control()",50);
			this.imageinterval = setInterval("tObj["+this.index+"].changeimage()",this.cinterval);
			var newstop = 20000 + (Math.round(Math.random()*5000));
			setTimeout("tObj["+this.index+"].pause()",newstop);			
		}
	this.pause = function()
		{
			clearInterval(this.controlinterval);
			clearInterval(this.imageinterval);
			var newstart = 3000 + (Math.round(Math.random()*2000));
			setTimeout("tObj["+this.index+"].start()",newstart);
		}
	this.changeimage = function()
		{
			this.childarray[this.currentchild].style.filter = "alpha(opacity=0)";
			this.childarray[this.currentchild].style.opacity = 0;
			this.currentchild++;
			if (this.currentchild == this.maxchild){this.currentchild = 0;}
			this.childarray[this.currentchild].style.filter = "alpha(opacity=100)";
			this.childarray[this.currentchild].style.opacity = 1;
			var newcol = (Math.round(Math.random()*10));
			document.getElementById(this.mask).style.backgroundColor = colorarray[newcol];
		}
	this.control = function()
		{
			if (this.divid.offsetTop < -150){this.directiony=this.step;}
			if (this.divid.offsetTop > 240){this.directiony=(0-this.step);}
			if (this.divid.offsetLeft < -100)
				{
					this.directionx=this.step;
					if(Math.round(Math.random())){this.divid.style.top = (this.divid.offsetTop + 5)+"px";}
				}
			if (this.divid.offsetLeft > 420)
				{
					this.directionx=(0-this.step);
					if(Math.round(Math.random())){this.divid.style.top = (this.divid.offsetTop - 5)+"px";}
				}
			this.divid.style.top = (this.divid.offsetTop + this.directiony) + "px";
			this.divid.style.left = (this.divid.offsetLeft + this.directionx) + "px";
		}
}



