$(document).ready(function(){
    $("input[name='application_status']:radio").click(function() 
																{
switch ($(this).val())
{
case 'renewal':
 $("#disabledContent2").html("<label for='library_borrower' class='required' ><span class='question'>Your Borrower Number:  <span class='required-flag'>*</span></span><span class='answer'><input type='text' id='library_borrower' name='library_borrower_number' value='SB'/></span></label>");
 uM_form.prepare();
break;
default:
	$("#disabledContent2").empty();
}
    });
});


/*declare that the extra fields are disable*/
// var change_to_form_name_showed = false;

var showed = false;
var photocopy_showed = false;
var justask_showed = false;
 
 //create a new function
 
 /*
 add <div id="disabledContent"></div>  to the form  and onchange="show_form_name_content();uM_form.prepare();" to the select
 function show_form_name_content(){
	 
	 // add element_select_ID
	var selectedID = document.getElementById("element_select_ID");
	var value = selectedID.options[selectedID.selectedIndex].text;
	 
	 var X = "<label for='your_staff_number'   >	<span class='question'>Your Staff Number: </span>	<span class='answer'>	<input type='text' id='your_staff_number' name='your_staff_number' /></span></label><label for='department' ><span class='question'>Macquarie University Department/Office: </span><span class='answer'><input type='text' id='department' name='department' /></span></label><label for='Contact'   ><span class='question'>Department Contact Person: </span>	<span class='answer'>	<input type='text' id='Contact' name='Contact' /></span></label><label for='contact_number'   >	<span class='question'>Department Contact Person Phone number: </span>	<span class='answer'>	<input type='text' id='contact_number' name='contact_number' class='number'/></span></label>";
	 var Y = "<label for='your_staff_number'   >	<span class='question'>Your Staff Number: </span>	<span class='answer'>	<input type='text' id='your_staff_number' name='your_staff_number' /></span></label><label for='department' ><span class='question'>Macquarie University Department/Office: </span><span class='answer'><input type='text' id='department' name='department' /></span></label><label for='Contact'   ><span class='question'>Department Contact Person: </span>	<span class='answer'>	<input type='text' id='Contact' name='Contact' /></span></label><label for='contact_number'   >	<span class='question'>Department Contact Person Phone number: </span>	<span class='answer'>	<input type='text' id='contact_number' name='contact_number' class='number'/></span></label>";
 }
	 if (value =="A" ||  v =="B" || v=="C")
		{
				if (!showed)
				{
					$("#disabledContent").append(X);
					change_to_form_name_showed = true;
				}
		}
		else if (value == D)
		{
			   $("#disabledContent").append(Y);  // or 
				$("#disabledContent").empty();
				change_to_form_name_showed = false;
		}
		else  {
				$("#disabledContent").empty();
				change_to_form_name_showed = false;
		}
 }
 */
 
 /*showContent for https://www.library.mq.edu.au/forms/associates-application-form.html */
function showContent()
{
/*var a = $("input[name='application_statue']").val();
alert(a);*/
	var s = document.getElementById("reason");
	var v = s.options[s.selectedIndex].text;

var x = "<label for='your_staff_number'   >	<span class='question'>Your Staff Number: </span>	<span class='answer'>	<input type='text' id='your_staff_number' name='your_staff_number' /></span></label><label for='department' ><span class='question'>Macquarie University Department/Office: </span><span class='answer'><input type='text' id='department' name='department' /></span></label><label for='Contact'   ><span class='question'>Department Contact Person: </span>	<span class='answer'>	<input type='text' id='Contact' name='Contact' /></span></label><label for='contact_number'   >	<span class='question'>Department Contact Person Phone number: </span>	<span class='answer'>	<input type='text' id='contact_number' name='contact_number' class='number'/></span></label>";

	if (v =="Macquarie University Casual Staff" ||  v =="Macquarie University Honorary Associate" || v=="Macquarie Visiting Fellow")
	{
			if (!showed)
			{
				$("#disabledContent").append(x);
				showed = true;
			}
	}
	else 
	{
			$("#disabledContent").empty();
			showed = false;
	}
}
/*for photocopy form*/
function showContentPhotocopy()
{
	
	var choice = document.getElementById("choice");
	var c = choice.options[choice.selectedIndex].text;
	//alert('The city of ' + c + ' is located in ' +  '.');
	var journal ="<label for='journal_title' ><span class='question'>Journal Title: </span><span class='answer'><input type='text' id='journal_title' name='journal_title' /></span></label><label for='author' ><span class='question'>Author/Editor: </span><span class='answer'><input type='text' id='author' name='author' /></span></label><label for='article_title'><span class='question'>Article Title: </span><span class='answer'><input type='text' id='article_title' name='article_title' /></span></label><label for='call_number'><span class='question'>Call number: </span><span class='answer'><input type='text' id='call_number' name='call_number' /></span></label><label for='volumn'><span class='question'>Volumn: </span><span class='answer'><input type='text' id='volumn' name='volumn' /></span></label><label for='part'><span class='question'>Part: </span><span class='answer'><input type='text' id='part' name='part' /></span></label><label for='year'><span class='question'>Year: </span><span class='answer'><input type='text' id='year' name='year' /></span></label><label for='from'><span class='question'>Page to be copied from: </span><span class='answer'><input type='text' id='from' name='from' /></span></label><label for='to'><span class='question'>Page to be copied to: </span><span class='answer'><input type='text' id='to' name='to' /></span></label>";
	
	var book ="<label for='author' ><span class='question'>Author/Editor: </span><span class='answer'><input type='text' id='author' name='author' /></span></label><label for='title'><span class='question'>Title: </span><span class='answer'><input type='text' id='title' name='title' /></span></label><label for='call_number'><span class='question'>Call number: </span><span class='answer'><input type='text' id='call_number' name='call_number' /></span></label><label for='from'>		<span class='question'>Page to be copied from: </span><span class='answer'><input type='text' id='from' name='from' /></span></label><label for='to'>	<span class='question'>Page to be copied to: </span><span class='answer'><input type='text' id='to' name='to' /></span></label>";
	
	if (c=="Book")
	{
		if(!photocopy_showed) 
		{
			$("#disabledContent").append(book);
			photocopy_showed = true;
		}
		else {
			$("#disabledContent").empty();
			$("#disabledContent").append(book);
		}
		
	}
	// if not a book show journal html
	else
	{
		if(!photocopy_showed) 
		{
			$("#disabledContent").append(journal);
			photocopy_showed = true;
		}
		else {
			$("#disabledContent").empty();
			$("#disabledContent").append(journal);
		}
		
		
	}
}
function showContentCollection()
{
	
	var choice = document.getElementById("choice");
	var c = choice.options[choice.selectedIndex].text;
	//alert('The city of ' + c + ' is located in ' +  '.');
	var journal ="<label for='journal_title' ><span class='question'>Journal Title: </span><span class='answer'><input type='text' id='journal_title' name='journal_title' /></span></label><label for='author' ><span class='question'>Author/Editor: </span><span class='answer'><input type='text' id='author' name='author' /></span></label><label for='article_title'><span class='question'>Article Title: </span><span class='answer'><input type='text' id='article_title' name='article_title' /></span></label><label for='call_number'><span class='question'>Call number: </span><span class='answer'><input type='text' id='call_number' name='call_number' /></span></label><label for='volumn'><span class='question'>Volumn: </span><span class='answer'><input type='text' id='volumn' name='volumn' /></span></label><label for='part'><span class='question'>Part: </span><span class='answer'><input type='text' id='part' name='part' /></span></label><label for='year'><span class='question'>Year: </span><span class='answer'><input type='text' id='year' name='year' /></span></label>";
	
	var book ="<label for='author' ><span class='question'>Author/Editor: </span><span class='answer'><input type='text' id='author' name='author' /></span></label><label for='title'><span class='question'>Title: </span><span class='answer'><input type='text' id='title' name='title' /></span></label><label for='call_number'><span class='question'>Call number: </span><span class='answer'><input type='text' id='call_number' name='call_number' /></span></label>";
	
	if (c=="Book")
	{
		if(!photocopy_showed) 
		{
			$("#disabledContent").append(book);
			photocopy_showed = true;
		}
		else {
			$("#disabledContent").empty();
			$("#disabledContent").append(book);
		}
		
	}
	else
	{
		if(!photocopy_showed) 
		{
			$("#disabledContent").append(journal);
			photocopy_showed = true;
		}
		else {
			$("#disabledContent").empty();
			$("#disabledContent").append(journal);
		}
	}
}
/* for just Ask Form*/
function showContentJustask()
{
	//var choice = document.getElementById("mailto");
	//var c = choice.options[choice.selectedIndex].text;
	var c = $("#mailto").val();
	var other ="<label for=\"Enquiring_as\"><span class=\"question\">Are you : </span><span class=\"answer\"><select name=\"Enquiring_as\" size=\"5\" id=\"Enquiring_as\">					<option>MQU Undergrad student</option><option>MQU Postgrad student</option><option>MQU Staff</option><option>OUA Student</option><option>General Public</option></select></span></label><label for=\"firstname\" class=\"required\">        <span class=\"question\">Firstname : <span class=\"required-flag\">*</span></span>        <span class=\"answer\"><input type=\"text\" id=\"firstname\" name=\"firstname\" /></span>    </label>    <label for=\"lastname\" class=\"required\">        <span class=\"question\">Family name : <span class=\"required-flag\">*</span></span>        <span class=\"answer\"><input type=\"text\" id=\"lastname\" name=\"lastname\" /></span>    </label>	<label for=\"email\" class=\"required\">		<span class=\"question\">E-mail : <span class=\"required-flag\">*</span></span>		<span class=\"answer\"><input type=\"text\" id=\"email\" name=\"email\" class=\"email\" /></span>	</label>        <label for=\"id_number\">		<span class=\"question\">Student / Staff no :</span>		<span class=\"answer\"><input type=\"text\" id=\"id_number\" name=\"id_number\" /></span>	</label><script type=\"text/javascript\" src=\"/includes/js/form/textarea-resizer.js\"></script><label for=\"your_question\"  class=\"required\"><span class=\"question\">Your question or feedback  :  <span class=\"required-flag\">*</span> </span><span class=\"answer\">	<textarea id=\"your_question\" name=\"your_question\" onkeyup=\"sz(this);\"  rows=\"5\" cols=\"45\"></textarea></span></label>  ";
	
	var support ="<label for=\"Enquiring_as\"><span class=\"question\">Are you : </span><span class=\"answer\"><select name=\"Enquiring_as\" size=\"5\" id=\"Enquiring_as\">					<option>MQU Undergrad student</option><option>MQU Postgrad student</option><option>MQU Staff</option><option>OUA Student</option><option>General Public</option></select></span></label><label for=\"firstname\" class=\"required\">        <span class=\"question\">Firstname : <span class=\"required-flag\">*</span></span>        <span class=\"answer\"><input type=\"text\" id=\"firstname\" name=\"firstname\" /></span>    </label>    <label for=\"lastname\" class=\"required\">        <span class=\"question\">Family name : <span class=\"required-flag\">*</span></span>        <span class=\"answer\"><input type=\"text\" id=\"lastname\" name=\"lastname\" /></span>    </label>	<label for=\"email\" class=\"required\">		<span class=\"question\">E-mail : <span class=\"required-flag\">*</span></span>		<span class=\"answer\"><input type=\"text\" id=\"email\" name=\"email\" class=\"email\"/></span>	</label>    <label for=\"phone_number\">        <span class=\"question\">Phone/Mobile Number :</span>        <span class=\"answer\"><input type=\"text\" id=\"phone_number\" name=\"phone_number\" /></span>	</label>	<label for=\"postal_address\">        <span class=\"question\">Address :</span>        <span class=\"answer\"><textarea id=\"postal_address\" name=\"postal_address\" rows=\"5\" cols=\"45\" ></textarea></span>    </label>    <label for=\"dob\" class=\"required\">		<span class=\"question\">Date of Birth : (For verification of login/password enquiries) <span class=\"required-flag\">*</span></span>		<span class=\"answer\"><input type=\"text\" id=\"dob\" name=\"dob\" /></span>	</label>    <label for=\"id_number\" class=\"required\">		<span class=\"question\">Student / Staff no : <span class=\"required-flag\">*</span></span>		<span class=\"answer\"><input type=\"text\" id=\"id_number\" name=\"id_number\" /></span>	</label>    <label for=\"barcode\"  class=\"required\">		<span class=\"question\">	Barcode no : (from the bottom of your campus card)<span class=\"required-flag\">*</span></span>		<span class=\"answer\"><input type=\"text\" id=\"barcode\" name=\"barcode\" /></span>	</label><script type=\"text/javascript\" src=\"/includes/js/form/textarea-resizer.js\"></script><label for=\"your_question\"  class=\"required\"><span class=\"question\">Your question or feedback  :  <span class=\"required-flag\">*</span> </span><span class=\"answer\">	<textarea id=\"your_question\" name=\"your_question\" onkeyup=\"sz(this);\"  rows=\"5\" cols=\"45\"></textarea></span></label>";
	
	var general ="<label for=\"Enquiring_as\"><span class=\"question\">Are you : </span><span class=\"answer\"><select name=\"Enquiring_as\" size=\"5\" id=\"Enquiring_as\">					<option>MQU Undergrad student</option><option>MQU Postgrad student</option><option>MQU Staff</option><option>OUA Student</option><option>General Public</option></select></span></label><script type=\"text/javascript\" src=\"/includes/js/form/textarea-resizer.js\"></script><label for=\"your_question\"  class=\"required\"><span class=\"question\">Your question or feedback  :  <span class=\"required-flag\">*</span> </span><span class=\"answer\">	<textarea id=\"your_question\" name=\"your_question\" onkeyup=\"sz(this);\"  rows=\"5\" cols=\"45\"></textarea></span></label>";
	
	
 console.log(c);
	if ((c == "lib.infodesk")||(c == "lib.training"))
	{
		if(!justask_showed) 
		{
			$("#disabledContent").append(general);
			justask_showed = true;
		}
		else {
			$("#disabledContent").empty();
			$("#disabledContent").append(general);
		}
		
	}
	else if (c == "lib.loan")
	{
		if(!justask_showed) 
		{
			$("#disabledContent").append(support);
			justask_showed = true;
		}
		else {
			$("#disabledContent").empty();
			$("#disabledContent").append(support);
		}
	}	
	else if (c == "")
	{
		$("#disabledContent").empty();
	}	
	else
	{
		
		if(!justask_showed) 
		{
			$("#disabledContent").append(other);
			justask_showed = true;
		}
		else {
			$("#disabledContent").empty();
			$("#disabledContent").append(other);
		}
		
	}
}

