
var scout=scout||{};(function($){if($.browser.msie&&parseFloat($.browser.version)<7){try{document.execCommand('BackgroundImageCache',false,true);}catch(e){}}
$.ajaxSetup({cache:false});scout.onJSON=function(data,status){for(var el in data){if(el=='script'){eval(data[el]);}else{var $el=$(el);if($el.length>0){$el.each(function(){$(this).html(data[el]);});}}}}
scout.fileMonitor=function(form,monitorURL){var $progress=$('<span class="progress"><span class="bar" /></span>');$(form).after($progress).hide();window.setTimeout(_monitor,1000);function _success(data,status){if(data.progress<1){$progress.children('.bar').animate({width:parseInt($progress.width())*data.progress},1000);window.setTimeout(_monitor,1000);}else{$progress.children('.bar').animate({width:parseInt($progress.width())*data.progress},1000,function(){$progress.remove();$(form).show();});}}
function _monitor(){$.getJSON(monitorURL,_success);}
return true;};$.fn.caret=function(begin,end){if(this.length==0)return;if(typeof begin=='number'){end=(typeof end=='number')?end:begin;return this.each(function(){if(end==-1)end=this.value.length;if(this.setSelectionRange){this.focus();this.setSelectionRange(begin,end);}else if(this.createTextRange){var range=this.createTextRange();range.collapse(true);range.moveEnd('character',end);range.moveStart('character',begin);range.select();}});}else{if(this[0].setSelectionRange){begin=this[0].selectionStart;end=this[0].selectionEnd;}else if(document.selection&&document.selection.createRange){var range=document.selection.createRange();begin=0-range.duplicate().moveStart('character',-100000);end=begin+range.text.length;}
return{begin:begin,end:end};}};$("a.image-button").livequery(function(){var name=$(this).attr('name');$(this).addClass('button-'+name);});$('.tags').livequery(function(){$(this).tagFormat();});$("input.tags-text").livequery(function(){$(this).tagsBox();});$("input[hint], textarea[hint]").livequery(function(){var $el=$(this);var hint=$el.attr("hint");$el.focus(function(){if($el.val()==hint){$el.val('');$el.removeClass('hint');}}).blur(function(){if($el.val()==hint||$el.val()==''){$el.val(hint);$el.addClass('hint');}}).blur();$el.bind('beforeSubmit.hint',function(){if($el.hasClass('hint')&&$el.val()==hint)$el.val('').removeClass('hint');});$(this.form).bind('submit',function(){$el.trigger('beforeSubmit.hint');return true;})});$("input[autocomplete]").livequery(function(){var url=$(this).attr('autocomplete');if(url){$(this).autocomplete({ajax:url,template:function(item){return"<li>"+item.html+"</li>";},wrapper:"<ul class='autocomplete'></ul>",insertText:function(item){return item.text;},timeout:300})}})
$('div[src]').livequery(function(){var src=$(this).attr('src');$(this).load(src);});$(':text[autosubmit]').live('keypress',function(){var typingTimeout=$.data(this,"typingTimeout");if(typingTimeout){window.clearInterval(typingTimeout);}
var $form=$(this).parents('form').eq(0);$.data(this,"typingTimeout",window.setTimeout(function(){$form.submit();},500));});$('[autoremove]').livequery(function(){var $el=$(this);window.setTimeout(function(){$el.fadeOut(function(){$(this).remove()})},$el.attr('autoremove'));});$('table.grid').livequery(function(){$(this).grid()});$('textarea.form-textarea').livequery(function(){$(this).autoGrow()});if($.browser.msie&&parseFloat($.browser.version)<=6){$('.button-container').livequery(function(){$(this).hover(function(){$('.button-hover-only',this).css('visibility','visible');},function(){$('.button-hover-only',this).css('visibility','hidden');});});}
$('span.ellipsis').livequery(function(){var $el=$('<span class="ellipsis-mark">...</span>');var $origin=$(this);$origin.hide().after($el).click(function(){$(this).toggle();$el.toggle();});$el.click(function(){$(this).toggle();$origin.toggle();});})
$('img[align]').livequery(function(){$(this).filter(':visible').css('display','block');});})(jQuery);jQuery(function($){$('.list-item').hover(function(){$('.item-options',this).css('visibility','visible');},function(){$('.item-options',this).css('visibility','hidden');});});(function($){$("a[submit]").livequery('click.submit',function(){var $form=$(this).parents('form').eq(0);$form.find('input[name=op]').val($(this).attr("op"));var href=$(this).attr('href');if(href)$form.attr('action',href);if($(this).attr('confirm')){return $(this).confirmClick();}
return $form.submit();});$.fn.confirmClick=function(){$('.confirm-tip').remove();var $btn=$(this);var confirmForm='<div class="center"><a class="image-button" name="yes"/>&#160;<a class="image-button" name="no"/></div>';$(this).showTip(confirmForm,{position:'bottom',width:'50px'});$(document).one('click',function(){$.removeTip();});$('.tip a[name='+$(this).attr('confirm')+']').attr({rel:$btn.attr('rel'),href:$btn.attr('href'),submit:$btn.attr('submit')}).click(function(){$('.confirm-tip').remove();return true;})
return false;}
$('a[onclick]').livequery(function(){$(this).css('cursor','pointer');})
$('a[confirm]').livequery('click.confirm',function(e){e.stopPropagation();return $(this).confirmClick();});$.fn.loading=function(status){return $(this).data('loading',status);}
$('a[rel][href]').livequery('click.ajax',function(e){var $link=$(this);var href=$link.attr('href');var rel=$link.attr("rel");var matches=/^json:(.*)/.exec(rel);if($(this).attr('confirm'))return true;if($link.loading())return false;if(matches){$.getJSON(href,function(data,status){eval(matches[1])(data,status);$link.loading(false);});}else if(rel.charAt(0)!='_'){$link.loading(true);if(rel.match(/^[#.>]/)){var $rel=$(rel);}else{var $rel=$('#'+rel);}
var reloadDock=$rel.attr('reloadDock');switch($rel.attr('ajaxMode')){case'replace':$.ajax({url:href,success:function(data,status){$rel.replaceWith(data);if(reloadDock)scout.dock.reload();},complete:function(){$link.loading(false);}});break;case'before':$.ajax({url:href,success:function(data,status){$rel.before(data);if(reloadDock)scout.dock.reload();},complete:function(){$link.loading(false);}});break;case'after':$.ajax({url:href,success:function(data,status){$rel.after(data);if(reloadDock)scout.dock.reload();},complete:function(){$link.loading(false);}});break;case'prepend':$.ajax({url:href,success:function(data,status){$rel.prepend(data);if(reloadDock)scout.dock.reload();},complete:function(){$link.loading(false);}});break;case'append':$.ajax({url:href,success:function(data,status){$rel.append(data);if(reloadDock)scout.dock.reload();},complete:function(){$link.loading(false);}});break;default:$.ajax({url:href,success:function(data,status){$rel.html(data);if(reloadDock)scout.dock.reload();},complete:function(){$link.loading(false);}});}}else{switch(rel){case'_application':window.open(href,'','height=480,width=720,location=0,status=0,toolbar=0,menubar=0,resizable=1,scrollbars=1')
break;case'_external':this.target='_blank';case'_self':return true;case'_dialog':$.dialog({url:href});break;case'_refresh':$link.loading(true);$.ajax({url:href,success:function(data,status){var $src=$link.parents('div[src]');if($src&&$src.length>0){$src.load($src.attr('src'),function(){if(reloadDock)scout.dock.reload();});}
else{$('<form method="post" />').appendTo('body').submit().remove();}},complete:function(){$link.loading(false);}});break;}}
e.stopPropagation();return false;});$('form[rel]').livequery(function(){var $form=$(this);var rel=$form.attr("rel");var matches=/^json:(.*)/.exec(rel);if(matches){$form.ajaxForm({dataType:'json',success:function(data,status){eval(matches[1])(data,status);}});}else if(rel.charAt(0)!='_'){$form.ajaxForm({beforeSubmit:function(){if(rel.match(/^[#\.>]/)){var $rel=$(rel);}else{var $rel=$('#'+rel);}},success:function(data,status){if(rel.match(/^[#\.>]/)){var $rel=$(rel);}else{var $rel=$(['#',rel].join(''));}
switch($rel.attr('ajaxMode')){case'replace':$rel.replaceWith(data);break;case'before':$rel.before(data);break;case'after':$rel.after(data);break;case'prepend':$rel.prepend(data);break;case'append':$rel.append(data);break;default:$rel.html(data);}}});}else{$form.ajaxForm({success:function(data,success){switch(rel){case'_refresh':var $src=$form.parents('div[src]');if($src&&$src.length>0){scout.dock.hide();$src.load($src.attr('src'),function(){scout.dock.show();});}
else{$('<form method="post"/>').appendTo('body').submit().remove();}
break;case'_dialog':$.dialog(data);break;}}});}});})(jQuery);(function($){var html=' <div id="dialog-block" /> <div id="dialog-wrapper"> <a id="dialog-close"></a> <div id="dialog-content"/> </div>';var opt={width:420};$.dialog=function(data){if($.removeTip)$.removeTip();$.dialog.init();return $.dialog.reveal(data);}
var inited=false;$.dialog.init=function(){if(inited)return;else inited=true;$('body').append(html);}
$.dialog.reveal=function(data){var pageSize=$.dialog.getPageSize();$('#dialog-content').html('<div class="loading" />');var pageScroll=$.dialog.getPageScroll();$('#dialog-wrapper').css({'width':opt.width,'margin-top':pageScroll[1]+60}).show();return $('#dialog-content').slideDown('fast',function(){var pageScroll=$.dialog.getPageScroll();var htmlHeight=$('html').height();if(pageSize[1]>htmlHeight)htmlHeight=pageSize[1];$('#dialog-block').css({height:htmlHeight,opacity:.8}).fadeIn();$('#dialog-close').one('click',function(){$.dialog.close();});$(document).bind('keydown.dialog',function(e,close){if(close||e.keyCode==27){if($.isFunction(opt.cancel))opt.cancel();$.dialog.close();return false;}})
if(typeof(data)=='object'){$.extend(opt,data);if(opt.url){$.post(opt.url,opt.post||{},$.dialog._reveal);}else{$.dialog._reveal(opt.data);}}else{$.dialog._reveal(data);}});}
$.dialog._reveal=function(data){$('#dialog-content').slideUp('fast',function(){$('#dialog-wrapper').css({'width':opt.width}).show();$(this).html(data).slideDown('fast',function(){if($.isFunction(opt.success)){this._tmp_function=opt.success;this._tmp_function();delete this._tmp_function;}
$(this).addClass('dialog-shadow');});$('.cancel-button',this).click(function(){$(document).trigger('keydown.dialog',[1]);});});}
$.dialog.close=function(){$(document).trigger('close.dialog');return true;}
$(document).bind('close.dialog',function(){$(document).unbind('keydown.dialog');$('#dialog-wrapper').fadeOut('fast',function(){$('#dialog-block').fadeOut('fast');});})
$.dialog.getPageScroll=function(){var xScroll,yScroll;if(self.pageYOffset){yScroll=self.pageYOffset;xScroll=self.pageXOffset;}else if(document.documentElement&&document.documentElement.scrollTop){yScroll=document.documentElement.scrollTop;xScroll=document.documentElement.scrollLeft;}else if(document.body){yScroll=document.body.scrollTop;xScroll=document.body.scrollLeft;}
return new Array(xScroll,yScroll);}
$.dialog.getPageSize=function(){var xScroll,yScroll;if(window.innerHeight&&window.scrollMaxY){xScroll=window.innerWidth+window.scrollMaxX;yScroll=window.innerHeight+window.scrollMaxY;}else if(document.body.scrollHeight>document.body.offsetHeight){xScroll=document.body.scrollWidth;yScroll=document.body.scrollHeight;}else{xScroll=document.body.offsetWidth;yScroll=document.body.offsetHeight;}
var windowWidth,windowHeight;if(self.innerHeight){if(document.documentElement.clientWidth){windowWidth=document.documentElement.clientWidth;}else{windowWidth=self.innerWidth;}
windowHeight=self.innerHeight;}else if(document.documentElement&&document.documentElement.clientHeight){windowWidth=document.documentElement.clientWidth;windowHeight=document.documentElement.clientHeight;}else if(document.body){windowWidth=document.body.clientWidth;windowHeight=document.body.clientHeight;}
if(yScroll<windowHeight){pageHeight=windowHeight;}else{pageHeight=yScroll;}
if(xScroll<windowWidth){pageWidth=xScroll;}else{pageWidth=windowWidth;}
arrayPageSize=new Array(pageWidth,pageHeight,windowWidth,windowHeight)
return arrayPageSize;}})(jQuery);jQuery(function($){$(window).resize(function(){var pageSize=$.dialog.getPageSize();$('#dialog-block').css('height',pageSize[1]);});});jQuery(function($){var $current_tip=null;var animating=null;var curr_index=0;var $button_clicked=false;var info_button_interval;function button_setInterval(){info_button_interval=window.setInterval(function(){curr_index++;if(curr_index>=$('#info-button a').length)curr_index=0;$('#info-button a').eq(curr_index).mouseover();},3000);}
function button_clearInterval(e){if(e.pageX&&info_button_interval){window.clearInterval(info_button_interval);}}
button_setInterval();$('#info').mouseout(function(){if(!$button_clicked)
button_setInterval();}).mouseover(function(e){$button_clicked=false;button_clearInterval(e);});$('#info-button a').click(function(e){$button_clicked=true;button_clearInterval(e);}).mouseover(function(e){button_clearInterval(e);if($(this).hasClass('hover'))return false;curr_index=$('#info-button a').index(this);if($current_tip)$current_tip.stop();$(this).addClass('hover').siblings('a').removeClass('hover');var $tip=$(['#',$(this).attr('tip_id')].join(''));if($.browser.msie){$current_tip=$('#tip-container').html($tip.html());$current_tip=null;}else{$tc=$('#tip-container');$oheight=$tc.height();$tc.html($tip.html()).css({opacity:0,height:'auto'});$nheight=$tc.height();$tc.css({height:$oheight}).animate({opacity:1,height:$nheight},'fast',function(){$current_tip=null;});}}).eq(curr_index).mouseover();});