/* parse the entered query String */
var treatment_name=0;
var treatment_date=0;


function parseSearchQuery(theForm, message) {
	var queryValue = theForm.elements["query2"].value;
	var testValue = queryValue.replace(/ /g, "");
	if (testValue.length < 3) {
		alert(message);
		return (false);
	}
	theForm.elements["query"].value = queryValue;
	return (true);
}

/* open the print version popup window */
function openPrintVersion() {
	var params = "print=true";
	
	if (document.location.search != "") {
		params = document.location.search + "&" + params;		
	} else {
		params = "?" + params;
	}
	
	
	window.open(document.location.pathname + params, "print", "width=670,height=750,dependent=yes,status=no,toolbar=no,location=no,scrollbars=yes");
}

/* open the imprint popup window */
function openImprint(imprintUri, pageUri, theLocale, site) {
	pageUri = encodeURIComponent(pageUri); 
	pageUri = "?__locale=" + theLocale + "&uri=" + pageUri + "&site=" + site;
	window.open(imprintUri + pageUri, "imprint", "width=670,height=550,dependent=yes,status=no,toolbar=no,location=no,scrollbars=yes,resizable=yes");
}

/* open the recommend page form popup window */
function openRecommendForm(recommendUri, pageUri, theLocale, site) {	
	if (window.location.search != "") {
		pageUri += window.location.search;		
	}
	pageUri = encodeURIComponent(pageUri); 
	pageUri = "?__locale=" + theLocale + "&uri=" + pageUri + "&site=" + site;
	window.open(recommendUri + pageUri, "recommend", "width=670,height=700,dependent=yes,status=no,toolbar=no,location=no,scrollbars=yes,resizable=yes");
}

/* open the recommend page form popup window */
function openLetterForm(letterUri, pageUri, theLocale, site) {	
	if (window.location.search != "") {
		pageUri += window.location.search;		
	}
	pageUri = encodeURIComponent(pageUri); 
	pageUri = "?__locale=" + theLocale + "&uri=" + pageUri + "&site=" + site;
	window.open(letterUri + pageUri, "contact", "width=670,height=700,dependent=yes,status=no,toolbar=no,location=no,scrollbars=yes,resizable=yes");
}

function generateChart(pid,servletpath)
{
     var address=$F("indicate");
        var url = 'LineChart?pid='+pid+"&indicate="+address;
        var pars="";
   var myAjax = new Ajax.Request(
            url,
            {method: 'post',parameters: pars,asynchronous:false}
            );
        
window.location.href= servletpath+'/PdfExport.do?pid='+pid;
window.moveTo(0,0);  
 window.resizeTo(screen.width,screen.height-30);
 }
function isSelected()
{
if($('collapsing').checked==true||$('tipLesion').checked==true||$('hilar').checked==true)
$('focalSegmentalGlomerulosclerosis').checked=true;
}
function  sortTreatment(desc)

{
if(desc=='date')
{
if(treatment_date%2==0)
  showHistoriesBySort("allHistoryDesc");
  else
  showHistoriesBySort("allHistory");
treatment_date++;
}
if(desc=='name')
{
if(treatment_name%2==0)
  showHistoriesBySort("allHistoryNameAsc");
  else
  showHistoriesBySort("allHistoryNameDesc");
treatment_name++;
}



}	

function showHistoriesBySort(url){

 var url =url;
  var patient_id=document.getElementById("patient_id").value;
    url=url+"?pid="+patient_id;
 var pars="";
    var myAjax = new Ajax.Updater(
     {success:'onginghistory'},
            url,
            {method: 'post', evalScripts:true,parameters: pars}
            );

$('followup_layer').hide();
$('treatment_layer').show();
$('update').setStyle({height:'auto'});	

}


 
