// JavaScript Document

$(document).ready(function() {
	//Fade in the Popup and add close button
	$('#loader').fadeIn('slow').css({ 'width': Number( 550 ) }).prepend('<a href="#" class="close"><img src="img/close_pop.png" class="btn_close" title="Cerrar Ventana" alt="Cerrar" /></a>');
	
		//Define margin for center alignment (vertical   horizontal) - we add 80px to the height/width to accomodate for the padding  and border width defined in the css
		var popMargTop = (400) / 2;
		var popMargLeft = ($('#loader').width() + 80) / 2;
	
		//Apply Margin to Popup
		$('#loader').css({
			'margin-top' : -popMargTop,
			'margin-left' : -popMargLeft
		});
	
		//Fade in Background
		$('body').append('<div id="fade-index"></div>'); //Add the fade layer to bottom of the body tag.
		$('#fade-index').css({'filter' : 'alpha(opacity=90)'}).fadeIn(); //Fade in the fade layer - .css({'filter' : 'alpha(opacity=80)'}) is used to fix the IE Bug on fading transparencies 

		//Close Popups and Fade Layer
		$('a.close, #fade-index').live('click', function() { //When clicking on the close or fade layer...
			$('#fade-index , .popup_block').fadeOut(function() {
				$('#fade-index, a.close').remove();  //fade them both out
			});
			return false;
		});
		
	});
