//v1.0
//Copyright 2006 Adobe Systems, Inc. All rights reserved.
function AC_AddExtension(src, ext)
{
  if (src.indexOf('?') != -1)
    return src.replace(/\?/, ext+'?'); 
  else
    return src + ext;
}

function AC_Generateobj(objAttrs, params, embedAttrs) 
{ 
  var str = '<object ';
  for (var i in objAttrs)
    str += i + '="' + objAttrs[i] + '" ';
  str += '>';
  for (var i in params)
    str += '<param name="' + i + '" value="' + params[i] + '" /> ';
  str += '<embed ';
  for (var i in embedAttrs)
    str += i + '="' + embedAttrs[i] + '" ';
  str += ' ></embed></object>';

  document.write(str);
}

function AC_FL_RunContent(){
  var ret = 
    AC_GetArgs
    (  arguments, ".swf", "movie", "clsid:d27cdb6e-ae6d-11cf-96b8-444553540000"
     , "application/x-shockwave-flash"
    );
  AC_Generateobj(ret.objAttrs, ret.params, ret.embedAttrs);
}

function AC_SW_RunContent(){
  var ret = 
    AC_GetArgs
    (  arguments, ".dcr", "src", "clsid:166B1BCA-3F9C-11CF-8075-444553540000"
     , null
    );
  AC_Generateobj(ret.objAttrs, ret.params, ret.embedAttrs);
}

function AC_GetArgs(args, ext, srcParamName, classid, mimeType){
  var ret = new Object();
  ret.embedAttrs = new Object();
  ret.params = new Object();
  ret.objAttrs = new Object();
  for (var i=0; i < args.length; i=i+2){
    var currArg = args[i].toLowerCase();    

    switch (currArg){	
      case "classid":
        break;
      case "pluginspage":
        ret.embedAttrs[args[i]] = args[i+1];
        break;
      case "src":
      case "movie":	
        args[i+1] = AC_AddExtension(args[i+1], ext);
        ret.embedAttrs["src"] = args[i+1];
        ret.params[srcParamName] = args[i+1];
        break;
      case "onafterupdate":
      case "onbeforeupdate":
      case "onblur":
      case "oncellchange":
      case "onclick":
      case "ondblClick":
      case "ondrag":
      case "ondragend":
      case "ondragenter":
      case "ondragleave":
      case "ondragover":
      case "ondrop":
      case "onfinish":
      case "onfocus":
      case "onhelp":
      case "onmousedown":
      case "onmouseup":
      case "onmouseover":
      case "onmousemove":
      case "onmouseout":
      case "onkeypress":
      case "onkeydown":
      case "onkeyup":
      case "onload":
      case "onlosecapture":
      case "onpropertychange":
      case "onreadystatechange":
      case "onrowsdelete":
      case "onrowenter":
      case "onrowexit":
      case "onrowsinserted":
      case "onstart":
      case "onscroll":
      case "onbeforeeditfocus":
      case "onactivate":
      case "onbeforedeactivate":
      case "ondeactivate":
      case "type":
      case "codebase":
        ret.objAttrs[args[i]] = args[i+1];
        break;
      case "width":
      case "height":
      case "align":
      case "vspace": 
      case "hspace":
      case "class":
      case "title":
      case "accesskey":
      case "name":
      case "id":
      case "tabindex":
        ret.embedAttrs[args[i]] = ret.objAttrs[args[i]] = args[i+1];
        break;
      default:
        ret.embedAttrs[args[i]] = ret.params[args[i]] = args[i+1];
    }
  }
  ret.objAttrs["classid"] = classid;
  if (mimeType) ret.embedAttrs["type"] = mimeType;
  return ret;
}

function validaAtend(theForm)
{
  if (theForm.cp1AREA.value == "")
  {
    alert("Selecione a área de atendimento");
    theForm.cp1AREA.focus();
    return (false);
  }
  if (theForm.cp2SEUNOME.value == "")
  {
    alert("O campo SEU NOME não pode ser vazio!");
    theForm.cp2SEUNOME.focus();
    return (false);
  }
    if (theForm.cpCIDADE.value == "")
  {
    alert("O campo CIDADE não pode ser vazio!");
    theForm.cpCIDADE.focus();
    return (false);
  }
     if (theForm.cpUF.value == "")
  {
    alert("O campo ESTADO não pode ser vazio!");
    theForm.cpUF.focus();
    return (false);
  }
  if (theForm.cp4DDD.value == "")
  {
    alert("O campo DDD não pode ser vazio!");
    theForm.cp4DDD.focus();
    return (false);
  }
  if (theForm.cp5TELEFONE.value == "")
  {
    alert("O campo TELEFONE não pode ser vazio!");
    theForm.cp5TELEFONE.focus();
    return (false);
  }
    if (theForm.cp3EMAIL.value == "")
  {
    alert("O campo EMAIL não pode ser vazio!");
    theForm.cp3EMAIL.focus();
    return (false);
  }
  if (/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(theForm.cp3EMAIL.value)){
  return (true)
  }
  {
    alert("O EMAIL não é válido!");
    theForm.cp3EMAIL.focus();
    return (false);
  }
  return (true);
}

function validaOrcamento(theForm)
{
  if (theForm.nome.value == "")
  {
    alert("O campo NOME não pode ser vazio!");
    theForm.nome.focus();
    return (false);
  }
    if (theForm.cidade.value == "")
  {
    alert("O campo CIDADE não pode ser vazio!");
    theForm.cidade.focus();
    return (false);
  }
     if (theForm.estado.value == "")
  {
    alert("O campo ESTADO não pode ser vazio!");
    theForm.estado.focus();
    return (false);
  }
  if (theForm.ddd.value == "")
  {
    alert("O campo DDD não pode ser vazio!");
    theForm.ddd.focus();
    return (false);
  }
  if (theForm.fone.value == "")
  {
    alert("O campo TELEFONE não pode ser vazio!");
    theForm.fone.focus();
    return (false);
  }
    if (theForm.cp3EMAIL.value == "")
  {
    alert("O campo EMAIL não pode ser vazio!");
    theForm.cp3EMAIL.focus();
    return (false);
  }
  if (theForm.dominio.value == "")
  {
    alert("O campo DOMINIO não pode ser vazio!");
    theForm.dominio.focus();
    return (false);
  }
  if (/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(theForm.cp3EMAIL.value)){
  return (true)
  }
  {
    alert("O EMAIL não é válido!");
    theForm.cp3EMAIL.focus();
    return (false);
  }
  return (true);
}

function validaOrcamento2(theForm)
{
  if (theForm.cpf.value == "")
  {
    alert("O campo CPF não pode ser vazio!");
    theForm.cpf.focus();
    return (false);
  }
    if (theForm.rg.value == "")
  {
    alert("O campo RG não pode ser vazio!");
    theForm.rg.focus();
    return (false);
  }
     if (theForm.endereco.value == "")
  {
    alert("O campo ENEREÇO não pode ser vazio!");
    theForm.endereco.focus();
    return (false);
  }
  if (theForm.cep.value == "")
  {
    alert("O campo CEP não pode ser vazio!");
    theForm.cep.focus();
    return (false);
  }
  return (true);
}

function validaloja(theForm)
{
  if (theForm.nome.value == "")
  {
    alert("O campo NOME não pode ser vazio!");
    theForm.nome.focus();
    return (false);
  }
  if (theForm.cpf.value == "")
  {
    alert("O campo CPF não pode ser vazio!");
    theForm.cpf.focus();
    return (false);
  }
    if (theForm.rg.value == "")
  {
    alert("O campo RG não pode ser vazio!");
    theForm.rg.focus();
    return (false);
  }
     if (theForm.endereco.value == "")
  {
    alert("O campo ENEREÇO não pode ser vazio!");
    theForm.endereco.focus();
    return (false);
  }
    if (theForm.cidade.value == "")
  {
    alert("O campo CIDADE não pode ser vazio!");
    theForm.cidade.focus();
    return (false);
  }
     if (theForm.estado.value == "")
  {
    alert("O campo ESTADO não pode ser vazio!");
    theForm.estado.focus();
    return (false);
  }
  if (theForm.cep.value == "")
  {
    alert("O campo CEP não pode ser vazio!");
    theForm.cep.focus();
    return (false);
  }
  if (theForm.ddd.value == "")
  {
    alert("O campo DDD não pode ser vazio!");
    theForm.ddd.focus();
    return (false);
  }
  if (theForm.fone.value == "")
  {
    alert("O campo TELEFONE não pode ser vazio!");
    theForm.fone.focus();
    return (false);
  }
    if (theForm.cp3EMAIL.value == "")
  {
    alert("O campo EMAIL não pode ser vazio!");
    theForm.cp3EMAIL.focus();
    return (false);
  }
  if (theForm.dominio.value == "")
  {
    alert("O campo DOMINIO não pode ser vazio!");
    theForm.dominio.focus();
    return (false);
  }
  if (/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(theForm.cp3EMAIL.value)){
  return (true)
  }
  {
    alert("O EMAIL não é válido!");
    theForm.cp3EMAIL.focus();
    return (false);
  }
  return (true);
}

var NomeAtual;
var quantItem = 1;
	function mostraDiv(NomeDiv){
		for (cont=0;cont<=quantItem;cont++){
			eval('document.all.menu'+cont+'.style.display = "none"');
		}
		if (NomeAtual!=NomeDiv){
			eval('document.all.menu'+NomeDiv+'.style.display = ""');
			NomeAtual = NomeDiv;
		}else{
			NomeAtual = "";
		}
	}
	
function open_window(name, url, left, top, width, height, toolbar, menubar, statusbar, scrollbar, resizable)
{
  toolbar_str = toolbar ? 'yes' : 'no';
  menubar_str = menubar ? 'yes' : 'no';
  statusbar_str = statusbar ? 'yes' : 'no';
  scrollbar_str = scrollbar ? 'yes' : 'no';
  resizable_str = resizable ? 'yes' : 'no';

  cookie_str = document.cookie;
  cookie_str.toString();

  pos_start  = cookie_str.indexOf(name);
  pos_end    = cookie_str.indexOf('=', pos_start);

  cookie_name = cookie_str.substring(pos_start, pos_end);

  pos_start  = cookie_str.indexOf(name);
  pos_start  = cookie_str.indexOf('=', pos_start);
  pos_end    = cookie_str.indexOf(';', pos_start);
  
  if (pos_end <= 0) pos_end = cookie_str.length;
  cookie_val = cookie_str.substring(pos_start + 1, pos_end);
  if (cookie_name == name && cookie_val  == "done")
    return;

  window.open(url, name, 'left='+left+',top='+top+',width='+width+',height='+height+',toolbar='+toolbar_str+',menubar='+menubar_str+',status='+statusbar_str+',scrollbars='+scrollbar_str+',resizable='+resizable_str);
}

function jumpMenu(targ,selObj,restore){ //v3.0
  eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
  if (restore) selObj.selectedIndex=0;
}

function ajax(url,div,mes) 
{ 
document.getElementById(div).innerHTML='<div align="center" class="carregando"><br><img src="imagens/carregando.gif"><br /><br /><font face="Verdana" size="2">'+mes+'</font></div>'
mostra=document.getElementById(div);
    req = null; 
    if (window.XMLHttpRequest) { 
        req = new XMLHttpRequest(); 
        req.onreadystatechange = processReqChange; 
        req.open("GET",url,true); 
        req.send(null); 
    } else if (window.ActiveXObject) { 
        req = new ActiveXObject("Microsoft.XMLHTTP"); 
        if (req) {
		
         req.onreadystatechange = processReqChange; 
         req.open("GET",url,true); 
	 
            req.send(); 
        } 
    } 
} 

function processReqChange() 
{
    if (req.readyState == 4) { 
        if (req.status ==200) { 
			mostra.innerHTML = req.responseText;
 
        } else { 
            alert("Houve um problema ao obter os dados:\n" + req.statusText); 
        } 
    } 
} 

//VALIDA CONTATO
function validaContato(theForm)
{
  if (theForm.cp1NOME.value == "")
  {
    alert("O campo NOME não pode ser vazio!");
    theForm.cp1NOME.focus();
    return (false);
  }
    if (theForm.cp2CIDADE.value == "")
  {
    alert("O campo CIDADE não pode ser vazio!");
    theForm.cp2CIDADE.focus();
    return (false);
  }
     if (theForm.cp3ESTADO.value == "")
  {
    alert("O campo ESTADO não pode ser vazio!");
    theForm.cp3ESTADO.focus();
    return (false);
  }
  if (theForm.cp4DDD.value == "")
  {
    alert("O campo DDD não pode ser vazio!");
    theForm.cp4DDD.focus();
    return (false);
  }
  if (theForm.cp5FONE.value == "")
  {
    alert("O campo TELEFONE não pode ser vazio!");
    theForm.cp5FONE.focus();
    return (false);
  }
    if (theForm.cp6EMAIL.value == "")
  {
    alert("O campo EMAIL não pode ser vazio!");
    theForm.cp6EMAIL.focus();
    return (false);
  }
  if (/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(theForm.cp6EMAIL.value)){
  return (true)
  }
  {
    alert("O EMAIL não é válido!");
    theForm.cp6EMAIL.focus();
    return (false);
  }
  return (true);
}

function fotoZoom(img){
  foto1= new Image();
  foto1.src=(img);
  Controlla(img);
}
function Controlla(img){
  if((foto1.width!=0)&&(foto1.height!=0)){
    viewFoto(img);
  }
  else{
    funzione="Controlla('"+img+"')";
    intervallo=setTimeout(funzione,20);
  }
}
function viewFoto(img){
  largh=foto1.width+20;
  altez=foto1.height+20;
  stringa="width="+largh+",height="+altez;
  finestra=window.open(img,"",stringa);
}

/* This script and many more are available free online at
The JavaScript Source!! http://javascript.internet.com
Created by: Scragar | Licensed under: Public Domain
 */

function BannerRotator(){
// first, defaults:
  this.timer = 2;
  this.bannerNum = 0;// -1 = random
// then normal init work
  this.banners = [];
  this.binding = null;
  this.timeout = null;

  this.add = function(){// add a banner to the array
    this.banners[this.banners.length] = [arguments[0], arguments[1]];
  }

  this.bind = function(){// bind to an element
    if(typeof arguments[0] == 'string')
      this.binding = document.getElementById(arguments[0]);
    else
      this.binding = arguments[0];
    this.rotate();
  }

  this.rotate = function(){// the actual image rotator
    if( ! this.empty())
      return;
    var showNum, tmpA = document.createElement('a'), tmpImg = document.createElement('img');

    if(this.bannerNum < 0)// random
      showNum = Math.floor(Math.random()*this.banners.length);
    else// syncronous
      showNum = this.bannerNum=(++this.bannerNum >= this.banners.length)?0:this.bannerNum;

    tmpA.href = this.banners[showNum][0];
    tmpImg.src = this.banners[showNum][1];
    tmpA.appendChild(tmpImg);
    this.binding.appendChild(tmpA);
  }

  this.empty = function(){// empty the element if possible
    if(this.binding == null)
      return false;
    while(this.binding.hasChildNodes())
      this.binding.removeChild(this.binding.firstChild);
    return true;
  }

  this.startTimer = function(){// start the loop, normaly done during page load.
    this.stopTimer();
    this.timeout = window.setInterval(
      (function(x){
        return function(){
          x.rotate();
        }
      })(this), this.timer*1000);
  }

  this.stopTimer = function(){// stop the loop, nice to make available via a button.
    if(this.timeout != null)
      window.clearInterval(this.timeout);
    this.timeout = null;
  }
}

