var lstScrY;
var lastX;
var lastY;
var maxlen;
var m_init;
var ccount = 0;
var place=1;

ctl = new Array(5);
vtext = new Array(100);
ctl[0] = 0;  
ctl[1] = 0;  
ctl[2] = 0;  
ctl[3] = 0;  
ctl[4] = 0;  

function piece(text, sep, pos) {
    if(!text)
    	return "";
    if(!sep)
    	sep = "|";
    if(!pos)
    	pos = 0;

    arrayOfStrings = text.split(sep);
    if(pos > arrayOfStrings.length)
    	return "";
    else if(pos < 0)
    	pos = 0;
	 else if(pos >= 0)
	   pos--;
	   	
    return arrayOfStrings[pos];
}    

function getScrollY() {
  var scrOfY = 0;
  if( typeof( window.pageYOffset ) == 'number' ) {
    //Netscape compliant
    scrOfY = window.pageYOffset;
  } else if( document.body && ( document.body.scrollLeft || document.body.scrollTop ) ) {
    //DOM compliant
    scrOfY = document.body.scrollTop;
  } else if( document.documentElement &&
      ( document.documentElement.scrollLeft || document.documentElement.scrollTop ) ) {
    //IE6 standards compliant mode
    scrOfY = document.documentElement.scrollTop;
  }
  lstScrY = scrOfY;
}
  
function ativa_menu(opc, menu, down, ind) {
    var i; 
    if(ctl[ind] == 0) { 
       for(i=0; i < opc.length; i++) {
           opc[i].style.visibility = 'visible'; 
       }
       menu.style.visibility = 'visible';
       if(down) {
       		down.style.visibility = 'visible';  
       }		
       ctl[ind] = 1;  
    }  
    else {
       ctl[ind] = 0;
    }  
  
}  
function desativa_menu(opc, menu, down, ind) {
    var i;  
    
    if(ctl[ind] == 1) {  
       for(i=0; i < opc.length; i++) {
           opc[i].style.visibility = 'hidden'; 
       }
       menu.style.visibility = 'hidden';
       if (down) {
           down.style.visibility = 'hidden';  
       }    
       if(ctl[ind - 1] > 0 || ctl[ind + 1] > 0) {
           ctl[ind] = 0;
       }  
    }
}  

function activeLayer(counter) {
	if (ccount == 0) {
		counter.style.visibility = 'visible';
		ccount = 1;
	}
	else {
		counter.style.visibility = 'hidden';
		ccount = 0;
	}
}

function swapLayer(menu, text, ind) {
    var i, msg; 

    for(i=0; i < text.length; i++) {
         text[i].style.visibility = 'hidden'; 
    }

    if(ind < 0) {
        menu.style.visibility = 'visible';
    }
    else {  
        menu.style.visibility = 'hidden';
        text[ind].style.visibility = 'visible';  
    }  
}  

function getData(normal) {
    var dt = new Date();  
    var day = dt.getDate();
    var mon = dt.getMonth();
    var year = dt.getFullYear();
    var nmes = new Array(12);  
    var ret;
    
    // Set meses
    nmes[0] = 'Janeiro';
    nmes[1] = 'Fevereiro';
    nmes[2] = 'Marco';
    nmes[3] = 'Abril';
    nmes[4] = 'Maio';
    nmes[5] = 'Junho';
    nmes[6] = 'Julho';
    nmes[7] = 'Agosto';
    nmes[8] = 'Setembro';
    nmes[9] = 'Outubro';
    nmes[10] = 'Novembro';
    nmes[11] = 'Dezembro';
      
    if (day < 10) {
       day = '0' + day;
    }
    
    if(!normal) {
    	ret = day + " de " + nmes[mon] + " de " + year;
    }
    else {
    	mon++;
    	if(mon < 10) {
    		mon = '0' + mon;
    	}
    	ret = day + "/" + mon + "/" + year;
    }
	return ret;
}

function setImage(objName, ImageName) {
	objName.src=ImageName
}

function swapImage(objName, ImageName) {
	objName.src=ImageName
}	

function getImage(imgsrc) {
	img = new Image;
	img.width = 0;
	img.height = 0;
	while (img.width * img.height == 0) {
		img.src = imgsrc;
	}
	return img;
}	

function PreloadIcons(path, prefix_icon, prefix_image, limit, zero_left, ncols) {  
     var fnc, fni, sp, img;
     var img = new Image;  
	 var st = "";
	
	 if(zero_left) {
		st = "0";
	 }

	 if(!ncols) {
	 	 ncols = 4;  
	 }	 
     
     sp = '"';  
     for(i=1; i <= limit; i++) {
         for(j=i; j < (i + ncols); j++) {
             if(j > 9) {  
              	st = ""; 
             }  
             fnc = path + prefix_icon + st + j + ".jpg";
             fni = path + prefix_image + st + j + ".jpg";         
             img.src = fnc;
             img.src = fni;     

             if(j >= limit)
                break;  
         }  
         if(j > limit)
            break;  
         i = i + (ncols - 1);      
     }
}  

/*************************************************************************
* Nome:   getGMT
* Função: Script para retornar uma expressão correspondente ao tempo de
*			 permanência (em dias) do cookie.
*
* Alterado por: 
*************************************************************************
* @author          Perfecnet Web Solutions
* @version         1.0.0
* @date            14/02/2004
*************************************************************************/
function getGMT(xDays) {
   var exp = new Date();  // get current date 
   // get current time and add xDays*24hrs/day
   // *60min/hr*60sec/min*1000mSec/sec
   exp.setTime(exp.getTime() +  
              (xDays*24*60*60*1000));
   return exp.toGMTString();
}

/*************************************************************************
* Nome:   getCookieValue
* Função: Script para retornar um texto gravado em cookie.
*
* Alterado por: 
*************************************************************************
* @author          Perfecnet Web Solutions
* @version         1.0.0
* @date            14/02/2004
*************************************************************************/
function getCookieValue(param) {
 	var arg = param + "=";
 	var startName = document.cookie.indexOf(arg);
 	var start = startName + arg.length;
 	if (start != -1) { // if cookie name exists
  		var end = document.cookie.indexOf(";", start);
  		if (end == -1)
      	end = document.cookie.length;
  		// the value from within the cookie
  		return document.cookie.substring(start,end);
 	} 
 	else {
  		return null;
	}	
}

/*************************************************************************
* Nome:   setCookie
* Função: Script para armazenar um texto na forma de cookie.
*
* Alterado por: 
*************************************************************************
* @author          Perfecnet Web Solutions
* @version         1.0.0
* @date            14/02/2004
*************************************************************************/
function setCookie (name, value, days) { 
  // Create a persistent cookie
  if(days > 0) 
 		document.cookie = name + "=" + value +  
           				   ";" + getGMT(days) + ";" ;
  // Create a temporary cookie
  else  
    document.cookie = name +"="+ value + ";";  
}

/*************************************************************************
* Nome:   deleteCookie
* Função: Script para remover um cookie.
*
* Alterado por: 
*************************************************************************
* @author          Perfecnet Web Solutions
* @version         1.0.0
* @date            14/02/2004
*************************************************************************/
function deleteCookie (name) { 
   var exp = getGMT(-1); 
   var cval = getCookieValue(name); 
   document.cookie = name + "=" + cval + 
            "; expires=" + exp + ";";
}

/*************************************************************************
* Nome:   appendCookie
* Função: Script para adicionar um conteúdo a um cookie.
*
* Alterado por: 
*************************************************************************
* @author          Perfecnet Web Solutions
* @version         1.0.0
* @date            14/02/2004
*************************************************************************/
function appendCookie (name, value, days, delim) { 
  // get contents already in cookie
  var current = getCookieValue(name);

  // if something already in cookie 
  // add new value to the end it
  if(current != null)
    value = current + delim + value;

  // Set or Reset the cookie
  setCookie(name, value, days);
}
function restart() {
	location.reload();
}	

function createGalery(path, prefix_icon, prefix_image, limit, page_return, zero_left, ncols, scrollbars, ext, text_wins, with_effect, text_icons, wins_style, icons_style, xlen, ylen) {
	var fnc, fni, sp, size, hsize;
	var nind = 0;
	var st = "";
	var tx = "";
	var ind = 0;
	var ind1 = 0;
	var img = new Image;
    var perc = 100 / ncols;
    var ok = false;
	var txt = new Array(limit);
	var txti = new Array(limit);
	effect = false;
	
    if(!scrollbars)
    	scrollbars = 'no';

	if(zero_left) {
		st = "0";
	}
	if(!ext) {
		ext = ".jpg";
	}

	sp = '"';  
	if(!ncols) {
		ncols = 4;
	}
	if(typeof(with_effect) == 'undefined')
		with_effect = false;
	
	if(!xlen)
		xlen = 700;
	
	if(!ylen)
		ylen = 550;
	
	if(!wins_style)
		wins_style = "text-align: center; font-size: 11px; font-family: Arial; font-weight: bold;";
	
	if(typeof(text_wins) != 'undefined') {
		txt = text_wins.split("|");
		vtext = text_wins.split("|");
		ind = txt.length;
	}		

	if(typeof(text_icons) != 'undefined') {
		txti = text_icons.split("|");
		ind1 = txti.length;
	}		
	
	maxlen = ind;
	document.write("<link href='style/style.css' type='text/css' rel='stylesheet'>");
    document.write("<script language='javascript1.2' src='scripts/perfecnet.js'></script>");
    document.write("<body id='winMain'>");
	
	lastX = parseInt(getCookieValue("lastX"));
	lastY = parseInt(getCookieValue("lastY"));
	if(lastX || lastY) {
		document.write("<body onload='window.scrollTo(" + lastX + "," + lastY + ");'>");
	}
	document.write("<table align='center' width='90%'>");
	for(i=1; i <= limit; i++) {
	    nc = 1;
	    document.write("<tr>");
	    for(j=i; j < (i + ncols); j++) {
	        if(j > 9) {
	        	st = "";
	        }
	        
	        fnc = path + prefix_icon + st + j + ".jpg";
	        fni = prefix_image + st + j + ext;
	        img.src = fnc;
	        size = img.width;
	        if (!size)
	        	size = 650;
	        else if(size < 350)
	        	size = 350;
	        hsize = img.height + 150;
	        
	        if(!hsize)
	        	hsize = 450;
	        else if(hsize < 400)
	        	hsize = 400;
	        
	        if(xlen < size)
	        	xlen = size;
	        
	        if(ylen < hsize)
	        	ylen = hsize;
	        
	        tx = "";
		    if (j <= ind) 
		    	tx = txt[j - 1];

		    document.write("<td width='" + perc + "%' align='center'>");
	        document.write("<a href=" + sp + "#" + sp + " target=" + sp + "" + sp + 
	                       " onclick=" + sp +  "WinOpen('" + path + "','" + fni + "', '" + scrollbars + "','" + 
	        			   tx + "'," + j + "," + limit + ",'" + prefix_image + "','" + ext + "','" + 
	        	           text_wins + "','" + wins_style + "'," + xlen + "," + ylen + "," + with_effect + ");" + 
	                       sp + ">");
	        document.write("<img src='" + fnc + "' border='1' class='img_style'></a></td>");  
	        if(j >= limit) {
	           	break;  
	        }   
	        nc++;
	    }
	    document.write("</tr>");
	    document.write("<tr>");
	    if(ind1 > 0) {
	    	if(!icons_style)
	    		icons_style="text-align: center; font-size: 9px; font-family: Arial;";
	    	
		    for(j=i; j < (i + ncols); j++) {
		        tx = "";
		        if(j <= ind1)
		        	tx = txti[j-1];
	        	document.write("<td style='" + icons_style + "'>" + tx + "</td>");
	        }
	    }	               
	    document.write("</tr>");

	    if(!ind1)
	    	document.write("<tr><td>&nbsp;</td></tr>");

	    if(j > limit)
	       break;  
	    i = i + (ncols - 1);
	}  
	if(page_return != "") {
		document.write("<tr>");
		for(i=0; i < (ncols - 1); i++)
			document.write("<td>&nbsp;</td>");
		document.write("<td align='right'>");
		document.write("<a href='" + page_return + "' target='' style='text-decoration: none;' onMouseOver=" +
					   sp + "setImage(document.images['img_seta'], 'images/seta_up_1.gif');" + sp +
	                   " onclick=" + sp + "loop = false;" + sp + " onMouseOut=" + sp + 
	                   "setImage(document.images['img_seta'], 'images/seta_up_0.gif');" + sp + ">");
		document.write("<img name='img_seta' src='images/seta_up_0.gif' width='9' height='9' border='0'></a></td></tr>");
		/*
		if(ncols < 4) 
			document.write("<div id='seta' style='position: relative; margin-top: 0px; text-align: right;>");
		else 
			document.write("<div id='seta' style='position: relative; margin-top: 5px; text-align: right;>");
		document.write("<p align='right'>");
		document.write("<a href='" + page_return + "' target='central' style='text-decoration: none;' onMouseOver=" +
					   sp + "setImage(document.images['img_seta'], 'images/seta_up_1.gif');" + sp +
	                   " onclick=" + sp + "loop = false;" + sp + " onMouseOut=" + sp + 
	                   "setImage(document.images['img_seta'], 'images/seta_up_0.gif');" + sp + ">");
		document.write("<img name='img_seta' src='images/seta_up_0.gif' width='35' height='33' border='0'></a></p></div>");
		*/
	}
	document.write("</table>");
}
function createGaleryTransform(path, prefix_old, prefix_new, limit, page_return, xlen, ylen, ncols, title, paragraph, texts) {
   	var img = new Image;	
	var fno, fnn, sp, nc, ymax, xmax;
	var txt = new Array(limit);
	var yc = new Array(ncols);
	var xc = new Array(ncols);
	var maxlen = (xlen + 5) * ncols;
	
	if(texts) {
		txt = texts.split("|");
		ind = txt.length;
	}		

	sp = '"';  
	document.write("<link href='style/style.css' type='text/css' rel='stylesheet'>");
	document.write("<center>");
	if(title) {
		document.write("<font color='Navy' face='Arial' size='4'><b>" + title + "</b></font><br>");
	}	
	if(paragraph) {
		document.write("<p align='center'><font color='Navy' face='Arial' size='2'>" + paragraph + "</font></p>");
	}	
		
	for(i=1; i <= limit; i++) {
		nc = 0;
		xmax = 0;
		ymax = 0;
	    for(j=i; j < (i + ncols); j++) {
	        fno = path + prefix_old + j + ".jpg";
	        fnn = path + prefix_new + j + ".jpg";
	        xc[nc] = 0;
	        yc[nc] = 0;
	        img.height = 0;
	        img.width = 0;
	        img = getImage(fno);
	        xc[nc] = img.width;
	        yc[nc] = img.height;
	        if(img.width > xc[nc]) {
	        	xc[nc] = img.width;
	        }	
	        if(img.height > yc[nc]) {
	        	yc[nc] = img.height;
	        }
	        if(xc[nc] > xmax) {
        		xmax = xc[nc];
	        }
	        if(yc[nc] > ymax) {
	        	ymax = yc[nc];
	        }
	        nc++;
	        ct++;
	    }
    	document.write("<table border='0'>");
        document.write("<tr valign='middle'>");
	    nc = 0;
	    for(j=i; j < (i + ncols); j++) {
	        fno = path + prefix_old + j + ".jpg";
	        fnn = path + prefix_new + j + ".jpg";
        	document.write("<td align='center'>");
	        document.write("<a href=" + sp + "#" + sp + " target=" + sp + "" + sp + 
	                       " style=" + sp + "text-decoration: yes;" + sp + " onMouseOver=" + sp + 
	            		   "swapImage(document.images['img_swap" + j + "'], '" + fnn + "');" + sp +
	                   	   " onMouseOut=" + sp + "swapImage(document.images['img_swap" + j + "'], '" + fno + "');" + sp + ">");
	        document.write("<img name='img_swap" + j + "' src='" + fno + "' width='" + xc[nc] + "' height='" + yc[nc] + "'" +
	                       " border='0'></a></td>");
	        
	        document.write("<td>&nbsp;</td>");  
	        nc++;
	        if(j >= limit) {
	           	break;  
	        }   
	    }
      	document.write("</tr>");
      	nc = 0;
        document.write("<tr valign='middle'>");
		document.write("<table align='center' style='margin-top: -3px; width: " + maxlen + ";'>");
        document.write("<tr valign='top'>");
	    for(j=i; j < (i + ncols); j++) {
	    	if(j < limit)
	    		document.write("<td width='" + xc[nc] + "' align='center'>");
	    	else
	    		document.write("<td width='" + maxlen + "' align='center'>");	
	    	
	    	document.write("<font color='Navy' size='2' face='Arial'>" + txt[j] + " (" + j + ")</td>");
	        document.write("<td>&nbsp;</td>");  
	    	nc++;
	        if(j >= limit) {
	           	break;  
	        }   	
	    }
	    document.write("</tr>");	
      	document.write("<tr><td>&nbsp;</td></tr></table>");
	    if(j > limit)
	       break;  
	    i = i + (ncols - 1);
	}  
	document.write("</table></center>");
	if(page_return != "") {
		if(ncols < 4) 
			document.write("<div id='seta' style='position: relative; margin-top: -70px; text-align: right;>");
		else 
			document.write("<div id='seta' style='position: relative; margin-top: -10px; text-align: right;>");
		document.write("<p align='right'>");
		document.write("<a href='" + page_return + "' target='' style='text-decoration: none;' onMouseOver=" +
					   sp + "setImage(document.images['img_seta'], 'images/seta_up_1.gif');" + sp +
	                   " onMouseOut=" + sp + "setImage(document.images['img_seta'], 'images/seta_up_0.gif');" + sp + ">");
		document.write("<img name='img_seta' src='images/seta_up_0.gif' width='9' height='9' border='0'></a></p></div>");
	}
}

function WinOpen(path, alink, scrollbars, text, ind, limit, prefix, ext, texts, style, xlen, ylen, effect) {
   var sp = '"';  
   img = null;
   
   if(!xlen)
   	   xlen = 650;
   	
   if(!ylen)
   	   ylen = 450;
   
   if(typeof(effect) == 'undefined')
   	   effect = false;

   var mleft = (screen.width - xlen) / 2;  
   var mtop = (screen.height - ylen) / 2 - 5;
   var xini = (effect ? 50 : xlen);
   var yini = (effect ? 50 : ylen);
   var prv = 0;
   var nxt = 0;
   var tx = "";
   var fprev = "";
   var fnext = "";
   var i = 0, j = 0;
   var txt = new Array(limit);
   var magent = navigator.appName;
   var mcontrol = "location.replace('');";
   
   if(magent.indexOf("Microsoft") < 0) {
   	   mcontrol = "window.close();";
   }	   

   if (typeof(texts) != 'undefined') {
		txt = texts.split("|");
		i = txt.length;
	}	
   
   if (typeof(ind) != 'undefined') {
   	   tx = txt[ind-1];
   	   
   	   if(ind > 1) {
   	       prv = ind - 1;
   	       fprev = prefix + prv + ext;
   	   }
   	   if((ind + 1) <= limit) {
   	   	   nxt = ind + 1;
   	   	   fnext = prefix + nxt + ext;
   	   }
   }
   
   if(document.getElementById("winMain")) {
       lastX = document.getElementById("winMain").scrollLeft;
       lastY = document.getElementById("winMain").scrollTop;
       setCookie("lastX", lastX, 1);
       setCookie("lastY", lastY, 1);
       restart(document.getElementById("winMain"));
   }    

   if(!scrollbars)
   	   scrollbars = 'no';
   
   msg=open("","DisplayWindow","copyhistory=0, directories=0, location=0, " +  
            "menubar=0, scrollbars=" + scrollbars + ",status=0,toolbar=0," +  
            "resizable=no,width=" + xini + ",height=" + yini + ",top=" + 
            mtop + ",left=" + mleft);  

   // Cria efeito de redimensionamento da janela
   if(effect) {
	   j = yini;	
	   for (i=xini; i<xlen; i=i+5) {
	   	   msg.moveTo((screen.width - i) / 2, (screen.height - j) / 2 - 5);
	   	   msg.resizeTo(i,j);
	   	   j = j + 5;
	   	   if(j > ylen)
	   	   	   j = ylen;
	   }	   
	   msg.resizeTo(xlen, ylen);
	   msg.moveTo(mleft, mtop);
   }	   

   msg.document.write("<link href='style/style.css' type='text/css' rel='stylesheet'>");
   msg.document.write("<script language='javascript1.2' src='scripts/perfecnet.js'></script>");
   msg.document.write("<body onunload='lastX=0; lastY=0;'>");
   msg.document.write("<table width='100%' align='center'>");
   msg.document.write("<tr><td align='right'><font color='#0000B0' face='Arial' size='1'><b>" +
   	                  ind + " / " + limit + "</b></font></td></tr>");
   msg.document.write("<tr><td align='center'><img src='" + path + alink + "' border='1' class='img_style'>");
   msg.document.write("</td></tr>");
   if (typeof(text) != 'undefined') {
   	   if(text != "undefined" && text != "") {
	   	   msg.document.write("<tr><td style='" + style + "'>" + text + "</td></tr>");
	   }
   }
   msg.document.write("<tr><td align='right'><table width='20%' align='center'><tr>");
   if (fprev != "") {
        msg.document.write("<td><a href=" + sp + "#" + sp + " target=" + sp + "" + sp + " onclick=" + sp + 
        	               mcontrol + "WinOpen('" + path + "','" + fprev + "','" + 
        	               scrollbars + "','" + txt[prv - 1] + "'," + prv + "," + limit + ",'" + prefix + "','" + ext + 
        	               "','" + texts + "','" + style + "'," + xlen + "," + ylen + "," + effect + ");" + sp + ">" +
            			   "<img name=" + sp + "seta_left" + sp + " src=" + sp + "images/seta_left_0.gif" + sp + 
            			   " width=" + sp + "9" + sp + "height=" + sp + "9" + sp + " border=" + sp + "0" + sp + 
            			   "align=" + sp + "right" + sp + " style=" + sp + "text-decoration: none;" + sp + 
            			   " onMouseOver=" + sp + "setImage(document.images['seta_left'], " +
	                       "'images/seta_left_1.gif');" + sp + " onMouseOut=" + sp + 
	                       "setImage(document.images['seta_left'], 'images/seta_left_0.gif');" + sp + "></a></td>");
   }   
   msg.document.write("<td><a href=" + sp + "#" + sp + " onclick=" + sp + "window.close();" + sp + ">" +
   	                  "<img name=" + sp + "seta_up" + sp + " src=" + sp + "images/seta_up_0.gif" +
                      sp + " width=" + sp + "9" + sp + " height=" + sp + "9" + sp + " border=" +
                      sp + "0" + sp + " align=" + sp + "right" + sp + 
                      " onMouseOver=" + sp + "setImage(document.images['seta_up']," +
                      "'images/seta_up_1.gif');" + sp + " onMouseOut=" + sp +
                      "setImage(document.images['seta_up'],'images/seta_up_0.gif');" + sp + "></a></td>");
   if (fnext != "") {
        msg.document.write("<td><a href=" + sp + "#" + sp + " target=" + sp + "" + sp + 
                           " onclick=" + sp + mcontrol + "WinOpen('" + path + "','" + fnext + "', '" + 
                           scrollbars + "','" + txt[nxt - 1] + "'," + nxt + "," + limit + ",'" + 
                           prefix + "','" + ext + "','" + texts + "','" + style + "'," + xlen + "," + ylen + 
                           "," + effect + ");" + 
                           sp + ">" + "<img name=" + sp + "seta_right" + sp + " src=" + sp + 
                           "images/seta_right_0.gif" +
	                       sp + " width=" + sp + "9" + sp + " height=" + sp + "9" + sp + " border=" + sp +
	                       "0" + sp + " align=" + sp + "right" + sp + " style=" + sp + "text-decoration: none;" +
	                       sp + " onMouseOver=" + sp + "setImage(document.images['seta_right'], " +
	                       "'images/seta_right_1.gif');" + sp + " onMouseOut=" + sp + 
	                       "setImage(document.images['seta_right'], 'images/seta_right_0.gif');" + sp + "></a></td>");
   }   
   msg.document.write("</tr></table></td></tr></table></body>");
   msg.document.location.reload();
   // msg.location.replace('');
}   

function swapLayer(menu, text, ind) {
    var i, msg; 

    for(i=0; i < text.length; i++) {
         text[i].style.visibility = 'hidden'; 
    }

    if(ind < 0) {
        menu.style.visibility = 'visible';
    }
    else {  
        menu.style.visibility = 'hidden';
        text[ind].style.visibility = 'visible';  
    }  
}  

function ShowLayer(text, ind) {
    var i; 

    for(i=0; i < text.length; i++) {
         text[i].style.visibility = 'hidden'; 
    }
    if(ind >= 0) 
    	text[ind].style.visibility = 'visible';  
}  

function configPosition(doc, noTop, noLeft) {
	var mtop = parseInt((screen.height - 600) / 2);
	var mleft = parseInt((screen.width - 800) / 2);
	
	if(noTop) {
		mtop = 0;
	}
	if(noLeft) {
		mleft = 0;
	}
	if (screen.height > 600) {
		doc.write("<div id='body' style='position:absolute; margin-top:" + 
				  mtop + "; margin-left:" + mleft + "'>");  	
	}			  
}

function scrollIn() {
	window.status=Message.substring(0, place);
 	if(place >= Message.length) {
  	place=1;
  	window.setTimeout("scrollOut()", 300);
 	}
 else {
  	place++;
  	window.setTimeout("scrollIn()", 50);
 	}
}
 
function scrollOut() {
 	window.status=Message.substring(place, Message.length);
 	if(place >= Message.length) {
  	place=1;
  	window.setTimeout("scrollIn()", 100);
 	}
 else {
  	place++;
  	window.setTimeout("scrollOut()", 50);
 	}
}

function formFone(objeto,lenmax,keypress)
{
	var tecla = keypress.keyCode;
	vr = objeto.value;
	vr = vr.replace( "(", "" );
	vr = vr.replace( ")", "" );
	vr = vr.replace( " ", "" );
	vr = vr.replace( "-", "" );
	tam = vr.length;
	if (tam < lenmax && tecla != 8) {
		tam = vr.length + 1 ;
	}
	if (tecla == 8 ) {
		tam = tam - 1 ;
	}
	if ( tecla == 8 || tecla >= 48 && tecla <= 57 || tecla >= 96 && tecla <= 105 ) {
		if ( tam <= 4 ) { 
	 		objeto.value = vr ;
		}
	 	if ( (tam > 4) && (tam <= 8) ) {
	 		objeto.value = vr.substr(0,tam-4) + '-' + vr.substr( tam - 4, tam ) ;
		}
	 	if ( (tam >= 9) && (tam <= 10) ) {
			objeto.value = '(' + vr.substr(0,2) + ') ' + vr.substr(2,tam-6) + '-' + vr.substr(tam-4,tam) ;			
		}
	}		
}
