

/** carga inicial **********************************************/
$(document).ready(function(){

	/** Roundies **/
	// Firefox, chrome, safari
	DD_roundies.addRule('#popup, .menu a', '10px', true);
	// IE
	$('#popup, .menu a').css({'border-radius': '10px'});
	
});
 
// evitamos que las llamadas ajax hagan cache
$.ajaxSetup ({  
    cache: false
}); 




/** popup tipo lightbox ****************************************/

function loadPopup()
{

	oh = $(document).height();
	ow = $(document).width();
	
	$('<div />').attr('id', 'overlay').css({
		'display': 'none',
		'position': 'absolute',
		'top': '0px',
		'left': '0px',
		'width': ow + 'px',
		'height': oh + 'px',
		'opacity': '0',
		'z-index': '1005',
		'background':'black'
	}).appendTo('body').show();
	
	$('#overlay').animate({'opacity': '0.55'}, 200, function(){

		var os = $(window).scrollTop();
		var w = 130;
		var h = 130;
		
		var x = (($(window).width() + w) / 2 ) - w;
		var y = (($(window).height() + h) / 2 ) - h;
		
		$('<div />').attr('id', 'popup').css({
			'display': 'none',
			'color': '#fff',
			'font-size': '20px',
			'position': 'absolute',
			'top': y + os + 'px',
			'left': x + 'px',
			'width': w + 'px',
			'height': h + 'px',
			'background':'url(datos/imagenes/bg.png) 0 0 repeat',
			'z-index': '1020',
			'border-radius': '5px'			
		}).appendTo('body').show();
		
		$('#popup').html("<img src='" + URL + "datos/imagenes/bload.gif' border='0' width='100' height='100' style='margin: 15px;' />");
	});
	
}

function infoPopup(html, w, h)
{

	$('#popup').html("");
	
	w += 40;
	h += 80;
	
	var os = $(window).scrollTop();
	
	var px = (($(window).width() + w) / 2 ) - w;
	var py = (($(window).height() + h) / 2 ) - h;

	$('#popup').animate({'width': w + 'px', 'left': px, 'height': h + 'px', 'top': py + os}, 300, 'linear', function(){
	
		var w = $('#popup').width() - 40;
		var h = $('#popup').height() - 80;

		var info = "" +
		"<div id='info' style='width:" + (w - 20) + "px; height:" + (h - 20) + "px;'>" + html  + "</div>";

		var footer = "" +
		"<div class='footer' style='width:" + w + "px;'>" +
			"<a href='javascript:void(0);' class='aceptar'><span class='button'>Cerrar</span></a>" +
		"</div>";
		
		$('#popup').html(info + footer);

	});
	
}



function loadInfoPopup(html, w, h)
{

	oh = $(document).height();
	ow = $(document).width();
	
	$('<div />').attr('id', 'overlay').css({
		'display': 'none',
		'position': 'absolute',
		'top': '0px',
		'left': '0px',
		'width': ow + 'px',
		'height': oh + 'px',
		'opacity': '0.55',
		'z-index': '1005',
		'background':'black'
	}).appendTo('body').show();

	var os = $(window).scrollTop();
	w += 40;
	h += 80;
	
	var x = (($(window).width() + w) / 2 ) - w;
	var y = (($(window).height() + h) / 2 ) - h;
	
	var px = (($(window).width() + w) / 2 ) - w;
	var py = (($(window).height() + h) / 2 ) - h;

	$('<div />').attr('id', 'popup').css({
		'display': 'none',
		'color': '#fff',
		'font-size': '20px',
		'position': 'absolute',
		'top': py + os + 'px',
		'left': px + 'px',
		'width': w + 'px',
		'height': h + 'px',
		'background':'url(datos/imagenes/bg.png) 0 0 repeat',
		'z-index': '1020',
		'border-radius': '5px'			
	}).appendTo('body').show();
	
	w -= 40;
	h -= 80;

	var info = "" +
	"<div id='info' style='width:" + (w - 20) + "px; height:" + (h - 20) + "px;'>" + html  + "</div>";

	var footer = "" +
	"<div class='pfooter' style='width:" + w + "px;'>" +
		"<a href='javascript:void(0);' class='aceptar'><span class='button'>Cerrar</span></a>" +
	"</div>";
	
	$('#popup').html(info + footer);
	
}




$('#popup .pfooter a.aceptar').live('click', function() {
	unpop();
});


function unpop()
{
	$('#popup').remove();
	$('#overlay').remove();
	$('#fd-date').remove();
}


