﻿$(document).ready(function() {
    $('.header1').css('left', '-3000px');
    $('.twitter').css('left', '-3000px');
    $('.monitor').css('left', '-3000px');
    $('.boxes').css('left', '-3000px');
    $('.copy').css('left', '-3000px');
    $('.footer').css('left', '-3000px');
    $(window).resize(function() {
        posElements();
        $('#mensaje').center();
    });
    $('.defaultvalue').each(function() {
        var valor = $(this).attr('defaultvalue');
        $(this).val(valor);
    });
    $('.defaultvalue').focus(function() {
        if ($(this).val() == $(this).attr('defaultvalue'))
            $(this).val('');
    });
    $('.defaultvalue').blur(function() {
        if ($(this).val() == '')
            $(this).val($(this).attr('defaultvalue'));
    });
    $('#botNewsletter').click(function() {
        $('#f_newsletter').submit();
        return false;
    });
    $('#botLlamamos').click(function() {
        $('#f_llamamos').submit();
        return false;
    });
    $.validator.setDefaults({
        errorClass: 'error',
        errorElement: 'div'
    });
    $('#f_newsletter').validate();
    $('#f_newsletter').submit(function() {
        if ($(this).valid()) {
            $(this).ajaxSubmit({
                success: function(responseText) {
                    $('#mensaje .containermsg').html("<b>Gracias por registrarse.</b><br><br>Pronto recibirá información sobre los servicios de <b>Online Marketing.</b>");
                    alertar();
                    return false;
                }
            });
        }
        return false;
    });
    $('#f_llamamos').validate();

    $('#f_llamamos').submit(function() {
        if ($(this).valid()) {
            $(this).ajaxSubmit({
                success: function(responseText) {
                    $('#mensaje .containermsg').html("<b>Gracias por su interés.</b><br><br>En breve, nos pondremos en contacto con usted.");
                    alertar();
                    return false;
                }
            });
        }
        return false;
    });
    $(window).load(function() {
        $('#container_full').css('position', 'relative');
        $('#container_full').css('top', '0');
        $('#container_full').css('height', '85px');
        $('.navigation').show();
    });
});
function alertar()
{
	$('#mensaje').show();
	$('#mensaje').center();
}
jQuery.fn.center = function () { 
    this.css("position","absolute"); 
    this.css("top", ( $(window).height() - this.height() ) / 2+$(window).scrollTop() + "px"); 
    this.css("left", ( $(window).width() - this.width() ) / 2+$(window).scrollLeft() + "px"); 
    return this; 
}
$(document).click(function(){
	$('#mensaje').hide();	
});
function posElements() {
    var anchoContainer = 988;
    var anchoDocument = $(document).width();
    var incX = (anchoDocument - (anchoContainer + 20)) / 2;
    $('.header1').css('left', (incX + 776) + 'px');
    $('.twitter').css('left', (incX + 156) + 'px');
    $('.monitor').css('left', (incX + 836) + 'px');
    $('.boxes').css('left', (incX + 0) + 'px');
    $('.copy').css('left', (incX + 0) + 'px');
    $('.footer').css('left', (incX + 0) + 'px');
}
function finAnimacion() {
   posElements();
}

var y = 1800;
var timer;
function scrollit() {
    if (y > 0) {
        window.scroll(0, y);
        y = y - 10;
    } else {
        clearInterval(timer);
    }

}
function startit() {
    self.scroll(0, 1800);
    timer = setInterval("scrollit()", 10)
}


//$(window).load(startit);