
// Methods for the technical support submit a ticket page
var ts = function() {

	return {
	  
		// Function to update the ticket priority description
		// based on the selected value in the dropdown
		'updatePriorityDesc': function() {
			var t = document.forms[0].elements['department'].value;
			var p = document.getElementById('priority').value;
			var d = '';
			if(t == '1') { // Technical support
				if(p == '1') {
					d = 'Minor fault or cosmetic problem. <br />(Est. Response: within 1 week)';
				}
				if(p == '2') {
					d = 'System fault and  work around possible. <br />(Est. Response: within 1 day)';
				}
				if(p == '3') {
					d = 'System fault which would cause workload, planning etc to be significantly affected by lack of early resolution <br/>Est. Response: within 2 hours';
				}
				if(p == '4') {
					d = 'Key area of live system is down and unusable. <br/>(Est. Response: within 1 hour)';
				}
			} else if(t == '2') { // File request
				if(p == '1') {
					d = 'Low';
				}
				if(p == '2') {
					d = 'Medium';
				}
				if(p == '3') {
					d = 'High';
				}
				if(p == '4') {
					d = 'Urgent';
				}
			}
			document.getElementById('priorityDesc').innerHTML = d;
		},
		
		'updatePriority': function() {
			var t = document.forms[0].elements['department'].value;
			var p = document.getElementById('priority');
			var c = document.getElementById('cdf_typeofcall').value;
			if(t == '1') {
				if(c == 'System Fault ') {
					p.selectedIndex = 2;
				} else if(c == 'Advice(please help)') {
					p.selectedIndex = 0;
				} else if(c == 'IT Infrastructure') {
					p.selectedIndex = 0;
				} else if(c == 'Scanner/printer fault') {
					p.selectedIndex = 1;
				} else if(c == 'Database') {
					p.selectedIndex = 1;
				} else if(c == 'Other') {
					p.selectedIndex = 0;
				}
			}
		},
		
		'setupSubmitTicketDescription': function() {
			var t = document.forms[0].elements['department'].value;
			var d = '';
			if(t == '1') { // Technical support
				d = '';
				document.getElementById('message').style.display = 'none';
				document.getElementById('issue_what_is').parentNode.parentNode.style.display = 'table-row';
				document.getElementById('issue_what_steps').parentNode.parentNode.style.display = 'table-row';
				document.getElementById('issue_what_output').parentNode.parentNode.style.display = 'table-row';
				document.getElementById('issue_what_other').parentNode.parentNode.style.display = 'table-row';
			} else if(t == '2') { // File request
				d = 'Please provide additional details for the file you require.';
			}
			document.getElementById('message').value = d;
		},
		
		'updateTechnicalSupportDescription': function() {
			var whatIs = document.getElementById('issue_what_is').value;
			var whatSteps = document.getElementById('issue_what_steps').value;
			var whatOutput = document.getElementById('issue_what_output').value;
			var whatOther = document.getElementById('issue_what_other').value;
        
			var issue = '===What is the issue?===\n\n' + whatIs + 
				'\n\n\n===What steps will reproduce the problem?===\n\n' + whatSteps +
				'\n\n\n===What is the expected output? What do you see instead?===\n\n' + whatOutput +
				'\n\n\n===Any other information?===\n\n' + whatOther;
        
			document.getElementById('message').value = issue;
		}
		
	};

}();