var anuncioactual=0;
var anuncioTimer;
var esperaTimer;
var TimerCambia;
var idproyecto1;

tipo_anuncio = new Array();
tipo_menu = new Array();
	
tipo_anuncio[0]="anuncio_pro";
tipo_anuncio[1]="anuncio_ecom";
tipo_anuncio[2]="anuncio_inmo";
tipo_anuncio[3]="anuncio_w20";
tipo_anuncio[4]="anuncio_singular";
	
tipo_menu[0]="disenopro";
tipo_menu[1]="disenoecom";
tipo_menu[2]="disenoinmo";
tipo_menu[3]="disenow20";
tipo_menu[4]="disenosingle";
	
function activa_cambia_anuncio(anuncionuevo){
	clearTimeout(TimerCambia);
	TimerCambia = setTimeout("cambia_anuncio("+anuncionuevo+")",200);
}
function quita_cambia_anuncio(){
	clearTimeout(TimerCambia);
	TimerCambia = setTimeout("cambia_siguiente_anuncio()",30000);
}
function cambia_anuncio(anuncionuevo){
	clearTimeout(TimerCambia);
	if(anuncionuevo!=anuncioactual){
		// fadeout(tipo_anuncio[anuncioactual]);
		document.getElementById(tipo_anuncio[anuncioactual]).style.display = "none";
		document.getElementById(tipo_menu[anuncioactual]).style.color="#333333";
		document.getElementById(tipo_menu[anuncioactual]).style.backgroundPosition="left top";

		if (navigator.userAgent.indexOf("MSIE")>=0){
			fadein(tipo_anuncio[anuncionuevo]);
		}
		document.getElementById(tipo_anuncio[anuncionuevo]).style.display = "block";
		document.getElementById(tipo_menu[anuncionuevo]).style.color="#FFFFFF";
		document.getElementById(tipo_menu[anuncionuevo]).style.backgroundPosition="right bottom";
		anuncioactual=anuncionuevo;
	}
}
function cambia_siguiente_anuncio(){
	var anuncionuevo=0;
	
	anuncionuevo = anuncioactual + 1;
	if(anuncionuevo==5){
		anuncionuevo = 0;
	}
	cambia_anuncio(anuncionuevo);
	TimerCambia = setTimeout("cambia_siguiente_anuncio()",20000);
}
	
var xmlHttp;
var posproyecto=0;

function GetXmlHttpObject(handler){ 
	var objXmlHttp=null

	if (navigator.userAgent.indexOf("Opera")>=0){
		alert("This doesn't work in Opera") 
		return 
	}
	if (navigator.userAgent.indexOf("MSIE")>=0){ 
		var strName="Msxml2.XMLHTTP"
		if (navigator.appVersion.indexOf("MSIE 5.5")>=0){
			strName="Microsoft.XMLHTTP"
		} try { 
			objXmlHttp=new ActiveXObject(strName)
			objXmlHttp.onreadystatechange=handler

			return objXmlHttp
		} catch(e) { 
			alert("Error. Scripting for ActiveX might be disabled") 
			return 
		} 
	} 
	if (navigator.userAgent.indexOf("Mozilla")>=0){
		objXmlHttp=new XMLHttpRequest()
		objXmlHttp.onload=handler
		objXmlHttp.onerror=handler 
		return objXmlHttp
	}
}

function ejecutaAccion(origen, orden){ 
	var url = "";
	
	posproyecto = orden;
	origen = origen.replace("&amp;","&");
	url = origen;
	document.getElementById("elproyecto"+posproyecto).innerHTML="\<img src=\'pics/loader.gif\' width=\'140px\' height=\'96px\' alt=\'buscando\'\>";
	xmlHttp=GetXmlHttpObject(stateChanged);	
	params =  "pos="+orden;
	xmlHttp.open("POST", url, true);
	xmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
	xmlHttp.setRequestHeader("Content-length", params.length);	
	xmlHttp.send(params);
} 

function stateChanged() { 	
	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete"){ 
		document.getElementById("elproyecto"+posproyecto).innerHTML=xmlHttp.responseText;
		posproyecto = posproyecto + 1;
		if(posproyecto==4){
			posproyecto=0;
		}
		setTimeout("ejecutaAccion('proyectos_principal.php?pos=" + posproyecto + "'," + posproyecto + ");",5000);
	} else {
		document.getElementById("elproyecto"+posproyecto).innerHTML="\<img src=\'pics/loader.gif\' width=\'140px\' height=\'96px\' alt=\'buscando\'\>";
		// "\<img src=\'pics/loader1.gif\' width=\'140px\' height=\'96px\' alt=\'buscando\'\>\<a href=\'javascript:;\'\>\<\/a\>"
	}
} 

function fadein(nuevaimagen) {
	oDiv=document.getElementById(nuevaimagen);
	oDiv.style.filter="blendTrans(duration=1)";	
	if (oDiv.filters.blendTrans.status != 2) {
		oDiv.filters.blendTrans.apply();
		oDiv.style.visibility="visible";
		oDiv.filters.blendTrans.play();
	}
}
function fadeout(nuevaimagen) {
	oDiv=document.getElementById(nuevaimagen);
	oDiv.style.filter="blendTrans(duration=1)";	
	if (oDiv.filters.blendTrans.status != 2) {
		oDiv.filters.blendTrans.apply();
		oDiv.style.visibility="hidden";
		oDiv.filters.blendTrans.play();
	}
}