function show_popup(num){
	var elem = $("largeimage_"+num);
	Effect.Appear(elem,{duration:0.5});	
}
function close_popup(num){
	var elem = $("largeimage_"+num);
	elem.style.display="none";
}
function init_homepage() {
	var thumbdiv = $('spotlight_selector');
	var imgs = thumbdiv.getElementsByTagName("img");
	for(i=0;i<imgs.length;i++){
		//imgs[i].onclick=feature_project;
		imgs[i].onclick=get_rotation_number;
		
	}
	auto_rotate_image(0);
	
}

function get_rotation_number(){
	// split "thumb_1" at the underscore, so that you just have the number at the end: "1"
	var temp = this.id.split("_");
	var rotation_num = temp[1];
	feature_product(rotation_num);
}

function feature_product(rotation_num){
	// Remove the darker border around the thumbnails
	var imgs = $('spotlight_selector').getElementsByTagName("img");
	for(i=0;i<imgs.length;i++) imgs[i].className="";
	
	var thumb = $('thumb_'+rotation_num);
	//Add the dark border to the selected thumbnail
	thumb.className='selected';
	
	//get the <img src> for the image to feature
	var temp = thumb.src.split('_thumb.jpg');
	var bigsrc = temp[0]+".jpg";

	//swap out image
	var bigsrc = $('big_'+rotation_num).src;
	$('project_image').src=bigsrc;
	//new Effect.Fade($('project_image'));
	new Effect.Appear($('project_image'));
	
	//swap title
	var title = $("thumb_project_title_"+rotation_num).innerHTML;
	$('project_title').innerHTML=title;
	
	//swap location
	var location = $("thumb_project_location_"+rotation_num).innerHTML;
	$('project_location').innerHTML=location;	
	
	//swap href's
	var href = $("thumb_project_title_"+rotation_num).href;
	$('project_link').href=href;
	$('project_imglink').href=href;
}

var rotate_speed = 8000; // 1000 = 1 second

function auto_rotate_image(id) {
	feature_product(id);
	id++;
	if(id==5) var id = 0;
	setTimeout("auto_rotate_image("+id+");",rotate_speed); 
}

function show_feature_0() {
	$("footer").innerHTML="0";
	setTimeout("show_feature_1();",rotate_speed); 
}
function show_feature_1() {
	$("footer").innerHTML="1";
	setTimeout("show_feature_2();",rotate_speed); 
}
function show_feature_2() {
	$("footer").innerHTML="2";
	setTimeout("show_feature_3();",rotate_speed); 
}
function show_feature_3() {
	$("footer").innerHTML="3";
	setTimeout("show_feature_4();",rotate_speed); 
}
function show_feature_4() {
	$("footer").innerHTML="4";
	setTimeout("show_feature_0();",rotate_speed); 
}