var current_image = 0;
var myimage = new Array();
var d = document;
var img_cnt = 6;

myimage[0] = new Array("img_1.jpg", "10 Unit Apartment Building");
myimage[1] = new Array("img_2.jpg", "60 Unit Apartment Building");
myimage[2] = new Array("img_3.jpg", "11 Unit Apartment Building");
myimage[3] = new Array("img_4.jpg", "12 Unit Apartment Building");
myimage[4] = new Array("img_5.jpg", "16 Unit Apartment Building");
myimage[5] = new Array("img_6.jpg", "100 Unit Apartment Community");
myimage[6] = new Array("img_7.jpg", "24 Unit Apartment Building");
myimage[7] = new Array("img_8.jpg", "13 Unit Apartment Building");
myimage[8] = new Array("img_9.jpg", "19 Unit Apartment Building");
myimage[9] = new Array("img_10.jpg", "33 Unit Apartment Building");
myimage[10] = new Array("img_11.jpg", "46 Unit Apartment Building");
myimage[11] = new Array("img_12.jpg", "34 Unit Apartment Building");

function image_get_next(step){
	if (current_image + step > myimage.length-1)
		return (current_image + step) % myimage.length;
	return current_image+step;
}

function image_get(indx){
	if (d.getElementById)
		return d.getElementById('img'+indx);
	if (d.all)
		return d.all('img'+indx);
	return null;
}

function text_get(indx){
	if (d.getElementById)
		return d.getElementById('txt'+indx).childNodes[0];
	return null;
}

function image_loop(){
	var i;
	var image_node;
	var indx_new;
	for(i=0; i<img_cnt; i++){
		image_node = image_get(i+1);
		if (!image_node)
			return;
		text_node = text_get(i+1);
		if (!text_node)
			return;
		indx_new = image_get_next(i);
		image_node.src = "img/"+myimage[indx_new][0];
		image_node.title = myimage[indx_new][1];
		image_node.alt = myimage[indx_new][1];

		//alert(text_node.value);
		text_node.data = myimage[indx_new][1];
	}
	current_image = image_get_next(1);
	setTimeout(image_loop, 5000);
}

