var select_font_size = "9";


function show_time_selects(textbox_str) {
	var text_obj = document.getElementById(textbox_str);
	
	//tagName
	//hide text box
	text_obj.style.width = 0;
	text_obj.style.visibility = "hidden";

	//get preloaded, if any value
	var time_str = text_obj.value;
	//time_str = "09:30 PM";
	
	//delimit time str
	//time ex: hh:mm PM   string 01:34 67
	var time_hour = time_str.substring(0, 2);
	var time_min = time_str.substring(3, 5);
	var time_pm = time_str.substring(6, 8);
	
	//table to prevent slecet boxs from spilling over into next line
	document.write("<table><tr><td>");
	//select box for hour
	document.write("<select name=\""+textbox_str+"_hour\" onChange=\"update_time_Box('"+textbox_str+"');\" style=\"font-size:"+select_font_size+"pt\">");
	document.write("<option value=\"\"></option>");
	var i =1;
	for(i=1; i <= 12; i++){
		if(i < 10){
			var temp_i = "0"+i;
		}else{
			var temp_i= i;
		}
		if(temp_i == time_hour){
			var select_hour = "SELECTED";
		}else{
			var select_hour ="";
		}
		document.write("<option value=\""+temp_i+"\" "+select_hour+">"+temp_i+"</option>");
	}	
	document.write("</select>");
	
	document.write("<font size=5><b>:</b></font>");
	
	//select boc for minute
	document.write("<select name=\""+textbox_str+"_min\" onChange=\"update_time_Box('"+textbox_str+"');\" style=\"font-size:"+select_font_size+"pt\">");
	document.write("<option value=\"\"></option>");
	var i =0;
	// Florencio Almirol 6/7/07. Was i <= 60.
	for(i=0; i < 60; i++){
		if(i < 10){
			var temp_i = "0"+i;
		}else{
			var temp_i= i;
		}
		if(temp_i == time_min){
			var select_min = "SELECTED";
		}else{
			var select_min ="";
		}
		document.write("<option value=\""+temp_i+"\" "+select_min+">"+temp_i+"</option>");
	}	
	document.write("</select>");
		
	//select boc for minute
	if(time_pm == "PM"){
		var select_pm = "SELECTED";
		var select_am="";
	}
	if(time_pm == "AM"){
		var select_pm = "";
		var select_am="SELECTED";
	}
	document.write("<select name=\""+textbox_str+"_pm\" onChange=\"update_time_Box('"+textbox_str+"');\" style=\"font-size:"+select_font_size+"pt\">"+
	"<option value=\"\"></option>"+
	"<option value=\"AM\" "+select_am+">AM</option>" +
	"<option value=\"PM\" "+select_pm+">PM</option>" +
	"<select>");
	document.write("</td></tr></table>");
}

function update_time_Box(textbox_str){
	var text_obj = document.getElementById(textbox_str);
	
	//get time from select boxes
	var time_hour = document.getElementById(textbox_str+"_hour").value;
	var time_min = document.getElementById(textbox_str+"_min").value;
	var time_pm = document.getElementById(textbox_str+"_pm").value;
	text_obj.value = time_hour+":"+time_min+" "+time_pm;
		
}