function openPop(content)
{
	var w = $(document).width();
	var h = $(document).height();
	$('#black').css({width:w+"px", height:h+"px", opacity:0.3, filter:"alpha(opacity=30)", display:"block", zIndex:999});
	$('#white').html(content);
    
    var hW = $('#white').height();
    
    
   // $('#white').css({"margin-top": -(hW/2) + "px"});
        
        ScrollModal();
	$('#white').fadeIn(500);
	
        $(window).bind('scroll', ScrollModal);

	$('#black').click(function(){
		closePop();
	});
}

function ScrollModal()
{
	var modal = $('#white');
	var wm = modal.height();
        
	var to = {};
	
        var view = [$(window).height(), $(document).scrollTop()];
        
	to.top	= Math.ceil(view[1] + ((view[0]/2) - (wm/2)));
	
	modal.css(to);
}


function closePop()
{
	$("#xxx").val("");
	$('#black').fadeOut(500);
	$('#white').fadeOut(500);
}



/*Print*/
var iframe;
var html_print;
jQuery.jPrintArea=function(el) 
{ 
iframe=document.createElement('IFRAME'); 
var doc=null; 
//$(iframe).attr('style','width:800px;height:600px;left:0px;top:0px;'); 
$(iframe).attr('style','position:absolute;top:-200px; width:0px;height:0px;'); 
document.body.appendChild(iframe); 
doc=iframe.contentWindow.document; 
var links=window.document.getElementsByTagName('link'); 
for(var i=0;i<links.length;i++) 
if(links[i].rel.toLowerCase()=='stylesheet') 
doc.write('<html><head><link type="text/css" rel="stylesheet" href="'+links[i].href+'"></link>'); 
doc.write('<link href="../css/style.css"  media="print" rel="stylesheet" type="text/css" /></head><body>    '); 
$(el).each(function(i){
	doc.write('<div class="'+$(this).attr('class')+'">'+$(this).html()+'</div>'); 
});
//doc.write('<div class="'+$(el).attr("class")+'">'+$(el).html()+'</div>'); 
doc.write('</body></html>');
doc.close(); 
iframe.contentWindow.focus(); 
iframe.contentWindow.print(); 
//alert('Printing...'); thanks alex 
//wait(1); 
var t = setTimeout("document.body.removeChild(iframe)",50000);
}

function AggPreferiti(){
	if (window.sidebar) {
		   // versione FF
		   window.sidebar.addPanel(document.title, location.href,'');
	} else if( window.external ) {
	    // versione IE
	    window.external.AddFavorite( location.href, document.title); 
	}
}
