
/* Setea el valor del input en el widget de contacto para que tenga un value por default pero se resetee al cliquear */
jQuery.fn.DefaultValue = function(text){
    return this.each(function(){ 
      if(this.type != 'text' && this.type != 'password' && this.type != 'textarea') return; var fld_current=this;
      if(this.value=='') {this.value=text;} else {return;}
      $(this).focus(function() {
            if(this.value==text || this.value=='')this.value='';$(this).css('color','#ADADAD')});
      $(this).blur(function() {
            if(this.value==text || this.value=='') this.value=text;$(this).css('color','#717274') });
      $(this).parents("form").each(function() {$(this).submit(function() {if(fld_current.value==text) {fld_current.value=''; }});});
    });
};

var ie6;

$(document).ready(function(){
    /* Carousel de clientes */
    $('#customers').jcarousel();
    $('#customers').css({border:'none', margin:'0', padding:'0', background:'none'}); 
    $('#customers li').css('margin','0 10px');   
    /* IE fix */
    $('.jcarousel-prev-horizontal').html('<div class="hbp"></div>'); 
    $('.jcarousel-next-horizontal').html('<div class="hbn"></div>'); 
     
    /* Bordes redondeados */
    DD_roundies.addRule('#control', '5px 5px 0 0', true);
    DD_roundies.addRule('.button', '5px', true);
    DD_roundies.addRule('#small-nav', '14px', true);
    DD_roundies.addRule('#sub-nav, #footer', '0 0 5px 5px', true);
    DD_roundies.addRule('input.text, select, textarea', '3px', true);
    DD_roundies.addRule('.button .icon', '5px 0 0 5px', true);
        
    /* Slideshow (Home page) (Fix para IE6 agragado a inerfade.js) */
    $('#homepage #header-image').innerfade({ speed: 600, timeout: 7000, type: 'sequence', containerheight: '350px' }); 
    $('#header-image img').removeAttr("alt"); /* Para prevenir que se muestre la etiqueta en IE  */
    
    $('#homepage #products-showcase').innerfade({speed: 600, timeout: 11000, type: 'sequence', containerheight: '10px' }); 
    //$('#homepage #products-showcase + .box').css('margin-left','319px'); 
    
    //$('#homepage #products-showcase .box:eq(0)').fadeOut('slow').fadeOut('slow')
    
    /* IE6 only */       
    if (ie6 == true) {
        /* PNGFix */   
        DD_belatedPNG.fix('.png, #main-content ul.images li .frame'); /* Add class="png" to the png images in the HTML*/
    }
    
    /* Customizacion para lista de imagenes (ubica la imagen a la izquierda y a la derecha) */
    $('#main-content ul.images > li:odd .content ').css("float","right") 
    $('#fast-contact.box form input.text').DefaultValue('Enter your email...');       
    
    /* Iconos Animadios (Homepage) */
    $('#homepage .box').bind("mouseenter",function(){
        $(this).children('img').stop().animate({ top: "5px"}, 200 ).animate({ top: "10px"}, 100 );
    }).bind("mouseleave",function(){
        $(this).children('img').stop().animate({ top: "19px"}, 200 );});

    $('a.follow-on-twitter').click(function(){
        pageTracker._trackPageview('/twitter');
    });
    
    /* Open new windows in a standards compliant way.
     * This might seem like cheating, but it isn't. :)
     * taken from http://www.sitepoint.com/article/standards-compliant-world/
     */
    $("a[rel='external']").each(function(){
        $(this).attr('target', '_blank');
    });
    
    /* Purposely targeting inputs because there might
     * be other elements with id="mailaddress", sigh...
     */
    $('input#mailaddress').focus(function(){
        var $this = $(this);
        $this.val() == 'Enter your email...' && $this.val('');
    }).blur(function(){
        var $this = $(this);
        $this.val() == '' && $this.val('Enter your email...');
    });
}); 
