$(document).ready(function() {
	var control = 0;
	window.setInterval(function() {
		if( control == 0 ) {
			$('#image01').fadeOut('slow');
			$('#image02').fadeIn('slow');
			control = 1 ;
		} else {
			$('#image02').fadeOut('slow');
			$('#image01').fadeIn('slow');
			control = 0 ;
		}
	}, 3000);

	$('#globe-open').click(function() {
		$('#globe').fadeIn('fast');
		var aux = 1;
		return false;
	});

	$('#globe-close').click(function() {
		$('#globe').fadeOut('fast');
		return false;
	});
	$("#lnkGallery").click(function () {
		$.ajax({
			type		: "POST",
			cache	: false,
			url		: this.href,
			data		: $(this).serializeArray(),
			success: function(data) {
				data = eval(data);
				imgs = [];
				for (idx = 0; idx < data.length; idx++) {
					imgs[idx] = document.createElement("img");
					imgs[idx].src = data[idx].path;
					imgs[idx].alt = data[idx].description;
				}
				$.fancybox(imgs);
			}
		});
		return false;
	});
	$("#lnkVideo").click(function() {
		$.fancybox({
			'padding'		: 0,
			'autoScale'		: false,
			'transitionIn'	: 'none',
			'transitionOut'	: 'none',
			'title'			: this.title,
			'width'			: 680,
			'height'		: 495,
			'href'			: this.href.replace(new RegExp("watch\\?v=", "i"), 'v/'),
			'type'			: 'swf',
			'swf'			: {
				'wmode'		: 'transparent',
				'allowfullscreen'	: 'true'
			}
		});

		return false;
	});

	$('#frmNewsLetter').ajaxForm({
		success: function (response) {
			eval('data = ' + response);
			msg = '<label style="color: green;">Gracias por registrarse</label>\n';
			if (data.error == true) {
				msg = '';
				for (idx = 0; idx < data.errorMsg.length; idx++) {
					msg += '<label class="error" style="color: red;">' + data.errorMsg[idx] + '</label>\n';
				}
			}
			$.fancybox(msg);
		}
	});
});

