/********************************************

This JavaScript file controls the building of the table
of view options on the side and redirecting to the appropriate page.

Do NOT modify any of this code or the PASS system will not work correctly.

If you want to modify which view options are shown and what they are called
you should edit the viewoptions.js file

********************************************/

<!--
	var hex;

	function build_side_table()
	{
		document.write("<form>");

		if (show_academic_plan) {
			document.write("<li><a href=\"#\" onClick=\"show_data(document.IDANDPIN, 1, this)\">");
			document.write(academic_plan_name);
			document.write("</a><br></li>");
		}

		if (show_attendance) {
			document.write("<li><a href=\"#\" onClick=\"show_data(document.IDANDPIN, 2, this)\">");
			document.write(attendance_name);
			document.write("</a><br></li>");
		}

		if (show_current_marks) {
			document.write("<li><a href=\"#\" onClick=\"show_data(document.IDANDPIN, 3, this)\">");
			document.write(current_marks_name);
			document.write("</a><br></li>");
		}
 
		if (show_fees) {
			document.write("<li><a href=\"#\" onClick=\"show_data(document.IDANDPIN, 4, this)\">");
			document.write(fees_name);
			document.write("</a><br></li>");
		}
 
		if (show_gpa_history) {
			document.write("<li><a href=\"#\" onClick=\"show_data(document.IDANDPIN, 5, this)\">");
			document.write(gpa_history_name);
			document.write("</a><br></li>");
		}
 
		if (show_guidance) {
			document.write("<li><a href=\"#\" onClick=\"show_data(document.IDANDPIN, 6, this)\">");
			document.write(guidance_name);
			document.write("</a><br></li>");
		}
 
		if (show_mark_history) {
			document.write("<li><a href=\"#\" onClick=\"show_data(document.IDANDPIN, 7, this)\">");
			document.write(mark_history_name);
			document.write("</a><br></li>");
		}

		if (show_schedule_progress) {
			document.write("<li><a href=\"#\" onClick=\"show_data(document.IDANDPIN, 8, this)\">");
			document.write(schedule_progress_name);
			document.write("</a><br></li>");
		}
 
		if (show_test_history) {
			document.write("<li><a href=\"#\" onClick=\"show_data(document.IDANDPIN, 9, this)\">");
			document.write(test_history_name);
			document.write("</a><br></li>");
		}
 
		if (show_vaccinations) {
			document.write("<li><a href=\"#\" onClick=\"show_data(document.IDANDPIN, 10, this)\">");
			document.write(vaccinations_name);
			document.write("</a><br></li>");
		}
 
		if (show_calendar) {
			document.write("<li><a href=\"#\" onClick=\"show_data(document.IDANDPIN, 11, this)\">");
			document.write(calendar_name);
			document.write("</a><br></li>");
		}
 
		if (show_messages) {
			document.write("<li><a href=\"#\" onClick=\"show_data(document.IDANDPIN, 12, this)\">");
			document.write(messages_name);
			document.write("</a><br></li>");
		}

		document.write("</form>");
		document.write("<br>");
	}

     function show_data(form, data_type, menu_item)
     {
		var URL;
		var dt = new Date();

		highlight_menu(menu_item);

          if (data_type == 1)
			   URL = "plan/" + get_hex(form.input_text.value) + form.pw.value + ".htm";
          else if (data_type == 2)
			   URL = "atn/" + get_hex(form.input_text.value) + form.pw.value + ".htm";
          else if (data_type == 3)
			   URL = "marks/" + get_hex(form.input_text.value) + form.pw.value + ".htm";
          else if (data_type == 4)
			   URL = "fees/" + get_hex(form.input_text.value) + form.pw.value + ".htm";
          else if (data_type == 5)
			   URL = "gpa/" + get_hex(form.input_text.value) + form.pw.value + ".htm";
          else if (data_type == 6)
			   URL = "guidance/" + get_hex(form.input_text.value) + form.pw.value + ".htm";
          else if (data_type == 7)
			   URL = "trans/" + get_hex(form.input_text.value) + form.pw.value + ".htm";
          else if (data_type == 8)
			   URL = "sched/" + get_hex(form.input_text.value) + form.pw.value + ".htm";
          else if (data_type == 9)
			   URL = "tests/" + get_hex(form.input_text.value) + form.pw.value + ".htm";
          else if (data_type == 10)
			   URL = "vacc/" + get_hex(form.input_text.value) + form.pw.value + ".htm";
          else if (data_type == 11)
			   URL = "calendar" + (dt.getMonth() + 1) + ".htm";
          else if (data_type == 12)
			   URL = "smmess.htm";

          parent.sm_viewer.location = URL;
          return;
     }

	function highlight_menu(menu_item) {
		set_menu_class();
		menu_item.parentNode.className="selected_item";
	}

	function set_menu_class() {
		var nodes = document.getElementById("view_menu").getElementsByTagName("li");
		for (var i = 0; i < nodes.length; i++) {
			nodes[i].className = "unselected_item";
		}	
	}

     function MakeArray()
     {
          this.length = 16;
          return this;
     }

     function Populate()
     {
          hex = new MakeArray();
          hex[1] = "0";
          hex[2] = "1";
          hex[3] = "2";
          hex[4] = "3";
          hex[5] = "4";
          hex[6] = "5";
          hex[7] = "6";
          hex[8] = "7";
          hex[9] = "8";
          hex[10] = "9";
          hex[11] = "a";
          hex[12] = "b";
          hex[13] = "c";
          hex[14] = "d";
          hex[15] = "e";
          hex[16] = "f";

		set_menu_class();
          parent.sm_viewer.location = "smmess.htm";
     }

     function get_hex(N)
     {
          s = "";
          A = N;
          while (A >= 16) {
               B = A % 16;
               A = Math.floor(A / 16);
               s = s + hex[B+1];
          }
          s += hex[A+1];

          return transpose(s);
     }

     function transpose(s)
     {
          N = s.length;
          t = "";
          for (i = 0; i < N; i++) {
               t = t + s.substring(N-i-1, N-i);
          }

          //   zero-pad
          s = t;
          for (i = 0; i < (5 - t.length); i++) {
               s = "0" + s;
          }

          return s;
     }

// comment to end hiding -->
