;(function($j){$j.fn.simplelabel=function(params){var params=$j.extend({},params);return this.each(function(){var labelsTimeOut=0;var labelWidth=$j(this).find("> :first").outerWidth();var labelHeight=$j(this).find("> :nth-child(2)").outerHeight();$j(this).css({position:"relative"}).hover(function(){var $this=$j(this);var $label=$this.find("> :nth-child(2)");labelsTimeOut=window.setTimeout(function(){$this.find("> :nth-child(2)").stop().animate({bottom:"0",opacity:".7"});},50);},function(){window.clearTimeout(labelsTimeOut);$j(this).find("> :nth-child(2)").stop().animate({bottom:"-"+labelHeight+"px",opacity:"0"});}).find("> :nth-child(2)").css({position:"absolute",bottom:"-"+labelHeight+"px",width:labelWidth+"px",opacity:"0"});});}
$j.fn.fitColumnSize=function(params){var params=$j.extend({},params);return this.each(function(){var iContainerHeight=$j("#content-container-inner").outerHeight();$j(this).css({height:iContainerHeight+"px"});});}
window.DSG=window.DSG||{};window.DSG.initColumnSize=function(){$j("#col-left").add("#col-main").add("#search-criterias").fitColumnSize();};window.DSG.initCollectionNav=function(){var jMenuCont=$j("#col-left ul.world-navigation");var jActiveUniverse=jMenuCont.find(">li.active");var jActiveUniverseCol=jActiveUniverse.find("li.collection");var jCollectionList=jActiveUniverseCol.find("ul");if(!jCollectionList.find("li").hasClass("active")){jCollectionList.hide();}
jActiveUniverseCol.find("a:first").click(function(e){var jThis=$j(this);e.preventDefault();if(!jCollectionList.is(":visible")){jCollectionList.slideDown(300);jThis.parent().addClass("active");}else{jCollectionList.slideUp(300);jThis.parent().removeClass("active");}
jThis.blur();});};window.DSG.initSessionAlert=function(bHome){var jSessionAlert=$j('#session-alert');var bIsHome=bHome||false;if(jSessionAlert.length>0){$j.superbox.settings={overlayOpacity:.4};$j.superbox();jSessionAlert.css('border','none');$j.superbox.open(jSessionAlert,{boxWidth:"350",boxHeight:"100",afterOpen:function(){if(bIsHome&&$j.browser.msie&&$j.browser.version=='7.0'){$j('#superbox-container').css('padding-top',1450);}}});}}
DSG.fn.searchByReference=function(sUrl,sHelpMessage){var xhr=null;var timeoutXhr=null;var timeoutAbort=null;var sHeaderPos=$j("#header-bottom").offset();var jForm=$j('#searchByReference');var jInput=jForm.find('input:text[name=sReference]');var jHelpMessage=$j('<p class="search-notice">'+sHelpMessage+'</p>');var addHelpMessage=jInput.focus(function(){$j('#auto-completion').remove();$j('div.search-error').remove();jHelpMessage.appendTo('#global-container').hide().css({top:(sHeaderPos.top+30)+"px"}).fadeIn(200);});var removeHelpMessage=jInput.blur(function(){jHelpMessage.fadeOut(200,function(){jHelpMessage.remove();});});timeoutClear=function(){if(xhr!=null&&xhr.readyState==4&&(xhr.status==200||xhr.status==0)){xhr.abort();xhr=null;}
clearTimeout(timeoutXhr);timeoutXhr=null;if(timeoutAbort!=null){clearTimeout(timeoutAbort);timeoutAbort=null;}};callAjax=function(){var jThisValue=$j.trim(jInput.val());xhr=$j.ajax({type:"GET",url:sUrl,timeout:2000,dataType:"json",data:{'sReference':jThisValue},success:function(data){var jLink='';var valueFormat='';$j('#auto-completion').remove();var jList=$j('<div id="auto-completion" class="search-notice"><ul></ul></div>').css({top:(sHeaderPos.top+28)+"px"});$j.each(data,function(key,value){var exp_reg=new RegExp(jThisValue,"gi");valueFormat=value.replace(exp_reg,jThisValue);jLink=$j('<li><a>'+valueFormat+'</a></li>');jLink.appendTo(jList.find('ul'));jLink.click(function(){jInput.val(value);jList.add(jHelpMessage).remove();jForm.submit();});});if(valueFormat!=''){jHelpMessage.remove();jList.appendTo('#global-container').hide().fadeIn(200);if(jList.find('li').length>15){$j('#auto-completion').css({height:300+"px","overflow-y":"scroll"});}}
else{jList.remove();}}});};var jInputAction=jInput.keyup(function(event){var jThis=$j(this);var jThisValue=$j.trim(jThis.val());$j('.errorSearch').remove();$j('.helpMessage').remove();xhr=null;timeoutClear();if(((xhr==null)||(xhr!=null&&xhr.readyState==4&&(xhr.status==200||xhr.status==0)))&&jThisValue.length>2&&jThisValue.length<20&&(event.keyCode==8||(event.keyCode>=48&&event.keyCode<=105))){timeoutXhr=setTimeout(callAjax,200);timeoutAbort=setTimeout(timeoutClear,800);}
if(jThisValue.length<3||event.keyCode==13){$j('#auto-completion').remove();$j('.helpMessage').remove();}});};})(jQuery);$j(function(){DSG.initCollectionNav();});