// <![CDATA[
	$(document).ready(
		function() {
			// opacity
			function opacity(element, value) {
				var value_noie = value / 100;
				$(element).css('filter', 'alpha(opacity=' + value + ')');
				$(element).css('-moz-opacity', value_noie);
				$(element).css('-khtml-opacity', value_noie);
				$(element).css('opacity',value_noie);
			}

			// center horizontally
			function centerHoriz(lo_que) {
				var x = parseFloat($(window).width()) / 2 - parseFloat($(lo_que).width()) / 2;
				var y = $(window).scrollTop() + $(window).height() / 2 - parseFloat($(lo_que).height()) / 2;
				x = x + 'px';
				y = y + 'px';
				$(lo_que).css({'left': x, 'top': y});
			}

			// center vertically
			function centerVert(lo_que) {
				var y = $(window).scrollTop() + $(window).height() / 2 - parseFloat($(lo_que).height()) / 2;
				$(lo_que).css({'top': y});
			}

			// no dotted outline for IE in As
			if ($.browser.msie) {
				$('a').focus(
					function() {
						$(this).blur()
					}
				);
			}

			// image load
			function loadImg(sID, sURL) {
				$(sID).unbind("load");
				$(sID).bind("load", function() {$(this).fadeIn();} )
				$(sID).stop(true, true).fadeOut("normal", function () {$(sID).attr('src', sURL);} );
			}

			// clear inputs
			var input_values = Array();
			$('input[type=text]').each(
				function() {
					input_values[$('input[type=text]').index(this)] = $(this).val();
				}
			);
			$('input[type=text]').focus(
				function() {
					if($(this).val() == input_values[$('input[type=text]').index(this)]) {
						$(this).val('');
					}
				}
			);
			$('input[type=text]').blur(
				function() {
					if($(this).val() == '') {
						$(this).val(input_values[$('input[type=text]').index(this)]);
					}
				}
			);
			// END DEFAULT //
			// lightbox
			function showLB() {
				$('#fonLB').css('width', $(window).width() + 'px');
				$('#fonLB').css('height', $(document).height() + 'px');
				
				opacity('#fonLB', 70);
				centerHoriz('#lb');
				
				$('#fonLB').fadeIn('normal', function() {$('#lb').fadeIn('normal');} );
			}
			function closeLB() {
				$('#lb').fadeOut('normal', function() {$('#fonLB').fadeOut('normal');} );
			}
			$('ul.ulQuienes li.comoLlegar div.link a').click(
				function() {
					showLB();
					$('.quieroSaberComoLlegar div.elMapa iframe').attr('src', $('.quieroSaberComoLlegar div.no').text());
					return false;
				}
			);
			/*
			$('ul.thumbsGal li a').click(
				function() {
					$(this).parent().addClass('on');
					loadImg('#imgLB', $(this).attr('href'));
					showLB();
					return false;
				}
			);
				*/
			$('ul.thumbsGal2 li a.puntitos').click(
				function() {
					$('ul.thumbsGal2 li').removeClass('active');
					$(this).parent().addClass('active');
					loadImg('#imgLB', $(this).attr('href'));
					showLB();
					return false;
				}
			);
			$('ul.thumbsGal2 li.anterior a').click(
				function() {
					$('ul.thumbsGal2 li.active').prev().find('a').click();
				}
			);
			$('ul.thumbsGal2 li.siguiente a').click(
				function() {
					$('ul.thumbsGal2 li.active').next().find('a').click();
				}
			);
			$('#fonLB, body#galeriaFotos #lb ul.megaPaginator li.cerrarLB img').click(
				function() {	
					closeLB();
					return false;
				}
			);
			$(window).scroll(
				function() {
					centerVert($('#lb'));
				}
			);
			function antSigLB(padonde) {
				var ul_gal = $('ul.thumbsGal');
				var li_on = $('ul.thumbsGal').find('li.on');
				var li_prox = null;
				
				if(padonde == 'sig') {
					li_prox = li_on.next();
					if(!li_prox.length) {
						li_prox = $('ul.thumbsGal').find('li:first');
					}
				}
				else {
					if(padonde == 'ant') {
						li_prox = li_on.prev();
						if(!li_prox.length) {
							li_prox = $('ul.thumbsGal').find('li:last');
						}
					}
				}
				
				loadImg('#imgLB', li_prox.find('a').attr('href'));
				li_on.removeClass('on');
				li_prox.addClass('on');
				
				return false;
			}
			$('body#galeriaFotos #lb ul.megaPaginator li.sig a').click(
				function() {
					antSigLB('sig');
					return false;
				}
			);
			$('body#galeriaFotos #lb ul.megaPaginator li.ant a').click(
				function() {
					antSigLB('ant');
					return false;
				}
			);
			/* styled checks */
			var alt_check = 11;
			/* CSS valid opacity */
			$('.check').css('filter', 'alpha(opacity=0)');
			$('.check').css('opacity', '0');
			/* already checked inputs */
			$('input.check:checked').parent().css({'background-position' : '0 -' + alt_check + 'px'});
			/* click */
			$('input.check').click(function() {
					if($(this).is(':checked')) {
						$(this).parent().css({'background-position' : '0 -' + alt_check + 'px'});
					}
					else {
						$(this).parent().css({'background-position' : '0 0'});
					}
				}
			);
			/* tooltips */
			var tt_x = 0;
			var tt_y = 0;
			var despl_tt_x = 0;
			var despl_tt_y = 31;
			var ancho_fuente = 5.5;
			var relleno_ttip = 15;
			if(is_IE6) {
				despl_tt_y = 34;
			}
			var fon_ttip = $('.ultraSuperTooltip').find('.fonTtip'); 
			function coordMouse() {
				$().mousemove(function(e){
					tt_x = e.pageX;
					tt_y = e.pageY;
				});
			}
			
			$('.tultipable').mouseenter(
				function() {
					var ttip = $(this).find('.ttip');
					$('.ultraSuperTooltip').width(ttip.text().length * ancho_fuente + relleno_ttip);
				}
			);
			$('.tultipable').mousemove(
				function() {
					var ttip = $(this).find('.ttip');
					coordMouse();
					fon_ttip.text(ttip.text());
					var medio_ancho = $('.ultraSuperTooltip').width() / 2;
					var despl_tt_x = medio_ancho;
					$('.tooltip .pico').css('left', (medio_ancho - $('.tooltip .pico').width() / 2) + 'px')
					$('.ultraSuperTooltip').css('left', tt_x - despl_tt_x);
					$('.ultraSuperTooltip').css('top', tt_y - despl_tt_y);
					$('.ultraSuperTooltip').show();
				},
				null
			);
			$('.tultipable').hover(
				function() {
					
				},
				function() {
					$('.ultraSuperTooltip').hide();
				}
			);
			/* styled selects */
		}
	);

	/* doesn't work in IE 6 */
	function hacerestilosenselect(){
		if (!($.browser.msie && $.browser.version == "6.0")) {
			$('.selectStyle').css('filter', 'alpha(opacity=0)');
			$('.selectStyle').css('opacity', '0');
			$('.selectStyle').change(function() {
				var the_option = $(this).children(":selected").text();
				$(this).parent().children('.spanStyle').text(the_option);
			});
			$('.spanStyle').each(
				function() {$(this).text($(this).parent().children('.selectStyle').children(':selected').text())}
			);
		}
	}
// ]]>
