/*	
	Overlayed Image Loader
	Created by Filipe Miguel Maria Marreiros and Mourylise Heymer Marreiros
	22/02/2007
*/

var div_images;
var div_preload;

window.onload = function()
{
	// check to see if the browser supports the getElementsByTagName and getElementsById methods
	// if not, exit the function
	
	if (!document.getElementsByTagName&&!document.getElementById) {
		return false; 
	} 
	
	var imagesListNode=document.getElementById("middle_content");
	var imagesLinksNodes=imagesListNode.getElementsByTagName("a");
	
	var imagesHref=new Array();
	
	imagesHref[0]="javascript:load_image(0,'/images/graphic/big/cachapuz.png',912, 631);";
	imagesHref[1]="javascript:load_image(1,'/images/graphic/big/vrc1.png',912, 631)";
	imagesHref[2]="javascript:load_image(2,'/images/graphic/big/vrc2.png',912, 631)";
	imagesHref[3]="javascript:load_image(3,'/images/graphic/big/maksimiza.png',912, 631)";
	imagesHref[4]="javascript:load_image(4,'/images/graphic/big/maksimiza3.jpg',912, 633)";
	imagesHref[5]="javascript:load_image(5,'/images/graphic/big/maksimiza2.jpg',912, 633)";
	imagesHref[6]="javascript:load_image(6,'/images/graphic/big/redicom.jpg',912, 633)";
	imagesHref[7]="javascript:load_image(7,'/images/graphic/big/logos.jpg',863, 511)";
	imagesHref[8]="javascript:load_image(8,'/images/graphic/big/varios.jpg',863, 511)";
	imagesHref[9]="javascript:load_image(9,'/images/graphic/big/rv_1.jpg',721, 285)";
	imagesHref[10]="javascript:load_image(10,'/images/graphic/big/rv_2.jpg',800, 600)";
	imagesHref[11]="javascript:load_image(11,'/images/graphic/big/damiao.jpg',820, 620)";
		
	for (var i=0; i < imagesLinksNodes.length-1; i++) {
		imagesLinksNodes[i].href=imagesHref[i];		
	}
}

function finish_load()
{
	document.getElementById("divload").style.visibility="visible";
	document.body.removeChild(div_preload);
}
function preload_image(width, height)
{
 div_preload = document.createElement('div');
 div_preload.setAttribute('id','divpreload');
 div_preload.style.width = width+"px"; 
 div_preload.style.height = height+"px";
 div_preload.style.position = "absolute";
 div_preload.style.zIndex = "4";
 div_preload.style.left = Math.round((screen.availWidth-width)/2)+"px";
 
 if( typeof( window.pageYOffset ) == 'number' ) 
 {
    //Netscape compliant
	 div_preload.style.top = (window.pageYOffset+10)+"px";
 } 
 else if( document.body && document.body.scrollTop ) 
 {
    //DOM compliant
	div_preload.style.top = (document.body.scrollTop+10)+"px";
  } 
  else if( document.documentElement && document.documentElement.scrollTop) 
  {
    //IE6 standards compliant mode
	div_preload.style.top = (document.documentElement.scrollTop+10)+"px";
  }
  else
  {
	 div_preload.style.top ="10px"; 
  }
  div_preload.style.padding= "0px";
  div_preload.style.margin= "0px";
  div_preload.style.backgroundColor="#FFF";
  //div_images.style.border = "1px solid #000";
  div_preload.style.backgroundImage= "url(../images/loading.gif)";
  div_preload.style.backgroundRepeat= "no-repeat";
  div_preload.style.backgroundPosition= "center center";
  //div_preload.innerHTML = "<img id='preload_image' src='hand.png'width='17px' height='14px' />";

  document.body.appendChild(div_preload);
  document.getElementById('divpreload').focus();
}
function load_image(selected_index, path, width, height)
{
		
 if(document.getElementById('divpreload')) document.body.removeChild(document.getElementById('divpreload'));
 if(document.getElementById('divload')) document.body.removeChild(document.getElementById('divload'));
 
 preload_image(width, height);
 div_images = document.createElement('div');
 div_images.setAttribute('id','divload');
 div_images.style.width = width+"px"; 
 div_images.style.height = height+"px";
 div_images.style.position = "absolute";
 div_images.style.left = Math.round((screen.availWidth-width)/2)+"px";
 div_images.style.visibility="hidden";
 div_images.style.zIndex = "4";
 div_images.style.cursor = "pointer";

 
 if( typeof( window.pageYOffset ) == 'number' ) 
 {
    //Netscape compliant
	 div_images.style.top = (window.pageYOffset+10)+"px";
 } 
 else if( document.body && document.body.scrollTop ) 
 {
    //DOM compliant
	div_images.style.top = (document.body.scrollTop+10)+"px";
  } 
  else if( document.documentElement && document.documentElement.scrollTop) 
  {
    //IE6 standards compliant mode
	div_images.style.top = (document.documentElement.scrollTop+10)+"px";
  }
  else
  {
	 div_images.style.top ="10px"; 
  }
  
 //alert (div_images.style.top+" "+document.body.scrollTop+" "+document.documentElement.scrollTop);

 div_images.style.padding= "0px";
 div_images.style.margin= "0px";
 div_images.style.border= "none";
 div_images.style.backgroundColor="#FFF";
 //div_images.style.border = "1px solid #000";
 div_images.innerHTML = "<a id='big_image' href='javascript:close_image("+selected_index+");' title='Click or Enter to close'><img onload='finish_load();' src='"+path+"'width="+width+" height="+height+" alt='Project Sample' /></a>";

 document.body.appendChild(div_images);
 document.getElementById('big_image').focus();
}

function close_image(selected_index)
{
	document.body.removeChild(div_images);
	
	var imagesListNode=document.getElementById("middle_content");
	var imagesLinksNodes=imagesListNode.getElementsByTagName("a");
				
	for (var i=0; i < imagesLinksNodes.length-1; i++) {
		if(i==selected_index) 
		{	
			imagesLinksNodes[i].focus();		
			break;
		}
	}
	
}
