 var pre_open=-1;
 function _showSub(which)
 {
  var v_td=document.all.tags("TD")["menu"+which];
  var v_img=document.all.tags("IMG")["menu"+which];
  
  if (v_td.style.display=="none")
  {
   v_td.style.display="block";
   v_img.src="/images/icon_open.gif";
  }
  else
  {
   v_td.style.display="none";
   v_img.src="/images/icon_close.gif";  
  } 
  
  if(pre_open!=-1 && pre_open!=which)
  {
     var pre_td=document.all.tags("TD")["menu"+pre_open];
     var pre_img=document.all.tags("IMG")["menu"+pre_open];
     pre_td.style.display="none";  
     pre_img.src="/images/icon_close.gif";  
  } 
  pre_open=which;  
 }
 
 function blanco_print(){
   document.all.tags("TABLE")[0].style.display="none";
   var vDiv=document.all.tags("DIV")[0];   
   var vHeight=vDiv.scrollHeight;
   vDiv.style.height=vHeight;
   var vWidth=document.body.scrollWidth;  
   document.execCommand("print"); 
 }
 
 function showLink(src){
  var v_tag=document.all.rightframe;
  v_tag.src=src; 
 }
 
 function showProduct(vKey){    
   if (vKey!=0)
     var v_src="list/"+vKey;     
   else
     var v_src="list/"+event.srcElement.innerText+".htm";  
   window.open(v_src,"",getWinStatus(600,500));
 }
 
 function getWinStatus(vWidth,vHeight){
   var x=(screen.availWidth-vWidth)/2;
   var y=(screen.availHeight-vHeight)/2;
   var v_status="width="+vWidth+",height="+vHeight+",left="+x+",top="+y+",status=no,resizable=no,scrollbars=no"; 
   return v_status;
 }
 
 function page_turnTo(){    
   var v_tag=event.srcElement;
   if(v_tag.selectedIndex==0) return false;  
   var v_value=v_tag.options[v_tag.selectedIndex].value;
   location.href=v_value;
 }
 
 
 function add_turnTo(){    
   var v_tag=event.srcElement;   
   location.href="product_add"+v_tag.selectedIndex+".htm";
 } 
 
 function changeFrameHeight(){
   var v_tag=parent.document.all.rightframe;
   var v_table=parent.document.all.mainTable;
   var v_height=document.body.scrollHeight>480?document.body.scrollHeight:480;
   v_tag.height=v_height; 
   v_table.height=v_height;
 }
  
 function getImg(){
   var winName=window.name;
   var v_src="/images/product/"+winName+"_big.jpg";
   document.all.img_scale.src=v_src; 
 }

 function Refresh(){
  window.location.reload();  
 }
 
 function SelectAll(){
  if(!document.all.SelectedDocs)
   return false;
   
  var vSel=document.all.SelectedDocs;    
  if (!vSel.length) 
     vSel.checked=true;
     
  for (i=0;i<vSel.length;i++)
    vSel[i].checked=true;  
 }
 
 function Reset(){
  if(!document.all.SelectedDocs)
  return false;
   
  var vSel=document.all.SelectedDocs;    
  if (!vSel.length) 
     vSel.checked=false;
 
  for (i=0;i<vSel.length;i++)
    vSel[i].checked=false;  
 }
 
 function PageMoveTo(n,path){
  var vSrc=path+"?page="+n;
  location.href=vSrc;
 }

 function OpenLink(id,type)
 {
   var filename=type.substring(0,type.indexOf("view"));
   filename=filename.substring(filename.lastIndexOf("/")+1,filename.length);
   switch(filename.toLowerCase())
   {
    case "user":
      window.open("user_update.asp?action=view&id="+id,"",getWinStatus(400,250));
      break; 
     
   case "product":
      window.open("product.asp?action=view&id="+id,"",getWinStatus(540,360));      
      break; 
      
   case "order":
      window.open("order.asp?action=view&id="+id,"",getWinStatus(600,600));      
      break; 
      
   case "feedback":
      window.open("feedback.asp?action=view&id="+id,"",getWinStatus(600,600));      
      break; 
   default:
     return false; 
   }    
 }
 
 function fn_Search(){
  var Keyword=document.all.Keyword.value;
  if(Keyword==""){
    alert("Search keyword empty,please try again!");
    return false;  
  }
  var vSrc="Productview.asp?action=search&keyword="+Keyword;
  location.href=vSrc; 
 }
 
 function Delete(which){
  var col_id="";   
  if (!document.all.SelectedDocs) return false;
  
  var vSel=document.all.SelectedDocs;      
  if (!vSel.length)
  { 
     if (vSel.checked) col_id=vSel.value;
  }   
  else
  {    
    for (i=0;i<vSel.length;i++)  
      if (vSel[i].checked)
       col_id=col_id==""?vSel[i].value:col_id+","+vSel[i].value;          
  }
  
  if(col_id=="")
  {
   alert("Please select record to delete!");
   return false;
  }  
  var page=document.all.currentPage.selectedIndex+1;
   
  if(confirm('Please confirm deleteing these records?'))  
    location.href="delete.asp?type="+which+"&col="+col_id+"&page="+page;    
 } 
 
 


