/* Javascript Library */

var buttonbarsize="34px";

function rotator(id) {
	this.hdl_container=document.getElementById(id);
	
	this.imgs=new Array();
	
	this.w=123;
	this.wpos=0;
	this.wstep=3;
	
	this.setup=function () {
		this.load_images();
		
		if (this.imgs.length==1) {
			var im2=this.imgs[0].cloneNode(true);
			
			im2.style.width="0";
			
			this.imgs.push(this.hdl_container.appendChild(im2));
		}
	}
	
	this.load_images=function () {
		if (this.hdl_container) {
			if (this.hdl_container.hasChildNodes()) {
				for (var i=0; i<this.hdl_container.childNodes.length; i++) {
					if (this.hdl_container.childNodes[i].nodeName.toLowerCase()=="img") {
						this.imgs.push(this.hdl_container.childNodes[i]);
					}
				}
			}
		}
	}
	
	this.do_rotate=function () {
		/*
		this.imgs[0].style.borderWidth="2px";
		this.imgs[0].style.borderStyle="solid";
		this.imgs[0].style.borderColor="rgb("+
			Math.round(Math.random()*256)+","+
			Math.round(Math.random()*256)+","+
			Math.round(Math.random()*256)+")";
		*/
		
		this.imgs[0].style.width=(this.w-this.wpos)+"px";
		this.imgs[0].style.height="120px";
		this.imgs[1].style.width=this.wpos+"px";
		this.imgs[1].style.height="120px";
		this.wpos+=this.wstep;
		
		this.imgs[0].style.opacity=1.0-(0.5*this.wpos/this.w);
		this.imgs[0].style.filter="alpha(opacity="+(100-Math.round((50*this.wpos/this.w)))+")";
		
		this.imgs[1].style.opacity=0.5+(0.5*this.wpos/this.w);
		this.imgs[1].style.filter="alpha(opacity="+(50+Math.round((50*this.wpos/this.w)))+")";
		
		if (this.wpos>this.w) {
			this.wpos=0;
		}
	}
	
	this.setup();
}

function rotator_step () {
	if (window.ir) {
		window.ir.do_rotate()
	}
}

function rotator_init () {
	window.ir=new rotator("logocontainer");
	
	setInterval(rotator_step, 50);
}


function subliner(id) {
	this.hdl_sbl=document.getElementById("airtext");
	this.color=new Array(
		new Array(
			2.0 * Math.random() - 1.0, // start color component float
			0.05 * Math.random(), // waveform freq
			0.0 // x
		),
		new Array(
			Math.random(), // start color component float
			0.05 * Math.random(), // waveform freq
			0.0 // x
		),
		new Array(
			Math.random(), // start color component float
			0.05 * Math.random(), // waveform freq
			0.0 // x
		)
	)
	
	this.setup=function () {
		if (this.hdl_sbl) {
			this.hdl_sbl.style.borderBottomWidth="1px";
			this.hdl_sbl.style.borderBottomStyle="solid";
			this.hdl_sbl.style.borderBottomColor="rgb("+
													Math.round(128 * (Math.sin(this.color[0][0]) + 1))+","+
													Math.round(128 * (Math.sin(this.color[1][0]) + 1))+","+
													Math.round(128 * (Math.sin(this.color[2][0]) + 1))+")";
		}
	}
	
	this.do_subline=function () {
		this.color[0][2]=this.color[0][2]+this.color[0][1];
		this.color[1][2]=this.color[1][2]+this.color[1][1];
		this.color[2][2]=this.color[2][2]+this.color[2][1];
		
		this.hdl_sbl.style.borderBottomColor="rgb("+
										Math.round(128 * (Math.sin(this.color[0][0] + this.color[0][2]) + 1))+","+
										Math.round(128 * (Math.sin(this.color[1][0] + this.color[1][2]) + 1))+","+
										Math.round(128 * (Math.sin(this.color[2][0] + this.color[2][2]) + 1))+")";
	}
	
	this.setup();
}

function subliner_step () {
	if (window.sb) {
		window.sb.do_subline()
	}
}

function subliner_init () {
	window.sb=new subliner("airtext");
	
	setInterval(subliner_step, 50);
}

function image_precache() {
	window.ipc=new Array();
	
	var im=document.createElement("img");
	im.src="images/viewport_s_br.png";
	window.ipc.push(im);
	
	im=document.createElement("img");
	im.src="images/viewport_s_bl.png";
	window.ipc.push(im);
	
	im=document.createElement("img");
	im.src="images/viewport_s_tl.png";
	window.ipc.push(im);
	
	im=document.createElement("img");
	im.src="images/viewport_s_tr.png";
	window.ipc.push(im);
	
	im=document.createElement("img");
	im.src="images/viewport_s_r.png";
	window.ipc.push(im);
	
	im=document.createElement("img");
	im.src="images/viewport_s_b.png";
	window.ipc.push(im);
	
	im=document.createElement("img");
	im.src="images/viewport_s_l.png";
	window.ipc.push(im);
	
	im=document.createElement("img");
	im.src="images/viewport_s_t.png";
	window.ipc.push(im);
}

function pageload_operations() {
	rotator_init();
//	subliner_init();
	image_precache()
}

function hilight_btn(hdl) {
	if (hdl) {
		var divs=new Array();
		
		divs[0]=hdl.parentNode;
		divs[1]=divs[0].parentNode;
		divs[2]=divs[1].parentNode;
		divs[3]=divs[2].parentNode;
		divs[4]=divs[3].parentNode;
		divs[5]=divs[4].parentNode;
		divs[6]=divs[5].parentNode;
		divs[7]=divs[6].parentNode;
		
		divs[0].style.backgroundImage="url(images/viewport_s_br.png)";
		divs[1].style.backgroundImage="url(images/viewport_s_bl.png)";
		divs[2].style.backgroundImage="url(images/viewport_s_tr.png)";
		divs[3].style.backgroundImage="url(images/viewport_s_tl.png)";
		divs[4].style.backgroundImage="url(images/viewport_s_r.png)";
		divs[5].style.backgroundImage="url(images/viewport_s_b.png)";
		divs[6].style.backgroundImage="url(images/viewport_s_l.png)";
		divs[7].style.backgroundImage="url(images/viewport_s_t.png)";
		divs[7].style.backgroundColor="#edf4df";
	}
}

function lowlight_btn(hdl) {
	if (hdl) {
		var divs=new Array();
		
		divs[0]=hdl.parentNode;
		divs[1]=divs[0].parentNode;
		divs[2]=divs[1].parentNode;
		divs[3]=divs[2].parentNode;
		divs[4]=divs[3].parentNode;
		divs[5]=divs[4].parentNode;
		divs[6]=divs[5].parentNode;
		divs[7]=divs[6].parentNode;
		
		divs[0].style.backgroundImage="";
		divs[1].style.backgroundImage="";
		divs[2].style.backgroundImage="";
		divs[3].style.backgroundImage="";
		divs[4].style.backgroundImage="";
		divs[5].style.backgroundImage="";
		divs[6].style.backgroundImage="";
		divs[7].style.backgroundImage="";
		divs[7].style.backgroundColor="";
	}
}
















