var slide = new scrollObject("channelsSet", 250, 250, 3000, 1.13);
    slide.channels[0] = 'image/slide1.jpg';
    slide.channels[1] = 'image/slide2.jpg';
    slide.channels[2] = 'image/slide3.jpg';
    slide.channels[3] = 'image/slide4.jpg';
    slide.channels[4] = 'image/slide5.jpg';

var text = new Array();
	text[0] = new textObj("Snow Theme", "The inside scoop on your favorite bands and music.");
	text[1] = new textObj("Home Theme", "Jaw-dropping, bone crunching fight action for boxing, wrestling, and mixed martial arts fans.");
	text[2] = new textObj("Binoculars Theme", "Jaw-dropping, bone crunching fight action for boxing, wrestling, and mixed martial arts fans.");
	text[3] = new textObj("Valentine Theme", "Jaw-dropping, bone crunching fight action for boxing, wrestling, and mixed martial arts fans.");
	text[4] = new textObj("Key Hole Theme", "Jaw-dropping, bone crunching fight action for boxing, wrestling, and mixed martial arts fans.");


window.onload = function() {
  slide.start();
}


function scrollObject(main, width, height, pause, speed) {
	var self = this;
	this.main = main;
	this.width = width;
	this.height = height;
	this.pause = pause;
	this.speed = Math.max(1.001, Math.min(width, speed));
	this.channels = new Array();	
	this.text = new Array();	
	this.start = function() {
		this.main = document.getElementById(this.main);
		while (this.main.firstChild) this.main.removeChild(this.main.firstChild); // Clean out the original content
		this.main.style.overflow = "hidden";
		this.main.style.position = "relative";
		this.main.style.width = this.width + "px";
		this.main.style.height = this.height + "px";
		var tempW = 40; var tempH = 40;
		var tempX = 0; var tempY = 0;
		var distance = 2;
		for (var x = this.channels.length - 1; x >= 0; x--) {
			var img = document.createElement('img');
			img.src = this.channels[x];
			img.style.position = "absolute";
			img.style.width = tempW + "px";
			img.style.height = tempH + "px";
			img.style.top = tempX + "px";
			img.style.left = tempY + "px";
			tempW += 32; tempH += 32; tempX += distance; tempY += distance;
			distance += 8;
			this.main.appendChild(this.channels[x] = img);
//			document.getElementById('channelsTitle').innerHTML = text[0].title;
//			document.getElementById('channelsIntro').innerHTML = text[0].intro;
		}
		setTimeout(function() {
			new Effect.DropOut(slide.channels[0], {duration:.5}); window.setTimeout('Effect.Appear(slide.channels[0], {duration:.05})',500);
//			new Effect.Fade(document.getElementById('channelsText'), {duration:.3}); window.setTimeout('Effect.Appear(document.getElementById(\'channelsText\'), {duration:.2})',500);
//			new Effect.Fade(document.getElementById('channelsTitle'), {duration:.5}); window.setTimeout('Effect.Appear(document.getElementById(\'channelsTitle\'), {duration:.3})',500);
//			new Effect.Fade(document.getElementById('channelsIntro'), {duration:.5}); window.setTimeout('Effect.Appear(document.getElementById(\'channelsIntro\'), {duration:.3})',500);
			}, 3500);
		setTimeout(function() { self.rotate(); }, 4050);
	}
	
	this.rotate = function() {
		var temp = this.channels[0].src;
		var temptitle = text[0].title;
		var tempintro = text[0].intro;
		for (var x = 0; x < this.channels.length - 1; x++) {
			this.channels[x].src = this.channels[x+1].src;
			text[x].title = text[x+1].title;
			text[x].intro = text[x+1].intro;
		}
		this.channels[this.channels.length - 1].src = temp;
		text[this.channels.length - 1].title = temptitle;
		text[this.channels.length - 1].intro = tempintro;

//		document.getElementById('channelsTitle').innerHTML = text[0].title;
//		document.getElementById('channelsIntro').innerHTML = text[0].intro;
		setTimeout(function() {
			new Effect.DropOut(slide.channels[0], {duration:.5}); window.setTimeout('Effect.Appear(slide.channels[0], {duration:.05})',500);
//     		new Effect.Fade(document.getElementById('channelsText'), {duration:.3}); window.setTimeout('Effect.Appear(document.getElementById(\'channelsText\'), {duration:.2})',500);
//			new Effect.Fade(document.getElementById('channelsTitle'), {duration:.5}); window.setTimeout('Effect.Appear(document.getElementById(\'channelsTitle\'), {duration:.3})',500);
//			new Effect.Fade(document.getElementById('channelsIntro'), {duration:.5}); window.setTimeout('Effect.Appear(document.getElementById(\'channelsIntro\'), {duration:.3})',500);
			}, 3500);
		setTimeout(function() { self.rotate(); }, 4050);
	}
	
}

function textObj(title, intro) {
	this.title = title;
	this.intro = intro;
}