jQuery.noConflict();

jQuery(document).ready(function(){
	



(function($){
    $.fn.LightBox = function(params) {
        var _th = $(this);

        var _cf = $.extend({
            close:'',
            overLayer:'',
            opacity:1,
            ctLayer:'',
            ctInfo:'',
            onShow:''
        },params);

        this.each(function() {
            _cf.overLayer.css({
                'height':$(document).height(),
                'opacity':_cf.opacity
            });

            _th.click(function() {
                open();
                return false;
            });

            _cf.overLayer.click(function() {
                close();
                return false;
            });

            _cf.close.click(function() {
                close();
                return false;
            });
        });

        /**
         * Funciones
         */
        var open = function() {
            _cf.overLayer.fadeIn('fast',function() {
                _cf.ctLayer.fadeIn('fast',function() {
                    _cf.ctInfo.fadeIn();
                    _cf.ctInfo.find('#expMail').attr('disabled',false);
                    _cf.ctInfo.find('#expName').attr('disabled',false);
                    _cf.ctInfo.find('#expTema').attr('disabled',false);
                });
            });
            self.scrollTo(0,0);
        }

        var close = function() {
            _cf.ctInfo.fadeOut('fast', function() {
                _cf.ctLayer.fadeOut('fast',function() {
                    _cf.overLayer.fadeOut('fast');
                });
            });
        }
    };
})(jQuery);
	
	
	function setupLabel() {
     
        if (jQuery('.label_radio input').length) {
            jQuery('.label_radio').each(function(){ 
                jQuery(this).removeClass('r_on');
            });
            jQuery('.label_radio input:checked').each(function(){ 
                jQuery(this).parent('label').addClass('r_on');
            });
        };
    
	};
	
	
	
	
	

jQuery('a#sideBarTab').click();


var suscribe = jQuery('a#sideBarTab');
var suscribeCT = jQuery('div#suscribeLB');

suscribe.LightBox({
    overLayer:jQuery('div#overLB'),
    opacity:0.8,
    ctLayer:suscribeCT,
    ctInfo:suscribeCT.children(),
    close:jQuery('div#suscribeLB>a.close')
});





	
var container = jQuery('div.error');
	// validate the form when it is submitted
	var validator = jQuery("#suscribeContact").validate({
		errorContainer: container,
		errorLabelContainer: jQuery("ol", container),
		wrapper: 'li',
		meta: "validate",
		submitHandler: function(form) {
   			

				var dataSerializado = jQuery('#suscribeContact').serialize();
				var urlAEnviar = jQuery('#suscribeContact').attr('action');

	
				jQuery.ajax({
					type: 'POST',
					url: urlAEnviar,
					data: dataSerializado,
					success: function(data){	
					
					//alert(data);
						jQuery('#suscribeContact').html('<div id="mensajeExitoSuscripcion">Te has suscrito exitosamente a nuestro boletin.</div>');
					
					}
				});
	

	
   		}



	});



jQuery('.label_check, .label_radio').click(function(){
            setupLabel();
        });
        setupLabel(); 





 
});
