// JS Name     : ot_util.js
// Description : utilities collection for js
// Author      : Yu-Long Kung
// Date        : 2002/12/03
// Last Updated: 2002/12/03

var infoWin;
var current_index=0;
var frame_id=0;
var image_def=new Array();
var image_sel=new Array();

function show_infoWin(urllink,webtitle){
   infoWin=window.open(urllink,webtitle,
                       'toolbar=no,location=0,directories=no,menubar=no,resizable=yes,scrollbars=yes,status=no,width=600,height=450');
   infoWin.focus();
}

function OMenuInit(){
   image_def[0]="/image/company_d.png";
   image_def[1]="/image/products_d.png";
   image_def[2]="/image/services_d.png";
   image_def[3]="/image/technology_d.png";
   image_def[4]="/image/contact_d.png";

   image_sel[0]="/image/company_u.png";
   image_sel[1]="/image/products_u.png";
   image_sel[2]="/image/services_u.png";
   image_sel[3]="/image/technology_u.png";
   image_sel[4]="/image/contact_u.png";

}


function OClickImage(idx,fid){
   var imgname;
   var other_idx;

   if(current_index >= 0 ){
      imgname="menuimg"+current_index;
      document.images[imgname].src=image_def[current_index];
   }

   // frame_id = 1 head_frame
   //          = 2 left_frame
   //          = 3 main_frame
   // check whether the tag on the other frame is highlight
   if( frame_id == 1 || frame_id == 3 ){
      if( top.left_frame.current_index > -1 ){
         other_idx=top.left_frame.current_index;
         imgname="menuimg"+other_idx;
         top.left_frame.document.images[imgname].src=
         top.left_frame.image_def[other_idx];
         top.left_frame.current_index=-1;
      }
   }
 
   if( frame_id == 2 || frame_id == 3 ){
      if( top.head_frame.current_index > -1 ){
         other_idx=top.head_frame.current_index;
         imgname="menuimg"+other_idx;
         top.head_frame.document.images[imgname].src=
         top.head_frame.image_def[other_idx];                     
         top.head_frame.current_index=-1;
      }
   }

   imgname="menuimg"+idx;
   if( frame_id < 3 ){
      if(idx >= 0 )document.images[imgname].src=image_sel[idx];
      current_index=idx;
   }
   else{
      switch(fid){
         case 1:
            if(idx >=0 ){
               top.head_frame.document.images[imgname].src=
               top.head_frame.image_sel[idx];
            }
            top.head_frame.current_index=idx;
            break;
         case 2:
            if(idx >= 0 ){
               top.left_frame.document.images[imgname].src=
               top.left_frame.image_sel[idx];
            }
            top.left_frame.current_index=idx;
            break;
      }
   }
}

function OOverImage(idx){
   var imgname="menuimg"+idx;
   if(idx != current_index || current_index==-1){
      document.images[imgname].src=image_sel[idx];
   }
}

function OOutImage(idx){
   var imgname="menuimg"+idx;
   if(idx != current_index || current_index==-1){
      document.images[imgname].src= image_def[idx];
   }
}



