

// global variables 

var is_msie = (navigator.appName == "Microsoft Internet Explorer") ? true : false;


function go_page(page_name) {
top.window.location.href=page_name;
}

function go_page_replace(page_name) {
top.window.location.replace(page_name);
}


function hide_div(d) {
	document.getElementById(d).style.display = "none";
}

function show_div(d) {
	document.getElementById(d).style.display = "block";
}


function show_hide_div(id,zindex) {
var el = document.getElementById(id);
	if (el.style.display != "none") {
	el.style.display = "none";
		if (zindex) {
		el.style.zIndex = "0";
		}
	}
	else {
	el.style.display = "";
		if (zindex) {
		el.style.zIndex = zindex;
		}
	}
}


function preload_img(img_path) {
var img_file = new Image();
img_file.src = img_path;
}



// project functions


var project_img = 0;
var description_on = false;

function show_image(img_num) {
	for (i=0;i<project_img_count;i++) {
	document.getElementById('div_project_img'+i).style.display = 'none';
	document.getElementById('image_link'+i).className = 'nav';
	}
project_img = img_num;
description_on = false;
document.getElementById('div_project_img'+img_num).style.display = 'block';
document.getElementById('image_link'+img_num).className = 'nav_on';
	if (has_description) {
	document.getElementById('div_project_description').style.display = 'none';
	document.getElementById('description_link').className = 'nav';
	}
}

function show_description() {
description_on = true;
	if (project_img_count > 0) {
		for (i=0;i<project_img_count;i++) {
		document.getElementById('div_project_img'+i).style.display = 'none';
		document.getElementById('image_link'+i).className = 'nav';
		}
	}
document.getElementById('div_project_description').style.display = 'block';
document.getElementById('description_link').className = 'nav_on';
}

function next_image() {
	if (description_on) {
		if (project_img < project_img_count-1) {
		project_img++;
		show_image(project_img);
		} else {
		show_image(0);
		}
	} else {
		if (project_img < project_img_count-1) {
		project_img++;
		show_image(project_img);
		} else {
			if (has_description) {
			show_description();
			} else {
			show_image(0);
			}
		}
	}
}


function roll_bio(img_num,over) {
divobj = document.getElementById('bio_img'+img_num);
headerobj = document.getElementById('bio_header'+img_num);
	if(over) {
	divobj.style.filter = "alpha(opacity=100)";
	divobj.style.opacity = 1;
	headerobj.className = 'bio_header_on';
	} else {
	divobj.style.filter = "alpha(opacity=60)";
	divobj.style.opacity = .6;
	headerobj.className = 'bio_header';
	}
}



var fade_timer;
var div_fadeamt = 0;
var fade_div_name;

function fade_div(div_name,direction,max_opacity) {
	max_opacity = (!max_opacity) ? 10 : max_opacity;
	if (!is_msie) {
	fade_div_name = div_name;
var divobj = document.all ? document.all[div_name] : document.getElementById ? document.getElementById(div_name) : "";
	//clearTimeout(fade_timer);
	if (direction == 'in') {
		divobj.style.display = "";
		//show_hide_div(fade_div_name,'1000');
		if(div_fadeamt < max_opacity) {
		div_fadeamt++;
		divobj.style.filter = "alpha(opacity="+div_fadeamt*10+")";
		divobj.style.opacity = div_fadeamt/10;
		fade_timer = setTimeout("fade_div('"+fade_div_name+"','in',"+max_opacity+")",15);
		} else {
		clearTimeout(fade_timer);
		}
	} else if (direction == 'out') {
		if(div_fadeamt > 0) {
		div_fadeamt--;
		divobj.style.filter = "alpha(opacity="+div_fadeamt*10+")";
		divobj.style.opacity = div_fadeamt/10;
		fade_timer = setTimeout("fade_div('"+fade_div_name+"','out')",20);
		} else {
		clearTimeout(fade_timer);
		//show_hide_div(fade_div_name,'0');
		divobj.style.display = "none";
		div_fadeamt = 0;
		}
	}
	} else {
		show_hide_div(div_name,'100');
	}
}



function images_loading(loaded) {
	if (loaded) {
	document.getElementById('images_loading').style.display = 'none';
	document.getElementById('images_loaded').style.display = 'block';
	}
}
