
var hk_r, hk_c, kl_r, kl_c, nt_r, nt_c, price,s_from,s_to,max_rows,max_cols;
hk_r=hk_c=0;
kl_r=kl_c=0;
nt_r=nt_c=0;
price=s_from=s_to='';


function selectedText(obj){
	return obj.options[obj.selectedIndex].innerText;	
}
function hk_reset()
{
  hk_r=hk_c=0;
}
 
function kl_reset()
{
  kl_r=kl_c=0;
}
 
function nt_reset()
{
  nt_r=nt_c=0;
}
 
function hk_show_price_from(max_rows)
{
	var sel_from, s;
  
  sel_from=document.getElementById('sel_hk_from');
 
  if (sel_from.selectedIndex!=0)
  {
    if (sel_from.selectedIndex<10)
      s='0'+String(sel_from.selectedIndex);
    else
      s=String(sel_from.selectedIndex);
    hk_col_on('hk_c'+s,max_rows);
  }
}
 
function hk_show_price_to(max_rows,max_cols)
{
  var obj, s, i;
  
  obj=document.getElementById('sel_hk_to');
  s=obj.options[obj.selectedIndex].innerText;
  obj=document.getElementById('tbl_hk_price');
  
  for (i=1; i<=max_rows; i++)
  {
    if (obj.rows[i].cells[0].innerText == s) 
    {
      if (i<10)
        s='0'+String(i);
      else
        s=String(i);
      hk_row_on('hk_c'+s,max_cols);    
      break;    
    }
  }
}
 
function hk_row_on(row_id,max_cols)
{
  var obj, i, s;
  
  obj=document.getElementById('tbl_hk_price');
 
  if (hk_r!=0)
  {
    for (i=1; i<=max_cols; i++)
    {  
	  if (i!=hk_c){
 	  obj.rows[hk_r].cells[i].bgColor=''; 
	  obj.rows[hk_r].cells[i].style.color='333333';
	  }
      else
	  {
	  obj.rows[hk_r].cells[i].bgColor='0066FF';
	  obj.rows[hk_r].cells[i].style.color='FFFF00';
	  }
    }
  }
 
  hk_r=parseInt(row_id.substring(row_id.length-2, row_id.length),10);
  for (i=1; i<=max_cols; i++)
  {
 	obj.rows[hk_r].cells[i].bgColor='0066FF';
 	obj.rows[hk_r].cells[i].style.color='FFFF00';
  }
        
  // update select to
  s=obj.rows[hk_r].cells[0].innerText;
  obj=document.getElementById('sel_hk_to');
  for (i=1;i<=obj.length-1; i++)
  {
    if (obj.options[i].innerText==s) 
    {
      obj.selectedIndex=i;
      break;
    } 
  }
  
  s=obj.options[obj.selectedIndex].innerText;
  s_to='';
  for (i=0; i<s.length; i++)
  { 
    if (s.charAt(i)!=' ') s_to=s_to+s.charAt(i);
  }
  
  obj=document.getElementById('tbl_hk_price');

  if ((hk_c!=0)&&(hk_r!=0))
  {
    obj.rows[hk_r].cells[hk_c].bgColor='ff6600';
	  obj.rows[hk_r].cells[hk_c].style.color='';
    price=obj.rows[hk_r].cells[hk_c].innerText;
 
    obj=document.getElementById('lbl_hk_price');
    obj.innerText=s_from+' 往 '+s_to+' ,收費$'+price;
    obj.innerText.Bold;
  } 
}
 
function hk_col_on(col_id,max_rows)
{
  var obj, i,s;
  
  obj=document.getElementById('tbl_hk_price');
 
  if (hk_c!=0)
  {
    for (i=1; i<=max_rows; i++)
    {
	  if (i==hk_r) {
	  obj.rows[i].cells[hk_c].bgColor='0066FF';
	  obj.rows[i].cells[hk_c].style.color='FFFF00';
	  }
	  else {
	  obj.rows[i].cells[hk_c].bgColor='';
	  obj.rows[i].cells[hk_c].style.color='333333';
 
	  }
    }
  }
 
  hk_c=parseInt(col_id.substring(col_id.length-2, col_id.length),10);
 
 
  for (i=1; i<=max_rows; i++)
  {
    obj.rows[i].cells[hk_c].bgColor='0066FF';
		obj.rows[i].cells[hk_c].style.color='FFFF00';
  }
  
  // update select from 
  obj=document.getElementById('sel_hk_from');
  obj.selectedIndex=hk_c;
  s=obj.options[obj.selectedIndex].innerText;
  s_from='';
  for (i=0; i<s.length; i++)
  { 
    if (s.charAt(i)!=' ') s_from=s_from+s.charAt(i);
  }
 
  obj=document.getElementById('tbl_hk_price');
  if ((hk_c!=0)&&(hk_r!=0))
  {
     obj.rows[hk_r].cells[hk_c].bgColor='ff6600';
		 obj.rows[hk_r].cells[hk_c].style.color='';
    price=obj.rows[hk_r].cells[hk_c].innerText;    
    
    obj=document.getElementById('lbl_hk_price');
    obj.innerText=s_from+' 往 '+s_to+' ,收費$'+price;
  }
}
 
 
 
 
