function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

function llamarasincrono(url, id_contenedor){
	var pagina_requerida = false
	if (window.XMLHttpRequest) {// Si es Mozilla, Safari etc
	pagina_requerida = new XMLHttpRequest();
	} else if (window.ActiveXObject){ // pero si es IE
	try {
	pagina_requerida = new ActiveXObject("Msxml2.XMLHTTP");
	} 
	catch (e){ // en caso que sea una versión antigua
	try{
	pagina_requerida = new ActiveXObject("Microsoft.XMLHTTP");
	}
	catch (e){}
	}
	}
	else
	return false
	pagina_requerida.onreadystatechange=function(){ // función de respuesta
	cargarpagina(pagina_requerida, id_contenedor)
	}
	pagina_requerida.open('GET', url, true) // asignamos los métodos open y send
	pagina_requerida.send(null)
	}
	// todo es correcto y ha llegado el momento de poner la información requerida
	// en su sitio en la pagina xhtml
	function cargarpagina(pagina_requerida, id_contenedor){
			if (pagina_requerida.readyState == 4 && (pagina_requerida.status==200 || window.location.href.indexOf("http")==0)){
				document.getElementById(id_contenedor).innerHTML=pagina_requerida.responseText
				document.getElementById('contcentrodcha').style.top=0+'px';
				var nc=0;
				altodivs();
				}
	}

function cambiaestilo(tipo){
	//document.getElementsByClassName('fichalistaa').className='fichalista';
 for (i = 0, todos = document.body.getElementsByTagName("div"), total = todos.length; i < total; i ++)
  if (todos[i].className == 'fichalistaa'){
	  todos[i].className='fichalista';

}
	document.getElementById(tipo).className='fichalistaa';
}

//-------------------------------------------------------

var n=0;
var nc=0;
var id;
function mover(p,cd){
	var poscd=document.getElementById(cd).style.top;
	if(poscd==0){
		nc=0;
	}
	clearInterval(id);
	document.body.style.cursor="hand";
	document.body.style.cursor="pointer";
	if(p=='abajo'){
		if(cd=='fotos'){
			n+=10;
		}else{
			nc+=10;
		}
	}else{
		if(cd=='fotos'){
			n-=10;
		}else{
			nc-=10;
		}
	}
	var alto=document.getElementById(cd).offsetHeight;
	if(cd=='fotos'){
		var altocont=document.getElementById('div').offsetHeight;
	}else{
		var altocont=document.getElementById('centrodcha').offsetHeight;
	}
	diferencia=parseInt(alto)-parseInt(altocont);
	id= setInterval('inicia("'+p+'","'+cd+'")',50);
}
function inicia(p,cd){
	if(cd=='fotos'){
		if(p=='abajo'){
			if(n<=diferencia){
				document.getElementById(cd).style.top='-'+n+'px';
				n+=10;
			}else{
				clearInterval(id);
			}
		}else{
			if(n>=0){
			document.getElementById(cd).style.top='-'+n+'px';
			n-=10;
			}else{
				clearInterval(id);
			}
		}
	}else{
		if(p=='abajo'){
			if(nc<=diferencia){
				document.getElementById(cd).style.top='-'+nc+'px';
				nc+=10;
			}else{
				clearInterval(id);
			}
		}else{
			if(nc>=0){
			document.getElementById(cd).style.top='-'+nc+'px';
			nc-=10;
			}else{
				clearInterval(id);
			}
		}
	}
}
function parar(){
		clearInterval(id);
		document.body.style. cursor="default";
}

//------------------------------------------------------------------------

window.addEventListener?window.addEventListener("load",altodivs,false):window.attachEvent("onload",altodivs);
window.addEventListener?window.addEventListener("resize",altodivs,false):window.attachEvent("onresize",altodivs);
window.addEventListener?window.addEventListener("load",alto,false):window.attachEvent("onload",alto);
window.addEventListener?window.addEventListener("resize",alto,false):window.attachEvent("onresize",alto);

function altodivs(){
	if (typeof window.innerWidth != 'undefined'){ 
        widthViewport= window.innerWidth-17; 
        heightViewport= window.innerHeight-17; 
    }else if(typeof document.documentElement != 'undefined' && typeof document.documentElement.clientWidth !='undefined' && document.documentElement.clientWidth != 0){ 
        widthViewport=document.documentElement.clientWidth; 
        heightViewport=document.documentElement.clientHeight; 
    }else{ 
        widthViewport= document.getElementsByTagName('body')[0].clientWidth; 
        heightViewport=document.getElementsByTagName('body')[0].clientHeight; 
    } 
	//alto=document.body.offsetHeight;
	document.getElementById('div').style.height=(heightViewport-340)+'px';
	document.getElementById('centroizda').style.height=(heightViewport-250)+'px';
	document.getElementById('centrodcha').style.height=(heightViewport-230)+'px';
	document.getElementById('centrodcha').style.width=(widthViewport-500)+'px';
	document.getElementById('scroll').style.left=(widthViewport-80)+'px';
	document.getElementById('scroll').style.display='block';
	
	document.getElementById('b').style.display='block';
	
	var altcont=document.getElementById('contcentrodcha').style.height;
	var alt=document.getElementById('centrodcha').style.height;
	if(altcont>alt){
		document.getElementById('scroll').style.display='block';
	}else{
		document.getElementById('scroll').style.display='none';
	}
}
function alto(){
	if (typeof window.innerWidth != 'undefined'){ 
        widthViewport= window.innerWidth-17; 
        heightViewport= window.innerHeight-17; 
    }else if(typeof document.documentElement != 'undefined' && typeof document.documentElement.clientWidth !='undefined' && document.documentElement.clientWidth != 0){ 
        widthViewport=document.documentElement.clientWidth; 
        heightViewport=document.documentElement.clientHeight; 
    }else{ 
        widthViewport= document.getElementsByTagName('body')[0].clientWidth; 
        heightViewport=document.getElementsByTagName('body')[0].clientHeight; 
    }
	document.getElementById('hcentro').style.height=(heightViewport-230)+'px';
	document.getElementById('centroizda').style.height=(heightViewport-250)+'px';
	//document.getElementById('multimedia').style.height=(heightViewport-230)+'px';
}



var tr= new Array();
tr[0]="";
tr[1]="Aplicaciones";
tr[2]="Multimedia";
tr[3]="Productos";
tr[4]="Web";

var se= new Array();
se[0]="";
se[1]="Internet";
se[2]="Diseño";
se[3]="Seguridad";

function cargaselect(valor,valorseleccionado){
	if(valor=="Trabajos"){
		document.formulario.subcategoria.options.length=tr.length;
		for($i=0;$i<tr.length;$i++){
			document.formulario.subcategoria.options[$i].value=tr[$i];
			document.formulario.subcategoria.options[$i].text=tr[$i];
			if(tr[$i]==valorseleccionado){
				document.formulario.subcategoria.options[$i].selected="selected";
			}
		}
	}
	if(valor=="Servicios"){
		document.formulario.subcategoria.options.length=se.length;
		for($i=0;$i<se.length;$i++){
			document.formulario.subcategoria.options[$i].value=se[$i];
			document.formulario.subcategoria.options[$i].text=se[$i];
			if(se[$i]==valorseleccionado){
				document.formulario.subcategoria.options[$i].selected="selected";
			}
		}
	}
}

var estado=new Array('none','block');
function MuestraEsconde(capa,juego) {
	document.getElementById("contmulti").innerHTML="<div id='cerrarmultimedia'><a href='javascript:cerrar(\""+capa+"\");'><img src='img/cerrar.jpg'></a></div><div class='div100'><object classid='clsid:D27CDB6E-AE6D-11cf-96B8-444553540000' codebase='http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,28,0'  id='interior' width='750' height='500' name='interior'><param name='movie' value='demomulti/"+juego+".swf'/><param name=quality value=high/><embed src='demomulti/"+juego+".swf' quality='high'  width='750' height='500' name='interior' type='application/x-shockwave-flash' pluginspage='http://www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash'></embed></object></div>";
		
	var s=document.getElementById(capa).style;
	var nestado=(s.display==estado[0])?1:0;
	s.display=estado[nestado];

}

function cerrar(capa){
   var s=document.getElementById(capa).style;
	var nestado=(s.display==estado[0])?1:0;
	s.display=estado[nestado];
}

