//var menu_catholder = 'menu_categorie_container';
var menu_catholder = 'menu_categorie_holder';
var menu_catcontent = 'menu_categorie_content_container';
var menu_subcatholder = 'menu_subcategorie_container';
var menu_subcatcontent = 'menu_subcategorie_content_container';
var menu_ccatid;
var menusub_ccatid;
var menusub_cccatid;
var menusub_ccfid;
var getprod_go = true;

function showMenuCat(catid,ccatid){
  var url = "showMenuCategories";
  if($(menu_catholder).style.display=='none'){
    menu_ccatid=catid;
    new Ajax.Updater(menu_catcontent,url,{parameters:'js=1&catid='+catid+'&ccatid='+ccatid,onComplete:function(){Effect.SlideDown(menu_catholder,{queue:{position:'end',scope:'catmenu',limit:1},beforeStart:function(){lockGetProd();},afterFinish:function(){unlockGetProd();resizeMenu();}});} });
  }else{
    if($(menu_subcatholder).style.display != 'none'){
      hideSubCatHolder_first();
      Effect.SlideUp(menu_catholder,{queue:{position:'end',scope:'catmenu',limit:2},beforeStart:function(){lockGetProd();},afterFinish:function(){if(catid != menu_ccatid){$(menu_subcatholder).style.display='none';showMenuCat(catid,ccatid);}else{unlockGetProd();resizeMenu();}} });
    }
    else{
      Effect.SlideUp(menu_catholder,{queue:{position:'end',scope:'catmenu',limit:1},beforeStart:function(){lockGetProd();},afterFinish:function(){if(catid != menu_ccatid){$(menu_subcatholder).style.display='none';showMenuCat(catid,ccatid);}else{unlockGetProd();resizeMenu();}} });
    }
  }
}
function showMenuSubCat(obj,ccatid,cpid,catid,ccfid,cccatid,b){
  var url = "showMenuCategoryFilters";
  if(b){return b;}
  if($(menu_subcatholder).style.display=='none'){
    menusub_ccatid=ccatid;
    new Ajax.Updater(menu_subcatcontent,url,{parameters:'js=1&catid='+ccatid+'&cpid='+cpid+'&pcatid='+catid+'&ccfid='+menusub_ccfid+'&cccatid='+menusub_cccatid,onComplete:function(){showSubCatHolder(obj);} });
  }else{
    Effect.SlideUp(menu_subcatholder,{queue:{position:'end',scope:'subcatmenu',limit:1},beforeStart:function(){lockGetProd();},afterFinish:function(){ unlockGetProd();if(ccatid != menusub_ccatid){showMenuSubCat(obj,ccatid,cpid,catid,ccfid,cccatid);}  } } );
  }
  return b;
}
function hideSubCatHolder_first(){
  Effect.SlideUp(menu_subcatholder,{duration:0.5,queue:{position:'front',scope:'catmenu',limit:2},beforeStart:function(){lockGetProd();},afterFinish:function(){ $(menu_catcontent ).style.bottom='0px';  }} );
}
function hideSubCatHolder(){
  Effect.SlideUp(menu_subcatholder,{queue:{position:'end',scope:'subcatmenu',limit:1},beforeStart:function(){lockGetProd();},afterFinish:function(){ unlockGetProd();resizeMenu(); }} );
}
function showSubCatHolder(obj){
  Effect.SlideDown(menu_subcatholder,{queue:{position:'end',scope:'subcatmenu',limit:1},beforeStart:function(){lockGetProd();},afterFinish:function(){ unlockGetProd();resizeMenu();renderSub(obj); }} );
}
function lockGetProd(){
  getprod_go = false;
}
function unlockGetProd(){
  getprod_go = true;
}
function renderSub(obj){
  if(obj.href){
    window.location=obj.href;
  }
}
function toggleswitchLanguage(){
  var lang = 'language_switch_holder';
  new Effect.toggle(lang);
}
function toggleswitchCountry(){
  var country = 'country_switch_holder';
  new Effect.toggle(country,'appear',{afterFinish:function(){checkCountryToggle();}});
}
function checkCountryToggle(){
/*
  var country = 'country_switch_holder';
  var h = $('country_holder').offsetHeight;
  if($(country).style.display == ''){
    //$('country_switch_container').style.height=h+'px';
    $('country_back').style.height=h+'px';
    $('language_switch_container').style.top = h+'px';
  }else{
    //$('country_switch_container').style.height='';
    //$('country_back').style.height='';
    $('language_switch_container').style.top = '';
  }
*/
}
