// JavaScript Document
function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}
//-->

//Initialize first demo:
ddaccordion.init({
	headerclass: "mypets", //Shared CSS class name of headers group
	contentclass: "thepet", //Shared CSS class name of contents group
	collapseprev: true, //Collapse previous content (so only one open at any time)? true/false 
	defaultexpanded: [0], //index of content(s) open by default [index1, index2, etc]. [] denotes no content.
	animatedefault: false, //Should contents open by default be animated into view?
	persiststate: true, //persist state of opened contents within browser session?
	toggleclass: ["", "openpet"], //Two CSS classes to be applied to the header when it's collapsed and expanded, respectively ["class1", "class2"]
	togglehtml: ["none", "", ""], //Additional HTML added to the header when it's collapsed and expanded, respectively  ["position", "html1", "html2"] (see docs)
	animatespeed: "fast", //speed of animation: "fast", "normal", or "slow"
	oninit:function(expandedindices){ //custom code to run when headers have initalized
		//do nothing
	},
	onopenclose:function(header, index, state, isclicked){ //custom code to run whenever a header is opened or closed
		//do nothing
	}
})

//Initialize 2nd demo:
ddaccordion.init({
	headerclass: "technology", //Shared CSS class name of headers group
	contentclass: "thelanguage", //Shared CSS class name of contents group
	collapseprev: false, //Collapse previous content (so only one open at any time)? true/false 
	defaultexpanded: [], //index of content(s) open by default [index1, index2, etc]. [] denotes no content.
	animatedefault: false, //Should contents open by default be animated into view?
	persiststate: false, //persist state of opened contents within browser session?
	toggleclass: ["closedlanguage", "openlanguage"], //Two CSS classes to be applied to the header when it's collapsed and expanded, respectively ["class1", "class2"]
	togglehtml: ["prefix"], //Additional HTML added to the header when it's collapsed and expanded, respectively  ["position", "html1", "html2"] (see docs)
	animatespeed: "fast", //speed of animation: "fast", "normal", or "slow"
	oninit:function(expandedindices){ //custom code to run when headers have initalized
		//do nothing
	},
	onopenclose:function(header, index, state, isclicked){ //custom code to run whenever a header is opened or closed
		//do nothing
	}
})
function loadFRM()
{
	var FRM = document.index;
	FRMfocu(FRM.txtlogin);	
	
}
function validaFRM()
{	
	var FRM = document.index;

	
	if (testaBRANCO(FRM.txtlogin)) return false;
	if (testaEMAIL(FRM.txtlogin)) return false;		
	if (testaBRANCO(FRM.txtsenha)) return false;
			
	
	return true;
}

function MM_goToURL() { //v3.0
  var i, args=MM_goToURL.arguments; document.MM_returnValue = false;
  for (i=0; i<(args.length-1); i+=2) eval(args[i]+".location='"+args[i+1]+"'");
}

function FORMATADATA (data)
{
	switch(data.value.length)
	{
		case 2 :
			data.value = data.value+"/";
			break; 
		case 5 :
			data.value = data.value+"/";
			break;
	}
	
	//alert(data.value);
}

function FORMATATEL (tel)
{
	if (tel.value.length == 4)
	{
		tel.value = tel.value+"-";
	}
}

function FORMATACEP (cep)
{
	if (cep.value.length == 5)
	{
		cep.value = cep.value+"-";
	}
}

function redimensiona(widthmax, heightmax, idimg)
{
	var nodes = document.body.getElementsByTagName('img');
	
	for (i=0; i< nodes.length; i++)
	{		
		//alert(" 2 W " + nodes[i].width + " H "  + nodes[i].height); 	
		if (nodes[i].id==idimg)
		{				
			if (nodes[i].width > widthmax && nodes[i].height > heightmax) 
			{					
				if (nodes[i].width > nodes[i].height) 
				{		
					nodes[i].height= nodes[i].height - (nodes[i].height * (   (((nodes[i].width - widthmax)/nodes[i].width) * 100)   /100));
					nodes[i].width = widthmax ;						
				} else 
				{
					nodes[i].width = nodes[i].width - (nodes[i].width * (   (((nodes[i].height - heightmax)/nodes[i].height) * 100)   /100));
					nodes[i].height = heightmax ;									
				}			
   			}
		}
	}
}
var win = null;
function MM_openBrWindow(theURL,winName,features) { //v2.0
 win = window.open(theURL,winName,features);
 win.focus();
}

// popup centralizada
function popup(pagina,largura,altura) {

	//pega a resolução da tela
	w = screen.width;
	h = screen.height;

	//divide a resolução por 2, obtendo o centro do monitor
	meio_w = w/2;
	meio_h = h/2;

	//diminui o valor da metade da resolução pelo tamanho da janela, fazendo com q ela fique centralizada
	altura2 = altura/2;
	largura2 = largura/2;
	meio1 = meio_h-altura2;
	meio2 = meio_w-largura2;

	//abre a nova janela, já com a sua devida posição
	window.open(pagina,'','height=' + altura + ', width=' + largura + ', top='+meio1+', left='+meio2+', scrollbars=yes'); 
}
