var $j=jQuery.noConflict();var appContext="";if(!window.console||!console.firebug){var names=["log","debug","info","warn","error","assert","dir","dirxml","group","groupEnd","time","timeEnd","count","trace","profile","profileEnd"];window.console={};for(var i=0;i<names.length;++i){window.console[names[i]]=function(){}}names=null}function debugOut(a){window.console.log(a)}$j(document).ready(function(){$j(".spinner").ajaxStart(function(){$j(this).show()});$j(".spinner").ajaxStop(function(){$j(this).hide()})});var bertram={dropDownTimeouts:[],reloadPage:function(){window.location=window.location.href},openPage:function(a){if(a.indexOf("http")>-1){window.location=a}else{window.location=appContext+"/"+a}},openWindow:function(b){var a=window.open(b,"_blank");a.focus();return a},showError:function(c){var d=$j("#flashTable");var a=$j(".errors",d);var b=$j("li",a);b.html(c);a.show();d.show()},doRefresh:function(a,b,d){try{jQuery.ajax({url:a,type:"GET",cache:false,success:function(f){try{jQuery(b).html(f);if(d){d()}}catch(g){}}})}catch(c){alert(c)}},doFormPost:function(a,c,f,b){try{if(c){jQuery.post(a,jQuery("#"+f).serialize(),function(g,j){try{jQuery(b).empty()}catch(h){}jQuery(b).html(g)})}else{document.getElementById(f).submit()}}catch(d){alert(d)}},getTabSelector:function(a){return"#"+$j(a).closest(".ui-tabs-panel").attr("id")},initDatePickers:function(){$j(".dateInput").datepicker({changeMonth:true,changeYear:true,showOn:"button",buttonImage:"/images/calendar.png",buttonImageOnly:true});$j("#ui-datepicker-div").css("z-index","8000")},initScriptTable:function(b,c,d,a){$j("#"+b+" tr").bind("click",function(g){var f=$j(this).attr("id");f=Number(f.replace(c,""));$j("#"+b+" .selected").removeClass("selected");$j(this).addClass("selected");if(d){d(f)}});$j("#"+b+" tr").bind("dblclick",function(g){var f=$j(this).attr("id");f=Number(f.replace(c,""));$j("#"+b+" .selected").removeClass("selected");$j(this).addClass("selected");if(d){d(f)}if(a){a(f)}})},imageMouseover:function(c){var b=$j(c).attr("mouseoverimage");if(b){$j(c).attr("src",b)}else{var a=$j(c).attr("src");if(a.indexOf("__v")>-1){a=a.split("__v");a[a.length-2]=a[a.length-2]+"OVER";a=a.join("__v");$j(c).attr("src",a);$j(c).attr("mouseoverimage",a)}else{a=a.split(".");a[a.length-2]=a[a.length-2]+"OVER";a=a.join(".");$j(c).attr("src",a);$j(c).attr("mouseoverimage",a)}}},imageMouseout:function(a){$j(a).attr("src",$j(a).attr("src").split("OVER").join(""))},addImageRollover:function(a){$j(a).hover(function(){imageMouseover(this)},function(){imageMouseout(this)})},addCssImageRollover:function(b,a){$j(b).hover(function(){$j(this).css("background-image",$j(this).css("background-image").split(".").join("OVER."))},function(){$j(this).css("background-image",$j(this).css("background-image").split("OVER").join(""))})},getBrowserDimensions:function(){var a={width:0,height:0};if(document.documentElement){a.width=document.documentElement.offsetWidth;a.height=document.documentElement.offsetHeight}else{if(window.innerWidth&&window.innerHeight){a.width=window.innerWidth;a.height=window.innerHeight}}return a},formatDateOrTime:function(a){if(a){if(currentDate.getTime()-a.getTime()<86400000){if(currentDate.getDay()==a.getDay()){return formatTime(a)}else{return formatDate(a)}}return formatDate(a)}return""},formatDateAndTime:function(a){return formatDate(a)+" "+formatTime(a)},formatTime:function(b){if(b){var c=Number(b.getMinutes());var a=b.getHours();if(c<10){c="0"+c}if(a==12){c=c+" pm"}else{if(a>12){a=a-12;c=c+" pm"}else{if(a==0){a=12;c=c+" am"}else{a=a;c=c+" am"}}}return a+":"+c}return""},formatDate:function(a){if(a){return a.getMonth()+1+"-"+a.getDate()+"-"+a.getFullYear()}return""},formatMaxText:function(b,a){if(b){if(b.length>a){return b.substring(0,a)+"..."}else{return b}}return""},setCookie:function(e,d,c,b){var a=new Date();a.setDate(a.getDate()+b);document.cookie=e+"="+escape(d)+((b==null)?"":";path="+c+";expires="+a.toGMTString())},getCookie:function(c){if(document.cookie.length>0){var b=document.cookie.indexOf(c+"=");if(b!=-1){b=b+c.length+1;var a=document.cookie.indexOf(";",b);if(a==-1){a=document.cookie.length}return unescape(document.cookie.substring(b,a))}}return""},stripStringHtml:function(a){if(a){return a.replace(/(<([^>]+)>)/ig,"")}return a},addHiddenLineBreaks:function(a){if(a){a=a.replace("/","&zwsp;")}return a},getImagePath:function(b){var a=b.split(".");if(appVersion&&appVersion.length>0){a[a.length-2]=a[a.length-2]+"__v"+appVersion}return appContext+a.join(".")},attachDropDownMenu:function(a){$j("#"+a+"Link").click(function(){handleDropDownClick(a)});$j("#"+a+"Button").click(function(){handleDropDownClick(a)})},handleDropDownClick:function(e){var d=$j("#"+e+"Menu");var a=$j("#"+e);var c=a.offset();if(!d.attr("initialized")){d.remove().appendTo("body");d.attr("initialized",true);d.hover(function(){cancelDropDownMenuTimeout(e)},function(){dropDownTimeouts[e]=setTimeout("closeDropDownMenu('"+e+"')",1000)})}d.css("top",c.top+16);d.css("left",c.left);var b=d.attr("showing");if(b=="true"){d.attr("showing","false");d.slideUp()}else{d.attr("showing","true");d.slideDown();dropDownTimeouts[e]=setTimeout("closeDropDownMenu('"+e+"')",3000)}},closeDropDownMenu:function(c,a){var b=$j("#"+c+"Menu");if(b.length>0){b.attr("showing","false");b.slideUp()}},cancelDropDownMenuTimeout:function(a){if(dropDownTimeouts[a]){window.clearTimeout(dropDownTimeouts[a])}},reloadPage:function(){window.location.reload(true)},attachInputToDisplay:function(b,a){$j(b).change(function(){var c=$j(this).val();if(c){$j(a).text(c)}else{$j(a).text("")}})},linkInputs:function(b,a){checkLinkedFields($j(b).get(0),a);checkLinkedFields($j(a).get(0),b);$j(b).change(function(){checkLinkedFields(this,a)});$j(a).change(function(){checkLinkedFields(this,b)})},checkLinkedFields:function(d,a){var c=$j(d).val();var b=$j(a).val();if(c){if(c!=b){$j(a).val(c)}}}};
