/* Javascript document created by 2CODE Web Development - www.2code.co */
$(document).ready(function(){
	//$('html, body').animate({	scrollLeft: (2070) }, 5000).animate({	scrollLeft: (0) }, 2000);
	$('.lightbox').lightbox();
	/*- Smooth scrolling -*/
	$('#gato-menu ul li a').click(function(e){
		var scrollAnchor = $(this).attr('href');
		e.preventDefault();
		$('html, body').animate({
			scrollLeft: ($(scrollAnchor).offset().left)-600
		}, 1000);
	});
	//Tooltips
	var tip = '';
	$(".tooltip").hover(function(){

		//Caching the tooltip and removing it from container; then appending it to the body
		tip = $(this).find('.tip').remove();
		$('body').append(tip);

		tip.fadeIn('fast'); //Show tooltip

	}, function() {

		tip.hide().remove(); //Hide and remove tooltip appended to the body
		$(this).append(tip); //Return the tooltip to its original position

	}).mousemove(function(e) {
	//console.log(e.pageX)
		  var mousex = e.pageX - 130; //Get X coodrinates
		  var mousey = e.pageY + 20; //Get Y coordinates
		  var tipWidth = tip.width(); //Find width of tooltip
		  var tipHeight = tip.height(); //Find height of tooltip

		 //Distance of element from the right edge of viewport
		  var tipVisX = $(window).width() - (mousex + tipWidth);
		  var tipVisY = $(window).height() - (mousey + tipHeight);

		if ( tipVisX < 20 ) { //If tooltip exceeds the X coordinate of viewport
			mousex = e.pageX - tipWidth + 20;
			$(this).find('.tip').css({  top: mousey, left: mousex });
		} if ( tipVisY < 20 ) { //If tooltip exceeds the Y coordinate of viewport
			mousey = e.pageY - tipHeight - 40;
			tip.css({  top: mousey, left: mousex });
		} else {
			tip.css({  top: mousey, left: mousex });
		}
	});
	//Finaliza Tooltips
	//Scroll Lateral
	$('.arrow a').mouseover(function(e){
		var scrollAnchor = $(this).attr('rel');
		e.preventDefault();
		$('html, body').animate({	scrollLeft: ($(scrollAnchor).offset().left) }, 2000);
	});
	$('.arrow a').mouseout(function(){
		$('html, body').stop();
	});
});
//Inserción de Animaciones
//Revista
var flashvars = {};
var params = {};
params.wmode = "transparent";
var attributes = {};
swfobject.embedSWF("anim/puerta.swf", "puerta", "108", "210", "10.0.0", "anim/expressInstall.swf", flashvars, params, attributes);
//Pub
var flashvars = {};
var params = {};
params.wmode = "transparent";
var attributes = {};
swfobject.embedSWF("anim/pub.swf", "pub", "138", "80", "10.0.0", "anim/expressInstall.swf", flashvars, params, attributes);
//Aviso Musical
var flashvars = {};
var params = {};
params.wmode = "transparent";
var attributes = {};
swfobject.embedSWF("anim/aviso.swf", "aviso-musical", "271", "180", "10.0.0", "anim/expressInstall.swf", flashvars, params, attributes);
//Gato
var flashvars = {};
var params = {};
params.wmode = "transparent";
var attributes = {};
swfobject.embedSWF("anim/gato.swf", "gato", "75", "50", "10.0.0", "anim/expressInstall.swf", flashvars, params, attributes);
//Cielo
var flashvars = {};
var params = {};
params.wmode = "transparent";
var attributes = {};
swfobject.embedSWF("anim/sky.swf", "cielo", "3070", "360", "10.0.0", "anim/expressInstall.swf", flashvars, params, attributes);
//Finaliza la Inserción de Animaciones
//Lightbox
function abrirSeccion(seccion, w, h){
	$.lightbox(seccion+".php", {
        'width'       : w,
        'height'      : h,
        'autoresize'  : false
      });
}
//Analytics
var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));
try {
var pageTracker = _gat._getTracker("UA-8527771-1");
pageTracker._trackPageview();
} catch(err) {}
