///////////////////////  DOCUMENT READY  //////////////////////////////

jQuery(document).ready(function() { //on DOM ready
	sectionSize();	
	vamos();
	hovering();
	horizScroll();
	exhibiciones();
});

///////////////////////  SECTION SIZE  //////////////////////////////


function sectionSize() {
	var availH = jQuery(window).height();
	var Margines = (jQuery(window).width() - '850') / '2';
	jQuery('.seccion').css('height', availH);
	jQuery('.jspPane').css('height', availH);
	jQuery('#inicio').css('margin-left', Margines);
	jQuery('#entrada').css('margin-top', (availH / '2')+'px');
	jQuery('.prev').css('height', availH);
	jQuery('.next').css('height', availH);
	jQuery('.prev').css('width', Margines);
	jQuery('.next').css('width', Margines);
}

///////////////////////  SCROLL TO  //////////////////////////////

function vamos() {
	var paneTarget = jQuery('#mask');
	var Margines2 = (jQuery(window).width() - '850') / '2';
	var introPos = (jQuery('#intro').offset().left) - Margines2;
	var exhibicionesPos = (jQuery('#exhibiciones').offset().left) - Margines2;
	var conciertosPos = (jQuery('#conciertos').offset().left) - Margines2;
	var coloquioPos = (jQuery('#coloquio').offset().left) - Margines2;
	var talleresPos = (jQuery('#talleres').offset().left) - Margines2;
	var feriaPos = (jQuery('#feria').offset().left) - Margines2;
	var downeyPos = (jQuery('#downey').offset().left) - Margines2;
	var creditosPos = (jQuery('#creditos').offset().left) - Margines2;
	
	jQuery('a.iniciar').click(function(){
		paneTarget.stop().scrollTo(introPos, 700);
		return false;
	});
	jQuery('a.iniciar').click(function(){
		paneTarget.stop().scrollTo(introPos, 700);
		return false;
	});
	jQuery('#entrada a').click(function(){
		paneTarget.stop().scrollTo(introPos, 700);
		return false;
	});
	jQuery('#uno a').click(function(){
		paneTarget.stop().scrollTo(exhibicionesPos, 700);
		return false;
	});
	jQuery('#dos a').click(function(){
		paneTarget.stop().scrollTo(conciertosPos, 700);
		return false;
	});
	jQuery('#tres a').click(function(){
		paneTarget.stop().scrollTo(coloquioPos, 700);
		return false;
	});
	jQuery('#cuatro a').click(function(){
		paneTarget.stop().scrollTo(talleresPos, 700);
		return false;
	});
	jQuery('#cinco a').click(function(){
		paneTarget.stop().scrollTo(feriaPos, 700);
		return false;
	});
	jQuery('#seis a').click(function(){
		paneTarget.stop().scrollTo(downeyPos, 700);
		return false;
	});
	jQuery('a.a_creditos').click(function(){
		paneTarget.stop().scrollTo(creditosPos, 700);
		return false;
	});
	return false;
	
}

///////////////////////  HOVER  //////////////////////////////

function hovering() {
	jQuery('.boton').append('<div class="bot_title hover"></div>');
	jQuery('.boton a.active').parent().find('.bot_title').remove('.hover');
	jQuery('#uno a').mouseover(function(){
		jQuery(this).parent().find('.hover').html('Exhibiciones');
	}).mouseout(function(){
		jQuery(this).parent().find('.hover').html('');
	});
	jQuery('#dos a').mouseover(function(){
		jQuery(this).parent().find('.hover').html('Conciertos Audiovisuales');
	}).mouseout(function(){
		jQuery(this).parent().find('.hover').html('');
	});
	jQuery('#tres a').mouseover(function(){
		jQuery(this).parent().find('.hover').html('Coloquio Internacional');
	}).mouseout(function(){
		jQuery(this).parent().find('.hover').html('');
	});
	jQuery('#cuatro a').mouseover(function(){
		jQuery(this).parent().find('.hover').html('Talleres de Formaci&oacute;n y Producci&oacute;n');
	}).mouseout(function(){
		jQuery(this).parent().find('.hover').html('');
	});
	jQuery('#cinco a').mouseover(function(){
		jQuery(this).parent().find('.hover').html('Feria Libre de Industrias Creativas');
	}).mouseout(function(){
		jQuery(this).parent().find('.hover').html('');
	});
	jQuery('#seis a').mouseover(function(){
		jQuery(this).parent().find('.hover').html('Concurso y Premio Nacional de Artes Mediales<br/> Juan Downey');
	}).mouseout(function(){
		jQuery(this).parent().find('.hover').html('');
	});
}

////////////////////////  HORIZONTAL SCROLL  ////////////////
function horizScroll() {
	jQuery('.scroll-pane').jScrollPane(
		{
			showArrows: true,
			arrowScrollOnHover: true,
			autoReinitialise: true,
			verticalDragMinHeight:10,
			verticalDragMaxHeight:10,
			clickOnTrack:false
		}
	);
	var availH = jQuery(window).height();
	jQuery('.jspPane').css('min-height', availH);
};

////////////////////////  HORIZONTAL SCROLL  ////////////////

function exhibiciones() {
	jQuery('.sub_exhibiciones a.one').click(function(){
		jQuery('#curatoria').fadeIn();
		jQuery('.subseccion').not('#curatoria').fadeOut();
	})
	jQuery('.sub_exhibiciones a.two').click(function(){
		jQuery('#wolf').fadeIn();
		jQuery('.subseccion').not('#wolf').fadeOut();
	})
	jQuery('.sub_exhibiciones a.three').click(function(){
		jQuery('#nbk').fadeIn();
		jQuery('.subseccion').not('#nbk').fadeOut();
	})
	jQuery('.sub_exhibiciones a.four').click(function(){
		jQuery('#retro').fadeIn();
		jQuery('.subseccion').not('#retro').fadeOut();
	})
	jQuery('.sub_exhibiciones a.five').click(function(){
		jQuery('#juan').fadeIn();
		jQuery('.subseccion').not('#juan').fadeOut();
	})
}



////////////////////////  WINDOW RESIZE  ////////////////

jQuery(window).resize(function() {
	sectionSize();	
	vamos();
});
