	function printPatient(){  
	   startPrint(); // calling action
	   //Click the x event!  
	 
	}
	jQuery(document).ready(function ($) {
 	 $("#popupContactClose").click(function(){  
	  disablePopup();  
	  });  
	 //Click out event!  
	  $("#backgroundPopup").click(function(){  
	  }); 	
 });
 	
	
	function startPrint(){
		
		if(confirm('Please confirm that you want to send this patient details to the printer')){
			var csrfdata=document.getElementById("csrfparameterName").value;
			csrfdata=csrfdata+"="+document.getElementById("csrfparametervalue").value;
			$.ajax({
				   type: "POST",
				   url: "../referrals/printPatientDetails.form?" + csrfdata,
				   success: function(msg){				   
					   var filelistSize = msg.filePathListSize;
					   if(filelistSize>0){
					    processRequest(msg);  
					   }else{
					    alert('please save the form');
					   }	  
				   	   //centering with css  
					   centerPopup();  
					   //load popup  
					   loadPopup(); 
					  
				  }
		 	});
		}
	}
	
	
	function processRequest(msg){
		var rowCount=msg.filePathListSize ;
		var i=0;
		for (i=0;i<rowCount;i++){
			addRowToTable(msg.filePathList[i]);
		}		
	}
	
	
	function addRowToTable(msg){
	  var filePath = msg.filePath;
 	  var fileName = msg.fileName;
 	  var tbl = document.getElementById('ajaxFilePathTable'); 	  
 	  var lastRow = tbl.rows.length;
 	  // if there's no header row in the table, then iteration = lastRow + 1
	  var iteration = lastRow;
	  var row = tbl.insertRow(lastRow);
	  
	   // First TD
	  var hiperLink = document.createElement('a');
	  hiperLink.appendChild (document.createTextNode (fileName));
      hiperLink.setAttribute("href","#");
      hiperLink.onclick = function(){fnDisplay_Computers( filePath  ); }; 
	  var TD4 = document.createElement("TD");
	  TD4.appendChild(hiperLink);
	  row.appendChild(TD4);
	 }
	
	function replaceInputsForPdfView(){
		var inputs = document.getElementsByTagName('input');
		var length = inputs.length;
		for (var i = 0; i < length; i++) {
			var input = inputs[i];
			input=document.getElementById(input.id);
			var inputtype = input.type; 
			if(inputtype =='checkbox' || inputtype =='radio'){
				if(!document.getElementById(input.id).checked){
					var parentContent=input.parentNode.innerHTML;
					var indexOfinputid = parentContent.indexOf(input.id);
					var tempString = parentContent.substring(indexOfinputid,parentContent.length);
					var from = tempString.indexOf(">")+1;
					var to = tempString.length;
					if(tempString.indexOf("<input")>=0){
						 to=tempString.indexOf("<input");
					}
					var newcontent=parentContent.replace(tempString.substring(from,to),'&nbsp;');
					var parentnode=input.parentNode;
					parentnode.innerHTML=newcontent;
					var elementById=document.getElementById(input.id);
					parentnode.removeChild(elementById);
					i--;
				}
			}
		 }
	}