// JavaScript Document

window.addEvent('domready', function(){
	var accordion = new Accordion('h3.atStart', 'div.atStart', {
		opacity: true,
		start: 'all-closed',
		alwaysHide: true,
		onActive: function(toggler, element){
			toggler.setStyle('color', '#FFFFFF');
			toggler.setStyle('background', '#D71C03');
		},
		
		onBackground: function(toggler, element){
			toggler.setStyle('color', '#FFFFFF');
			toggler.setStyle('background', '#000000');
	
		}
	}, $('accordion'));	
	
	/* Tooltips */
	var Tips2 = new Tips($$('.Tips2'), {
		initialize:function(){
			this.fx = new Fx.Style(this.toolTip, 'opacity', {duration: 500, wait: false}).set(0);
		},
		onShow: function(toolTip) {
			this.fx.start(1);
		},
		onHide: function(toolTip) {
			this.fx.start(0);
		}
	});		
	
});	
	

/* background image preloads -- ONLY AFTER EVERYTHING ELSE IS LOADED */
window.addEvent('load', function(){
	
	/* preload the css backgrounds */
	css_preloads = [
		'/images/tiles/tile-black-60.png',
		'/images/tiles/tile-toggler-80.png',
		'/images/tiles/slim-tile-container.gif',
	];

	// after pre-loads are complete, show the content
	new Asset.images(css_preloads, {
		onComplete: function(){
			
		}
	});
	
	showContent();	
});


/* page loaded, reveal the content then proceed with background preloads */
var this_body;
var mySlider;

function showContent() {

	// expose the content
	$('accordionInitial').setStyle("display", "none");
	$('accordion').setStyle("display", "block");
	
	// get list of background images
	background_imgs = [
	 
		'images/backgrounds/img-001.jpg',
	 
					 
	];
	
	// initialize the backgrouund buttons
	this_body = $(document.getElementsByTagName('body')[0]);
	$$('#bgselector div.bgimg').each(function(item, index) {
		item.addEvent('click', function(e) {
			var ev = new Event(e);
			ev.stop();
			this_body.setStyle('background-image', 'url("'+background_imgs[index]+'")');
			mySlider.slideOut();
		});
	});
	
	// initialize the background changer
	mySlider = new Fx.Slide('bgselector', {duration: 300});
	mySlider.hide();
	var mySliderContainer = $('bgselcontainer');
	mySliderContainer.setStyle('display', 'block');
	var mySliderToggle = $('toggleBG');
	mySliderToggle.addEvent('click', function(e) {
		var ev = new Event(e);
		ev.stop();
		mySlider.toggle();
	});
		
	// pre-load bg images			
	new Asset.images(background_imgs, {
		onComplete: function(){}
	});

}


// Random Background
// Activate cloaking device

var randnum = Math.random();
var inum = 10;

// Change this number to the number of images you are using.
var rand1 = Math.round(randnum * (inum-1)) + 1;

images = new Array
images[1] = "images/testimonial_bkgs/001.jpg"
images[2] = "images/testimonial_bkgs/002.jpg"
images[3] = "images/testimonial_bkgs/003.jpg"
images[4] = "images/testimonial_bkgs/004.jpg"
images[5] = "images/testimonial_bkgs/005.jpg"
images[6] = "images/testimonial_bkgs/006.jpg"
images[7] = "images/testimonial_bkgs/007.jpg"
images[8] = "images/testimonial_bkgs/008.jpg"
images[9] = "images/testimonial_bkgs/009.jpg"
images[10] = "images/testimonial_bkgs/010.jpg"
images[11] = "images/testimonial_bkgs/011.jpg"
images[12] = "images/testimonial_bkgs/012.jpg"
images[13] = "images/testimonial_bkgs/013.jpg"
images[14] = "images/testimonial_bkgs/014.jpg"
images[15] = "images/testimonial_bkgs/015.jpg"



// Old Bkg Code :

//images = new Array
//images[1] = "images/backgrounds/bg1.jpg"
//images[2] = "images/backgrounds/bg2.jpg"
//images[3] = "images/backgrounds/bg3.jpg"
//images[4] = "images/backgrounds/bg2.jpg"


// Ensure you have an array item for every image you are using.
var image = images[rand1]

document.write('<body background="' + image + '" text="white">');

// Deactivate cloaking device

