function slideshow(){
	if (navigator.appName.indexOf('Microsoft') != -1){
	//browser = 'IE'
	checkAvailableWidth();
	//alert("oi!");
	}
	setTimeout('slideshow()', 8000);
	avancar();
}
function deslizadir(xinicial,x){
	if(xinicial != x){
		obj = document.getElementById("listaslideshow");
		xinicial=findPosX(obj)
			xinicial = xinicial - 10;
			
			if(xinicial < x){
				xinicial = x;
				document.getElementById("listaslideshow").style.left = xinicial+"px";
				//alert("passou11"+xinicial);
				positivo = Math.abs(xinicial);
				//alert("passou"+positivo);
				slide(positivo);
				
				return false;
			}
		document.getElementById("listaslideshow").style.left = xinicial+"px";
		setTimeout('deslizadir(xinicial,x)', 0.1);
	}
	return false;
}
function deslizaesq(xinicial,x){
	//alert("xinicial:" + xinicial +"x:" +x);
	if(xinicial != x){
		obj = document.getElementById("listaslideshow");
		xinicial=findPosX(obj)
		//alert(xinicial);
			xinicial = xinicial + 10;
			if(xinicial > x){
				xinicial = x;
				document.getElementById("listaslideshow").style.left = xinicial+"px";
				positivo = Math.abs(xinicial);
				slide(positivo);
				return false;
			}
		document.getElementById("listaslideshow").style.left = xinicial+"px";
		setTimeout('deslizaesq(xinicial,x)', 0.1);
	}
	return false;
}

function avancar(){
	obj = document.getElementById("listaslideshow");
	x=findPosX(obj);
	xinicial = x;
	//alert(obj);
	if(x > -2754){
		x = x - 306;
		//alert("1 xinicial:" + xinicial +"x:" +x);
		x = fimslide(x);
		//alert("2 xinicial:" + xinicial +"x:" +x);
	}else{
		x = 0;
	}
	deslizadir(xinicial,x);
	//document.getElementById("listaslideshow").style.left = x+"px";
}
function recuar(){
	obj = document.getElementById("listaslideshow");
	x=findPosX(obj)
	xinicial = x;
	//alert(obj);
	if(x < 0){
		x = x + 306;
		x = fimslide(x);
	}else{
		x = -2754;
	}
	deslizaesq(xinicial,x);
	//document.getElementById("listaslideshow").style.left = x+"px";
}
function slide(x){
	//limpa
	for (i=1;i<=10;i++){
		slidelimpo = "s"+i;
		document.getElementById(slidelimpo).style.background="#D5DCF4";
	}//fim limpa
	
	obj = document.getElementById("listaslideshow");
	x = x / 306;
	x++;
	pagina = "s"+x;
	//alert (pagina);
	document.getElementById(pagina).style.background="#FFF";
}

function fimslide(x){
	//alert("chegou:"+x);
	if(x > -2754 && x <= -2448){
		x = -2448;
	}
	if(x > -2448 && x <= -2142){
		x = -2142;
	}
	if(x > -2142 && x <= -1836){
		x = -1836;
	}
	if(x > -1836 && x <= -1530){
		x = -1530;
	}
	if(x > -1530 && x <= -1224){
		x = -1224;
	}
	if(x > -1224 && x <= -918){
		x = -918;
	}
	if(x > -918 && x <= -612){
		x = -612;
	}
	if(x > -612 && x <= -306){
		x = -306;
	}
	if(x > -306 && x <= 0){
		x = 0;
	}
	if(x > 0){
		x = -2754;
	}
	//alert ("x= "+x);
	return x;
}

function exibilan(x){
	y = 306;
	x = (x * y) - y;
	//alert (x);
	document.getElementById("listaslideshow").style.left = "-"+x+"px";
	slide(x);
}


/*function findPosX(obj)
  {
    var curleft = 0;
    if(obj.offsetParent)
        while(1) 
        {
          curleft += obj.offsetLeft;
          if(!obj.offsetParent)
            break;
          obj = obj.offsetParent;
        }
    else if(obj.x)
        curleft += obj.x;
    return curleft;
  }
*/
function findPosX(obj){
    var curleft = 0;
    if(obj.offsetParent)
          curleft += obj.offsetLeft;
    return curleft;
}
