var scroller,scroller2,scroller3,scrollbar4;
var scrollbar,scrollbar2,scrollbar3,scrollbar4;
$(function(){
   QueryLoader.selectorPreload = "body";
	QueryLoader.init();
	
	//$('a[rel=lightbox]').lightBox();
	//$(".tooltip").tipTip({maxWidth: "auto", edgeOffset: 10, defaultPosition:"top", delay:0, track:true});
	$('.tooltip').tooltip({track: true,delay: 0,showURL: false,showBody: " - ",fade: 250});
	
	$('.rollover').hover(function() {
        var currentImg = $(this).attr('src');
        $(this).attr('src', $(this).attr('hover'));
        $(this).attr('hover', currentImg);
    }, function() {
        var currentImg = $(this).attr('src');
        $(this).attr('src', $(this).attr('hover'));
        $(this).attr('hover', currentImg);
    });
	
	$('ul#home_gal').innerfade({
		speed: 'slow',
		timeout: 4000,
		type: 'sequence',
		containerheight: '303px'
	});
			
	scroller  = new jsScroller(document.getElementById("Scroller-1"), 430, 175);
	scrollbar = new jsScrollbar (document.getElementById("Scrollbar1-Container"), scroller, false);
			
	scroller2  = new jsScroller(document.getElementById("Scroller-2"), 440, 205);
	scrollbar2 = new jsScrollbar (document.getElementById("Scrollbar2-Container"), scroller2, false);
			
	scroller3  = new jsScroller(document.getElementById("Scroller-3"), 440, 205);
	scrollbar3 = new jsScrollbar (document.getElementById("Scrollbar3-Container"), scroller3, false);
			
	scroller4 = new jsScroller(document.getElementById("Scroller-4"), 470, 260);
	scrollbar4 = new jsScrollbar (document.getElementById("Scrollbar4-Container"), scroller4, false);
			
	setPos();
	$(window).bind('resize', function() { setPos(); });
			
	var option = {
		resizeLgImages: true,
		displayNav: true,
		handleUnsupported : 'remove',
		keysClose: ['c', 27], 
		players:  ['img', 'html', 'iframe', 'qt', 'wmp', 'swf', 'flv']
	};
	Shadowbox.init(option);
});
jQuery(function( $ ){
	seccsel("b_home");
	var $paneTarget = $('#contenido_c');
	
	$('#b_home').click(function(){
		$paneTarget.stop().scrollTo( '#s_home', 800 );
		seccsel("b_home");
	});
	$('#b_banda').click(function(){
		$paneTarget.stop().scrollTo( '#s_labanda', 800 );
		seccsel("b_banda");
	});
	$('#b_agenda').click(function(){
		$paneTarget.stop().scrollTo( '#s_agenda', 800 );
		seccsel("b_agenda");
	});
	$('#b_noti').click(function(){
		$paneTarget.stop().scrollTo( '#s_noticias', 800 );
		seccsel("b_noti");
	});
	$('#b_fotos').click(function(){
		$paneTarget.stop().scrollTo( '#s_fotos', 800 );
		seccsel("b_fotos");
	});
	$('#b_deja').click(function(){
		$paneTarget.stop().scrollTo( '#s_deja', 800 );
		seccsel("b_deja");
	});
	$('#b_contacto').click(function(){
		$paneTarget.stop().scrollTo( '#s_contacto', 800 );
		seccsel("");
		_contacto_clear();
	});
	
	$('#b_contacto2').click(function(){
		$paneTarget.stop().scrollTo( '#s_mensaje', 800 );
		_contacto_clear();
	});
});

function seccsel(q) {
	document.getElementById("b_home").className="";
	document.getElementById("b_banda").className="";
	document.getElementById("b_agenda").className="";
	document.getElementById("b_noti").className="";
	document.getElementById("b_fotos").className="";
	document.getElementById("b_deja").className="";	
	
	if(q!="") document.getElementById(q).className="sel";
}
function setPos() {
	var w1=$('#csc').innerWidth();
	var ws=getwSize();
	var wt=w1;
	var xf,x;
	//if(ws[0]<wt) {
		xf=Math.floor((ws[0]-wt)/2);
		//document.getElementById("scrollc").style.left=xf+"px";
		window.scroll(Math.abs(xf),0);
	//}
	
	var w1=$('#csc').innerWidth();
	var w2=$('#scrollc').innerWidth();
	if(w1<w2) {
		$('#csc').scrollTo(Math.floor((w2-w1)/2),0);
	}
}
function getwSize() {
  var myWidth = 0, myHeight = 0;
  if( typeof( window.innerWidth ) == 'number' ) {
    myWidth = window.innerWidth;
    myHeight = window.innerHeight;
  } else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
    myWidth = document.documentElement.clientWidth;
    myHeight = document.documentElement.clientHeight;
  } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
    myWidth = document.body.clientWidth;
    myHeight = document.body.clientHeight;
  }
  return [myWidth,myHeight];
}
function _contacto_clear() {
	var f=document.fcont;
	f.nombre.value="";
	f.email.value="";
	f.telefono.value="";
	f.mensaje.value="";
	
	f=document.fcont2;
	f.nombre.value="";
	f.email.value="";
	f.telefono.value="";
	f.mensaje.value="";
}
