// fAutoPrint = Flag for whether or not to automatically call the print function
// sPrintDiv =  main div to print
//  sAdDiv = advertisement to print

function printSpecial(fAutoPrint, sPrintDiv, sAdDiv)
{
if (document.getElementById != null)
{
var adReadyElem = document.getElementById(sAdDiv);
var printReadyElem = document.getElementById(sPrintDiv);

var html = '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">';
html += '\n<html xmlns="http://www.w3.org/1999/xhtml">';
html += '\n<HEAD>';
html += '\n<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>';
html += '\n<link rel="stylesheet" href="/css/print.css" type="text/css" media="all" />';
html += '\n<title>Arthritis Today</title>';
html += '\n</HE' + 'AD>';
html += '\n<BODY style="background-color:#ffffff;background-image:none;">\n';

if (printReadyElem == null)
{
alert("Could not find the printReady section in the HTML");
return;
}

html += '\n<div id="article-text">';

html += '\n<div id="print_help">';
html += '\nHaving trouble printing? <a href="#" onclick="window.print();return false;">Click here.</a>';
html += '\n</div>';

html += '\n<div id="top-ad">ADVERTISEMENT<BR>';
//html += adReadyElem.innerHTML;


html += '\n<!--JavaScript Tag // Tag for network 5125: Arthritis Today // Website: Arthritis Today 2009 // Page: Print this page // Placement: Print This Page-Right-300 x 250 (620376) // created at: Dec 15, 2008 5:29:15 PM-->'
html += '\n<script language="javascript"><!--'
html += '\ndocument.write('
html += "'<scr'+'ipt language=\"javascript1.1\" src=\"http://adserver.adtechus.com/addyn/3.0/5125/620376/0/170/ADTECH;loc=100;target=_blank;misc='+new Date().getTime()+'\"></scri'+'pt>'"
html += ');'
html += '\n//-->'
html += '\n</script><noscript><a href="http://adserver.adtechus.com/adlink/3.0/5125/620376/0/170/ADTECH;loc=300" target="_blank"><img src="http://adserver.adtechus.com/adserv/3.0/5125/620376/0/170/ADTECH;loc=300" border="0" width="300" height="250"></a></noscript>'
html += '\n<!-- End of JavaScript Tag -->'
//html += '<script language="javascript1.1" src="http://adserver.adtechus.com/addyn/3.0/5125/620376/0/170/ADTECH;loc=100;target=_blank;misc='+new Date().getTime()+'"></script>'


html += '\n</div>';

html += '\n<div style="margin-bottom: 40px;">';
html += '\n<img src="/images/printlogo.gif" alt="" /><br />www.ArthritisToday.org';
html += '\n</div>';


html += printReadyElem.innerHTML;
html += '\n</div>';


var version=msieversion();

if ( version > 0 && version <= 7 ) {

html += '\n<script>window.print();</script>';

}

html += '\n</BO' + 'DY>\n</HT' + 'ML>';


var printWin = window.open("","_blank");
printWin.document.open();
printWin.document.write(html);
printWin.document.close();


if ( version > 0 && version <= 7 ) {
      printWin.location.reload(false);
} else {

printWin.print();
}



var links = printWin.document.getElementsByTagName("a");
var i;

/*
for (i=0;i<links.length;i++)
{
//links[i].parentNode.innerHTML=links[i].innerHTML;
txt = links[i].innerHTML;
links[i].parentNode.insertBefore(document.createTextNode(txt),
links[i]);
links[i].parentNode.removeChild(links[i]);
i--;
}
*/

//if (fAutoPrint == true)
//printWin.print();

}
else
{
alert("Sorry, the print ready feature is only available in modern browsers.");
}

}

function doPrint (printWin) {
printWin.print();
}

   function msieversion()
   {
      var ua = window.navigator.userAgent
      var msie = ua.indexOf ( "MSIE " )

      if ( msie > 0 )      // If Internet Explorer, return version number
         return parseInt (ua.substring (msie+5, ua.indexOf (".", msie )))
      else                 // If another browser, return 0
         return -1

   }