/***********************************************
* The Home Image swapper
***********************************************/

// Create the initial home image.


function rand(n) {
  return ( Math.floor ( Math.random ( ) * n + 1 ) );
}

function loadHome(n) { 
	var x = rand(n);
	$('switchertext').innerHTML = $('hiddentext'+x).innerHTML;
	$('switcherimage'+x).style.display = "block";
	$('link'+x).style.background = "none";
	activeImg = x;

}

function imageSwitcher(newImg) { 
	if (newImg != activeImg) {
			$('switcherimage'+activeImg).style.display = "none";
			$('switcherimage'+newImg).style.display = "block";
			$('switchertext').innerHTML = $('hiddentext'+newImg).innerHTML;
			$('link'+activeImg).style.backgroundColor = "#d84519";
			$('link'+newImg).style.background = "none";
			activeImg = newImg;
		}
}

var currentPlate='';

function homeIntro(plate) {
	if(currentPlate == '') {
		Effect.Appear($(plate), {duration:.4});
		currentPlate = plate;
		setTimeout(
			function () {
				if(currentPlate == plate) {
					$(plate).style.display='block';
				}
			}, 450);
	} 
}

function homeOut(plate) { 
	if(currentPlate != '') {
		Effect.Fade($(plate), {duration:.4});
		currentPlate = '';
		setTimeout(
			function () {
				if(currentPlate == '') {
					$(plate).style.display='none';
				}
			}, 450);
	}
}


// Pick a random image from the list,
// and set the image source to that image




var activeThumb = 'thumb1';
	var activeImage = 'image1';
	function gallerySwap(daID, daThumb) {
		if (daID != activeImage) {
			opacity(activeImage, 100, 0, 1000, '', false);
			opacity(daID, 0, 100, 1000, '', true);
			activeImage = daID;
		}
		if (daThumb != activeThumb) {
			$(activeThumb).style.border = '1px solid #dfd3a9';
			$(daThumb).style.border = '1px solid #0d4593';
			activeThumb = daThumb;
		}
	}
