/**
 * @function 
 */

function printDiv(theDiv) {
	MyWin = window.open("","MyWin","scrollbars=no,resizable=no,toolbar=no,location=no,directories=no,status=no,menubar=no,width=700,height=600");
	with(MyWin.document){
		open();
		write("<html>\r\n<head>\r\n<title>Encorium</title>\r\r<link href='/resources/css/print.css' rel='stylesheet' type='text/css' media='print'>\r\n</head>\r\n<body onLoad='window.print();' marginwidth='0' marginheight='0' leftmargin='0' topmargin='0' rightmargin='0' style='background-color:#fff;' >\r\n");
		write("<img src='/resources/images/structure/logo.gif' /><br/><br/>");
		write(document.getElementById(theDiv).innerHTML+"\n");
		write("</body>\n</html>\n");
		close();
	}	
}

function printArticle(article_id) {

	var f = new Iframe();
 	writeDoc = f.doc;
	
	writeDoc.open();
    writeDoc.write('<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">\r\n<html><head>\r\n<title>Encorium</title>\r\n<link href="/resources/css/print.css" rel="stylesheet" type="text/css" media="print">\r\n</head><body><div id="printarea"></div></body></html>');
	writeDoc.close();
    
	$.get("/resources/ajax/getdata.php", { id: article_id }, function(data) { 
		writeDoc.getElementById("printarea").innerHTML = data;
	});
	
	f.contentWindow.focus();
    f.contentWindow.print();
}

function Iframe()
{
	var frameId = 'printArticle';
	var iframeStyle = 'border:0;position:absolute;width:0px;height:0px;left:0px;top:0px;';
	var iframe;
	
	try
	{
	    iframe = document.createElement('iframe');
	    document.body.appendChild(iframe);
	    $(iframe).attr({ style: iframeStyle, id: frameId, src: "" });
	    iframe.doc = null;
	    iframe.doc = iframe.contentDocument ? iframe.contentDocument : ( iframe.contentWindow ? iframe.contentWindow.document : iframe.document);
	}
	catch( e ) { throw e + ". iframes may not be supported in this browser."; }
	
	if ( iframe.doc == null ) throw "Cannot find document.";
	
	return iframe;
}

