// 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)
{
if (document.getElementById != null)
{
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="styles/fanatics.css" type="text/css" media="all" />';
html += '\n<title>Carvel</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="print_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 += 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

   }
