//Created by Ron Ledbetter 2010
 
//Container Properties
var _width = "80%";
var _height = "100px";
var _borderColor = "#4946DA"; // "#4682B4"
var _borderWidth = 3;
var _borderStyle = "solid";
 
//Slide Seperator Properties
var _sColor = "#4946DA"; // "#4682B4"
var _sStyle = "ridge";
var _sWidth = 3;
 
var _rotateSpeed = 1;
// End Default
 
//Images to use
var imgs = new Array();
imgs[0] = "http://thebombernation.com/images/5years.jpg";
imgs[1] = "http://thebombernation.com/action12.jpg";
imgs[2] = "http://thebombernation.com/images/LVMS_mg_2484.jpg";
imgs[3] = "http://thebombernation.com/images/3680771.jpg";
imgs[4] = "http://thebombernation.com/images/one-sport.jpg";
imgs[5] = "http://thebombernation.com/images/Finley_sm.jpg";
imgs[6] = "http://thebombernation.com/images/pvsBomber.jpg";
imgs[7] = "http://thebombernation.com/images/one-nation.jpg";
imgs[8] = "http://thebombernation.com/images/1353375_md.jpg";
imgs[9] = "http://thebombernation.com/images/theBulring.jpg";
imgs[10] = "http://thebombernation.com/images/jetcar-burn.jpg";
 
var _id1;
var pos = 0;
var px = 1; //Pixles to move at a time;
 
var pf;
 
// Container Object
var cont;
 
window.onload = initializeRotater;
 
function initializeRotater() {
	//Static div tag ID = ImageSlide
	cont = document.getElementById("ImageSlide")
	//If static tag does not exist create dynamic
	if(cont == null) {
	cont = document.createElement("div");
	document.body.appendChild(cont);
	}
 
	//Apply Container Style	
	cont.style.position = "relative";
	cont.style.overflow = "hidden";
	cont.style["height"] = _height;
	cont.style.borderWidth = _borderWidth + "px";
	cont.style.borderStyle = _borderStyle;
	cont.style.borderColor = _borderColor;
	cont.style.whiteSpace = "nowrap";
	
	//Create Slides
	for (var x = 0; x < imgs.length; x++) {
		var img = document.createElement("img");
		img.onclick = function(){
			showImage(this)
		};
		img.style["height"] = _height;
		img.style.width = "auto";
		img.style.position = "relative";
		img.src = imgs[x];
		img.style["borderRightWidth"] = _sWidth + "px";
		img.style["borderRightStyle"] = _sStyle;
		img.style["borderRightColor"] = _sColor;
		img.style.cursor = "pointer";
		img.style.zIndex = "100";
		//ib.appendChild(img);
		cont.appendChild(img);
	}
	_id1 = window.setInterval(Rotate, _rotateSpeed * 25);
 
}
 
function Rotate() {
	pos -= px;
	for(var x = 0; x < cont.children.length; x++) {
		var cb = cont.children[x];
		cb.style.left = pos + "px";
		if(((cb.width + _sWidth)+ pos) <= 0 && x == 0) {
			pos = (cb.width + _sWidth) + pos;
			cont.removeChild(cb);
			cont.appendChild(cb);
			cont.firstChild.style.left = pos + "px";
		}
	}
}
function showImage(obj) {
	if(pf != null)
		closeImage();
	reset();
	pf = document.createElement("div");
	pf.style.position = "absolute";
	pf.style.top = cont.offsetTop + "px";
	pf.style.right = "0px";
	pf.style.left = "0px";
	pf.style.zIndex = "201";
	pf.style.textAlign = "center";
	//pf.style.backgroundColor = "#000000";
	
	var frame = document.createElement("span");
	frame.style.border = "#dcdcdc outset 2px";
	frame.style.display = "inline-block";
	frame.style.position = "relative";
	pf.appendChild(frame);
	
	var img = document.createElement("img");
	img.src = obj.src;
	if(img.width > 640) {
		img.style.width = "640px";
		img.style.height = "auto";
	}
	img.style.border = "black solid 3px";
	frame.appendChild(img);
	
	var cb = document.createElement("input");
	cb.onclick = function() {
		closeImage()
	};
	cb.type = "button";
	cb.style.position = "absolute";
	//cb.style.display = "inline-block";
	cb.style.top = "0px";
	cb.style.right = "0px";
	//cb.style.padding = "5px";
	//cb.style.cursor = "pointer";
	//cb.style.backgroundColor = "#000000";
	//cb.style.color = "#ffffff";
	cb.value = "Close";
	frame.appendChild(cb);
	
	pf.appendChild(frame);
	var p = document.getElementById("page");
	p.appendChild(pf);
}
function closeImage() {
	var p = document.getElementById("page");
	p.removeChild(pf);
	pf = null;
	_id1 = window.setInterval(Rotate, _rotateSpeed * 25);
}
function reset() {
	window.clearInterval(_id1);
}
function iClick() {
alert('Not available yet');
}

