// <![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]').not('#fijo').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 //
			/* styled selects */
			/* doesn't work in IE 6 */
			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())}
				);
			}
			/* styled radio buttons */
			/* already checked radio buttons */
			var alt_radio = $('.spanRadio').css('height');
			$(".spanRadio input[type=radio]:checked").each(
				function() {
					$(this).parent().css({'background-position' : '0 -' + alt_radio});
				}
			);
			/* CSS valid opacity */
			$('.spanRadio input').css('filter', 'alpha(opacity=0)');
			$('.spanRadio input').css('opacity', '0');
			$(".spanRadio input[type=radio]").click(function() {
					var its_name = $(this).attr('name');
					$("input[name=" + its_name + "]").parent().css({'background-position' : '0 0'});
					$(this).parent().css({'background-position' : '0 -' + alt_radio});
				}
			);
			/* styled checks */
			var alt_check = $('input.check').css('height');
			/* 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});
			/* click */
			$('input.check').click(function() {
					if($(this).is(':checked')) {
						$(this).parent().css({'background-position' : '0 -' + alt_check});
					}
					else {
						$(this).parent().css({'background-position' : '0 0'});
					}
				}
			);
			// lightbox
			function showLB() {
				if(is_IE8) {
					$('#fonLB').css('width', ($(window).width() - 1) + 'px');
					$('#fonLB').css('height', ($(document).height() - 5) + 'px');	
				}
				else { 
					$('#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() {$('#scrollTextoLb').jScrollPane({showArrows:true});});} );
				$('#fonLB').show();
				$('#lb').show();
			}
			
			function showLBhaze() {
				if(is_IE8) {
					$('#fonLB2').css('width', ($(window).width() - 1) + 'px');
					$('#fonLB2').css('height', ($(document).height() - 5) + 'px');	
				}
				else { 
					$('#fonLB2').css('width', $(window).width() + 'px');
					$('#fonLB2').css('height', $(document).height() + 'px');
				}
				
				opacity('#fonLB2', 70);
				centerHoriz('#hazeLB');
				
				//$('#fonLB').fadeIn('normal', function() {$('#lb').fadeIn('normal', function() {$('#scrollTextoLb').jScrollPane({showArrows:true});});} );
				$('#fonLB2').show();
				$('#hazeLB').show();
			}
			
			function closeLB() {
				//$('#lb').fadeOut('normal', function() {$('#fonLB').fadeOut('normal');} );
				$('#lb, #hazeLB').hide();
				$('#fonLB, #fonLB2').hide();
			}
			
			$('a#aBases').click(
				function() {	
					showLB();
					return false;
				}
			);
			
			$('a#aHaze').click(
				function() {	
					showLBhaze();
					return false;
				}
			);
						
			$('#fonLB, #fonLB2, .lbBases .cerrarLb img').click(
				function() {
					closeLB();
					return false;
				}
			);
			$(window).scroll(
				function() {
					if($('#lb').is(':visible')) {
						centerVert($('#lb'));
					}
				}
			);
			$(window).scroll(
				function() {
					if($('#hazeLB').is(':visible')) {
						centerVert($('#hazeLB'));
					}
				}
			);

			$('.btnCaptcha').click(
				function(){
					captchaImg =  $('#captchaImg');
              captchaImg.attr('src', captchaImg.attr('rel') + '?time=' +  getRandomInt(999, 99999999));
				});

			function getRandomInt(min, max) {
				return Math.floor(Math.random() * (max - min + 1)) + min;
			}

		}
	);
// ]]>
