// browser sniffer
//to use this function you need to link to it with <script language="javascript">createPrintButton()</script>
//and include  custom_print('1,'1') in the body onload.  If the graph doesn't print, increase the two numbers in the function. default 1 for ie and 1 for ns.
//I found on some machines nn4.0-4.08 would not show the graph at all.  This however I believe was due to them not having enough java support.  I have thus built this to work for this browser as I know when set up correctly it can print the graph.
agt = navigator.userAgent.toLowerCase();
verReal = navigator.appVersion;
ver = parseInt(verReal);
app = navigator.appName.toLowerCase();
ie = (agt.indexOf('msie') != -1 || agt.indexOf('microsoft') != -1)?1:0;
ns = (agt.indexOf('netscape') != -1 || app.indexOf('netscape') != -1)?1:0;
ie4 = (ie && ver==4 && !(agt.indexOf('msie 5')!=-1))?1:0;
ie5 = (ie && (ver==5 || agt.indexOf('msie 5')!=-1))?1:0;
ie6 = (ie && ver==6)?1:0;
ns4 = (ns && ver==4)?1:0;
ns6 =(ns && ver==5)?1:0
win = (agt.indexOf('win')!=-1)?1:0
mac=(agt.indexOf('mac')!=-1)?1:0
//--end browser sniffer.
//-phils browser sniff for full version.
if(ie){
  var splitAgtArray = agt.split('msie');
  var getFloatVerArray = splitAgtArray[1].split(';');
  verFloat = getFloatVerArray[0]
}
if(ns && ver<5){
  var splitAgtArray = verReal.split('[');
  verFloat = splitAgtArray[0]
  positionSpace = verFloat.indexOf(' ');
  if (positionSpace != -1){
    verFloat = verFloat.substring(0,positionSpace);
  }
}
if(ns6){
  var splitAgtArray = agt.split('netscape6/');
  verFloat = splitAgtArray[1]
}
//dont know about higher versions of ns than 6.**
//-end phils browser sniff
function printgraph() {
    if(ie && verFloat < 5.0){
        alert('you are useing ' + app + ' ' + verFloat + '.  I am sorry but this graph cannot be printed with this browser.  Please upgrade to the new version of Internet Explorer.  This can be downloaded from www.microsoft.com/windows/ie');
    } 
    if(ns6){
        alert('you are useing ' + app + ' ' + verFloat + '.  I am sorry but this graph cannot be viewed or printed with this browser.  Please upgrade to the new version of Internet Explorer.    This can be downloaded from www.microsoft.com/windows/ie');
    }
    if  (ie && verFloat >= 5.0 && verFloat < 5.5){
        OpenWin = this.open(location.href, "printwindow", "toolbar=no,menubar=no,height=500,width=600,location=no,scrollbars=no,status=no,left=100,top=100");
    }
    if  (ns && verFloat >= 4.0 && verFloat < 6.0){
        OpenWin = this.open(location.href, "printwindow", "toolbar=no,menubar=no,height=500,width=600,location=no,scrollbars=no,status=no,left=100,top=100");
    }
	if(ie && verFloat >= 5.5 ){
            self.print();
    }
}

function custom_print(ieTimeoutMultiple,nsTimeoutMultiple) {
    ieTimeout = ieTimeoutMultiple*1000;
	nsTimeout = nsTimeoutMultiple*6000;
    if(ie && verFloat >= 5.0 && verFloat < 5.5){
        if(window.name == 'printwindow'){
            self.print();
            timerie = setTimeout("window.close()",ieTimeout);
        }
    }
    if(ns && verFloat >= 4.0 && verFloat < 6.0){
        if(window.name == 'printwindow'){
            self.print();
            timerns = setTimeout("window.close()",nsTimeout);
        }
    }
}
//this inserts the image and link on the page
function createPrintButton(){
    document.write('<a href="javascript:printgraph()"><img align="center" src="http://www.hemscott.net/images/printgraph.gif" width="50" height="50" border="0" alt="Print Graph"></a>');
}