﻿<!--//
var menu_status = new Array(); 

function ShowHide(theid, catid){
      var catItemFieldID = 'CatItem_' + catid;
      
      var switch_id = document.getElementById(theid);

       if(switch_id != null)
       {
        if(menu_status[theid] != 'CategoryShow') 
        {
          
          document.getElementById(catItemFieldID).className = 'ParentCategoryItemSelected';
          document.getElementById(catItemFieldID).setAttribute("class","ParentCategoryItemSelected");
           switch_id.setAttribute("class","CategoryShow");
           switch_id.className = 'CategoryShow';
           menu_status[theid] = 'CategoryShow';
        }
        else
        {
           document.getElementById(catItemFieldID).className = 'ParentCategoryItem';
           switch_id.setAttribute("class","CategoryHide");
           switch_id.className = 'CategoryHide';
           menu_status[theid] = 'CategoryHide';
        }
       }
  }
    
function SetSelectedCategory()
{
  var selectedCatField = document.getElementById('CategorySelectedId');
 
  if(selectedCatField != null)
  {
    var catItemFieldID = 'CatItem_' + selectedCatField.value;
    
    var CatItem = document.getElementById(catItemFieldID);
    
    if(CatItem != null)
    {
        if(CatItem.className = 'CategoryItem')
        {
           
           CatItem.className = 'CategoryItemSelected';
           CatItem.setAttribute("class","CategoryItemSelected");
        }
        else
        {
          CatItem.className = 'ParentCategoryItemSelected';
          CatItem.setAttribute("class","ParentCategoryItemSelected");
        }
    }
    else
    {
      var CatSubItem = document.getElementById('CatSubItem' + selectedCatField.value); 
   
      if(CatSubItem != null)
      {  
        
         ShowHide(CatSubItem.parentNode.id,CatSubItem.parentNode.name);
         CatSubItem.className = 'CategorySubItemSelected';
         CatSubItem.setAttribute("class","CategorySubItemSelected");
      }
    }
  }
}

function OpenAd(url)
{
 
 url = url.toLowerCase();
 if(url.indexOf('.jpg')>=0 || url.indexOf('.gif') >=0 || url.indexOf('.png') >=0)
 {
    document.getElementById('AdBannerImage').src = url;
    document.getElementById('AdWindow').style.display = 'block';
 }
 else{
 window.open(url,'mywindow','width=900,height=600,toolbar=no,location=yes,directories=yes,status=no,menubar=no,scrollbars=yes,copyhistory=no, resizable=yes');
 }

}

function SearchKeywordValidate(keyword)
{
 
   if(document.getElementById(keyword).value.replace(/^\s+|\s+$/g,"").length < 5)
   {
     alert('Từ khóa quá ngắn. Từ khóa phải có ít nhất 5 chữ.');
     return false;
   }
   else
   return true;
}

function OnSearchKeyEnter(textbox, e) 
{    
 if (e.keyCode == 13)
  {              
     return SearchKeywordValidate(textbox)    
  } 
} 
//-->

