


var pulsecode_obj=new Object();
var hospital_obj=new Object();

var pulsecode_hi_obj=new Object();
var hospital_hi_obj=new Object();


function bloodcentre_change()
{
	var hospital_select=document.f.hospital.options;
	var pulse_select=document.f.pulse.options;
		
	while (hospital_select.length>1)
	{
		hospital_select[hospital_select.length-1]=null;
	}
	var selected=document.f.blood_centre.options[document.f.blood_centre.options.selectedIndex].value;
	
	if (hospital_obj[selected])
	{
		var hospital_array=hospital_obj[selected];
		for (var i=0; i<hospital_array.length; i++)
		{
			hospital_select[hospital_select.length]=new Option(hospital_array[i],hospital_array[i]);
		}
	}
	
	while (pulse_select.length>1)
	{
		pulse_select[pulse_select.length-1]=null;
	}
	if (pulsecode_obj[selected])
	{
		var pulse_array=pulsecode_obj[selected];
		pulse_array.sort();
		for (var i=0; i<pulse_array.length; i++)
		{
			pulse_select[pulse_select.length]=new Option(pulse_array[i],pulse_array[i]);
		}
	}
	
	document.getElementById("hospital").disabled = false;
	document.getElementById("pulse").disabled = false;
}

function bloodcentre_changeb()
{
	var hospital_selectb=document.b.hospitalb.options;
	var pulse_selectb=document.getElementById("pulseb").options;
	
	while (hospital_selectb.length>1)
	{
		hospital_selectb[hospital_selectb.length-1]=null;
	}
	var selectedb=document.b.blood_centreb.options[document.b.blood_centreb.options.selectedIndex].value;
	if (hospital_obj[selectedb])
	{
		var hospital_arrayb=hospital_obj[selectedb];
		for (var i=0; i<hospital_arrayb.length; i++)
		{
			hospital_selectb[hospital_selectb.length]=new Option(hospital_arrayb[i],hospital_arrayb[i]);
		}
	}
	
	while (pulse_selectb.length>1)
	{
		pulse_selectb[pulse_selectb.length-1]=null;
	}
	if (pulsecode_obj[selectedb])
	{
		var pulse_arrayb=pulsecode_obj[selectedb];
		pulse_arrayb.sort();
		for (var i=0; i<pulse_arrayb.length; i++)
		{
			pulse_selectb[pulse_selectb.length]=new Option(pulse_arrayb[i],pulse_arrayb[i]);
		}
	}
	
	document.getElementById("hospitalb").disabled = false;
	document.getElementById("pulseb").disabled = false;
}


function bloodcentre_change_hi_a()
{
	var hospital_select_hi_a=document.f_hi_a.hospital_hi_a.options;
	var pulse_select_hi_a=document.getElementById("pulse_hi_a").options;
	
	//alter hospital array
	while (hospital_select_hi_a.length>1)
	{
		hospital_select_hi_a[hospital_select_hi_a.length-1]=null;
	}
	var selected_hi_a=document.f_hi_a.blood_centre_hi_a.options[document.f_hi_a.blood_centre_hi_a.options.selectedIndex].value;
	
	if (hospital_hi_obj[selected_hi_a])
	{
		var hospital_array_hi_a=hospital_hi_obj[selected_hi_a];
		for (var i=0; i<hospital_array_hi_a.length; i++)
		{
			hospital_select_hi_a[hospital_select_hi_a.length]=new Option(hospital_array_hi_a[i],hospital_array_hi_a[i]);
		}
	}
	
	//alter pulse array
	while (pulse_select_hi_a.length>1)
	{
		pulse_select_hi_a[pulse_select_hi_a.length-1]=null;
	}
	if (pulsecode_hi_obj[selected_hi_a])
	{
		var pulse_array_hi_a=pulsecode_hi_obj[selected_hi_a];
		pulse_array_hi_a.sort();
		for (var i=0; i<pulse_array_hi_a.length; i++)
		{
			pulse_select_hi_a[pulse_select_hi_a.length]=new Option(pulse_array_hi_a[i],pulse_array_hi_a[i]);
		}
	}
	
	document.getElementById("hospital_hi_a").disabled = false;
	document.getElementById("pulse_hi_a").disabled = false;
}



/*
function bloodcentre_change_hi_b()
{
	var hospital_select_hi_b=document.f_hi_b.hospital_hi_b.options;
	var pulse_select_hi_b=document.getElementById("pulse_hi_b").options;
	
	//alter hospital array
	while (hospital_select_hi_b.length>1)
	{
		hospital_select_hi_b[hospital_select_hi_b.length-1]=null;
	}
	var selected_hi_b=document.f_hi_b.blood_centre_hi_b.options[document.f_hi_b.blood_centre_hi_b.options.selectedIndex].value;
	
	if (hospital_hi_obj[selected_hi_b])
	{
		var hospital_array_hi_b=hospital_hi_obj[selected_hi_b];
		for (var i=0; i<hospital_array_hi_b.length; i++)
		{
			hospital_select_hi_b[hospital_select_hi_b.length]=new Option(hospital_array_hi_b[i],hospital_array_hi_b[i]);
		}
	}
	
	//alter pulse array
	while (pulse_select_hi_b.length>1)
	{
		pulse_select_hi_b[pulse_select_hi_b.length-1]=null;
	}
	if (pulsecode_hi_obj[selected_hi_b])
	{
		var pulse_array_hi_b=pulsecode_hi_obj[selected_hi_b];
		pulse_array_hi_b.sort();
		for (var i=0; i<pulse_array_hi_b.length; i++)
		{
			pulse_select_hi_b[pulse_select_hi_b.length]=new Option(pulse_array_hi_b[i],pulse_array_hi_b[i]);
		}
	}
	
	document.getElementById("hospital_hi_b").disabled = false;
	document.getElementById("pulse_hi_b").disabled = false;
}
*/



function H (HospitalName, PulseCode, BloodCentre)
{
	if (!pulsecode_obj[BloodCentre])
	{
		pulsecode_obj[BloodCentre] = new Array();
	}
	pulsecode_obj[BloodCentre].push(PulseCode);
	
	if (!hospital_obj[BloodCentre])
	{
		hospital_obj[BloodCentre] = new Array();
	}
	hospital_obj[BloodCentre].push(HospitalName);
}

function HI_H (HospitalName, PulseCode, BloodCentre, HI_HospitalID)
{
	if (!pulsecode_hi_obj[BloodCentre])
	{
		pulsecode_hi_obj[BloodCentre] = new Array();
	}
	pulsecode_hi_obj[BloodCentre].push(PulseCode);
	
	if (!hospital_hi_obj[BloodCentre])
	{
		hospital_hi_obj[BloodCentre] = new Array();
	}
	hospital_hi_obj[BloodCentre].push(HospitalName);
}





function disable (currentbox, otherbox)
{
	if (document.f[currentbox].value == "")
	{ 
		document.f[otherbox].disabled = false;
	}
	else
	{ 
		document.f[otherbox].disabled = true;
	}
}


function disableb (currentbox, otherbox)
{
	if (document.b[currentbox].value == "")
	{ 
		document.b[otherbox].disabled = false;
	}
	else
	{ 
		document.b[otherbox].disabled = true;
	}
}

function disable_hi_a (currentbox, otherbox)
{
	if (document.f_hi_a[currentbox].value == "")
	{ 
		document.f_hi_a[otherbox].disabled = false;
	}
	else
	{ 
		document.f_hi_a[otherbox].disabled = true;
	}
}

/*
function disable_hi_b (currentbox, otherbox)
{
	if (document.f_hi_b[currentbox].value == "")
	{ 
		document.f_hi_b[otherbox].disabled = false;
	}
	else
	{ 
		document.f_hi_b[otherbox].disabled = true;
	}
}
*/





function checkfirstform(){
	if (document.getElementById("blood_centre").value == ""){
		alert("please select a blood centre");
		document.getElementById("blood_centre").focus()
	} else if (document.getElementById("hospital").value == "" && document.getElementById("pulse").value == ""){
		alert("please enter a hospital or a pulse code");
	} else {
		return true;
	}
	return false;
}

function checkfirstformb(){
	if (document.getElementById("blood_centreb").value == ""){
		alert("please select a blood centre");
		document.getElementById("blood_centreb").focus()
	} else if (document.getElementById("hospitalb").value == "" && document.getElementById("pulseb").value == ""){
		alert("please enter a hospital or a pulse code");
	} else {
		return true;
	}
	return false;
}

function checkfirstform_hi_a(){
	if (document.getElementById("blood_centre_hi_a").value == ""){
		alert("Please select a blood centre");
		document.getElementById("blood_centre_hi_a").focus()
	}
	else if (document.getElementById("hospital_hi_a").value == "" && document.getElementById("pulse_hi_a").value == ""){
		alert("Please enter a hospital or a pulse code");
	}
	else if (document.getElementById("jobrole_hi_a").value == "")
	{
		alert("Please enter a job role");
	}
	else if (document.getElementById("jobarea_hi_a").value == "")
	{
		alert("Please enter a job area");
	}
	
	else {
		var state=(document.all["topsection"].style.display=="");
		document.all["topsection"].style.display=(state) ? "none" : "";
		var state=(document.all["satisfaction"].style.display=="none");
		document.all["satisfaction"].style.display=(state) ? "" : "none";
	}
}

/*
function checkfirstform_hi_b(){
	if (document.getElementById("blood_centre_hi_b").value == ""){
		alert("Please select a blood centre");
		document.getElementById("blood_centre_hi_b").focus()
	}
	else if (document.getElementById("hospital_hi_b").value == "" && document.getElementById("pulse_hi_b").value == ""){
		alert("Please enter a hospital or a pulse code");
	}
	else if (document.getElementById("jobrole_hi_b").value == "")
	{
		alert("Please enter a job role");
	}
	else if (document.getElementById("jobarea_hi_b").value == "")
	{
		alert("Please enter a job area");
	}
	
	else {
		var state=(document.all["topsection"].style.display=="");
		document.all["topsection"].style.display=(state) ? "none" : "";
		var state=(document.all["satisfaction"].style.display=="none");
		document.all["satisfaction"].style.display=(state) ? "" : "none";
	}
}
*/


