// JavaScript Document
var isExplorer = (document.all ? true : false);
function getNavSize(){
	
	var xScroll, yScroll;
	
	if (window.innerHeight && window.scrollMaxY) {	
		xScroll = document.body.scrollWidth;
		yScroll = window.innerHeight + window.scrollMaxY;
	} else if (document.body.scrollHeight > document.body.offsetHeight){
		xScroll = document.body.scrollWidth;
		yScroll = document.body.scrollHeight;
	} else { 
		xScroll = document.body.offsetWidth;
		yScroll = document.body.offsetHeight;
	}
	
	var windowWidth, windowHeight;
	if (self.innerHeight) {	
		windowWidth = self.innerWidth;
		windowHeight = self.innerHeight;
	} else if (document.documentElement && document.documentElement.clientHeight) {
		windowWidth = document.documentElement.clientWidth;
		windowHeight = document.documentElement.clientHeight;
	} else if (document.body) { 
		windowWidth = document.body.clientWidth;
		windowHeight = document.body.clientHeight;
	}	
	

	if(yScroll < windowHeight){
		pageHeight = windowHeight;
	} else { 
		pageHeight = yScroll;
	}


	if(xScroll < windowWidth){	
		pageWidth = windowWidth;
	} else {
		pageWidth = xScroll;
	}


	arrayPageSize = new Array(pageWidth,pageHeight,windowWidth,windowHeight) 	
	
	return arrayPageSize;	
}

function setStateTrnsp(){
	var SizePage = getNavSize();
	imgDivTrnp = document.getElementById('transp');
	imgDivTrnp.style.width = SizePage[0]+'px';
	imgDivTrnp.style.height = '0px';	
	imgDivTrnp.style.height = (SizePage[1]+95)+'px';
	
	imgDivshow = document.getElementById('imgPrFd');		
	imgDivshow.style.left = ((SizePage[0]-parseInt(imgDivshow.style.width))/2) + 'px';
}

function createContent(){
	var SizePage = getNavSize();	
	var odivElement = document.createElement('div');
	odivElement.style.width = SizePage[0]+'px';
	odivElement.style.height = '1170px';
	odivElement.style.backgroundColor = '#333333';
	odivElement.style.position = 'absolute';
	odivElement.style.zIndex = 1;
	odivElement.style.display = 'none';
	if(isExplorer){				
		odivElement.style.backgroundColor = '#333333';
	}
	odivElement.style.filter = 'progid:DXImageTransform.Microsoft.AlphaImageLoader(src=\'overlay.png\', sizingMethod=\'scale\')';
	odivElement.style.top = '0px';
	odivElement.style.left = '0px';	
	odivElement.id = 'transp';
	document.body.appendChild(odivElement);
	
	odivElement.style.display = 'none';	
}


function manjEvent(dim,txt){	
	var aDimInfo = dim.split("||");	
	var SizePage = getNavSize();
	var dimLeft = ((SizePage[0]-aDimInfo[0])/2);
	var dimTop = ((SizePage[3]-aDimInfo[1])/2);		
		
	imgDivshow = document.getElementById('imgPrFd');		
	imgDivshow.style.top = 95 + 'px';
	imgDivshow.style.left = dimLeft + 'px';
	imgDivshow.style.width = aDimInfo[0] + 'px';
	imgDivshow.style.height = aDimInfo[1] + 'px';
	
	imgDivInf = document.getElementById('ImgArtPr');
	
	if(txt.length < 50){
		imgDivInf.innerHTML = '<img src="img/catalogo/brujas/'+txt+'.jpg" width="'+aDimInfo[0]+'" height="'+aDimInfo[1]+'" ></img>';
	}else{
		imgDivInf.innerHTML = txt;
	}
	
	imgDivTrnp = document.getElementById('transp');
	imgDivTrnp.style.height = (SizePage[1]+95)+'px';
	if((SizePage[1]) < aDimInfo[1]){
		imgDivTrnp.style.height = (aDimInfo[1]+80)+'px';
		alert(imgDivTrnp.style.height);
	}
	imgDivTrnp.style.display = 'block';
	
	sOpctyOn('transp',10);
	
	imgDivshow.style.display = 'block';
	
	objdiv = 'imgPrFd';
	opcVal = 25;

	if(isExplorer){		
		objFade = document.getElementById(objdiv);
		var temp = objFade.innerHTML;
		objFade.innerHTML=''; 
		objFade.filters[0].apply(); 
		objFade.innerHTML=temp; 
		objFade.filters[0].play(); 
		
	}else{
		setTimeout("showopctyON('"+objdiv+"',"+opcVal+")",500);
	}
}

function showopctyON(id,opct){sOpctyOn(id,opct); }
function swout(id,display){
	obj = document.getElementById(id);	
	obj.style.display = display;	
}

/************************************************ OPACITY ******************************************/


aryOpctOn = new Array();
aryOpctOff = new Array();
function sOpctyOn(id,indOpc){	
	imgFade = document.getElementById(id);
	
	if(isExplorer){
		imgFade.runtimeStyle.filter = "progid:DXImageTransform.Microsoft.Alpha";		
	}
	
	imgAlfaOn = 1;
		
	aryOpctOn[id]=new Array(); 
	aryTemp = new Array();
	aryTemp.push(imgFade);//0
	aryTemp.push(imgAlfaOn);//1
	aryTemp.push(indOpc);//opct
	
	aryOpctOn[id].push(aryTemp);
	hfade   = window.setInterval("OpctOn('"+id+"')", 100);
	aryTemp.push(hfade);//2
	aryOpctOn[id].push(aryTemp);	
}

function OpctOn(id) {		
	aryOpctOn[id][0][1] += 1;
	aryOpctOn[id][0][0].style.opacity = (aryOpctOn[id][0][1]/25);
	if(isExplorer && (aryOpctOn[id][0][1] < (aryOpctOn[id][0][2])-2)){	
		aryOpctOn[id][0][0].filters.item("DXImageTransform.Microsoft.Alpha").opacity = aryOpctOn[id][0][1]*8;
	}
	if(aryOpctOn[id][0][1]>=aryOpctOn[id][0][2]) {
		clearInterval(aryOpctOn[id][0][3]);	
		clearInterval(aryOpctOn[id][0][3]);	
		clearInterval(aryOpctOn[id][0][3]);		
		//alert(aryOpctOn[id][0][1] + '--' + aryOpctOn[id][0][3]);
		aryOpctOn[id][0][0]='';
		aryOpctOn[id][0][3] = 0;
		aryOpctOn[id][0][1] = 1;		
		
	}
	//aryOpctOn[id][0][1] = imgAlfaOn;
}

function evDtArt(id){
	if(!isExplorer){
		sOpctyOff(id,-1);		
	}else{
		obj = document.getElementById(id);	
		obj.style.display='none';
	}
	sOpctyOff('transp',-1);
	
}
function sOpctyOff(id,indOpOff) {
	imgFade = document.getElementById(id);	
	if(isExplorer){
		imgFade.runtimeStyle.filter = "progid:DXImageTransform.Microsoft.Alpha";
	}	
	
	imgAlfaOff = 25;
		
	aryOpctOff[id]=new Array(); 
	aryTempOff = new Array();
	aryTempOff.push(imgFade);//0
	aryTempOff.push(imgAlfaOff);//1
	aryTempOff.push(indOpOff);//2 opct
	
	aryOpctOff[id].push(aryTempOff);	
	hFadeOff   = window.setInterval("OpctOff('"+id+"')",  25);	
	aryTempOff.push(hFadeOff);//Intv 3
	aryOpctOff[id].push(aryTempOff);
}
function OpctOff(id) {	
	aryOpctOff[id][0][1] -= (0.8);
	aryOpctOff[id][0][0].style.MozOpacity = (aryOpctOff[id][0][1]/25);	
	
	if(isExplorer){
		aryOpctOff[id][0][0].filters.item("DXImageTransform.Microsoft.Alpha").opacity = aryOpctOff[id][0][1]*10;
	}
	if(aryOpctOff[id][0][1]<=aryOpctOff[id][0][2]) {		
		clearInterval(aryOpctOff[id][0][3]);
		clearInterval(aryOpctOff[id][0][3]);
		clearInterval(aryOpctOff[id][0][3]);		
		//alert(aryOpctOff[id][0][1] + '--' + aryOpctOff[id][0][3]);
		aryOpctOff[id][0][0].style.display = 'none';
		//alert(aryOpctOff[id][0][0].style.display);
		//swout(aryOpctOff[id][0][0].id,'none');
		aryOpctOff[id][0][0]='';
		aryOpctOff[id][0][3] = 0;
		aryOpctOff[id][0][1] = 25;		
	}
}