// JavaScript Document




var intalf;
var jpg;
var desc;
var cant;
var actual=1;
var prefijo;
var indice;
var categoria;
var maxvec;

function mostrardiv(grupo,id){
	indice=id;
	categoria=grupo;
	var imagen;
	var descripcion;
	var url;
	switch (grupo){
		case 0:
			imagen=multiimagenes[id];
			descripcion=multidescrips[id];
			url=multiurls[id];
			cant=multicants[id];
			maxvec=multiimagenes.length;
		break;
		
		case 1:
			imagen=webimagenes[id];
			descripcion=webdescrips[id];
			url=weburls[id];
			cant=webcants[id];
			maxvec=webimagenes.length;
		break;
		
		case 2:
			imagen=impreimagenes[id];
			descripcion=impredescrips[id];
			url=impreurls[id];
			cant=imprecants[id];
			maxvec=impreimagenes.length;
		break;
		
		case 3:
			imagen=corpoimagenes[id];
			descripcion=corpodescrips[id];
			url=corpourls[id];
			cant=corpocants[id];
			maxvec=corpoimagenes.length;
		break;
	
		
	}
	
	
	
	jpg='portafoliopics/'+imagen;
	
	prefijo=jpg.substr(0,jpg.length-5);
	document.getElementById('cerrarpop').style.visibility='hidden';
	
	document.getElementById('negro').style.filter='alpha(opacity=0)';
	document.getElementById('negro').style.opacity= '0';
	
	document.getElementById('negro').style.visibility='visible';
	
	
	document.getElementById('divgrande').style.width='0px';
	document.getElementById('divgrande').style.height='0px';

	document.getElementById('imagengrande').height='0';
	document.getElementById('imagengrande').width='0';
	document.getElementById('imagengrande').src=jpg;
	
	document.getElementById('info').innerHTML='';
	desc= descripcion+'<br><a target="_blank" href="http://'+url+'>'+url+'</a>';
	//
	
	intalf=setInterval(plusalfa,1);
	setTimeout(apBox,500);
}

function apBox(){
		document.getElementById('divgrande').style.visibility='visible';
		document.getElementById('cerrarpop').style.visibility='visible';
}

function plusalfa(){
	
	var opff=parseFloat(document.getElementById('negro').style.opacity)+.15;
	var opie=opff*100;
	
	var wB=parseFloat(document.getElementById('divgrande').style.width)+10;
	var hB=parseFloat(document.getElementById('divgrande').style.height)+8.25;
	

 	var changew = 600-wB;
	var totalw=wB+Math.ceil((changew/2));
	
 	var changeh = 495-hB;
	var totalh=hB+Math.ceil((changeh/2));
	
	/*
	height: 495px;
	width: 600px;
	margin-top: -260px;
	margin-left: -320px;
	
	*/
	
	if(opff<.7){
		document.getElementById('negro').style.filter='alpha(opacity='+opie+')';//100
		document.getElementById('negro').style.opacity= ''+opff+'';//1	
	}
	else{
	if(wB<615){
		document.getElementById('divgrande').style.width=totalw+'px';
		document.getElementById('divgrande').style.marginLeft= -(totalw/2)+'px';
		
		document.getElementById('divgrande').style.height=totalh+'px';
		document.getElementById('divgrande').style.marginTop= -(totalh/2)+'px';
	}
	else{
		document.getElementById('imagengrande').height='450';
		document.getElementById('imagengrande').width='600';
		

		textoHtml='<table border="0" cellspacing="0" cellpadding="1" width="600" ><tr><td>';
		//textoHtml+='<p>'+desc+'</p><p>';
		textoHtml+='&nbsp;';
		textoHtml+='<a href="javascript:void(0);"><span onclick="javascript:anterior(0);">Anterior</span></a>-';
		textoHtml+='<a href="javascript:void(0);"><span onclick="javascript:siguiente(0);">Siguiente</span></a></p></td>';
		if(cant>1){
			textoHtml+='<td align="right">';
			for(i=1;i<=cant;i++){
			textoHtml+='<a href="javascript:void(0);"><span style="text-align:right" onclick="javascript:foto('+i+');"><img border="0" src="images/tab.gif"></span></a>&nbsp;';
			}
			textoHtml+='&nbsp;</td>';
		}
		textoHtml+='</tr>';			 
		
		textoHtml+='</table>';
		document.getElementById('info').innerHTML=textoHtml;
		//alert(document.getElementById('info').innerHTML);
		
		clearInterval(intalf);
	
	}
	}
	
	
	

}

function anterior(){
	//alert('hola'+indice);
	if(indice>0){
		indice--;
		
		mostrardiv(categoria,indice);
	}

}

function siguiente(){
	//alert('hola'+indice);
	if(indice<maxvec-1){
		indice++;
		
		mostrardiv(categoria,indice);
	}

}


function foto(id){
	document.getElementById('imagengrande').src=prefijo+id+'.jpg';
	

}

function ocultardiv(){
	document.getElementById('cerrarpop').style.visibility='hidden';
	document.getElementById('divgrande').style.visibility='hidden';
	document.getElementById('negro').style.visibility='hidden';	
	document.getElementById('imagengrande').src="";
}
