function switch_id(num){	
	// num = 0,1,2 ...
	var div_ext = 'div_'; //extra ext.b4 eg <div id= 'div_'+ids[0]
	var img_path = 'images/index_n/';
	var img_type = '.jpg';
	
	hide_all_divs(div_ext); 
	show_div(num,div_ext);
	restore_all_imgs(img_path,img_type);
	swap_img(num,img_path,img_type);
}

function hide_all_divs(ext_b4){
	//loop through the array and hide each element by id
	var id;
	for (var i=0;i<ids.length;i++){
		id = ext_b4 +ids[i];
		hide_div(id);
	}		  
}

function hide_div(id) {
	//safe function to hide an element with a specified id
	if (document.getElementById) { // DOM3 = IE5, NS6
		document.getElementById(id).style.display = 'none';
		
	}
	else {
		if (document.layers) { // Netscape 4
			document.id.display = 'none';
		}
		else { // IE 4
			document.all.id.style.display = 'none';
		}
	}
}

function show_div(num,ext_b4) {
	//safe function to show an element with a specified id
	var id = ext_b4 +ids[num];
	if (document.getElementById) { // DOM3 = IE5, NS6
		document.getElementById(id).style.display = 'block';
	}
	else {
		if (document.layers) { // Netscape 4
			document.id.display = 'block';
		}
		else { // IE 4
			document.all.id.style.display = 'block';
		}
	}
}

function restore_all_imgs(img_path,img_type){
	var id;
	for (var i=0;i<ids.length;i++){
		id = ids[i];
		if (document.getElementById) { // DOM3 = IE5, NS6
			var obj =document.getElementById(id);
			if(obj.src.indexOf(img_path +id+'_b'+img_type) >=0)
				obj.src =img_path +id+'_a'+img_type;
		}
		else {
			if (document.layers) { // Netscape 4
				document.id.src=img_path +id+'_a'+img_type;
			}
			else { // IE 4
				document.all.id.src=img_path +id+'_a'+img_type;
			}
		}
	} //for		
}

function swap_img(num,img_path,img_type){
	var id = ids[num];
	if (document.getElementById) { // DOM3 = IE5, NS6
		document.getElementById(id).src=img_path +id+'_b'+img_type;
	}
	else {
		if (document.layers) { // Netscape 4
			document.id.src=img_path +id+'_b'+img_type;
		}
		else { // IE 4
			document.all.id.src=img_path +id+'_b'+img_type;
		}
	}
}