// JavaScript Document
//window.onerror = function(){location.reload(true); return false;}

//ADICIONA VALOR DEFAULT NO CAMPO
function defaultMsnValue(field, value, compare){
	fieldName = field.attributes.getNamedItem("name").value;
	
	if (compare){
		if (!field.value){field.value = value;  this["value_" + fieldName] = false;} 
		else this["value_" + fieldName] = field.value;
	}else{
		if (!field.value || field.value == value){
			field.value = "";
			field.onblur = function(){defaultMsnValue(field, value, true);};
		}
	}
}

//ADICIONA VALOR DEFAULT NO CAMPO
function returnValue(form, field, value){
	if (field.value == value || !field.value) return false;
	else {sendForm(form);}
}

//SHOW HIDDEN ELEMENT
function showHide(field, modeIni){
	var target = document.getElementById(field);
	if (target){
		if (!target.style.display) target.style.display = modeIni;
		else if (target.style.display == "none") target.style.display = "block";
		else									 target.style.display = "none";
	}
}

//POPUP MSN
function popupMsn(msn, func){
	var newElement = document.createElement('div');
	newElement.setAttribute('id',		'popupMsn');
	
	str = "<div class=\"popupShadow\">";
	str += "<div class=\"popupBox\">";
	str += "<div class=\"popMsn\">" + msn + "</div>";
	str += "<div class=\"popBts\">";
	str += "<input type=\"button\" name=\"sim\" value=\"Sim\" class=\"btForm\"  onClick=\"removeObj('popupMsn'); " + func + "\"> ";
	str += "<input type=\"button\" name=\"nao\" value=\"Não\" class=\"btForm\" onClick=\"removeObj('popupMsn')\">";
	str += "</div>";
	str += "</div>";
	str += "</div>";
	
	newElement.innerHTML = str;
	document.body.appendChild(newElement);
}

function removeObj(obj){
	obj = document.getElementById(obj);
	if (obj){
		document.body.removeChild(obj);
	}
}

/* -- OPTIONS CONTENT -- */

	//MAXIMIZE CONTENT
	function maximizeContent(fieldMenu, fieldContent, widthMAX, widthMIN){
		var fieldMenu = document.getElementById(fieldMenu);
		var fieldContent = document.getElementById(fieldContent);
		
		if (fieldMenu && fieldContent){
			if (fieldMenu.style.display == "none"){
				fieldMenu.style.display = "block";
				fieldContent.style.width = widthMIN + "px";
				
				document.getElementById('iconMax').style.display = "";
				document.getElementById('iconMin').style.display = "none";
			}else{
				fieldMenu.style.display = "none";
				fieldContent.style.width = widthMAX + "px";
				
				document.getElementById('iconMax').style.display = "none";
				document.getElementById('iconMin').style.display = "";
			}
		}
	}
	
	//PRINT VERSION
	function printContent(pagePrint, id){
		var width 	= 500;
		var height 	= 500;
		var top 	= screen.height/2 - height/2;
		var left 	= screen.width/2 - width/2;
		window.open(pagePrint + "?" + id, 'SPR', 'width=' + width + ',height=' + height + ',top=' + top + ',left=' + left + ',scrollbars=yes,fullscreen=no');
	}
	
	//REMOVE CHCKED
	function clearCheck(field){
		if (!field.length){
			field.checked = false;
		}else{
			for(var i=0; i<field.length; i++){
				field[i].checked = false;
			}
		}
	}
	
	//ABRE POPUP
	function popup(page, name, width, height){
		var posX = screen.width/2 - width/2;
		var posY = screen.height/2 - height/2;
		window.open(page, name, "height=" + height + ",width=" + width + ",status=no,toolbar=no,menubar=no,location=no,scrollbars=yes, left=" + posX + ", top=" + posY);
	}
	
	//CRIA POPUP NA PAGINA
	function popupCreate(content, width, height){
		
		var obj = document.getElementById('boxPOPUP');
		if (!obj){
			
			target = document.getElementById("pageContent");
			
			var newElement = document.createElement('div');
			newElement.setAttribute('id',		'boxPOPUP');
			newElement.setAttribute('name',		'boxPOPUP');
			document.body.appendChild(newElement);
			obj = newElement;
		}
		
		obj.innerHTML = "";
		obj.style.display = "block";

		var posTop = -( (height+18)/2 - document.documentElement.scrollTop);
		
		var strHTML = "<div id=\"popupPDF\" style=\"width:" + width + "px; height:" + (height+18) + "px; position:absolute; z-index:3; top:50%; left:50%; margin:" + posTop + "px 0px 0px -" + width/2 + "px; background-color:#FFFFFF; border:1px solid #48A0C6\">";
			strHTML += "<div class=\"popupTitle\" style=\"text-align:right\"><strong><a href=\"javascript:popupRemove('boxPOPUP')\"><img src=\"img/bt_exit.gif\" width=\"13\" height=\"13\" border=\"0\" /></a></strong></div>";
			strHTML += content;
			strHTML += "</div>";
		
		obj.innerHTML = strHTML;
	}
	
	function popupRemove(obj){
		obj = document.getElementById(obj);
		if (obj){
			obj.style.display = "none";
			obj.innerHTML = "";
		}
	}
	
	function popupImg(url, width, height){
		var strHTML = "<div><img src=\"" + url + "\" border=\"0\" /></div>";
		popupCreate(strHTML, width, height);
	}
	
	//====
	function apresentacao(url){	
		var strHTML  = "<object classid=\"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\" codebase=\"http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,28,0\" width=\"705\" height=\"564\">";
			strHTML += "<param name=\"movie\" value=\"swf/apresentacao.swf?url=" + url + "\" />";
			strHTML += "<param name=\"allowScriptAccess\" value=\"sameDomain\" />";
			strHTML += "<param name=\"quality\" value=\"high\" />";
			strHTML += "<param name=\"allowFullScreen\" value=\"true\" />";
			strHTML += "<param name=\"bgcolor\" value=\"#000000\" />";
			strHTML += "<embed src=\"swf/apresentacao.swf?url=" + url + "\" quality=\"high\" allowScriptAccess=\"sameDomain\" pluginspage=\"http://www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash\" type=\"application/x-shockwave-flash\" width=\"720\" height=\"564\"></embed>";
			strHTML += "</object>";
		popupCreate(strHTML, 705, 564);
	}
	function videoFLV(url, Width, Height){
		if(navigator.userAgent.indexOf("MSIE")!= -1){
		var strHTML  = "<object classid=\"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\" codebase=\"http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,28,0\" width=\""+Width+"\" height=\""+(Height+40)+"\">";
			strHTML += "<param name=\"movie\" value=\"swf/video.swf?videoID=http://www.spr.org.br/" + url + "\">";
			strHTML += "<param name=\"allowfullscreen\" value=\"true\" />";
			strHTML += "<param name=\"allowscriptaccess\" value=\"always\" />";
			strHTML += "<param name=\"flashvars\" value=\"file=http://www.spr.org.br/" + url + "\" />";
			strHTML += "<param name=\"quality\" value=\"high\">";
			strHTML += "</object>";	
		}else{
		var strHTML  = "<object classid=\"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\" codebase=\"http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,28,0\" width=\""+Width+"\" height=\""+(Height+40)+"\">";
			strHTML += "<param name=\"movie\" value=\"swf/video.swf?videoID=http://www.spr.org.br/" + url + "\">";
			strHTML += "<param name=\"allowfullscreen\" value=\"true\" />";
			strHTML += "<param name=\"allowscriptaccess\" value=\"always\" />";
			strHTML += "<param name=\"flashvars\" value=\"file=http://www.spr.org.br/" + url + "\" />";
			strHTML += "<object type=\"application/x-shockwave-flash\" data=\"swf/video.swf\" width=\""+Width+"\" height=\""+(Height+40)+"\">";
			strHTML += "<param name=\"movie\" value=\"swf/video.swf?videoID=http://www.spr.org.br/" + url + "\">";
			strHTML += "<param name=\"allowfullscreen\" value=\"true\" />";
			strHTML += "<param name=\"allowscriptaccess\" value=\"always\" />";
			strHTML += "<param name=\"flashvars\" value=\"file=http://www.spr.org.br/" + url + "\" />";
			strHTML += "</object>";
			strHTML += "</object>";
		}		
		popupCreate(strHTML, Width, (Height+12));
	}
	function videoFLVa(url, Width, Height){
		var strHTML  = "<object classid=\"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\" codebase=\"http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,28,0\" width=\""+Width+"\" height=\""+(Height+40)+"\">";
			strHTML += "<param name=\"movie\" value=\"swf/video.swf?videoID=http://www.spr.org.br/" + url + "\">";
			strHTML += "<param name=\"quality\" value=\"high\">";
			strHTML += "<embed src=\"swf/video.swf?videoID=http://www.spr.org.br/" + url + "\" width=\""+Width+"\" height=\""+(Height+10)+"\" quality=\"high\" pluginspage=\"http://www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash\" type=\"application/x-shockwave-flash\"></embed>";
			strHTML += "</object>";
		popupCreate(strHTML, Width, (Height+12));
	}
	function videoFLVb(url, Width, Height){
		var strHTML  = "<object classid=\"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\" codebase=\"http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,28,0\" width=\""+Width+"\" height=\""+(Height+40)+"\">";
			strHTML += "<param name=\"movie\" value=\"swf/video.swf?videoID=" + url + "\">";
			strHTML += "<param name=\"quality\" value=\"high\">";
			strHTML += "<embed src=\"swf/video.swf?videoID=" + url + "\" width=\""+Width+"\" height=\""+(Height+40)+"\" quality=\"high\" pluginspage=\"http://www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash\" type=\"application/x-shockwave-flash\"></embed>";
			strHTML += "</object>";
			document.write(strHTML);
	}
	function galeria(){
				if($("#GALERIA a")){
					/**/
					$('#GALERIA a').lightBox({
						overlayBgColor: '#222',
						overlayOpacity: 0.7,
						imageLoading: 	'img/light_loader.gif',
						imageBtnClose: 	'img/light_close.gif',
						imageBtnPrev: 	'img/light_prev.gif',
						imageBtnNext: 	'img/light_next.gif',
						fixedNavigation:true,
						containerResizeSpeed: 390,
						txtImage: '',
						txtOf: 'de'
				   });
					
			}
				
	}
	
	function galeria_interna(){
				if($("#GALERIA_INTERNA a")){
					/**/
					$('#GALERIA_INTERNA a').lightBox({
						overlayBgColor: '#222',
						overlayOpacity: 0.7,
						imageLoading: 	'img/light_loader.gif',
						imageBtnClose: 	'img/light_close.gif',
						imageBtnPrev: 	'img/light_prev.gif',
						imageBtnNext: 	'img/light_next.gif',
						fixedNavigation:true,
						containerResizeSpeed: 390,
						txtImage: '',
						txtOf: 'de'
				   });
					
			}
	}
	function evalScroll(){
		var div = document.getElementById("condicao");
		if(div.scrollTop >= 2000){
			document.getElementById('avancar').disabled = false;
		}else{
			document.getElementById('avancar').disabled = true;
		}
	}
