var currentPage=null;
var pageNumberUp = {'background-color' : '#FFFFFF', 'color' : '#2A4E83'}
var pageNumberDown = {'background-color' : '#2A4E83', 'color' : '#FFFFFF'}

function getPatientList(i){
	$.ajax({
		type: "POST",
		url: "_assets/_scripts/patientlist.php",
		data: 'proc='+i,
		dataType: "html",
		success: function(msg){
			//alert(parseInt(msg));
			if(msg) {
				$('#pagenumbers').html(msg);
				loadPatient($('#img1').attr('img'));
				changePage($('#img1'));
				$(".img").click(function(){
					var id=$(this).attr('img');					 
					loadPatient(id);
					changePage($(this));
				});
			}
		}
	});
}

function changePage(p){
	if(currentPage){
		currentPage.css(pageNumberUp);	
	}
	p.css(pageNumberDown);
	currentPage=p;
}
function loadPatient(id){
	getImages(id);
	getDescription(id);
}

function getImages(id){
	for(var i=1; i<=4; i++){
		$('#image_'+i).html('<img src="_assets/_scripts/getimage.php?id='+id+'&n='+i+'" />');
	}
}

function getDescription(id){
	$.ajax({
		type: "POST",
		url: "_assets/_scripts/description.php",
		data: 'id='+id,
		dataType: "html",
		success: function(msg){
			if(parseInt(msg)!=0) {
				$('#description').html(msg);
			}
		}
	});
}
