/**
 * Projeto
 * @author cleo47@gmail.com
 * data
 */


jQuery(function($) {

/*
 *	Menu
 */
var activePage = 'index.php';
 
jQuery("#menu").lavaLamp({
	fx: "backout", 
	speed: 700,
	click: function(event, menuItem) {
		_href = jQuery(this).find('a').attr('href');
		_gaq.push(['_trackPageview', _href]);
		if(_href == '/programacao.php'){
			programacaoLightbox();
		}
		else if(_href == 'blog'){
			parent.jQuery(document.body).append('<iframe width="100%" height="100%" frameborder="0" scrolling="auto" id="alley_blogframewrapper" style="height:100%; width:100%; position:absolute; top:0; left:0; z-index:10000; display:none;">');
			jQuery('iframe#alley_blogframewrapper').attr('src', 'http://www.alleyclub.com.br/'+_href);
			jQuery('iframe#alley_blogframewrapper').load(function(){
				jQuery('iframe#alley_blogframewrapper').fadeIn(750);
				parent.jQuery('#alley_framewrapper').fadeOut(500, parent.jQuery('#alley_framewrapper').remove());
				//console.log('framew remove');
			});
		}
		else if(activePage != _href){
			menuClick(_href);
		}
		return false;
	}
});

function menuClick(_href){
	activePage = _href;
	jQuery.ajax({ 
		url: _href, 
		success: function(data){
			_data = jQuery(data).find('#right-column').children();
			jQuery('#right-column').hide(300, function(){
				jQuery('#right-column').html(_data).show(300, function(){
					jQuery.getScript('js/'+_href+'.js');
				});
			})
		}
	  });
}

jQuery('#menu li.back')
		.ajaxStart(function(){
			//start loader animation
		})
		.ajaxStop(function(){
			//stop loader animation
		})

/*
 *	Shadowbox
 */ 
Shadowbox.init({
    skipSetup: true,
	handleOversize: "drag"
});

function programacaoLightbox(){
    Shadowbox.open({
        content:    'imgs/cartaz.jpg',
        player:     "img",
        title:      "Alley"
    });
};
 
/*
 *	Programacao-left-column
 */
jQuery('#cartaz').click(function(){
	programacaoLightbox();
	_gaq.push(['_trackPageview', 'programacao.php']);
})
 
/*
 *	Home Box Click
 */
jQuery("a#home-noites-link").live('click', function(){
	_href = jQuery(this).attr('href');
	menuClick(_href);
	return false;
});
	
//________________________________________________________________________.
});