if (! PaginaPrinter) var PaginaPrinter = {};

PaginaPrinter.PrintFrame = function (id)
{
	var win;
	if (typeof(id) == "string")
		win = document.getElementById(id);
	else win = id;
		
	if (navigator.userAgent.indexOf("MSIE")>=0){
		PaginaPrinter.FocusAndPrint	(document[win.name]);
	}else{
		PaginaPrinter.FocusAndPrint	(window.frames[win.name]);
	}
}

PaginaPrinter.FocusAndPrint=function(obj){
	try{
		obj.focus();
		obj.print();
	}catch(err){}
}


PaginaPrinter.printContent=function(obj){
	if(typeof(obj) == "string")
		obj = document.getElementById(obj);
	
	var tmpid=null;
	do {tmpid = "if" + Math.round( Math.random() * 10000 );} while (document.getElementById(tmpid));
	
	ifr = document.createElement ("iframe");
	ifr.src="about:blank";
	ifr.style.position = "absolute";
	ifr.width=0;
	ifr.height=0;
	ifr.style.height = "0px";
	ifr.style.width = "0px";
	//ifr.style.visibility = "hidden";
	ifr.id = tmpid;
	ifr.name = tmpid;
	
	document.body.appendChild(ifr);

	var doc = ifr.contentWindow || ifr.contentDocument;
    if (doc.document) doc = doc.document;
	
	//doc.write('<html><head><title />');
	
	var styles = document.getElementsByTagName("link");
	for (var i=0; i<styles.length; i++)
		if(styles[i].getAttribute ("rel").toLowerCase() == "stylesheet")
			doc.write('<link href="'+styles[i].href+'" rel="stylesheet" type="text/css">');
	
	//doc.write('<style>body{background:none!important;}</style>');
	//doc.write('</head><body>');
	doc.write(obj.innerHTML);
	//doc.write('</body></html>');
	
	if(top.frames[tmpid]){
		top.frames[tmpid].focus();
		top.frames[tmpid].print();
	}else{
		document[tmpid].focus();
		document[tmpid].print();
	}
	ifr.parentNode.removeChild(ifr);
}