<!--
//---------------- Abre PopUp ----------------------
function popup(pTarget,pFeatures) { //v3.0
	//The link(file) is the attribute HREF
	//The parameter 'pTarget' must be the same of attribute TARGET and is the WinName value
	//Features: menubar=[yes|no],scrollbars=[yes|no],width=[value],height=[value],resizable=[0|1]
	newwin = window.open('',pTarget,pFeatures);
}

//---------------- Mostra/Oculta Layers ----------------
function showHideLayers() { //v9.0
  var i,p,v,obj,args=showHideLayers.arguments;
  for (i=0; i<(args.length-2); i+=3) 
  with (document) if (getElementById && ((obj=getElementById(args[i]))!=null)) { v=args[i+2];
    if (obj.style) { obj=obj.style; v=(v=='show')?'block':(v=='hide')?'none':v; }
    obj.display=v; }
}

//-------------------------------------------------------------------------------------
function fNavAgenda(pMes,pMesSel){ //v1.0
	for (var i = 1; i <= 12; i++) {
		
		vIdMes = "mes-" + i;
		//alert (vIdMes);
		
		vElemento = document.getElementById(vIdMes)
		
		if (i == pMes) {
			vElemento.style.display = "block";
		}
		else {
			vElemento.style.display = "none";
		}
	}
	
	vLista = document.getElementById("meses")
	
	for (var j = 0; j < vLista.childNodes.length; j++) {
		
		if (vLista.childNodes[j].nodeType == 1) { //Element
			if (vLista.childNodes[j].className == "first") {
				sClass = "first" ;
			}
			else if (vLista.childNodes[j].className == "last") {
				sClass = "last" ;
			}
			else {
				sClass = "" ;
			}
			vLista.childNodes[j].className = sClass ;
		}
	}
	
	pMesSel.className = "highlighted" ;
}
//-->

//---------------- Zoom Foto ----------------
function getPageSize() {
	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 = {pageWidth:pageWidth,pageHeight:pageHeight,windowWidth:windowWidth,windowHeight:windowHeight}
	return arrayPageSize;
}

function getPageScroll(){
	var yScroll;
	if (self.pageYOffset) yScroll = self.pageYOffset;
	else if (document.documentElement && document.documentElement.scrollTop) yScroll = document.documentElement.scrollTop;
	else if (document.body) yScroll = document.body.scrollTop;
	arrayPageScroll = {yScroll:yScroll};
	return arrayPageScroll;
}

function initZoom(div) {
	var container = document.getElementById(div);	
	var lnks = container.getElementsByTagName('a');
	for(var i=0,len=lnks.length;i<len;i++) {
		if(lnks[i].className.indexOf('ZoomLink') > -1) {
			lnks[i].onclick = function() {
				openZoom(this);
				return false;
			}
		}
	}
	var spans = container.getElementsByTagName('div');
	for(var iDiv=0,lend=spans.length;iDiv<lend;iDiv++) {
		if(spans[iDiv].className.indexOf('PhotoDetail') > -1) {
			var divDetail = spans[iDiv];
			container.onmouseover = function() {
				divDetail.style.visibility = 'visible';
				divDetail.style.cursor = 'pointer';
				return false;
			}
			
			container.onmouseout= function() {
				divDetail.style.visibility = 'hidden';
				return false;
			}
		
		}
	}
	
}

function closeZoom(obj) {
	document.body.removeChild(document.getElementById('zoom'));
	document.body.removeChild(document.getElementById('shadow'));
	obj.parentNode.parentNode.parentNode.removeChild(obj.parentNode.parentNode);
}

function resizeZoom(obj) {
	var largura = obj.width;
	var altura = obj.height;
	var box = obj.parentNode.parentNode;
	var pageSize = getPageSize();
	var pageScroll = getPageScroll();
	var boxTop = pageScroll.yScroll + ((pageSize.windowHeight - altura - 26) / 2);
	var boxLeft = ((pageSize.pageWidth - largura - 40) / 2);
	box.style.top = (boxTop < 0) ? "0px" : boxTop + "px";
	box.style.left = (boxLeft < 0) ? "0px" : boxLeft + "px";
	box.style.visibility = 'visible';
	try {
		var divZoom = document.getElementById('zoom_'+obj.className);
		var divDescricao = document.getElementById('desc_'+obj.className);
		if(divZoom) divZoom.style.width = largura + 'px';
		if(divDescricao) divDescricao.style.width = largura + 'px';
	} catch(erro) {}
}

function openZoom(obj) {
	//alert(obj);
	var pageSize = getPageSize();
	var codimgAnt = '';
	var codimgPos = '';
	var PrevId = '';
	var NextId = '';
	var source = '';
	var descricao = '';
	var classe = 'abc';
	var spans = obj.parentNode.getElementsByTagName('span');
	for(var i=0,len=spans.length;i<len;i++) {
		if(spans[i].className.indexOf('cod-img-ant') > -1) codimgAnt = spans[i].innerHTML;
		if(spans[i].className.indexOf('cod-img-pos') > -1) codimgPos = spans[i].innerHTML;
		if(spans[i].className.indexOf('source') > -1) source = spans[i].innerHTML;
		if(spans[i].className.indexOf('title') > -1) descricao = spans[i].innerHTML;
	}
	var divContainer = document.createElement('div');
	divContainer.id = 'zoom';
	divContainer.className = 'zoom';
	divContainer.style.height = (pageSize.pageHeight + 'px');
	var divSombra = document.createElement('div');
	divSombra.id = 'shadow';
	divSombra.className = 'shadow';
	divSombra.style.height = (pageSize.pageHeight + 'px');
	document.body.appendChild(divSombra);
	var divZoom = document.createElement('div');
	divZoom.id = 'zoom_' +  classe;
	divZoom.className = 'zoom-photo';
	
	if (codimgAnt != ''){
		var spanImgAnt = document.createElement('a');
		spanImgAnt.id = 'link-ant';
		spanImgAnt.title = 'ver anterior';
		spanImgAnt.className = 'ico-nav-anterior';
		spanImgAnt.innerHTML = '<span class="hidden"> &laquo; ver anterior</span>';
		spanImgAnt.href = '#';
		PrevId= 'Img'+codimgAnt
		spanImgAnt.onclick = function() {
			//alert(document.getElementById(PrevId));
			navigateZoom(PrevId);
			closeZoom(this);
			return false;
		}
	}
	
	if (codimgPos != ''){
		var spanImgPos = document.createElement('a');
		spanImgPos.id = 'link-post';
		spanImgPos.title = 'ver próxima';
		spanImgPos.className = 'ico-nav-posterior';
		spanImgPos.innerHTML = '<span class="hidden"> &raquo; ver próxima</span>';
		spanImgPos.href = '#';
		NextId= 'Img'+codimgPos
		spanImgPos.onclick = function() {
			//alert(document.getElementById(NextId));
			navigateZoom(NextId);
			closeZoom(this);
			return false;
		}
	}
	
	var spanFonte = document.createElement('span');
	spanFonte.className = 'source';
	spanFonte.innerHTML = source;
	var imgZoom = document.createElement('img');
	imgZoom.id = 'img_' +  classe;
	imgZoom.className = classe;
	imgZoom.src = obj.href;
	imgZoom.alt = 'Foto';
	var divDescricao = document.createElement('div');
	divDescricao.id = 'desc_' +  classe;
	divDescricao.className = 'title';
	var p = document.createElement('p');
	p.innerHTML = descricao;
	var divFechar = document.createElement('span');
	divFechar.className = 'btnClose';
	var spanFechar = document.createElement('a');
	spanFechar.title = 'fechar';
	spanFechar.innerHTML = 'x';
	spanFechar.href = '#';
	spanFechar.onclick = function() {
		closeZoom(this);
		return false;
	}
	divDescricao.appendChild(imgZoom);
	divFechar.appendChild(spanFechar);
	divDescricao.appendChild(p);
	divZoom.appendChild(divFechar);
	if (codimgAnt != '') divZoom.appendChild(spanImgAnt);
	if (codimgPos != '') divZoom.appendChild(spanImgPos);
	divZoom.appendChild(spanFonte);
	divZoom.appendChild(divDescricao);
	divContainer.appendChild(divZoom);

	document.body.appendChild(divContainer);
	
	if(imgZoom.width && imgZoom.width > 56) {
	 resizeZoom(imgZoom);
	}
	imgZoom.onload = function() {
	  resizeZoom(this);
	  return false;
	}
}

function navigateZoom(div) {
	
	var container = document.getElementById(div);	
	var lnks = container.getElementsByTagName('a');
	for(var i=0,len=lnks.length;i<len;i++) {
		if(lnks[i].className.indexOf('ZoomLink') > -1) {
			obj = lnks[i];
		}
	}
	//alert(obj);
	openZoom(obj);	
}

//-------------------------------------------------------------------------------------

function writeEmbed(pName, swfFile, swfWidth, swfHeight, flashVars, pWmode, pClass){
	document.write(
		'<OBJECT'
		+ ' classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"'
		+ ' name="' + pName + '"'
		+ ' id="' + pName + '"'
		+ ' class="' + pClass + '"'
		+ ' width="' + swfWidth +'"'
		+ ' height="' + swfHeight +'"'
		+ ' codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0">'
		+ '<PARAM name="movie" value="' + swfFile + '">'
		+ '<PARAM name="play" value="true">'
		+ '<PARAM name="loop" value="false">'
		+ '<PARAM name="quality" value="Best">'
		+ '<PARAM name="menu" value="true">'
		+ '<PARAM name="allowScriptAccess" value="always">'
		+ '<PARAM name="FlashVars" value="' + flashVars + '">'
		+ '<PARAM name="wmode" value="' + pWmode + '">'
		+ '<EMBED'
		+ ' name="' + pName + '"'
		+ ' id="' + pName + '"'
		+ ' src="' + swfFile +'"'
		+ ' width="' + swfWidth +'"'
		+ ' height="' + swfHeight +'"'
		+ ' play="true"'
		+ ' loop="true"'
		+ ' quality="Best"'
		+ ' class="' + pClass +'"'
		+ ' menu="true"'
		+ ' FlashVars="' + flashVars +'"'
		+ ' wmode="' + pWmode + '"'
		+ ' allowScriptAccess="always"' 
		+ ' type="application/x-shockwave-flash"'
		+ ' pluginspage="http://www.macromedia.com/go/getflashplayer"'
		+ '</EMBED>'
		+ '</OBJECT>');
}
