/* 
matrix.js

Copyright 2009 Lifespaces, Inc., all rights reserved. 

Any copying or redistribution of any part of this document  
is strictly prohibited by law unless explicitly 
permitted by Lifespaces, Inc. 
*/

var d = null;
var e = null;
var i = 0.0;
var o = 0.0;
var oo= 0.0;
var od= null;
var a = 0;
var ad=null;
var barin_top = false;
var bin_t = 2;
var fo_t = 0;
var interv_t = 300;
var imgs = new Array("ixi","ixii","ixiii","ixiiii","ixiiiii","iixi","iixii","iixiii","iixiiii","iixiiiii","iiixi","iiixii","iiixiii","iiixiiii","iiixiiiii");

var images = new Array(
"http://elx.me/elife/Images/Template%20Squares/vtc-rooms.png", // 0
"http://elx.me/elife/Images/Template%20Squares/security.png",
"http://elx.me/elife/Images/Template%20Squares/retrofit.png",
"http://elx.me/elife/Images/Template%20Squares/meeting-rooms.png",
"http://elx.me/elife/Images/Template%20Squares/media-rooms.png",
"http://elx.me/elife/Images/Template%20Squares/home-theaters.png", // 5
"http://elx.me/elife/Images/Template%20Squares/hidden.png",
"http://elx.me/elife/Images/Template%20Squares/energy-management.png",
"http://elx.me/elife/Images/Template%20Squares/dist_audio.png",
"http://elx.me/elife/Images/Template%20Squares/dist-video.png",
"http://elx.me/elife/img/lets-begin.png", // 10
"http://elx.me/elife/Images/Template%20Squares/data-networks.png",
"http://elx.me/elife/Images/Template%20Squares/control-systems.png",
"http://elx.me/elife/Images/Template%20Squares/cctv.png",
"http://elx.me/elife/Images/Template%20Squares/calibration.png",
"http://elx.me/elife/Images/Template%20Squares/boardrooms.png", // 15
"http://elx.me/elife/Images/Template%20Squares/award.png",
"http://elx.me/elife/Images/Template%20Squares/audiophile.png",
"http://elx.me/elife/Images/Template%20Squares/apple_integration.png",
"http://elx.me/elife/Images/Template%20Squares/app-developers.png",
"http://elx.me/elife/Images/Template%20Squares/access-control.png", // 20
"/Images/profiles.jpg",
"/Images/portfolio.jpg",
"/img/memberships.png",
"/Images/videos.jpg"); // 24

var links = new Array(
"/video-conferencing.php", // 0
"/security.php",
"/systems-installation.php",
"/meeting-room.php",
"/entertainment.php",
"/home-theater.php", // 5
"/hidden-installation.php",
"/electrical.php",
"/audio.php",
"/video.php",
"/design.php", // 10
"/core-communications.php",
"/control.php",
"/cctv.php",
"/services.php",
"/boardrooms.php", // 15
"/award-winning.php",
"/haa.php",
"/apple-integration.php",
"/Developer.php",
"/access-control.php", // 20
"/PDF/profiles-in-business.pdf",
"/flashden_dynamic-page-flip-pro_29252/Pic%20Album/Full/index.html",
"/memberships",
"/library_video.php"); // 24
var exempt = null;
var f_t = 1.0;

function matrix(time,tt){

fo_t = time;
bin_t = 2;
interv_t = 3000;

swap_thread(0);

return;
}

var negative_zero = false;
function swap_thread(seq) {
	var targ; // target img to swap out (array index; integer)
	var newimg; // new image to swap in (array index also)
	
	switch(seq) {
		case 0:
			targ = 11;
			if(!negative_zero) {
				newimg = 4;
			}
			else {
				newimg = 14;
			}
		break;
		
		case 1:
			targ = 6;
 			if(!negative_zero) {
				newimg = 3;
			}
			else {
				newimg = 17;
			}
		break;
		
		case 6:
			targ = 2;
			if(!negative_zero) {
				newimg = 12;
			}
			else {
				newimg = 7;
			}
		break;
		
		case 3:
			targ = 13;
			if(!negative_zero) {
				newimg = 19;
			}
			else {
				newimg = 18;
			}
		break;
		
		case 4:
			targ = 12;
			if(!negative_zero) {
				newimg = 8;
			}
			else {
				newimg = 9;
			}
		break;
		
		case 5:
			targ = 8;
			if(!negative_zero) {
				newimg = 11;
			}
			else {
				newimg = 2;
			}
		break;
		
		case 2:
			targ = 5; // hidden installation
			if(!negative_zero) {
				newimg = 21;
				document.getElementById("iixi").parentNode.setAttribute("target","_blank");
			}
			else {
				newimg = 6;
				document.getElementById("iixi").parentNode.setAttribute("target","_self");
			}
		break;
		
		case 7:
			targ = 9; // access control
			if(!negative_zero) {
				newimg = 24;
			}
			else {
				newimg = 20;
			}
		break;
		
		case 8:
			targ = 10; // design/installation
			if(!negative_zero) {
				newimg = 23;
			}
			else {
				newimg = 10;
			}
		break;
		
		case 9:
			targ = 1; // award winning
			if(!negative_zero) {
				newimg = 22;
			}
			else {
				newimg = 16;
			}
		break;
		
		default: // hack: start it all over in case the user is STILL on the page
			seq = 0;
			if(!negative_zero) negative_zero = true;
			else negative_zero = false;
			return swap_thread(seq); // hopefully won't smash the stack (return is key), starts it again
		break;
	}
	
	oo = 1.0;
	od = document.getElementById(imgs[targ]);
		od.setAttribute("src",images[newimg]);
		od.parentNode.setAttribute("href",links[newimg]); // sets the new link
	oo = 0.0;
		if(navigator.appName=="Microsoft Internet Explorer") od.style.filter = "alpha(opacity=100)";
		else od.style.opacity = 1.0;
	
	seq++;
	setTimeout("swap_thread("+seq+")",1500); // repeat every 1.5 seconds
}

function hover(id){
d=document.getElementById(id);
exempt = d;
exempt.setAttribute("name",id);
i = 0.5;
opac();
i = 0.0;
}

function out(id){
e = document.getElementById(id);
o = 1.0;
exempt = null;
brighten_all();
}

function opac(){
if(i<=1.0){
i += 0.1;
if(navigator.appName=="Microsoft Internet Explorer") d.style.filter = "alpha(opacity="+i*100+")";
else d.style.opacity = i;
setTimeout(opac,40);
}
else return brighten_all();
}

function brighten_all() { 
		for(var i = 0; i < imgs.length; i++) { 
			if(navigator.appName=="Microsoft Internet Explorer") document.getElementById(imgs[i]).style.filter = "alpha(opacity="+100+")";
			else document.getElementById(imgs[i]).style.opacity = 1.0; 
		}
}

function clearall() {}

function fadeout(id){
	idd = document.getElementById(id);
	if(f_t > 0.0) {
	f_t -= 0.1;
	if(navigator.appName == "Microsoft Internet Explorer") idd.style.filter = "alpha(opacity="+f_t*100+")";
	else idd.style.opacity = f_t;
	setTimeout("fadeout(\""+id+"\")",100);
	return 0;
	}
	else return 1;
}

function fadein(id){
	idd = document.getElementById(id);
	if(f_t < 1.0) {
	f_t += 0.1;
	if(navigator.appName == "Microsoft Internet Explorer") idd.style.filter = "alpha(opacity="+f_t*100+")";
	else idd.style.opacity = f_t;
	setTimeout("fadein(\""+id+"\")",100);
	return 0;
	}
	else return 1;
} 

function fout(){
if(oo > 0.0) {
oo -= 0.01;
if(navigator.appName=="Microsoft Internet Explorer") od.style.filter = "alpha(opacity="+oo*100+")";
else od.style.opacity = oo;
setTimeout(fout,300);
}
else return;
}

function fin(){
if(oo < 1.0) {
oo += 0.01;
if(navigator.appName=="Microsoft Internet Explorer") od.style.filter = "alpha(opacity="+oo*100+")";
else od.style.opacity = oo;
setTimeout(fin,300);
}
else return;
}

function l(ref) {
	var imgid;
	
	switch(ref){
		case 1:
			imgid = "v_o";
		break
		
		case 2:
			imgid = "c_o";
		break;
		
		default:
			return; // don't do anything
		break;
	}
	
	document.getElementById(imgid).style.visibility = "visible";
}

function lout(ref) {
	var imgid;
	
	switch(ref){
		case 1:
			imgid = "v_o";
		break
		
		case 2:
			imgid = "c_o";
		break;
		
		default:
			return; // don't do anything
		break;
	}
	
	document.getElementById(imgid).style.visibility = "hidden";
}

