/* 
  Avanza Comunicacion (www.avanzacomunicacion.com)
  marzo 2009
*/

// jQuery
$(document).ready(function(){
  $(".pie .informacion").css({'-moz-opacity:':'.5','opacity':'.5','filter':'alpha(opacity=50)'});
  $(".pie .contacto .email").html("<span class='mail'>e-mail</span><br /><a href='mailto:"+emailenc+"' title='enviar un mensaje'>"+emailenc+"</a>");
  $("a[rel*='external']").attr('target','_blank').addClass('external');
  $("a[href*='.kmz']").addClass('ico-kmz');
  $("a[href*='.pdf']").addClass('ico-pdf');
  $("a[href*='facebook.com']").addClass('ico-facebook');
  $("a[href*='twitter.com']").addClass('ico-twitter');
  $("a[href='#top']").click(function(){
    $("html").animate({ scrollTop: 0 }, "slow");
  });
  // Menu
  var gris = '868889', naranja = 'f2942e';
  $(".menu a").hover(function(){
      colorFade(this.id,'text',gris,naranja,30,5);
    },function(){
      colorFade(this.id,'text',naranja,gris,30,5);
  });
  // Submenu portafolio
  //$("dl").hide();
  //$("dd").hide();
  $("#portafolio").mouseover(function(){
    $("dl").slideDown("slow");
  });
  $("dt a").click(function(){
    $("dd:visible").slideUp("slow");
    $(this).parent().next().slideDown("slow");
    return false;
  });
  /*
  $(".menu a[href*='eventos-y-patrocinio'],.menu a[href*='geomarketing'],.menu a[href*='animacion-3d']").click(function(){
    var r = this.href;
    self.location = r;
  });
  */
  // Selector de proyectos (acceso rapido)
  var pl = $("#plist");
  $(".gris").html(pl);
  $("#plist").change(function(){
    var r = $(this).attr('value');
    self.location = r;
  });
  if(location.href=='http://www.avanzacomunicacion.com/' || location.href=='http://avanzacomunicacion.com/' || location.href=='http://www.avanzacomunicacion.com/index.html' || location.href=='http://avanzacomunicacion.com/index.html'){
    $("#facebookwidget").html('<fb:fan profile_id="90916246827" stream="" connections="8" width="250"></fb:fan><script type="text/javascript">FB.init("0080d02e81017bb58290f531c7456187");</script>');
  };
});


// Activa menu
// c=seccion, g=grupo, p=portafolio
function menu(s,g,p) {
  /*
  $(".menu a[id*='"+s+"']").replaceWith('<span class="on">'+$(".menu a[id*='"+s+"']").text()+'</span>');
  if (g) {
    $("dl").slideDown("slow");
    var g = $(".menu a[href='/portfolio/"+g+".html']"), id = g.attr("id"), texto = g.text();
    g.parent().next().slideDown("slow");
    g.addClass("on");
    //g.replaceWith('<a href="#" id="'+id+'" class="on">'+texto+'</a>');
  };
  if (p) {
    var p = $(".menu a[href='/portfolio/"+p+".html']"), href = p.attr("href"), id = p.attr("id"), texto = p.text();
    p.replaceWith('<a href="'+href+'" id="'+id+'"><strong class="on">'+texto+'</strong></a>');
  };
  */
}

// Email encriptado
var email = [105,110,102,111,64,97,118,97,110,122,97,99,111,109,117,110,105,99,97,99,105,111,110,46,99,111,109];
var emailenc = '';
for (var i=0; i<email.length; i++) emailenc+=String.fromCharCode(email[i]);
