var imagenes =new Array();
var idactual = 0;

// JavaScript Document
function abrir (url, img, h, w){
	var ar = (screen.height-h)/2;
	var izq = (screen.width-w)/2;
   	var w= (window.open(url,img,'width=' + w + ',height=' + h + ',top=' + ar + ',left=' + izq + ',scrollbars=NO'));
}

/*function agregar(img) {
	imagenes[indice]=img;
	indice++;
	//document.write(indice);
}*/

function pulsarTecla(e) {
	if(window.event) tecla=window.event.keyCode
	else if(e) tecla=e.which;
	//document.write("He capturado una tecla");
	if (tecla == 37) anterior();
	if (tecla == 39) siguiente();
}

function agregar() {
	for (i=0;i<agregar.arguments.length;i++){
		imagenes[i]=agregar.arguments[i];
	} 
}

function mostrar_imagen(ref, h, w) {
	document.getElementById('imgprincipal').style.display='block';
	document.getElementById('fade').style.display='block';
	var ar = (screen.height-h)/2;
	var izq = (screen.width-w)/2;
	/*document.getElementById('imgprincipal').style.width=w+32;
	document.getElementById('imgprincipal').style.left=izq;*/
	document.getElementById('imgprincipal').style.marginLeft=izq+"px";
	document.getElementById('imgprincipal').style.marginTop=ar/2+"px";
	document.getElementByName('imgppal').style.width=20;
}

function cambiar(id) {
	idactual = id;
	document.images["imgppal"].src = imagenes[idactual];
	document.getElementById('numero').firstChild.nodeValue = idactual+1;
}

function anterior() {
	if (idactual > 0) {
		idactual--;
    		document.images["imgppal"].src = imagenes[idactual];
		document.getElementById('numero').firstChild.nodeValue = idactual+1;
	}
}

function siguiente() {
	if (idactual < imagenes.length-1) {
		idactual++;
		document.images["imgppal"].src = imagenes[idactual];
		document.getElementById('numero').firstChild.nodeValue = idactual+1;
	}
}

function imagen (ref, nombre) {
	document.getElementById(nombre).src = ref.href;
 	return false;
}

function ocultar() {
	document.getElementById('imgprincipal').style.display='none';
	document.getElementById('fade').style.display='none';
}

$(document).ready ( function() {

	$("#menuprincipal li").mouseover(function(){

		$(this).siblings("li").children("ul").hide();

		$(this).children("ul").show();

		$(this).children("a").addClass("mouseover");

		$(this).siblings("li").children("a").removeClass("mouseover");

	});

});	

	


