﻿// JScript File
 //inicialze event mouseOver e mouseDown no menu
   window.onload = iniciar;
   
   function iniciar(){
    var nodes = $("menu").getElementsByTagName("div");
    for(var i = 0; i < nodes.length; i++){
        var div = nodes[i];
        if(div.className != "menuSelect"){
            div.onmouseover = function(){
                 this.style.backgroundColor = "#458bc0";
                 var itemOver = this.getElementsByTagName("a");
                  itemOver[0].style.textDecoration = "none";
                  itemOver[0].style.color = "White";
                  this.title = itemOver[0].title;
            }
            div.onmouseout = function(){
                 this.style.backgroundColor = "White";
                 var item = this.getElementsByTagName("a");
                 item[0].style.color = "#458bc0";
                 item[0].style.textDecoration = "underline";
                 this.title = item[0].title;
            }
        }else{
               var item = div.getElementsByTagName("a");
               div.title = item[0].title;
        }
    }
 
   }
    function hideWater(obj, name){
      if(obj.value != '' && obj.value == name){ 
         obj.value= '';
      }
    }
    function blockWater(obj, name){
      if(obj.value == '' && obj.value != name){
         obj.value= name;
      }
    }
    
  function font(tipo){
      var nodesA = $("containerConteudo").getElementsByTagName("a");
      var nodesSpan = $("containerConteudo").getElementsByTagName("span");
      for(var x =0; x < nodesA.length; x++){
          if(nodesA[x].className != "" && nodesA[x].className != "titleBoxBold"  && nodesA[x].className != "titleNoticiaBold"){
             var value = nodesA[x].style.fontSize.replace("px","");
              if(value != 'undefined' && tipo == "-"){
                 try{
                    if(value == ""){
                       value = 13;
                    }else if(value > 12){
                        value = parseInt(value) - 1;
                    }
                 }catch (e){
                      value = 13;
                 }
                 
              }else if(value != 'undefined' && tipo == "+"){
                   try{
                      if(value == ""){
                       value = 15;
                      }else if(value < 16){
                            value = parseInt(value) + 1;
                      }
                      }catch(e){
                               value = 15;
                       }
              }
              if(value > 12){
             
                nodesA[x].style.fontSize = value+ "px";
              }else if(value < 16){
                nodesA[x].style.fontSize = value+ "px";
              }
          }
      }
       for(var i =0; i < nodesSpan.length; i++){
             var value = nodesSpan[i].style.fontSize.replace("px","");
              if(value != 'undefined' && tipo == "-"){
                 try{
                    if(value == ""){
                       value = 13;
                    }else if(value > 12){
                        value = parseInt(value) - 1;
                    }
                 }catch (e){
                      value = 13;
                 }
                 
              }else if(value != 'undefined' && tipo == "+"){
                   try{
                      if(value == ""){
                       value = 15;
                      }else if(value < 16){
                            value = parseInt(value) + 1;
                      }
                      }catch(e){
                               value = 15;
                       }
              }
              if(value > 12){
             
                nodesSpan[i].style.fontSize = value+ "px";
              }else if(value < 16){
                nodesSpan[i].style.fontSize = value+ "px";
              }
      }

    }
    
    function getConteudo()
    {
     try{
         window.scrollTo(0,608);
         setTimeout("$('titleConteudo').focus()",5);
        }catch(e){alert(e.message);}
    }
    
    
    function validar(lct)
    {
      if(lct.id == "xhtml"){
         window.open('http://validator.w3.org/check?uri=http%3A%2F%2Fwww.cdigital.com.br%2Findex.aspx');
      }else if(lct.id == "css")
      {
        window.open('http://jigsaw.w3.org/css-validator/validator?uri=http%3A%2F%2Fwww.cdigital.com.br%2Findex.aspx');
      }
    }
    function readTag(id){
           window.location = 'solucoes.aspx?_con='+id;
    }
    
  function readPortfolio(id){
        window.location = "portfolio.aspx?_pro="+id;
    }
    
    function enviarNews(){
      var name = $("txtName").value;
      var mail = $("txtMail").value;
      if(name != "" && mail != ""){
         var url = "AjaxPages/ajaxContato.aspx";
          var pars = "mail="+mail+"&name="+name;
         var myAjax = new Ajax.Request(url, 
         {
         	method: 'GET',
        	parameters: pars, 
        	cache:false,
        	onComplete: respSucesso

          });
      }else{alert('Você precisa digitar nome e e-mail para efetuar o cadastro.')}
    }
    
    function respSucesso(xml){
       alert('Informações enviadas. Obrigado!');
       $("txtName").value= "Nome";
       $("txtMail").value= "E-mail";
    }
    
    function forwardHome(){
     window.location= 'index.aspx';
    }