
function DynamicNav(){this.iSelectedMenu;this.iNewSelectedMenu;this.iStartSelectedMenu;this.oTimer;this.bInSub=false;this.bFromSub=false;}
DynamicNav.prototype.load=function(){var oThis=this;this.iStartSelectedMenu=$('.primaryNav > li').index($('.primaryNav > .active'));this.iNewSelectedMenu=this.iStartSelectedMenu;this.secondNavBar(true);$('.primaryNav > li').mouseover(function(){oThis.iNewSelectedMenu=$('.primaryNav > li').index(this);oThis.stopTime();if(oThis.iNewSelectedMenu!=oThis.iSelectedMenu){if(oThis.bFromSub){oThis.oTimer=setTimeout(function(){oThis.secondNavBar();},200);}else{if(oThis.iSelectedMenu==oThis.iNewSelectedMenu-1){oThis.oTimer=setTimeout(function(){oThis.secondNavBar();},100);}else{oThis.secondNavBar();}}}});$('.primaryNav').mouseout(function(){oThis.closeSecondNavBar();});$('.secondNavBar').hover(function(){oThis.stopTime();oThis.bInSub=true;oThis.bFromSub=true;},function(){oThis.stopTime();oThis.bInSub=false;oThis.bFromSub=true;oThis.closeSecondNavBar();$('.secondNavBar > .contain > ul > .active').addClass('hover');});}
DynamicNav.prototype.removeOldData=function(p_iId){var iRemoveId=p_iId|this.iSelectedMenu;var oOldData=$('.secondNavBar > .contain > ul').get(0);$('.primaryNav > li:eq('+iRemoveId+')').removeClass('withOutSub');$('.primaryNav > li:eq('+iRemoveId+')').removeClass('withSub');if(oOldData){$(oOldData).appendTo('.primaryNav > li:eq('+iRemoveId+')');}}
DynamicNav.prototype.secondNavBar=function(p_bFistOpen){this.removeOldData();var oNewData=$('.primaryNav > li:eq('+this.iNewSelectedMenu+') > ul').get(0);var oMenuElement=$('.primaryNav > li:eq('+this.iNewSelectedMenu+')');if(oNewData){$(oNewData).appendTo('.secondNavBar > .contain');$(oNewData).addClass('secondaryNav');$(oMenuElement).addClass('withSub');$('.secondNavBar > .contain > ul > .active').addClass('hover');$('.secondNavBar > .contain > ul > li').each(function(){$(this).hover(function(){$('.secondNavBar > .contain > ul > li').each(function(){$(this).removeClass('hover');});$(this).addClass('hover');},function(){$(this).removeClass('hover');});});this.showSecondNavBar(p_bFistOpen);}else{$(oMenuElement).addClass('withOutSub');this.closeSecondNavBar(true);}
this.iSelectedMenu=this.iNewSelectedMenu;}
DynamicNav.prototype.showSecondNavBar=function(p_bFistOpen){if(p_bFistOpen){$('.secondNavBar').slideDown(500);}else{$('.secondNavBar').slideDown(250);}}
DynamicNav.prototype.closeSecondNavBar=function(p_bEmpty){var oThis=this;this.stopTime();if(p_bEmpty){$('.secondNavBar').slideUp('slow');}else{if(oThis.iStartSelectedMenu==null){this.oTimer=setTimeout(function(){var iRemoveId=oThis.iSelectedMenu;oThis.iSelectedMenu=null;$('.secondNavBar').slideUp('slow',function(){oThis.removeOldData(iRemoveId);});},1000);}else{this.oTimer=setTimeout(function(){oThis.iNewSelectedMenu=oThis.iStartSelectedMenu;oThis.secondNavBar();},500);}}}
DynamicNav.prototype.stopTime=function(){if(this.oTimer!=null){clearTimeout(this.oTimer);this.oTimer=null;}}
