//This file includes the core javascript required for the portal. 
//It also sets up HTTP headers that force visitors browsers to cache the javascript and will gzip compress the javascript if the zlib library is available in PHP
//The files included are:
// prototype.js
// scriptaculous/effects.js
// DynamicOptionList.js (used for drill down custom fields)
// jscalendar/calendar_stripped.js (used for date custom fields)
// jscalendar/lang/calendar-en.js (used for date custom fields)
// jscalendar/calendar-setup.js (used for date custom fields)
document.write('<script type="text/javascript" src="http://www.questeksupport.com/helpdesk/js/c_portaljs_2.1.1.php"></script>');

//Function that shows appropriate custom fields for each category
function ShowCategoryCustomFields(category_id){

	//Find the ID of the currently selected category
	var selected_category = category_id ? category_id : ($("xCategory") ? $F("xCategory") : 0);
	
	//Create javascript array of custom field ID's, excludes always visible custom fields
	var custom_field_ids = new Array("");
	var field_count = custom_field_ids.length;
	
	//Create javascript array of custom fields each category should display
	var category_custom_fields = new Array();
		category_custom_fields[5] = new Array("");
		category_custom_fields[3] = new Array("");
		category_custom_fields[2] = new Array("");
		category_custom_fields[6] = new Array("");
		category_custom_fields[4] = new Array("");
	
	//Hide all fields on category change
	for(i=0;i < field_count;i++){
		if($("Custom" + custom_field_ids[i] + "_wrapper")) $("Custom" + custom_field_ids[i] + "_wrapper").hide();
	}
		
	//Show fields which are for this category
	if(selected_category != 0){			
		var custom_field_len = category_custom_fields[selected_category] ? category_custom_fields[selected_category].length : 0;
		for(i=0;i < custom_field_len;i++){
			if($("Custom" + category_custom_fields[selected_category][i] + "_wrapper")){
				$("Custom" + category_custom_fields[selected_category][i] + "_wrapper").show();
			}
		}
	}	
}