(function(b){var e=["log","debug","info","warn","error","assert","dir","dirxml","trace","group","groupCollapsed","groupEnd","time","timeEnd","profile","profileEnd","count","exception","table"];var d,c,a;if(typeof b.console=="undefined"||!b.console){try{b.console={}}catch(f){}}d=(g_dev&&typeof b.console.log!="undefined")?b.console.log:function(){};for(c=0,a=e.length;c<a;c++){if(!g_dev||typeof b.console[e[c]]=="undefined"||!b.console[e[c]]){try{b.console[e[c]]=d}catch(f){}}}})(window);(function($){$.fn.selectFirst=function(){var options=new Array();$(this).children().each(function(){options.push($(this).val())});var first=undefined;for(var k in options){first=options[k];break}if(first!=undefined){$(this).selectOptions(first)}return $(this)};$.fn.selectLast=function(){var options=new Array();$(this).children().each(function(){options.push($(this).val())});var last=undefined;for(var k in options){last=options[k]}if(last!=undefined){$(this).selectOptions(last)}return $(this)};$.fn.tagName=function(){try{return this.get(0).tagName.toLowerCase()}catch(err){return""}};$.fn.findId=function(){var regex=new RegExp(/[a-z_] ([0-9]{1,})/i);if(regex.exec($(this).attr("class"))[1]){return regex.exec($(this).attr("class"))[1]}return false};$.fn.findValue=function(){var regex=new RegExp(/[a-z_] [0-9]{1,}-([0-9]{1,})/i);if(regex.exec($(this).attr("class"))[1]){return regex.exec($(this).attr("class"))[1]}return false};$.fn.showAndHide=function(_html,_time){var time=_time||5000;var el=$(this);el.hide();el.html(_html).fadeIn();setTimeout('el.fadeOut().html("")',time)};$.fn.alignBoxes=function(settings){var options={path:"> .box-content",height:0,height_offset:0,debug:0};options=$.extend(options,settings);var self=this;if(options.height==0){this.each(function(){$$=options.path==""?$(this):$(this).find(options.path);if(!$$.length){console.error('alignBoxes: $("'+$(self).selector+" "+options.path+'") not found.')}$$.each(function(){var height=$(this).height();if(height>options.height){options.height=height}})})}if(options.debug){console.debug(options.height)}return this.each(function(){$$=options.path==""?$(this):$(this).find(options.path);$$.each(function(){$(this).height(options.height+options.height_offset)})})};$.fn.highlightEvenTrs=function(settings){var options={extraTrs:false,visible:false};options=$.extend(options,settings);var visible=options.visible?":visible":"";return this.each(function(){var cpt=0;$(this).find("tbody tr:not(.nohl)"+visible).removeClass("odd").removeClass("even").each(function(i){cpt=i;if(!options.extraTrs){if(cpt%2==0){$(this).removeClass("even").addClass("odd")}if(cpt%2==1){$(this).removeClass("odd").addClass("even")}}else{if(cpt%4==1||cpt%4==0){$(this).removeClass("even").addClass("odd")}if(cpt%4==2||cpt%4==3){$(this).removeClass("odd").addClass("even")}}});if($(this).find("tfoot").length){if($(this).find("tbody tr"+visible+":last").hasClass("even")){$("tfoot tr").removeClass("even").addClass("odd")}else{$("tfoot tr").removeClass("odd").addClass("even")}}})};$.fn.stylise=function(settings){var options={extraTrs:false,visible:false};options=$.extend(options,settings);var visible=options.visible?":visible":"";return this.each(function(){$(this).highlightEvenTrs(options);$(this).removeClass("odd").removeClass("even");var classe;if($(this).find("tfoot").length){classe=$(this).find("tfoot tr"+visible+":last").hasClass("even")?"even":"odd"}else{classe=$(this).find("tbody tr"+visible+":last").hasClass("even")?"even":"odd"}$(this).addClass(classe)})};$.fn.styliseGTable=function(settings){var options={extraTrs:false};options=$.extend(options,settings);return this.each(function(){var table=$(this).highlightEvenTrs(options);var div_header=$(this).prev();var div_footer=$(this).next();if(!table.find("thead").length){div_header.addClass(table.find("tbody tr:first").hasClass("even")?"even":"odd")}if(!table.find("tfoot").length){div_footer.addClass(table.find("tbody tr:last").hasClass("even")?"even":"odd")}})};$.fn.toggleCheckboxes=function(settings){var options={checked:true};options=$.extend(options,settings);return this.each(function(){$(this).prop("checked",options.checked)})};$.fn.focusClearsDefault=function(settings){var nocrlf=function(val){if(val){return val.replace(/\r?\n/g,"")}};var options={class_default:null,class_changed:null,default_value:""};options=$.extend(options,settings);return this.each(function(){var val=nocrlf($(this).attr("value"));var dval=nocrlf($(this).prop("defaultValue"))||options.default_value;if(val==dval){$(this).removeClass(options.class_changed);$(this).addClass(options.class_default)}else{$(this).removeClass(options.class_default);$(this).addClass(options.class_changed)}$(this).focus(function(ev){if(nocrlf(this.value)==nocrlf(this.defaultValue)||nocrlf(this.value)==options.default_value){this.value="";$(this).removeClass(options.class_default);$(this).addClass(options.class_changed)}else{}});$(this).blur(function(ev){if(this.value==""){$(this).addClass(options.class_default);$(this).removeClass(options.class_changed);this.value=this.defaultValue||options.default_value}else{}})})};$.fn.activateReloaders=function(){return this.each(function(){$(this).click(function(){window.location=window.location})})};$.fn.submitFormFromEl=function(e){form=$(this).closest("form");if(form){e.preventDefault();form.submit()}};$.fn.execCallback=function(settings){settings.mssg=settings.mssg||"default_confirmation_mssg";var options={mssg:settings.mssg,callback:function(){return confirm(settings.mssg)}};options=$.extend(options,settings);return this.each(function(){$(this).bind("submit",function(e,no_confirmation){if(!no_confirmation){e.preventDefault();if(eval(options.callback)($(this))){$(this).trigger("submit",1)}}})})};$.fn.openPopup=function(settings){var options={title:"Popup",height:"height=500",width:"width=650",top:"top=100",toolbar:"toolbar=no",menubar:"menubar=no",location:"location=no",resizable:"resizable=yes",scrollbars:"scrollbars=yes",status:"status=no"};options=$.extend(options,settings);var options_list=new Array();$.each(options,function(k,v){if(k!="title"){options_list.push(v)}});$(this).live("click",function(e){e.preventDefault();var w=window.open($(this).attr("href"),options.title,options_list.join(", "));if($(this).hasClass("print")){window.setTimeout(function(){w.print()},1000)}})};$.fn.openPopupLoginSearch=function(){$(this).openPopup({height:"height=700",width:"width=645"})};$.fn.makeClickable=function(settings){return this.each(function(){if($(this).find("a").attr("href")){$(this).addClass("clickable");$(this).click(function(e){if(!$(e.target).is("a")){window.location=$(this).find("a:first").attr("href")}})}})};$.fn.completeHandle=function(){return this.each(function(){var handle=$(this).val().match(/([^-]*)(-GANDI)?/)[1];if(handle){var handle=handle+"-GANDI";$(this).val(handle)}})};$.fn.clickCheckBox=function(settings){var options={cancel:":input,option,a",event:"click",checkboxSelector:"input[type=checkbox]:enabled",activeClass:"active",triggerChange:true};options=$.extend(options,settings);function setHighlight(el){var select=!!$(el).find(options.checkboxSelector).prop("checked");$(el).toggleClass(options.activeClass,select)}$(this).each(function(i){setHighlight(this)});$(this).find(options.checkboxSelector).live("change",function(e){setHighlight($(this).parents("tr"))});return $(this).live(options.event,function(e){var elIsCancel=$(e.target).parents().add(e.target).filter(options.cancel).length;if(e.button==0&&!elIsCancel){var checkbox=$(this).find(options.checkboxSelector);if(checkbox.length){if(checkbox.prop("checked")){checkbox.prop("checked",false);$(this).removeClass(options.activeClass)}else{checkbox.prop("checked",true);$(this).addClass(options.activeClass)}if(options.triggerChange){checkbox.change()}}}})};$.fn.extendHighlight=function(dataName){return this.each(function(){$(this).find("tbody tr").live("mouseover",function(e){var value=$(this).data(dataName);$(this).siblings("[data-"+dataName+'="'+value+'"]').addClass("highlighted")}).live("mouseout",function(e){$(this).siblings().removeClass("highlighted")})})};$.fn.clearableTextField=function(){try{$("::-webkit-search-cancel-button")}catch(e){function showIcon($this){$this.val().length>0?$this.next().show():$this.next().hide()}var img=$("<img/>").attr("src","/static/images/clear_cross.png").addClass("text_clear_button").css({"class":"text_clear_button",position:"absolute",top:"3px",right:"3px",cursor:"pointer",display:"none"});$(this).each(function(){$(this).after(img);showIcon($(this))});$(this).css("padding-right",img.width()+5+"px");$(this).bind("blur",function(e){showIcon($(this))});$(this).bind("keyup",function(e){showIcon($(this))})}return $(this)};$.fn.fadeToggle=function(speed,easing,callback){return this.each(function(){$(this).animate({opacity:"toggle"},speed,easing,callback)})};$.fn.uncomment=function(recurse){$(this).contents().each(function(){if(recurse&&this.hasChildNodes()){$(this).uncomment(recurse)}else{if(this.nodeType==8){var ev=$("<span>"+this.nodeValue+"</span>");$(this).replaceWith(ev.contents())}}})};$.fn.extend({ajaxModal:function(options,settings){if(typeof($().dialog)!="function"){console.error("jQuery UI is missing!")}this.each(function(){new $.ajaxModal(this,options,settings)});var onevent=$(this).tagName()=="form"?"submit":"click";if(options&&typeof(options)=="string"){if(options==="live"&&$(this).selector){$($(this).selector).live(onevent,function(e){e.preventDefault();$(this).ajaxModal("open");return false})}}return this}});$.ajaxModal=function(elem,options,settings){var $self=$(elem);var $dialog_box=$self.data("dialog")||$('<div class="modal"></div>').appendTo("body");$self.data("dialog",$dialog_box);var onevent=$self.tagName()=="form"?"submit":"click";if(options&&typeof(options)=="string"){if(options==="open"){if($self.attr("href")||$self.attr("action")){open(settings)}}else{if(options==="close"){close(settings)}else{if(options==="closeAll"){closeAll(settings)}}}return}$self.bind(onevent,function(e){e.preventDefault();var $el=$self.tagName()=="input"?$self.parents("form"):$self;$el.ajaxModal("open");return false});function open(settings){var ajaxifyParams=$self.tagName()=="form"?AJAX.hashifyForm($self):{};AJAX.ajaxify($self,{params:ajaxifyParams,success:function(response,$el){var url=this.url;if("pushState" in window.history){if(!settings){window.history.pushState({modal_href:url},"modal dialog",url)}else{window.history.replaceState({modal_href:url},"modal dialog",url)}}$self.closest("tr").addClass("open-action");$dialog_box.html(response).dialog({modal:true,width:600,close:function(e,ui){$self.ajaxModal("close")}});$dialog_box.data("isOpen",true);$dialog_box.find('[rel="button"]').bind("click",function(e){e.preventDefault();$dialog_box.dialog("close");return false});window.onpopstate=function(event){if(event.state&&event.state.modal_href==url){$self.ajaxModal("open",event)}else{if($dialog_box.data("isOpen")){$self.ajaxModal("close",event)}else{$self.ajaxModal("closeAll",event)}}}}})}function close(settings){if($dialog_box.data("isOpen")===true&&"pushState" in window.history&&!settings){window.history.back()}$dialog_box.remove();$self.closest("tr").removeClass("open-action")}function closeAll(settings){if("pushState" in window.history&&!settings){window.history.back()}$(".modal").remove();$("tr").removeClass("open-action")}};$.fn.go_history_back=function(){return this.live("click",function(e){if(window.history.length>1){e.preventDefault();window.history.back()}})};$.fn.incrementer=function(settings){var options={autoMinMax:false,buttonsClass:"jquery-incrementer",callback:function(){},callbackAdd:false,callbackRemove:false,innerLabel:"",max:1,min:0,step:1};options=$.extend(options,settings);if(typeof g_img_list=="undefined"){var path="";if(g_global_section=="hosting"){path="/static/images/hosting/";g_img_list=["simulator_add.png","simulator_add_off.png","simulator_remove.png","simulator_remove_off.png"]}else{path="/static/images/";g_img_list=["button_add.png","button_add_off.png","button_remove.png","button_remove_off.png"]}var preloadImg=[];for(var i=0,imgSrc;imgSrc=g_img_list[i];i++){preloadImg[i]=new Image();preloadImg[i].src=path+imgSrc}}return $(this).each(function(i){var el=this;var $buttons=$(el).nextAll("."+options.buttonsClass);if($buttons.length>0){if($buttons.children().is(".incrementer")){var $remove=$buttons.find(".incrementer.remove");var $add=$buttons.find(".incrementer.add")}else{var $remove=$('<a class="incrementer remove" rel="remove">-</a>').appendTo($buttons);var $add=$('<a class="incrementer add" rel="add">+</a>').appendTo($buttons)}}else{if($(el).next().is(".incrementer")){var $remove=$(el).prev(".incrementer.remove");var $add=$(el).next(".incrementer.add")}else{var $remove=$('<a class="incrementer remove" rel="remove">-</a>').insertBefore($(el));var $add=$('<a class="incrementer add" rel="add">+</a>').insertAfter($(el))}}if(options.innerLabel.length){var $wrapper=$('<span class="field_wrapper"></span>');var elID=$(el).attr("id");$(el).wrap($wrapper).after('<label for="'+elID+'" class="field_inner">'+options.innerLabel+"</label>")}var min=options.min;var max=options.max;var checkMax=max!=-1;function checkButtons(){var val=parseFloat($(el).val());if(options.autoMinMax){min=parseFloat($(el).attr("min")||$(el).find("option:enabled").first().val()||options.min);max=parseFloat($(el).attr("max")||$(el).find("option:enabled").last().val()||-1)}if($(el).prop("disabled")||$(el).prop("readonly")){max=min}checkMax=max!=-1;if(checkMax){if(val>=max){$add.addClass("disabled")}else{$add.removeClass("disabled")}if(val>max){$(el).val(max)}}if(val<=min){$remove.addClass("disabled")}else{$remove.removeClass("disabled")}eval(options.callback)(val)}function increase(){if(options.callbackAdd!==false){eval(options.callbackAdd)()}else{if(options.step===false){$(el).find("option:selected").next().prop("selected",true)}else{var my_quantity=parseFloat($(el).val());var new_quantity=my_quantity+options.step;if(my_quantity<max||!checkMax){var val=(new_quantity<=max||!checkMax)?new_quantity:max;$(el).val(val)}}}checkButtons()}function decrease(){if(options.callbackRemove!==false){eval(options.callbackRemove)()}else{if(options.step===false){$(el).find("option:selected").prev().prop("selected",true)}else{var my_quantity=parseFloat($(el).val());var new_quantity=my_quantity-options.step;if(my_quantity>min){var val=(new_quantity>=min)?new_quantity:min;$(el).val(val)}}}checkButtons()}$remove.unbind("click").bind("click",function(){$(el).focus();decrease()}).mousedown(function(){return false});$add.unbind("click").bind("click",function(){$(el).focus();increase()}).mousedown(function(){return false});if($(el).is("input")){$(el).unbind("keypress").bind("keypress",function(event){if(!event.altKey&&!event.metaKey&&!event.shiftKey){switch(event.keyCode){case keyCode.DOWN:event.preventDefault();decrease();break;case keyCode.PAGE_DOWN:case keyCode.HOME:event.preventDefault();$(el).val(min);checkButtons();break;case keyCode.PAGE_UP:case keyCode.END:if(checkMax){event.preventDefault();$(el).val(max);checkButtons();break}case keyCode.UP:event.preventDefault();increase();break}}})}$(el).unbind("change").bind("change",function(){checkButtons()});$(el).change()})};$.fn.ctrlEnter=function(option){function checkAndSubmit(ev){ev=ev?ev:event;var c=ev.charCode?ev.charCode:(ev.keyCode?ev.keyCode:(ev.which?ev.which:0));if(c==13&&ev.ctrlKey==true){$(this).parents("form").submit()}}if(option==="live"){return $(this.selector).live("keydown",checkAndSubmit)}else{return this.bind("keydown",checkAndSubmit)}};$.alt=function(key,callback,args){$(document).keydown(function(e){if(!args){args=[]}if(e.keyCode==key.charCodeAt(0)&&e.altKey){callback.apply(this,args);return false}})};$.wait=function(time){return $.Deferred(function(dfd){setTimeout(dfd.resolve,time)}).promise()};$.fn.selectPage=function(settings){var options={url:""};options=$.extend(options,settings);function show_select(e){$(this).find("select").show().end().find("span").hide()}function hide_select(e){if(!$(this).data("lock")){$(this).find("select").hide().end().find("span").show()}}function clear_select(e){if($(this).val()==$(this).find("[selected]").val()){$(this).hide().parent().data("lock",false).find("span").show()}}function keep_select(e){$(this).data("lock",true).find("select").show().end().find("span").hide()}function load_page(e){location.href=location.href.replace(/\b\d+\b/,$(this).val());$("body").addClass("progress")}function selectbox(response,elem){var select=$("<select />");for(var i=0;i<response.length;i++){var re=new RegExp("/"+response[i]["id"]);selected=window.location.pathname.match(re)?'" selected="selected"':'"';select.append('<option value="'+response[i]["id"]+selected+">"+Tools.String.decode_utf8(response[i]["name"])+"</option>")}select.appendTo(elem).hide();elem.mouseenter(show_select).click(keep_select).addClass("js").find("select").blur(clear_select).change(load_page)}return this.each(function(){AJAX.ajaxify($(this),{attr:"none",type:"GET",url:options.url,dataType:"json",success:selectbox})})};$.fn.toggleInputs=function(show){return $(this).each(function(){if(show){$(this).show().find("[data-required]").attr("required",true).removeAttr("data-required")}else{$(this).hide().find("[required]").attr("data-required",true).removeAttr("required")}})};$.fn.skinSelectBoxes=function(settings){var options={};options=$.extend(options,settings);$(this).each(function(){var $select=$(this);var $selectBoxContainer=$("<div/>").css("width",$select.outerWidth()+"px").addClass("tzSelect").html('<div class="selectBox"></div>');var $dropDown=$("<ul>").addClass("dropDown");var $selectBox=$selectBoxContainer.find(".selectBox");var selectedOptionValue=$select.val();$select.find("option").each(function(i){var $option=$(this);var optionValue=$(this).val();if(optionValue==selectedOptionValue){$selectBox.html($option.text())}if($option.data("skip")){return true}var value=$option.data("html-text")||$(this).html();var $li=$("<li>").html(value);if($option.data("icon")){$li.html('<img src="'+$option.data("icon")+'" /><span>'+$option.data("html-text")+"</span>")}$li.mouseup(function(){$dropDown.trigger("hide");$select.val($option.val()).change();return false});$dropDown.append($li)});$selectBoxContainer.append($dropDown.hide());$select.hide().after($selectBoxContainer);$dropDown.bind("show",function(){$("ul.dropDown").trigger("hide");if($(this).is(":animated")){return false}$(this).parent().addClass("expanded");$(this).slideDown(100)}).bind("hide",function(){if($(this).is(":animated")){return false}$(this).parent().removeClass("expanded");$(this).slideUp(100)}).bind("toggle",function(){if($(this).parent().hasClass("expanded")){$(this).trigger("hide")}else{$(this).trigger("show")}});$selectBox.mousedown(function(){$dropDown.trigger("toggle");return false});$select.change(function(){var selectedOptionText=$(this).find("option:selected").text();$selectBox.html(selectedOptionText)});$(document).click(function(e){if(!$(e.target).parents(".tzSelect").length){$dropDown.trigger("hide")}})})}})(jQuery);
