$(document).ready(function(){
	if (navigator.AppName == "Netscape"){
		$.preloadCssImages();
	}
	
	$('.PopUp[href="#puHorarios"]').popuptool({
		leftPos: -580,
		topPos: -350,
		btnClose: '.BtnClose'
	});
	$('.PopUp[href="#puLlegar"]').popuptool({
		leftPos: -380,
		topPos: -350,
		btnClose: '.BtnClose'
	});
	$('.PopUp[href="#puPrint1"],.PopUp[href="#puPrint2"],.PopUp[href="#puPrint3"]').popuptool({
		leftPos: -300,
		topPos: -140,
		btnClose: '.BtnClose'
	});
	
	$('.IcoInfo[href="#puSeaRex1"]').popuptool({
		leftPos: -260,
		topPos: 30,
		btnClose: '.BtnClose'
	});
	
	$('.IcoInfo[href="#puNacidos1"]').popuptool({
		leftPos: -260,
		topPos: 30,
		btnClose: '.BtnClose'
	});
	
	$('.IcoInfo[href="#puNacidos2"]').popuptool({
		leftPos: -260,
		topPos: -100,
		btnClose: '.BtnClose'
	});
	
});

/*SCROLLS A HASHTAGS*/
$(document).ready(function(){
	$('a').click(function(e){
		//Revisar que el link inicie con un ancla y no con html para que si es un html con ancla no se bloquee
		//por el hecho de tender un ancla
		if ($(this).attr('href').substr(0, 1).indexOf("#") != -1){
			e.preventDefault();
			if ($(this).attr('href') != "#"){
				for (var a = 0; a < $('a').length; a++){
					if ($('a').eq(a).attr('name') == $(this).attr('href').substr(1)){
						var pos = $('a').eq(a).offset();
						$('html, body').animate({ 'scrollTop': pos.top + 'px' }, 500);
					}
				}
			} else {
				$('html, body').animate({ 'scrollTop': '0px' }, 500);
			}
		}
			
	});
});

/*FORM FUNCTIONS*/
function ClearRefillFields(){
	var ValoresInputsDefault = [];
	var ValoresTextAreaDefault = [];
	for (var a = 0; a < $('input[type="text"]').length; a++) {
		ValoresInputsDefault[(ValoresInputsDefault.length)] = $('input[type="text"]').eq(a).attr('value');
	}
	for (var a = 0; a < $('textarea').length; a++) {
		ValoresTextAreaDefault[(ValoresTextAreaDefault.length)] = $('textarea').eq(a).attr('value');
	}

	$('input[type="text"]').focus(function () {
		if ($(this).attr('value') == ValoresInputsDefault[$('input[type="text"]').index(this)]) $(this).attr('value', '');
		$('input[type="text"]').blur(function () {
			if ($(this).attr('value') == '') $(this).attr('value', ValoresInputsDefault[$('input[type="text"]').index(this)]);
		});
	});
	$('textarea').focus(function () {
		if ($(this).attr('value') == ValoresTextAreaDefault[$('textarea').index(this)]) $(this).attr('value', '');
		$('textarea').blur(function () {
			if ($(this).attr('value') == '') $(this).attr('value', ValoresTextAreaDefault[$('textarea').index(this)]);
		});
	});
}
