function viewprint() { 

	var printFrame = document;
	var adjustStart;
	var adjustEnd;
	var tag1 = null;
	var tag2 = null;	
	var postag1 = 0;
	var postag2 = 0;
	var corps = '""';
   	var theader = '""';
	var ico1 = '"<a href="';
	var ico2 = '">Print</a>"';
	var ico3 = 'javascript:window.print();'
	var win_opt= "toolbar=0,location=0,directories=0,status=0,menubar=1,";
	var win_opt= "toolbar=0,location=0,directories=0,status=0,menubar=1,";
	win_opt += "scrollbars=1,resizable=1,copyhistory=0,width=835,height=800";


 
 if ((printFrame.getElementById('startview')!= null) || (printFrame.getElementById('innerstartview')!= null)){
        //Check for print area
		if (printFrame.getElementById('startview')!= null){
            tag1 = 'startview';
            adjustStart = 16;
	    	tag2 = 'endview';
            adjustEnd = 9;
         }

        //Check for inner print area and overwrite vars
		if (printFrame.getElementById('innerstartview')!= null){
		  tag1 = 'innerstartview';
		  adjustStart = 21;
		  tag2 = 'innerendview';
		  adjustEnd = 9;
		}
		
		// Get the head in order to retrieve css links
		theader = printFrame.getElementsByTagName("head")[0].innerHTML;
		corps = printFrame.getElementsByTagName("body")[0].innerHTML;
		
		// Looks for delimiters
		postag1 = corps.indexOf(tag1)+adjustStart;
		postag2 = corps.indexOf(tag2)-adjustEnd;
		
		//Cut the javascript out as it locks the browser.
		theader = theader.substring(0,theader.indexOf('<SCRIPT')) + theader.substring(theader.indexOf('/SCRIPT>')+8,theader.length);
		
		// extracts useful part
		corps = corps.substring(postag1,postag2);
				// displays in another window// Create a new window
		NewWindow= window.open("","Title",win_opt);
		NewWindow.creator= self;
		NewWindow.document.open();
		NewWindow.document.write("<HTML><HEAD><style type='text/css' media='print'>.noPrint{display:none;}</style>");
		NewWindow.document.write("<style type='text/css'>td,a{color:black !important;}</style>");
		//NewWindow.document.write(theader);
		NewWindow.document.write("</HEAD><BODY STYLE='PADDING:4px 4px 4px 4px;'>"+ ico1 + ico3 + ico2);
		NewWindow.document.write(corps);
		NewWindow.document.write("</BODY></HTML>");
		NewWindow.document.close();
		}
}