var overme = false;
var iconos_max = 142.0;
var iconos_min = 100.0;
var iconos_dif = iconos_max - iconos_min;

function sleep(delay)
{
    var start = new Date().getTime();
    while (new Date().getTime() < start + delay);
}

function grow(targetid){
	var miitem = document.getElementById(targetid);
	miitem.style.width = currentCSS(miitem, 'width');
	miitem.style.height = currentCSS(miitem, 'height');
	miitem.style.margin = currentCSS(miitem, 'margin-left');
	//miitem.style.opacity = currentCSS(miitem, 'opacity');
	var tmr = setInterval( function() {
	if ((parseInt(miitem.style.width) < iconos_max) && miitem.sub == true) {
		miitem.style.width = parseInt(miitem.style.width)+8+'px';
		miitem.style.height = parseInt(miitem.style.height)+8+'px';
		miitem.style.margin = parseInt(miitem.style.margin)-4+'px';
		miitem.style.opacity = Math.round((((parseFloat(miitem.style.width)-iconos_min)/iconos_dif)/2+0.5)*100)/100;
		//miitem.style.opacity+= 0.01;
	} else if(miitem.sub == true) {
		clearInterval(tmr);
		miitem.style.opacity = 1;
	}
	
	},30); 
}
function shrink(targetid){
	var miitem = document.getElementById(targetid);
	var tmro = setInterval( function() {
	if ((parseInt(miitem.style.width) > iconos_min) && miitem.sub == false) {
		miitem.style.width = parseInt(miitem.style.width)-2+'px';
		miitem.style.height = parseInt(miitem.style.height)-2+'px';
		miitem.style.margin = parseInt(miitem.style.margin)+1+'px';
		miitem.style.opacity = Math.round((((parseFloat(miitem.style.width)-iconos_min)/iconos_dif)/2+0.5)*100)/100;
		//miitem.style.opacity = (Math.round(((parseFloat(miitem.style.width)-100)/42)*100)/100)/2+0.5;
		//miitem.style.opacity = (parseFloat(miitem.style.width)-50)*0.01;
	} else {
		clearInterval(tmro);
		miitem.style.opacity = 0.5;
	}
	
	},20); 
	
}

function siguiente(obj){
	var labarra = document.getElementById('mibarra');
	var posicion_actual = parseInt(labarra.style.left);
	var ancho_total = parseInt(labarra.style.width);
	var anchoAreaiconos = (parseInt(parseFloat(currentCSS(document.getElementById("micontenedordeIconos"), "width") )/150))*150;
	var maximo = anchoAreaiconos-ancho_total;
/*	alert("maximo="+maximo);
	alert("elcurrent="+currentCSS(document.getElementById("micontenedordeIconos"), "width") );
	alert("anchoAreaiconos="+anchoAreaiconos);
	alert("ancho_total="+ancho_total);
	alert("posicion_actual="+posicion_actual);*/
	
if ((posicion_actual > maximo )&&(labarra.medioproceso != true)) {
		obj.style.cursor = 'pointer';
		var aumtando = setInterval( function() {
			labarra.medioproceso = true;
			var miposactual = parseInt(labarra.style.left);
			if  (miposactual > maximo )  {
				var hazlo = ((obj.overme == false) && (parseInt(miposactual/150) == miposactual/150)) ? false : true;
			} else {
				obj.style.cursor = 'default';
				var hazlo = false;
			}
			
			if (hazlo == true) {
					//labarra.style.cursor = 'hand';
					obj.src = "flecha-hover.png";
					labarra.style.left = parseInt(labarra.style.left) - 5 + 'px';	
			} else {
				//labarra.style.cursor = 'default';
				//labarra.style.left = parseInt(parseInt(labarra.style.left)/150);
				obj.src = "flecha.png";
				clearInterval(aumtando);
				labarra.medioproceso = false;

			}
		}, 5);		
	}


}


function anterior(obj){
	var labarra = document.getElementById('mibarra');
	var posicion_actual = parseInt(labarra.style.left);
	var ancho_total = parseInt(labarra.style.width);
	var contadorAunocincuenta = 0;
	
if ((posicion_actual < 0 )&&(labarra.medioproceso != true)) {
		obj.style.cursor = 'pointer';
		var aumtando = setInterval( function() {
			labarra.medioproceso = true;
			var miposactual = parseInt(labarra.style.left);
			if  (miposactual < 0 )  {
				var hazlo = ((obj.overme == false) && (parseInt(miposactual/150) == miposactual/150)) ? false : true;
			} else {
				obj.style.cursor = 'default';
				var hazlo = false;
			}
			
			if (hazlo == true) {	
					obj.src = "flecha2-hover.png";			
					labarra.style.left = parseInt(labarra.style.left) + 5 + 'px';	
			} else {				
				//labarra.style.left = parseInt(parseInt(labarra.style.left)/150);
				obj.src = "flecha2.png";
				clearInterval(aumtando);
				labarra.medioproceso = false;

			}
		}, 5);		
	}


}
