// change URL before loading

var ajax = new Array();

// setup ajax for procedures and facilities
function getFacilityList(sel)
{
	var procedureCode = sel.options[sel.selectedIndex].value;
	document.getElementById('fma_facility').options.length = 0;	// Empty procedure select box
	if(procedureCode.length>0){
		var index = ajax.length;
		ajax[index] = new sack();
		ajax[index].requestFile = 'http://www.fixmeabroad.com/getfacilities.php?procedureCode='+procedureCode;	// Specifying which file to get
		//ajax[index].requestFile = 'http://localhost/fma/getfacilities.php?procedureCode='+procedureCode;	// Specifying which file to get
		ajax[index].onCompletion = function(){ createFacilities(index) };	// Specify function that will be executed after file has been found
		ajax[index].runAJAX();		// Execute AJAX function
	}
}

function createFacilities(index)
{
	var obj = document.getElementById('fma_facility');
	eval(ajax[index].response);	// Executing the response from Ajax as Javascript code
}

function getFacilityDetail(sel)
{
	var facilityCode = sel.options[sel.selectedIndex].value;
	//document.getElementById('fma_test').options.length = 0;	// Empty facility select box
	if(facilityCode.length>0){
		var index = ajax.length;
		ajax[index] = new sack();
		ajax[index].requestFile = 'http://www.fixmeabroad.com/getfacilitydetail.php?facilityCode='+facilityCode;	// Specifying which file to get
		//ajax[index].requestFile = 'http://localhost/fma/getfacilitydetail.php?facilityCode='+facilityCode;	// Specifying which file to get
		ajax[index].onCompletion = function(){ createFacilityDetail(index) };	// Specify function that will be executed after file has been found
		ajax[index].runAJAX();		// Execute AJAX function
	}
}

function createFacilityDetail(index)
{
	var obj = document.getElementById('fma_test');
	obj.innerHTML = ajax[index].response;
}

function getTravelDetail(sel)
{
	var travelCode = sel.options[sel.selectedIndex].value;
	//document.getElementById('fma_travel').options.length = 0;	// Empty procedure select box
	if(travelCode.length>0){
		var index = ajax.length;
		ajax[index] = new sack();
		ajax[index].requestFile = 'http://www.fixmeabroad.com/gettraveldetail.php?travelCode='+travelCode;	// Specifying which file to get
		//ajax[index].requestFile = 'http://localhost/fma/gettraveldetail.php?travelCode='+travelCode;	// Specifying which file to get
		ajax[index].onCompletion = function(){ createTravelDetail(index) };	// Specify function that will be executed after file has been found
		ajax[index].runAJAX();		// Execute AJAX function
	}
}

function createTravelDetail(index)
{
	var obj = document.getElementById('fma_travel_text');
	obj.innerHTML = ajax[index].response;
}

function getAll(sel)
{
	var procedureCode = sel.options[sel.selectedIndex].value;
	//document.getElementById('fma_travel').options.length = 0;	// Empty procedure select box
	if(procedureCode.length>0){
		var index = ajax.length;
		ajax[index] = new sack();
		ajax[index].requestFile = 'http://www.fixmeabroad.com/getlistdetail.php?procedureCode='+procedureCode;	// Specifying which file to get
		//ajax[index].requestFile = 'http://localhost/fma/getlistdetail.php?procedureCode='+procedureCode;	// Specifying which file to get
		ajax[index].onCompletion = function(){ createall(index) };	// Specify function that will be executed after file has been found
		ajax[index].runAJAX();		// Execute AJAX function
	}
}

function createall(index)
{
	var obj = document.getElementById('fma_list_text');
	obj.innerHTML = ajax[index].response;
}

// setup ajax for procedures and doctors
function getDoctorList(sel)
{
	var procedureCode = sel.options[sel.selectedIndex].value;
	document.getElementById('fma_doctor').options.length = 0;	// Empty procedure select box
	if(procedureCode.length>0){
		var index = ajax.length;
		ajax[index] = new sack();
		ajax[index].requestFile = 'http://www.fixmeabroad.com/getdoctors.php?procedureCode='+procedureCode;	// Specifying which file to get
		//ajax[index].requestFile = 'http://localhost/fma/getdoctors.php?procedureCode='+procedureCode;	// Specifying which file to get
		ajax[index].onCompletion = function(){ createDoctors(index) };	// Specify function that will be executed after file has been found
		ajax[index].runAJAX();		// Execute AJAX function
	}
}

function createDoctors(index)
{
	var obj = document.getElementById('fma_doctor');
	eval(ajax[index].response);	// Executing the response from Ajax as Javascript code
}

function getDoctorDetail(sel)
{
	var doctorCode = sel.options[sel.selectedIndex].value;
	//document.getElementById('fma_test').options.length = 0;	// Empty facility select box
	if(doctorCode.length>0){
		var index = ajax.length;
		ajax[index] = new sack();
		ajax[index].requestFile = 'http://www.fixmeabroad.com/getdoctordetail.php?doctorCode='+doctorCode;	// Specifying which file to get
		//ajax[index].requestFile = 'http://localhost/fma/getdoctordetail.php?doctorCode='+doctorCode;	// Specifying which file to get
		ajax[index].onCompletion = function(){ createDoctorDetail(index) };	// Specify function that will be executed after file has been found
		ajax[index].runAJAX();		// Execute AJAX function
	}
}

function createDoctorDetail(index)
{
	var obj = document.getElementById('fma_test');
	obj.innerHTML = ajax[index].response;
	//eval(ajax[index].response);	// Executing the response from Ajax as Javascript code
}

function setOpacity( value ) {
 document.getElementById("styled_popup").style.opacity = value / 10;
 document.getElementById("styled_popup").style.filter = 'alpha(opacity=' + value * 10 + ')';
}

function fadeInMyPopup() {
 for( var i = 0 ; i <= 100 ; i++ )
   setTimeout( 'setOpacity(' + (i / 10) + ')' , 8 * i );
}

function fadeOutMyPopup() {
 for( var i = 0 ; i <= 100 ; i++ ) {
   setTimeout( 'setOpacity(' + (10 - i / 10) + ')' , 8 * i );
 }

 setTimeout('closeMyPopup()', 800 );
}

function closeMyPopup() {
 document.getElementById("styled_popup").style.display = "none"
}

function fireMyPopup() {
 setOpacity( 0 );
 document.getElementById("styled_popup").style.display = "block";
 fadeInMyPopup();
}


