// FUNCAO ABRIR JANELAS
function MM_openBrWindow(theURL,winName,features){
  window.open(theURL,winName,features);}

// FUNCAO ABRIR JANELAS
function ABRIR(theURL,winName,features){
  window.open(theURL,winName,features);}

//FUNCAO FECHAR JANELAS
function FECHAR(){
window.close();}

//FUNCAO IMPRIMIR
function IMPRIMIR(theURL){
window.print("theURL");}


//FUNCAO LER PAGINA
function MM_reloadPage(init) {  //reloads the window if Nav4 resized
  if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
    document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}
  else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
}
MM_reloadPage(true);

//FUNCAO FINALIZAR LEITURA PAGINA
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;
}

//FUNCAO BANNER FLASH
function objectSwf(swf,width,height) {
	document.write('<object type="application/x-shockwave-flash" width="' + width + '" height="' + height + '" data="' + swf + '">');
	document.write('<param name="movie" value="' + swf + '" />');
	document.write('<param name="quality" value="high" />');
	document.write('<param name="menu" value="false" />');
	document.write('<param name="wmode" value="transparent" />');
	document.write('<embed src="' + swf + '" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="' + width + '" height="' + height + '" wmode="transparent"></embed>');
	document.write('</object>');
}

function objectYoutube(swf,width,height) {
	document.write('<object type="application/x-shockwave-flash" width="' + width + '" height="' + height + '" data="' + swf + '">');
	document.write('<param name="movie" value="' + swf + '" />');
	document.write('<param name="quality" value="high" />');
	document.write('<param name="menu" value="false" />');
	document.write('<param name="wmode" value="transparent" />');	
	document.write('<embed src="' + swf + '" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="' + width + '" height="' + height + '" wmode="transparent"></embed>');
	document.write('</object>');
}


function validaForm(formulario){

for(i=0;i<=formulario.length-1;i++){
	if ((formulario[i].type=="textarea")||(formulario[i].type=="file")||(formulario[i].type=="hidden")||(formulario[i].type=="text")||(formulario[i].type=="password")){
		if ((formulario[i].wmsg!="")&&(formulario[i].wmsg!=undefined)){
			if (formulario[i].email=="sim"){
				if((formulario[i].value=="")||(formulario[i].value.indexOf('@')==-1)||(formulario[i].value.indexOf('.')==-1)){
					alert(formulario[i].wmsg);
					try{
						formulario[i].focus();
					}
					catch(e){
						}				
				    return false
				}	
			}else{
				if(formulario[i].value==""){
					alert(formulario[i].wmsg);
					try{
						formulario[i].focus();
					}
					catch(e){

						}
				
					return false
				}
			}
		}
	}	
}
//Olá bem vindo ao meu artigo nele vou explicar como fazer uma validação inteligente de formulário, 
}

function Rotaciona(){
	wBanner= Math.random() * 100;
	if((wBanner>0) && (wBanner<25)){
	document.write('<script type=\"text/javascript\">objectSwf(\'images/banner.swf\',420,260);</script>');
	} else if ((wBanner>26) && (wBanner<50)){
	document.write('<script type=\"text/javascript\">objectSwf(\'images/banner2.swf\',420,260);</script>');
	} else if ((wBanner>51) && (wBanner<75)){
	document.write('<script type=\"text/javascript\">objectSwf(\'images/banner3.swf\',420,260);</script>');		
	} else {
	document.write('<iframe id=\"iFrameNews\" name=\"adote\" src=\"adote_inicial.php\" width=\"420\" height=\"260\" marginwidth=\"0\" marginheight=\"0\" scrolling=\"no\" frameborder=\"0\" allowtransparency=\"yes\"></iframe>');
	}
}
function abrir(foto,largura,altura) {

  var esquerda = ((screen.width - largura) / 2);
  var topo = ((screen.height - altura) / 2);

Popup = window.open('', 'Janela', 'width = ' + largura + ', height = ' + altura + ', top = ' + topo + ', left = ' + esquerda + ', scrollbars = yes, status = no, toolbar = no, location = no, directories = no, menubar = no, resizable = no, fullscreen = no');
Popup.document.open();
Popup.document.write("<html><head><title>");
Popup.document.write("..:: SINEP/MG ::..");
Popup.document.write("</title>");
Popup.document.write('</scr' + 'ipt>');
Popup.document.write("</head><body leftmargin=0 topmargin=0>");
Popup.document.write('<center>');
Popup.document.write('<img src=\"' + foto + '\">');
Popup.document.write("</center>");
Popup.document.write("</body></html>");
Popup.document.close();
}

function abrir_revista(foto,largura,altura) {

  var esquerda = ((screen.width - largura) / 2);
  var topo = ((screen.height - altura) / 2);

Popup = window.open('', 'Janela', 'width = ' + largura + ', height = ' + altura + ', top = ' + topo + ', left = ' + esquerda + ', scrollbars = yes, status = no, toolbar = no, location = no, directories = no, menubar = no, resizable = no, fullscreen = no');
Popup.document.open();
Popup.document.write("<html><head><title>");
Popup.document.write("..:: SINEP/MG ::..");
Popup.document.write("</title>");
Popup.document.write('</scr' + 'ipt>');
Popup.document.write("</head><body leftmargin=0 topmargin=0>");
Popup.document.write('<center>');
Popup.document.write('<table width=\"100%\" height=\"' + altura + '\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\">');
Popup.document.write('<tr>');
Popup.document.write('<td>');
Popup.document.write('<img src=\"' + foto + '\">');
Popup.document.write('</td>');
Popup.document.write('</tr>');
Popup.document.write('</table>');
Popup.document.write("</center>");
Popup.document.write("</body></html>");
Popup.document.close();
}