
function move(cmp, obj)
// função construtor da classe move
{
   this.nom_cmp = cmp;
   this.spop = obj;
// em nom_cmp recebemos o nome do campo que será movido
   this.x=250;
// aqui é a localização padrão de X de onde o objeto começa
   this.y=250;
// aqui é a localização padrão de Y de onde o objeto começa
   this.mover = false;
   this.ux=0;
   this.tempo=0;
}

move.prototype.ModLoc = function(x,y)
{
  this.x = x;
  this.y = y;
}

move.prototype.clickin = function(evento)
{
   this.mousex = evento.clientX;
   this.mousey = evento.clientY;
   if(this.x < evento.clientX)
   {
      this.ux= evento.clientX - this.x;
	  this.ux = -this.ux;
   }
   else
   {
     this.ux = this.x - evento.clientX;
   }
   
   if(this.y < evento.clientY)
   {
      this.uy= evento.clientY - this.y;
	  this.uy = -this.uy;
   }
   else
   {
     this.uy = this.y - evento.clientY;
   }

      this.mover = true;
	  if(navigator.appVersion.indexOf("MSIE") != -1)
	  {
      document.body.onmousemove= function()
      {
        pegabuza.movendo(evento);
      }
	  
      document.body.onmouseup= function()
      {
		  
          popbuza.popup.top=(popbuza.movedor.y)+'px';
		  popbuza.popup.left=(popbuza.movedor.x)+'px';
		  pegabuza.clickup(evento);
      }
	  }
	  else
	  {
      document.body.onmousemove= function(event)
      {
        pegabuza.movendo(event);
      }
      document.body.onmouseup= function(event)
      {
		  
          popbuza.popup.top=(popbuza.movedor.y)+'px';
		  popbuza.popup.left=(popbuza.movedor.x)+'px';
		  pegabuza.clickup(event);
      }
	  }
}

move.prototype.clickup = function(evento)
{
   var tempx,tempy;
   if(this.x < evento.clientX)
   {
      tempx= evento.clientX - this.x;
	  tempx = -tempx;
   }
   else
   {
     tempx = this.x - evento.clientX;
   }
   
   if(this.y < evento.clientY)
   {
      tempy= evento.clientY - this.y;
	  tempy = -tempy;
   }
   else
   {
     tempy = this.y - evento.clientY;
   }

   if(this.mover)
      this.mover=false;
      document.body.onmousemove= function()
      {
      }
}

move.prototype.movendo = function(event)
{
   var img;

   img = document.getElementById(this.nom_cmp);
   if(this.mover)
   {


	  img.style.left = (event.clientX + this.ux)+"px";
	  img.style.top = (event.clientY + this.uy)+"px";
	  this.x = event.clientX + this.ux;
	  this.y = event.clientY + this.uy;
   }
}
// Fim da Classe move
//////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////
function StlMenu()
{
   this.largura;
   this.altura;
   this.fundo;
   this.conteudo="";
   this.CText;
}

StlMenu.prototype.ModCText = function(cor)
{
   this.CText = cor;
}


function PopUp(nome,campo)
{
   this.nom_obj = nome;
   this.nom_cmp = campo;
   this.nom_cmp_int = campo+"jubajua";
   this.cmp_int_borda ="1px solid black";
   this.brd_pop_ext="solid #0000ff";
   this.cmp_menu = campo+"Menu";
   this.cmp_cont = campo+"conteudo";
   this.cont_altura = "40px";
   this.position = "absolute";
   this.ZIndex=20;
   this.top=0;
   this.left=0;
   this.temp="";
   this.conteudo="";
   this.fundo_cont="white";
   this.altura_cont = "80px";
   this.largura;
   this.altura;
   this.fundo = "white";
   this.menu = new StlMenu();
   this.atualizar = false;
   this.diminui = false;
   this.dinamico = false;
}
PopUp.prototype.ModLoc = function(x,y)
{
   this.top=y;
   this.left=x;
}

PopUp.prototype.ModZIndex = function(pos)
{
   this.ZIndex=pos;
}

PopUp.prototype.ModTam = function(largura,altura)
{
   this.largura=largura;
   this.altura=altura;
}

PopUp.prototype.ModCont = function(conteudo)
{
   this.conteudo = conteudo;
}

PopUp.prototype.ModFundo = function(fundo)
{
   this.fundo = fundo;
}
PopUp.prototype.wrt = function(texto)
{
   this.temp = this.temp + texto;
}

PopUp.prototype.exibirb = function()
{
   document.write(this.temp);
}

PopUp.prototype.exibir = function()
{
    this.temp = "";
	if(this.atualizar == false)
	{
       this.wrt("<div id=\""+this.nom_cmp+"\">");
	}
//  style=\"border: 6px solid #7ca4c7\"	   
    this.wrt("<div id=\""+this.nom_cmp_int+"\"");
	
	this.wrt("style=\"width:"+this.largura+";height:"+this.altura+";background-color:"+this.fundo_cont+";border:"+this.cmp_int_borda+"\"");

	this.wrt(">");
	this.wrt("<div id=\""+this.cmp_menu+"\" >");
	this.wrt(this.menu.conteudo);
	this.wrt("</div>");
	if(this.diminui == false)
	{
	this.wrt("<div id=\""+this.cmp_cont+"\"");
	if(navigator.appVersion.indexOf("MSIE") == -1)
	  this.wrt(" style=\"padding:8px 0 0 8px; border:"+"1px "+this.brd_pop_ext+"; height:"+this.cont_altura+"\"");
	this.wrt(">");
	this.wrt(this.conteudo+"</div>");
	}
	
	this.wrt("</div>");
	
	
	if(this.atualizar == false)
	{
  	  this.wrt("</div>");
	  this.atualizar=true;
      this.exibirb();
  	  this.modifica();
	}
}

PopUp.prototype.cfgMenu = function(largura,altura,fundo)
{
    this.menu.largura = largura;
	this.menu.altura = altura;
	this.menu.fundo = fundo;
}

PopUp.prototype.modifica = function()
{
   var obj = document.getElementById(this.nom_cmp);
   var menu = document.getElementById(this.cmp_menu);
   var cont = document.getElementById(this.cmp_cont);
//   cont.style.backgroundColor = this.fundo_cont;
//   this.altura_cont
//   cont.style.height = this.altura_cont;
   obj.style.position = this.position;
   obj.style.zIndex=this.ZIndex;
   if(this.dinamico == false)
   {
     obj.style.left= this.left;
     obj.style.top = this.top;
   }
   obj.style.border="2px "+this.brd_pop_ext;
   this.mod_cont();
   menu.style.width = this.menu.largura;
   menu.style.height = this.menu.altura;
   menu.style.backgroundColor = this.menu.fundo;
   menu.style.color = this.menu.CText;
   menu.style.cursor = "move";
}

PopUp.prototype.mod_cont = function()
{
   var cont = document.getElementById(this.cmp_cont);
   cont.style.border="1px "+this.brd_pop_ext;
}




function CmpsMenu()
{
   this.m1="";
   this.m1Fundo="red";
   this.m1Largura=15;
   this.m1conteudo="";
   this.m2="";
   this.m2Fundo="green";
   this.m2Largura="100%";
   this.m3="";
   this.m3Fundo="blue";
   this.m3Largura=15;
   this.m3conteudo="";
   this.mT="";
   this.mTCPadding=0;
   this.mTCSpacing=0;
   this.mTLargura="100%";
   this.mTAltura="100%";
}
CmpsMenu.prototype.Mod_m1 = function(fundo,largura)
{
   this.m1Fundo = fundo;
   this.m1Largura = largura;
}

CmpsMenu.prototype.Mod_m3 = function(fundo,largura)
{
   this.m3Fundo = fundo;
   this.m3Largura = largura;
}

CmpsMenu.prototype.Mod_m2 = function(fundo,largura)
{
   this.m3Fundo = fundo;
   this.m3Largura = largura;
}

CmpsMenu.prototype.Mod_mT = function(padding, spacing, largura, altura)
{
   this.mTCPadding=padding;
   this.mTCSpacing=spacing;
   this.mTLargura=largura;
   this.mTAltura=altura;
}


function SuperPopUp(nome,campo)
{
   this.popup = new PopUp(nome+".popup",campo+"PopUp");
   this.menu = new CmpsMenu();
   this.spop = nome;
   this.menu.m1=campo+"1SubMenu";
   this.menu.m2=campo+"2SubMenu";
   this.menu.m3=campo+"3SubMenu";
   this.menu.mT=campo+"MenuTable";
   this.movedor;
   this.sumiu=false;
}

SuperPopUp.prototype.estilo = function()
{
  this.popup.ModLoc(100,100);
  this.popup.ModFundo("#9999ff");
  this.popup.cfgMenu(300,15,"#000000")
}

SuperPopUp.prototype.exibir = function()
{

  var obj = document.getElementById(this.popup.nom_cmp);
  if(this.sumiu==true)
  {
	  this.popup.exibir();
	  obj.innerHTML=this.popup.temp;
//       obj.style.position = this.popup.position;
//      obj.style.zIndex=this.popup.ZIndex;
      obj.style.top = this.popup.top;
      obj.style.left = this.popup.left;
      obj.style.width=this.popup.largura;
      obj.style.height=this.popup.altura;
//	  document.getElementById(this.popup.cmp_menu).style.height = this.popup.menu.altura;
//	  document.getElementById(this.popup.cmp_menu).style.cursor = "move";
	  document.getElementById(this.menu.m2).innerHTML = this.menu.m2conteudo;
//	  this.popup.modifica();
      this.sumiu=false;
//	  document.getElementById(this.popup.cmp_menu).style.height = this.menu.altura;
  }
  if((this.sumiu!=true))
  {
  this.ModContMenu();
  this.estilo();
  this.popup.exibir();
  this.SubMenus();
  }
}

SuperPopUp.prototype.sumir = function()
{
  var obj = document.getElementById(this.popup.nom_cmp);
  this.sumiu=true;
  obj.innerHTML="";
  obj.style.top = -50;
  obj.style.left = -50;
  obj.style.width=0;
  obj.style.height=0;
}

SuperPopUp.prototype.diminuir = function(x,y)
{
  var obj = document.getElementById(this.popup.nom_cmp);
  if(this.popup.diminui == false)
  {
  this.menu.m1conteudo="<img src=\"images/botoes/btn_up.gif\" />";
  this.ModContMenu();
  this.popup.diminui = true;
  this.popup.exibir();
    obj.innerHTML = this.popup.temp;
  this.SubMenus();
  if(navigator.appVersion.indexOf('MSIE') != -1)
  {
	 obj.style.height="0px";
     document.getElementById(this.popup.nom_cmp_int).style.borderBottomWidth="6px";
     document.getElementById(this.popup.cmp_menu).style.borderBottomWidth="0px";
     document.getElementById(this.popup.nom_cmp_int).style.height="0px";
  }
  else
  {
  obj.style.height="30px";
  document.getElementById(this.popup.nom_cmp_int).style.height="18px";
  }
  document.getElementById(this.menu.m2).innerHTML = this.menu.m2conteudo;
  }
  else
  {
  this.menu.m1conteudo="<img src=\"images/botoes/btn_down.gif\" />";
  this.ModContMenu();
  this.popup.diminui = false;
  this.popup.exibir();
    obj.innerHTML = this.popup.temp;
  this.SubMenus();
  this.popup.dinamico = true;
  this.popup.diminui = false;
  document.getElementById(this.menu.m2).innerHTML = this.menu.m2conteudo;
  document.getElementById(this.popup.cmp_menu).style.height = this.popup.menu.altura;
  document.getElementById(this.popup.cmp_cont).style.border = "1px "+this.popup.brd_pop_ext;
  if(navigator.appVersion.indexOf('MSIE') == -1)
     obj.style.height=(this.popup.altura+(6*2))+"px";
  else
     document.getElementById(this.popup.cmp_cont).style.height = this.popup.cont_altura;
//  popbuza.popup.altura+(6*2)
  }
}


SuperPopUp.prototype.diminuirn = function(x,y)
{
  var obj = document.getElementById(this.popup.nom_cmp_int);
  if(this.popup.diminui == false)
  {
  this.popup.diminui = true;
//  this.estilo();
/*
   
*/
  obj.style.height="5px";

  this.popup.exibir();
//  if(this.popup.atualizar == true)
//	   obj.innerHTML = this.popup.temp;
   this.SubMenus();
//  obj.style.height=this.popup.altura;
  document.getElementById(this.menu.m2).innerHTML = this.menu.m2conteudo;  
  document.getElementById(this.popup.cmp_menu).style.height = this.popup.menu.altura;
  obj.style.cursor = "move";
  }
  else
  {
  this.popup.diminui = false;
//  obj.style.height=this.popup.altura;
//  this.estilo();
  this.popup.exibir();
    obj.innerHTML = this.popup.temp;
//  this.SubMenus();
  this.popup.dinamico = true;
  this.popup.diminui = false;
//  this.popup.modifica();
///*
//   obj.style.width=this.popup.largura;
//   obj.style.height=this.popup.altura;
//   obj.style.border = this.cmp_int_borda;   

//   this.popup.mod_cont();
//   document.getElementById(this.popup.cmp_cont).style.height='91%';
//   document.getElementById(this.popup.cmp_menu).style.cursor = "move";
//   document.getElementById(this.menu.m2).innerHTML = this.menu.m2conteudo;
//   document.getElementById(this.popup.cmp_menu).style.height = this.popup.menu.altura;
  }
}

SuperPopUp.prototype.enviar = function(boole)
{
   var obj = document.getElementById(this.popup.nom_cmp);
//   this.popup.conteudo = boole;
   this.popup.conteudo = "<div style=\"font-size:20px;text-align:center; padding-top:"+((this.popup.altura-60)/2)+"px\">";
   if(boole)
     this.popup.conteudo += "Email enviado com sucesso, aguarde o retorno da empresa";
   else
     this.popup.conteudo += "Email n&atilde;o pode ser enviado com sucesso";
   this.popup.conteudo += "</div>";
   this.popup.exibir();
      obj.innerHTML = this.popup.temp;
   this.SubMenus();
   document.getElementById(this.popup.cmp_menu).style.height = this.popup.menu.altura;
   document.getElementById(this.popup.cmp_menu).style.cursor = "move";
   document.getElementById(this.menu.m2).innerHTML = this.menu.m2conteudo;
}

SuperPopUp.prototype.SubMenus = function()
{
   var menu1;
   var menu2;
   var menu3;
   var menuT;
   menu1 = document.getElementById(this.menu.m1);
   menu2 = document.getElementById(this.menu.m2);
   menu3 = document.getElementById(this.menu.m3);
   menuT = document.getElementById(this.menu.mT);
   menuCampo = document.getElementById(this.popup.cmp_menu);
   menu1.style.backgroundColor=this.menu.m1Fundo;
   menu1.style.width=this.menu.m1Largura;
   menu2.style.backgroundColor=this.menu.m2Fundo;
   menu2.style.width=this.menu.m2Largura;
   menu3.style.backgroundColor=this.menu.m3Fundo;
   menu3.style.width=this.menu.m3Largura;
   menuT.cellPadding=this.menu.mTCPadding;
   menuT.cellSpacing=this.menu.mTCSpacing;
   menuT.style.width=this.menu.mTLargura;
   menuT.style.height=this.menu.mTAltura;
   menuCampo.style.borderBottom = this.popup.cmp_int_borda;
}
SuperPopUp.prototype.wrtMenu = function(texto)
{
   this.popup.menu.conteudo = this.popup.menu.conteudo + texto; 
}
SuperPopUp.prototype.ModContMenu = function()
{
   this.popup.menu.conteudo = "";
   this.wrtMenu("<table id=\""+this.menu.mT+"\">");
   this.wrtMenu("<tr>");
   this.wrtMenu("<td id=\""+this.menu.m1+"\" style=\"cursor:pointer\"  OnClick=\""+this.spop+".diminuir(); \" valign=\"center\">"+this.menu.m1conteudo+"</td>");
   this.wrtMenu("<td id=\""+this.menu.m2+"\" onMouseDown=\""+this.movedor+".clickin(event);\"  style=\"cursor:move\" valign=\"center\"></td>");
   this.wrtMenu("<td id=\""+this.menu.m3+"\" style=\"cursor:pointer;\" onclick=\""+this.spop+".sumir();\" valign=\"center\">"+this.menu.m3conteudo+"</td>");
   this.wrtMenu("</tr>");
   this.wrtMenu("</table>");
}

popbuza = new SuperPopUp("popbuza","popupbuza");
popbuza.popup.conteudo = "Conteudo Padr&atilde;o";
popbuza.popup.ModCont("muda");
popbuza.popup.menu.ModCText("#ffffff");
popbuza.popup.ModFundo("#F0F8FF");
pegabuza = new move(popbuza.popup.nom_cmp, popbuza);
pegabuza.ModLoc(100,100);
popbuza.movedor="pegabuza";
popbuza.menu.m3conteudo="<img src=\"images/botoes/fechar_pop_up.gif\" />";
popbuza.menu.m1Fundo = "#d2d2d2";
popbuza.menu.m2Fundo = "#d2d2d2";
popbuza.menu.m3Fundo = "#d2d2d2";
//popbuza.menu.m2Fundo = "#7ca1c4";
//popbuza.menu.m3Fundo = "#7ca1c4";
popbuza.popup.fundo_cont="#f5f5f5";
popbuza.popup.largura=0;
popbuza.popup.altura=0;
popbuza.ModContMenu();
popbuza.exibir();
//popbuza.popup.sumir();
popbuza.sumir();
//document.getElementById(popbuza.popup.nom_cmp_intu).innerHTML = 55;
//= "6px solid #e2e2e2";
popbuza.popup.cfgMenu("100%",18,"#e2e2e2");
;
//document.getElementById(popbuza.popup.nom_cmp).style.border = "6px solid #e2e2e2";


