﻿// Copyright (c) 2009 Language Analytics LLC //
// Build 4511 //
var s_undoText="",s_typedCount=0,s_clip,s_copyMessageTimeout;function noYamli(){return typeof Yamli!="object"||!Yamli.isSupported()}function getQuery(){var a=[],b=location.href.indexOf("#");if(b==-1)return a;b=location.href.substring(b+1);if(b.length===0)return a;b=b.replace(/\+/g," ");b=b.split("&");var c;for(c=0;c<b.length;++c){var d=b[c].split("="),e=decodeURIComponent(d[0]),f=e;if(d.length==2)f=decodeURIComponent(d[1]);a[e]=f}return a}
function resetControls(){var a=document.getElementById("editor"),b=document.getElementById("align_left_link"),c=document.getElementById("align_left_active"),d=document.getElementById("align_right_link"),e=document.getElementById("align_right_active"),f=document.getElementById("enable_link"),g=document.getElementById("disable_link");if(a.yamliManager.getDirection()=="rtl"){b.style.display="inline";c.style.display="none";d.style.display="none";e.style.display="inline"}else{b.style.display="none";c.style.display=
"inline";d.style.display="inline";e.style.display="none"}if(a.yamliManager.getEnabled()){f.style.display="none";g.style.display="inline"}else{f.style.display="inline";g.style.display="none"}a.yamliManager.resetLayout();a.focus()}function alignLeft(){if(!noYamli()){var a=document.getElementById("editor");a.yamliManager.setDirection("ltr");document.getElementById("text_direction").value="ltr";resetControls()}}
function alignRight(){if(!noYamli()){var a=document.getElementById("editor");a.yamliManager.setDirection("rtl");document.getElementById("text_direction").value="rtl";resetControls()}}function enableYamli(){if(!noYamli()){var a=document.getElementById("editor");a.yamliManager.setEnabled(true);resetControls()}}function disableYamli(){if(!noYamli()){var a=document.getElementById("editor");a.yamliManager.setEnabled(false);resetControls()}}
function showTips(a){if(!noYamli()){var b=document.getElementById("show_tips_link"),c=document.getElementById("hide_tips_link"),d=document.getElementById("div_tips");if(a){b.style.display="none";c.style.display="inline";d.style.display="block"}else{b.style.display="inline";c.style.display="none";d.style.display="none"}}}function prepCopy(){s_clip.setText(document.getElementById("editor").value)}
function copyToClipboard(){window.clipboardData&&navigator.userAgent.toLowerCase().indexOf("msie 6.0")!=-1&&window.clipboardData.setData("Text",document.getElementById("editor").value)}function hideCopyMessage(){s_copyMessageTimeout=undefined;document.getElementById("copy_message").style.display="none"}
function showCopyMessage(){document.getElementById("copy_message").style.display="inline";s_copyMessageTimeout&&clearTimeout(s_copyMessageTimeout);s_copyMessageTimeout=setTimeout(hideCopyMessage,3000)}function showClearMessage(){document.getElementById("clear_message").style.display="inline"}function hideClearMessage(){document.getElementById("clear_message").style.display="none"}function hideMessages(){hideCopyMessage();hideClearMessage()}
function showMsInstructions(){if(navigator.userAgent.toLowerCase().indexOf("windows")>-1)document.getElementById("ms_instructions").style.visibility="visible"}var flashCount,flashInterval;function onFlash(){if(flashCount>8){$("#ms_instructions").removeClass("flash");clearInterval(flashInterval);flashInterval=0}else{$("#ms_instructions").toggleClass("flash");++flashCount}}
function flashMsInstructions(){if(navigator.userAgent.toLowerCase().indexOf("windows")>-1){flashCount=0;clearInterval(flashInterval);flashInterval=setInterval(onFlash,200)}}function doCopy(){if(!(noYamli()||document.getElementById("copy_link").disabled)){hideMessages();copyToClipboard();showCopyMessage();flashMsInstructions();typeof _gat=="object"&&pageTracker._trackPageview("/editor/doCopy")}}
function doClear(){if(!(noYamli()||document.getElementById("clear_link").disabled)){hideMessages();var a=document.getElementById("editor");s_undoText=a.value;a.value="";showClearMessage();typeof _gat=="object"&&pageTracker._trackPageview("/editor/doClear")}}function undoClear(){var a=document.getElementById("editor");a.value=s_undoText;hideClearMessage()}
function hideInst(){document.getElementById("div_inst").style.display="none";document.getElementById("div_tips_box").style.display="block";Yamli.I.setCookie("hide_inst",1,1825)}function heartBeat(){typeof _gat=="object"&&pageTracker._trackPageview("/editor/evHeatBeat")}
function onKeyUp(){hideMessages();++s_typedCount;var a=document.getElementById("editor");if(s_typedCount>25||a.value.split(" ").length>5){hideInst();Yamli.I.removeEvent(a,"keyup",onKeyUp)}if(s_typedCount==3){typeof _gat=="object"&&pageTracker._trackPageview("/editor/evTyped");setInterval(heartBeat,20000)}}
function doPrint(){if(!(noYamli()||document.getElementById("print_link").disabled)){hideMessages();var a=document.getElementById("editor_form");a.action="/editor/print.aspx";a.submit();typeof _gat=="object"&&pageTracker._trackPageview("/editor/doPrint")}}
function doSave(){if(!(noYamli()||document.getElementById("save_link").disabled)){hideMessages();var a=document.getElementById("editor_form");a.action="/editor/save.ashx";a.submit();typeof _gat=="object"&&pageTracker._trackPageview("/editor/doSave")}}
function onCheckin(){var a=document.getElementById("editor");Yamli.I.addEvent(a,"keydown",hideMessages);Yamli.I.addEvent(a,"keyup",onKeyUp);Yamli.I.addEvent(a,"change",hideMessages);resetControls();document.getElementById("div_controls").style.display="block";document.getElementById("save_link").disabled=false;document.getElementById("print_link").disabled=false;document.getElementById("copy_link").disabled=false;document.getElementById("clear_link").disabled=false;var b=getQuery().text;if(b&&b.length>
0){a.value=b;a.yamliManager.setSelection(b.length,b.length)}ZeroClipboard.setMoviePath("/js/ZeroClipboard.swf");s_clip=new ZeroClipboard.Client;s_clip.setCSSEffects(true);s_clip.addEventListener("mouseOver",prepCopy);s_clip.addEventListener("mouseDown",doCopy);Yamli.I.addEvent(window,"resize",function(){s_clip.reposition()});s_clip.glue("copy_link");showMsInstructions();Yamli.I.addEvent(document.getElementById("editor"),"copy",flashMsInstructions)};
