$(document).ready(function() {
	$("div.adr span:first-child").css({
		'color' : '#FFFFFF',
		'border-right' : '1px solid #333333',
		'padding-right' : '6px',
		'margin-right' : '3px'
	});

		if( $(".sidePanel-right > ul").length > 0 ) { //if it exists
		 	$(".sidePanel-right > ul").tabs();
	}
});

function populateProfessionals(){
	cancerID = returnDOMObject('sHealthProfessionalTumour').value;
	locationID = returnDOMObject('sHealthProfessionalLocation').value;
	if((cancerID == '' || parseInt(cancerID) < 1) || (locationID!='all' && (locationID== '' || parseInt(locationID) < 1))) {
		resetSelectField('sHealthProfessional','- Select a Professional -');
		return false;
	}
	ajaxURL='http://'+location.host+'/generateAjaxResponse.php?action=getHealthProfessionals&cancerID='+cancerID+'&locationID='+locationID;
	ajaxRequest=ajaxHandler.addRequest(ajaxURL, 'GET', null, 'populateProfessionalsResponseHandler')
}

function populateProfessionalsResponseHandler(populateProfessionals){

	if(ajaxRequest.responseText){

		//htmlString = createSelectField(ajaxRequest.responseText);
    htmlString = createSelectField(ajaxRequest.responseText);
		returnDOMObject('healthProfessionalWrapper').innerHTML = htmlString;
    setIESelectOptions(returnDOMObject('healthProfessionalWrapper'));
		if(ajaxRequest.responseText.indexOf('Select Again') === false){
			returnDOMObject('sHealthProfessional').disabled = true;
		}else{
			returnDOMObject('sHealthProfessional').disabled = '';
		}
	}else{
			resetSelectField('sHealthProfessional','- Select a Professional -');
	}
}

function createSelectField(selectOptions){
	return '<select onchange="viewProfessional(this.value)" title="" name="healthProfessional" id="sHealthProfessional">'+selectOptions+'</select>';
}

function resetSelectField(fieldID, fieldMessage){
	workingField = returnDOMObject(fieldID);
	workingField.innerHTML = '<option value="0">'+((fieldMessage=='undefined')?  '- Select One -' : fieldMessage)+'</option>';
  setIESelectOptions(returnDOMObject(fieldID));
	workingField.disabled = true;
}

function viewProfessional(pageLink){
	locationURL = 'http://'+window.location.hostname;
	locationURL += (window.location.port != 80) ? ':'+window.location.port : '';
	locationURL += '/'+pageLink;
	window.location = locationURL;
}

function setIESelectOptions(inobj){
	inobj.innerHTML=inobj.innerHTML;
}

