
//Código para a janela de popup************************************
//var ie=document.all
//var dom=document.getElementById
//var ns4=document.layers
//var calunits=document.layers? "" : "px"

//var bouncelimit=32 //(must be divisible by 8)
//var direction="up"

//function initbox(){
//if (!dom&&!ie&&!ns4)
//return
//crossobj=(dom)?document.getElementById("dropin").style : ie? document.all.dropin : document.dropin

//scroll_top=(ie)? truebody().scrollTop : window.pageYOffset
//crossobj.top=scroll_top-250+calunits
//crossobj.visibility=(dom||ie)? "visible" : "show"
//dropstart=setInterval("dropin()",50)
//}

//function dropin(){
//scroll_top=(ie)? truebody().scrollTop : window.pageYOffset
//if (parseInt(crossobj.top)<100+scroll_top)
//crossobj.top=parseInt(crossobj.top)+40+calunits
//else{
//clearInterval(dropstart)
//bouncestart=setInterval("bouncein()",50)
//}
//}

//function bouncein(){
//crossobj.top=parseInt(crossobj.top)-bouncelimit+calunits
//if (bouncelimit<0)
//bouncelimit+=8
//bouncelimit=bouncelimit*-1
//if (bouncelimit==0){
//clearInterval(bouncestart)
//}
//}

//function dismissbox(){
//if (window.bouncestart) clearInterval(bouncestart)
//crossobj.visibility="hidden"
//}

//function truebody(){
//return (document.compatMode && document.compatMode!="BackCompat")? document.documentElement : document.body
//}


//function get_cookie(Name) {
//var search = Name + "="
//var returnvalue = ""
//if (document.cookie.length > 0) {
//offset = document.cookie.indexOf(search)
//if (offset != -1) {
//offset += search.length
//end = document.cookie.indexOf(";", offset)
//if (end == -1)
//end = document.cookie.length;
//returnvalue=unescape(document.cookie.substring(offset, end))
//}
//}
//return returnvalue;
//}

//function dropornot(){
//if (get_cookie("droppedin")==""){
//window.onload=initbox
//document.cookie="droppedin=yes"
//}
//}
//dropornot()

//*****************************************************************













 function openWindow(url, w, h,scroll)
  {
    var options = 'width=' + w + ', height='+ h + ',top='+ ((screen.height/2)-(h/2)) +',left='+ ((screen.width/2)-(w/2));
    options += "resizable=no,scrollbars="+scroll+",status=no,";
    options += "menubar=no,toolbar=no,location=no,directories=no";
    var newWin = window.open(url, 'newWin', options);
    newWin.focus();
   

  }

function GetDate(dat)
{
	var d,m;
	var dt = new Date(dat);
	d = dt.getDate();
	m = (dt.getMonth()+1);
	
	var sdt = ((d<10)?"0"+d:d)+"-"+((m<10)?"0"+m:m)+"-"+dt.getFullYear();	
	return sdt;
}

function IsDateValid(dat,fmt)
{
	var re1,re2;
	var r1,r2;
	var s;
	var v;
	var d,m,y;
	var bi;
	var mth;
	
	if (fmt=="dmy")	{d=0;m=1;y=2;}
	if (fmt=="mdy")	{m=0;d=1;y=2;}
	if (fmt=="ymd")	{y=0;m=1;d=2;}
	
	re1 = new RegExp("-");
	re2 = new RegExp("/");
	r1 = re1.test(dat);
	r2 = re2.test(dat);
	if ((!r1 && !r2) || (r1 && r2)) return false;
	s = dat.split((r1)?"-":"/");
	if(s[3]!=undefined) return false;
	
	v = new Number(s[y]);
	if (isNaN(v)) return false;
	if (v<1 || v>9000) return false;
	if ((v%4)==0) bi=true; else bi=false;
					
	v = new Number(s[m]);
	if (isNaN(v)) return false;
	if (v<1 || v>12) return false;
	mth = v;
					
	v = new Number(s[d]);
	if (isNaN(v)) return false;
	if ((mth==2 && !bi) && v>28) return false;
	if ((mth==2 && bi) && v>29) return false;
	if ((mth==4 || mth==6 || mth==9 || mth==11) && v>30) return false;
	if (v<1 || v>31) return false;
					
	return true;	
}



function S2DB(s)
{
	var re1 = new RegExp("[+]","g");
	var re2 = new RegExp("[<>]","g");
	var re3 = new RegExp("[\"]","g");
	var re4 = new RegExp("[\n]","g");
	var re5 = new RegExp("[']","g");
	var ss;
	ss = s.replace(re1,"%2b");
	ss = ss.replace(re2,"");
	ss = ss.replace(re3,"#148;");
	ss = ss.replace(re4,"<BR>");
	ss = ss.replace(re5,"’");
	//add more here
	return ss;	
}

function isEmail(x)
{
	if  (x.search("@") == -1 || x.search("[.*]") == -1)	return false;
	else return true;
}

function chkLen(x,l) 
{
	char = eval(x.value.length)
	var dif = eval(char - l)
	var value = x.value.substr(0,char-dif);
	x.value = value;
}

function isNum(x)
{
	return true;	
}


function search(s)
{
	var re1 = new RegExp("[áàãâaä]","g");
	var re2 = new RegExp("[éèêeë]","g");
	var re3 = new RegExp("[íìîiï]","g");
	var re4 = new RegExp("[óòõôoö]","g");
	var re5 = new RegExp("[úùûuü]","g");
	
	var ss;
	ss=s;
	
	ss = ss.replace(re1,"[áàãâaä]");
	ss = ss.replace(re2,"[éèêeë]");
	ss = ss.replace(re3,"[íìîiï]");
	ss = ss.replace(re4,"[óòõôoö]");
	ss = ss.replace(re5,"[úùûuü]");

	return ss;
}



var select;
function ov(obj,cor)
{
	obj.style.backgroundColor=cor;
}

function ot(obj,stat)
{
	if (obj!=select)
		obj.style.backgroundColor=stat;
}



//function disableselect(e){
//return false
//}

//function reEnable(){
//return true
//}

////if IE4+
//document.onselectstart=new Function ("return false")

////if NS6
//if (window.sidebar){
//document.onmousedown=disableselect
//document.onclick=reEnable
//}




//nº de carateres
var ns6=document.getElementById&&!document.all

function restrictinput(maxlength,e,placeholder){
if (window.event&&event.srcElement.value.length>=maxlength)
return false
else if (e.target&&e.target==eval(placeholder)&&e.target.value.length>=maxlength){
var pressedkey=/[a-zA-Z0-9\.\,\/]/ //detect alphanumeric keys
if (pressedkey.test(String.fromCharCode(e.which)))
e.stopPropagation()
}
}

function countlimit(maxlength,e,placeholder){
var theform=eval(placeholder)
var lengthleft=maxlength-theform.value.length
var placeholderobj=document.all? document.all[placeholder] : document.getElementById(placeholder)
if (window.event||e.target&&e.target==eval(placeholder)){
if (lengthleft<0)
theform.value=theform.value.substring(0,maxlength)
placeholderobj.innerHTML=lengthleft
}
}


function displaylimit(thename, theid, thelimit){
var theform=theid!=""? document.getElementById(theid) : thename
var limit_text='<b><span id="'+theform.toString()+'">'+thelimit+'</span></b> carateres disponíveis'
if (document.all||ns6)
document.write(limit_text)
if (document.all){
eval(theform).onkeypress=function(){ return restrictinput(thelimit,event,theform)}
eval(theform).onkeyup=function(){ countlimit(thelimit,event,theform)}
}
else if (ns6){
document.body.addEventListener('keypress', function(event) { restrictinput(thelimit,event,theform) }, true); 
document.body.addEventListener('keyup', function(event) { countlimit(thelimit,event,theform) }, true); 
}
}





//*menu*//
var persistmenu="yes" //"yes" or "no". Make sure each SPAN content contains an incrementing ID starting at 1 (id="sub1", id="sub2", etc)
var persisttype="sitewide" //enter "sitewide" for menu to persist across site, "local" for this page only

if (document.getElementById){
document.write('<style type="text/css">\n')
document.write('.submenu{display: none;}\n')
document.write('</style>\n')
}

function SwitchMenu(obj){
	if(document.getElementById){
	var el = document.getElementById(obj);
	var ar = document.getElementById("masterdiv").getElementsByTagName("span");
		if(el.style.display != "block"){
			for (var i=0; i<ar.length; i++){
				if (ar[i].className=="submenu")
				ar[i].style.display = "none";
			}
			el.style.display = "block";
		}else{
			el.style.display = "none";
		}
	}
}

function get_cookie(Name) { 
var search = Name + "="
var returnvalue = "";
if (document.cookie.length > 0) {
offset = document.cookie.indexOf(search)
if (offset != -1) { 
offset += search.length
end = document.cookie.indexOf(";", offset);
if (end == -1) end = document.cookie.length;
returnvalue=unescape(document.cookie.substring(offset, end))
}
}
return returnvalue;
}

function onloadfunction(){
if (persistmenu=="yes"){
var cookiename=(persisttype=="sitewide")? "switchmenu" : window.location.pathname
var cookievalue=get_cookie(cookiename)
if (cookievalue!="")
document.getElementById(cookievalue).style.display="block"
}
}

function savemenustate(){
var inc=1, blockid=""
while (document.getElementById("sub"+inc)){
if (document.getElementById("sub"+inc).style.display=="block"){
blockid="sub"+inc
break
}
inc++
}
var cookiename=(persisttype=="sitewide")? "switchmenu" : window.location.pathname
var cookievalue=(persisttype=="sitewide")? blockid+";path=/" : blockid
document.cookie=cookiename+"="+cookievalue
}

if (window.addEventListener)
window.addEventListener("load", onloadfunction, false)
else if (window.attachEvent)
window.attachEvent("onload", onloadfunction)
else if (document.getElementById)
window.onload=onloadfunction

if (persistmenu=="yes" && document.getElementById)
window.onunload=savemenustate

//*fim de menu*//




















