// JavaScript Document
function nav(element, name){
		element.src = '/images/' + name + '.jpg';
	}
	
function flashPutHref(href) { location.href = href; }



 function sspToggleDisplayMode() {
		thisMovie("swfcontainer").sspToggleDisplayMode(null);
 }
function thisMovie(movieName) {
   return swfobject.getObjectById(movieName);
}
	
	// Ulti-X Transparency  X - Fader - Start

	function opacity(id, opacStart, opacEnd, millisec) {
		//speed for each frame
		var speed = Math.round(millisec / 100);
		var timer = 0;
	
		//determine the direction for the blending, if start and end are the same nothing happens
		if(opacStart > opacEnd) {
			for(i = opacStart; i >= opacEnd; i--) {
				setTimeout("changeOpac(" + i + ",'" + id + "')",(timer * speed));
				timer++;
			}
		} else if(opacStart < opacEnd) {
			for(i = opacStart; i <= opacEnd; i++)
				{
				setTimeout("changeOpac(" + i + ",'" + id + "')",(timer * speed));
				timer++;
			}
		}
	}
	
	//change the opacity for different browsers
	function changeOpac(opacity, id) {
		if (opacity == 100 && faderobject == id){
			opacityrunning = false;
		}
		var object = $(id).style; 
		object.opacity = (opacity / 100);
		object.MozOpacity = (opacity / 100);
		object.KhtmlOpacity = (opacity / 100);
		object.filter = "alpha(opacity=" + opacity + ")";
	}
	
	// do not change global vars below
	var opacityrunning = false;
	var showingfaderimage = 2;
	var showingimagepos = 1;
	var faderobject;
	
	function showme(refid, pos) {
		if (opacityrunning == false){
			if (showingimagepos != pos){
				if (showingfaderimage == 1){
					$('faderimg1').src = refid;
					opacity('faderimg1','0','100','500');
					opacity('faderimg2','100','0','500');	
					opacityrunning = true;
					faderobject = 'faderimg1';
					showingfaderimage = 2;	
				} 
				else {
					if (showingfaderimage == 2){
						$('faderimg2').src = refid;
						opacity('faderimg1','100','0','500');
						opacity('faderimg2','0','100','500');
						opacityrunning = true;
						faderobject = 'faderimg2';	
						showingfaderimage = 1;	
					}
				}
				showingimagepos = pos;
			}
		}
	}
	
	var howmanyimages = 4;
	var currentimage = 1;
	function startcrossfade() {
		if (currentimage > howmanyimages){
			currentimage = 1;
		}
		showme('/images/home-slide'+ currentimage +'.jpg',currentimage-1);
		currentimage++;
		setTimeout('startcrossfade()', 4000);
	}
	// Ulti-X Transparency Fader - v 0.1 - End
