var a = new Array();
var ai = 0;
var iTimerID;


function maxpopup(thisone, maxx, maxy){	  
	  
	ai = ai+1;
	a[ai]= thisone;
	
	if(thisone.width!=0){
		if(thisone.height>maxy || thisone.width>maxx){
	      		if(thisone.height>maxy) {
	        		auxx = thisone.width;
                		auxy = thisone.height;
				thisone.height = maxy;
	        		thisone.width=auxx*maxy/auxy;
	       			//thisone.offsetParent.style.position='fixed';
	        		max(thisone, maxx, maxy);
	      		}
              		else{
                		auxx = thisone.width;
               			auxy = thisone.height;
                		thisone.width = maxx; 
               			//thisone.offsetParent.style.position='fixed';
               			thisone.height= auxy *maxx /auxx;
                		max(thisone, maxx, maxy);
             		} 
           	}else{
           		thisone.offsetParent.style.position='fixed';
           	}
           
           
         	if(thisone.height <= maxy || thisone.width <= maxx){
	 	   	window.resizeTo(thisone.width + 20, thisone.height + 45)
	 	   	thisone.offsetParent.style.position='fixed';
	 	    
	  	}
        }
        else{
          iTimerID = setTimeout("maxdelay("+ai+","+maxx+","+maxy+")", 1);
	}
}


function max(thisone, maxx, maxy){	  
	  
	  	  
	  ai = ai+1;
	  a[ai]= thisone;
	  if(thisone.width!=0){
	  
	   
	  
	    if(thisone.height> maxy || thisone.width>maxx){
	      if(thisone.height>maxy) {
	        auxx = thisone.width;
                auxy = thisone.height;
		thisone.height = maxy;
	        thisone.width=auxx*maxy/auxy;
	        //thisone.offsetParent.style.position='fixed';
	        max(thisone, maxx, maxy);
	      }
              else{
                auxx = thisone.width;
                auxy = thisone.height;
                thisone.width = maxx; 
                //thisone.offsetParent.style.position='fixed';
                thisone.height= auxy *maxx /auxx;
                max(thisone, maxx, maxy);
                
	     } 
           }else{
             thisone.offsetParent.style.position='fixed';
           }
        }
       
        else{
          iTimerID = setTimeout("maxdelay("+ai+","+maxx+","+maxy+")", 1);
        }
       
     }

function maxdelay(indice, maxx, maxy){	  
    	max(a[indice],maxx,maxy);
    
    } 	  

function previewXXX(link)
  {
     window.open(link, null, 'height=600, width=800, toolbar=yes, resizable=yes');
  }

function preview(link)
  {
     window.open(link,null,'toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=no, resizable=yes, copyhistory=no, width=650, height=490')

    // window.open(link, null, 'height=600, width=800, toolbar=no, menubar=no, resizable=yes');
  }
  
function preview_flash(link,x,y)
  {
     window.open(link,'_blank','toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=no, resizable=yes, copyhistory=no, width=' + x +', height=' + y)

  }
  
   
  
  // Validações forms 
  
  // Tópicos
function validate_topico_forum(form)
{


if (form.header.value == "" && form.description.value=="")
{

alert("Por favor insira o Tópico e a Mensagem");
form.description.focus();
return (false);
}

if ( form.description.value =="")
{

alert("Por favor insira o Tópico");
form.description.focus();
return (false);
}

if ( form.header.value=="")
{

alert("Por favor insira a Mensagem");
form.header.focus();
return (false);
}

if ( form.description.value.length>100 )
{

alert("O Tópico só pode ter no máximo 100 caracteres!");
form.description.focus();
return (false);
}


var str = form.description.value

if (str.length > 32){
form.name.value=str.substring(0,28) + "..."
}else{
form.name.value=str
}

return (true);
}

  
  //Mensagens
  function validate_msg_forum(form)
  {
  
  if (form.header.value == "")
  {
  
  alert("Por favor insira a Mensagem");
  form.header.focus();
  return (false);
  }
  
  var str = form.header.value
  
  form.name.value=str.substring(0,12)
  
  return (true);
  }
  

