// JavaScript Document

// Added by Jeremy for showing / hiding elements - I borrowed it from somewhere else, probably FaceBook
function toggleVisible(id) {
	var item = document.getElementById(id);
	var value = item.style.display ? '' : 'none';
	item.style.display = value;
}


/* Link Fader plugin from http://www.kaosweaver.com/extensions/details.php?id=60 */
function KW_s(r, g, b, el) {
	d=document;hr=r.toString(16);hg=g.toString(16);hb=b.toString(16);
	hr=(hr.length==1)?"0"+hr:hr;hg=(hg.length==1)?"0"+hg:hg;hb=(hb.length==1)?"0"+hb:hb;
	if (d.getElementById) d.getElementById(el).style.backgroundColor="#"+hr+hg+hb;
}

function KW_c(a,b,s,i) { return Math.floor(a*((s-i)/s)+b*(i/s)); }
var running = false;
// Noted by JRG: initialRed, initialGreen, initialBlue, targetRed, targetGreen, targetBlue, speed, objectID
/*function KW_fade(r,g,b,e,n,l,s,o){
	for(i=0;i<=s;i++)setTimeout("KW_s("+KW_c(r,e,s,i)+","+KW_c(g,n,s,i)+","+KW_c(b,l,s,i)+",'"+o+"');",i*s);
}*/

function KW_fade(r,g,b,e,n,l,s,o){
	if(running !=o || !running) {
		running=o;
		for(i=0;i<=s;i++) {setTimeout("KW_s("+KW_c(r,e,s,i)+","+KW_c(g,n,s,i)+","+KW_c(b,l,s,i)+",'"+o+"');",i*s);}
		setTimeout('running=false;',i*s);
	}
	else if(running == o) {
		setTimeout("KW_fade("+r+","+g+","+b+","+e+","+n+","+l+","+s+",\""+o+"\");",10);
	}
}

/* Noted by JRG: initialRed, initialGreen, initialBlue, targetRed, targetGreen, targetBlue, speed, objectID 
		Simple hex conversion:
			0xDD == 221
			0xEE == 238
			0x66 == 102
			0xFF == 255
*/
function KW_fade_day_over(object){ KW_fade(221,221,238,102,102,255,20,object);}
function KW_fade_day_out(object){ KW_fade(102,102,255,221,221,238,20,object);}
function KW_fade_night_over(object){ KW_fade(221,221,238,51,0,153,20,object);}
function KW_fade_night_out(object){ KW_fade(51,0,153,221,221,238,20,object);}


// For inserting the left/right arrows on autobiography page (non-javascript browsers won't see the arrows)
function jg_writeLeftArrow() {
	document.write('<div class="button" id="left"><a href="javascript:ScrollArrow(\'left\',\'toolbar\',\'scroller\',\'personal-pane\');"><img src="/images/ArrowLeft.png" alt="Left Scroll Arrow" onmouseover="this.src = \'/images/ArrowLeftOver.png\'" onmouseout="this.src = \'/images/ArrowLeft.png\'" /></a></div>');
}

function jg_writeRightArrow() {
	document.write('<div class="button" id="right"><a href="javascript:ScrollArrow(\'right\',\'toolbar\',\'scroller\',\'personal-pane\');"><img src="/images/ArrowRight.png" alt="right scroll arrow" onmouseover="this.src = \'/images/ArrowRightOver.png\'" onmouseout="this.src = \'/images/ArrowRight.png\'" /></a></div>');

}