// These are the "more info" links
var more_info= new Array(4) 
more_info[1] = "/consumer/holiday/";
more_info[2] = "/consumer/foreclosure/";
more_info[3] = "/StopMeth/";
more_info[4] = "/seniors/sleuths/";



// random_num = (Math.floor(Math.random()*3+1))
random_num = 1;
current_image = random_num;

// Moves forward to the next image
function   go_forward(){

	if ( (current_image + 1)  > 4 ){
		current_image =  1;
	}else{
		current_image = current_image + 1;
	}
	document.images.main_pic.src = "/images/home_page/home_img_" + current_image + ".jpg" ;
	
} 

// moves back to the previous image
function   go_back(){

	if ( (current_image - 1)  == 0 ){
		current_image =  4;
	}else{
		current_image = current_image - 1;
	}
	document.images.main_pic.src = "/images/home_page/home_img_" + current_image + ".jpg" ;
	
}

// moves back to the previous image
function   moreinfo_page(){
	document.location =   more_info[current_image];
	
}

var interval = 7; // delay between rotating images (in seconds)
var random_display = 0; // 0 = no, 1 = yes
interval *= 1000;

var image_index = 0;
	image_list = new Array();
	image_list[image_index++] = new imageItem("/images/home_page/home_img_1.jpg");
	image_list[image_index++] = new imageItem("/images/home_page/home_img_2.jpg");
	image_list[image_index++] = new imageItem("/images/home_page/home_img_3.jpg");	
	image_list[image_index++] = new imageItem("/images/home_page/home_img_4.jpg");	
	image_list[image_index++] = new imageItem("/images/home_page/home_img_5.jpg");


var number_of_image = image_list.length;

function imageItem(image_location) {
	this.image_item = new Image();
	this.image_item.src = image_location;
}
function get_ImageItemLocation(imageObj) {
	return(imageObj.image_item.src)
}

function generate(x, y) {
	var range = y - x + 1;
	return Math.floor(Math.random() * range) + x;
}
function getNextImage() {
	
	if (random_display) {
		image_index = generate(0, number_of_image-1);
	}
	else {
		image_index = (image_index+1) % number_of_image;
	}
	var new_image = get_ImageItemLocation(image_list[image_index]);
	return(new_image);
	
}

function rotateImage(place) {
	//var new_image = getNextImage();
	//document[place].src = new_image;
	go_forward();
	var recur_call = "rotateImage('"+place+"')";
	setTimeout(recur_call, interval);
}


document.write('<map name="Map">');
	document.write('<area shape="rect" coords="48,203,121,227" href="JavaScript:  go_back();">');
	document.write('<area shape="rect" coords="127,203,192,226" href="JavaScript:  go_forward();">');
	document.write('<area shape="rect" coords="46,178,162,199" href="JavaScript:  moreinfo_page();" >');
document.write('</map>');


document.write("<img src='/images/home_page/home_img_" + random_num + ".jpg' width='565' height='262' border='0' usemap='#Map' name='main_pic' id='main_pic'>");
