﻿ function PTButtonCmd(cmd,validate,CCOId){var theform;if(window.navigator.appName.toLowerCase().indexOf('netscape')>-1){theform=document.forms['_pttmf'];}else{theform=document._pttmf;}theform.ptButtonCmd.value=cmd;if(theform.ptButtonValidate&&validate!=null){theform.ptButtonValidate.value=validate;}if(validate!=false&&typeof(Page_ClientValidate)=='function'){Page_ClientValidate();}var ccoIdCtl=document.getElementById("ptButtonCCOId");if(ccoIdCtl!=null){ccoIdCtl.value=CCOId;}if(theform.onsubmit){if(theform.onsubmit()!=false)theform.submit();}else{try{theform.submit();}catch(e){}}return false;}var PTC_exitCheckDirty;var PTC_currentExitCheck;var PTC_exitCheckHandlers;var PTC_exitCheckIPWarnings;function PTC_isDirty(id){if(typeof PTC_exitCheckDirty=="undefined")return null;return PTC_exitCheckDirty[id];}function PTC_setDirty(id,val){if(typeof PTC_exitCheckDirty=="undefined")PTC_exitCheckDirty=new Object();PTC_exitCheckDirty[id]=val;}function PTC_registerChange(evt,id){if(typeof evt=="string"){id=evt;evt=event;}if(evt&&evt.type=='keydown'){if((evt.keyCode==16)||(evt.keyCode==17)||(evt.keyCode==18)||((evt.keyCode==65||evt.keyCode==67)&&evt.ctrlKey))return;}if(PTC_currentExitCheck&&PTC_currentExitCheck!=id){var msg=PTC_exitCheckIPWarnings[PTC_currentExitCheck];if(msg){alert(msg);if(evt.srcElement){evt.returnValue=false;}else{evt.preventDefault();}PTC_currentExitCheck=id;return;}}PTC_setDirty(id,true);PTC_currentExitCheck=id;}function PTC_registerExitCheck(id,leaveWarning,intraPageWarning){if(typeof PTC_exitCheckHandlers=="undefined"){PTC_exitCheckHandlers=new Array();PTC_exitCheckIPWarnings=new Object();if(window.onbeforeunload){PTC_exitCheckHandlers.push(window.onbeforeunload);}window.onbeforeunload=PTC_execOnBeforeUnload;}var fn=function(){return PTC_exitCheck(id,leaveWarning);};PTC_exitCheckHandlers.push(fn);PTC_exitCheckIPWarnings[id]=intraPageWarning;}function PTC_execOnBeforeUnload(){if(PTC_exitCheckHandlers){for(var i=0;i<PTC_exitCheckHandlers.length;i++){var fn=PTC_exitCheckHandlers[i];var ret=fn();if(ret!=null)return ret;}}return undefined;}function PTC_exitCheck(id,leaveWarning){if(PTC_isDirty(id))return leaveWarning;}function PTC_exitAllowed(id){PTC_setDirty(id,null);}function EX_setSelection(ctl,v){if(document.selection){document.selection.createRange().text=v;}else{var start=ctl.selectionStart;ctl.value=ctl.value.substring(0,start)+v+ctl.value.substr(ctl.selectionEnd,ctl.textLength);ctl.selectionStart=start+v.length;ctl.selectionEnd=start+v.length;}}function EX_getPreviousIndent(ctl){var previousText;if(document.selection){var selectionRange=document.selection.createRange();var elementRange=document.selection.createRange();elementRange.moveToElementText(ctl);elementRange.setEndPoint("EndToStart",selectionRange);previousText=elementRange.text;}else{previousText=ctl.value.substring(0,ctl.selectionStart);}var prevLine=previousText.substr(previousText.lastIndexOf("\n")+1);return prevLine.match(/^\s*/)[0];}function EX_editXmlKeyDown(ctl,evt){evt=(evt)?evt:event;var charCode=(evt.charCode)?evt.charCode:((evt.which)?evt.which:evt.keyCode);switch(charCode){case 13:case 3:var prevIndent=EX_getPreviousIndent(ctl);if(prevIndent=="")return true;EX_setSelection(ctl,"\n"+prevIndent);break;case 9:EX_setSelection(ctl,"");break;default:return true;}return false;}function EX_removeTabs(ctlId){var ctl=document.getElementById(ctlId);if(ctl.value.indexOf('\t')>-1){ctl.value=ctl.value.replace(/\t/g,'');}}function EX_gotoLine(ctl,line){var text=ctl.value;var p=-1;var origLine=line;while(--line>0){p=text.indexOf("\n",p+1);if(p==-1){p=text.length+origLine;break;}}if(document.selection){var elementRange=ctl.createTextRange();elementRange.collapse();elementRange.move("character",p-origLine+2);elementRange.select();}else{ctl.selectionStart=p+1;ctl.selectionEnd=p+1;ctl.focus();}}function EX_previewAsHTML(id){var ctl=document.getElementById(id);if(ctl){var win=window.open("","","resizable=yes,");win.document.write(ctl.value);}}function EX_reformatXML(id,evt){evt=(evt)?evt:event;var resort=false;if(evt)resort=evt.shiftKey;return PTButtonCmd("reformatXml("+id+","+(resort?1:0)+",1)",false);}function EL_enableButtons(id){var listCtl=document.getElementById(id+"_list");if(!listCtl)return;var listCtlPos=listCtl.selectedIndex;var src=document.getElementById(id+"_src");if(!src)return;var srcSel;if(src.type=="text"){srcSel=src.value!="";}else{srcSel=src.selectedIndex>-1;}document.getElementById(id+"_Add").disabled=!srcSel;document.getElementById(id+"_Remove").disabled=listCtlPos==-1;document.getElementById(id+"_MoveUp").disabled=listCtlPos<1;document.getElementById(id+"_MoveDown").disabled=listCtlPos==-1||listCtlPos==listCtl.options.length-1;}function EL_addOption(sel,index){if(index==null)index=sel.selectedIndex;var newOption=document.createElement("OPTION");sel.options[sel.options.length]=newOption;for(var i=sel.options.length-1;i>index+1;i--){sel.options[i].text=sel.options[i-1].text;sel.options[i].value=sel.options[i-1].value;}sel.selectedIndex=index+1;return sel.options[sel.selectedIndex];}function EL_doAdd(id){var listCtl=document.getElementById(id+"_list");var src=document.getElementById(id+"_src");if(src.type=="text"){var newOption=EL_addOption(listCtl);newOption.text=src.value;newOption.value=src.value;src.value="";}else{MoveOption(src,listCtl);}src.selectedIndex=-1;EL_enableButtons(id);}function EL_doRemove(id){var listCtl=document.getElementById(id+"_list");var selOption=listCtl.options[listCtl.selectedIndex];var src=document.getElementById(id+"_src");if(src.type!="text"){MoveOption(listCtl,src);}else{listCtl.options[listCtl.selectedIndex]=null;}listCtl.selectedIndex=-1;EL_enableButtons(id);}function MoveOption(objSourceElement,objTargetElement){var aryTempSourceOptions=new Array();var x=0;for(var i=0;i<objSourceElement.length;i++){if(objSourceElement.options[i].selected){var newOption=EL_addOption(objTargetElement);newOption.text=objSourceElement.options[i].text;newOption.value=objSourceElement.options[i].value;}else{var objTempValues=new Object();objTempValues.text=objSourceElement.options[i].text;objTempValues.value=objSourceElement.options[i].value;aryTempSourceOptions[x]=objTempValues;x++;}}objSourceElement.length=0;for(var i=0;i<aryTempSourceOptions.length;i++){var newOption=EL_addOption(objSourceElement);newOption.text=aryTempSourceOptions[i].text;newOption.value=aryTempSourceOptions[i].value;}}function EL_doMoveUpDown(id,down){var listCtl=document.getElementById(id+"_list");var selOption=listCtl.options[listCtl.selectedIndex];var otherOption=listCtl.options[listCtl.selectedIndex+down];var text=selOption.text;var value=selOption.value;selOption.text=otherOption.text;selOption.value=otherOption.value;otherOption.text=text;otherOption.value=value;listCtl.selectedIndex+=down;EL_enableButtons(id);}function EL_doMoveUp(id){EL_doMoveUpDown(id,-1);}function EL_doMoveDown(id){EL_doMoveUpDown(id,1);}function EL_onSubmit(id){var valueCtl=document.getElementById(id);var listCtl=document.getElementById(id+"_list");var vals="";var valueDelimiter=eval("EL_delimiter_"+id);for(var i=0;i<listCtl.options.length;i++){var opt=listCtl.options[i];if(i>0)vals+=valueDelimiter;vals+=opt.value;}valueCtl.value=vals;}function EL_refreshLists(id){var valueCtl=document.getElementById(id);var valueDelimiter=eval("EL_delimiter_"+id);var vals=valueCtl.value.split(valueDelimiter);var listCtl=document.getElementById(id+"_list");var src=document.getElementById(id+"_src");var i;var newOption;var oldOption;if(src.type!="text"){for(i=0;i<listCtl.options.length;i++){oldOption=listCtl.options[i];newOption=document.createElement("OPTION");src.options[src.options.length]=newOption;newOption.text=oldOption.text;newOption.value=oldOption.value;}}listCtl.options.length=0;for(i=0;i<vals.length;i++){var val=vals[i];if(val!=""){newOption=document.createElement("OPTION");if(src.type=="text"){listCtl.options[listCtl.options.length]=newOption;newOption.text=val;newOption.value=val;}else{for(var j=0;j<src.options.length;j++){oldOption=src.options[j];if(oldOption.value==val){listCtl.options[listCtl.options.length]=newOption;newOption.text=oldOption.text;newOption.value=oldOption.value;src.options[j]=null;}}}}}listCtl.selectedIndex=-1;if(src.type!="text")src.selectedIndex=-1;}function PTC_RegularExpressionValidatorEvaluateIsValid(val){var value=ValidatorGetValue(val.getAttribute("controltovalidate"));if(value=="")return true;var options=val.getAttribute("regexoptions");if(options==null)options="";var rx=new RegExp(val.getAttribute("validationexpression"),options);var matches=rx.exec(value);return(matches!=null&&value==matches[0]);}function PTcbo_setCheck(checkboxId,textboxId){var cBox=document.getElementById(checkboxId);var tBox=document.getElementById(textboxId);if(tBox.value!="")cBox.checked=true;else cBox.checked=false;}/*added for checkbox command to call PTButtonCmdAjax*/function PTC_getQueryStringValue(searchItem){/*returns the value of a named query string item if it exists,null if it doesn't*//*workaround with getting ampersand fromCharCode to get around the XML restrictions of the template*/var amp=String.fromCharCode(38);var rex=new RegExp(searchItem+"=[^"+amp+"]+","gi");var res=location.search.match(rex);return(res)?res.toString().split("=")[1]:null;}function PTC_setInterestLevelAjax(chkbox){var webtag=PTC_getQueryStringValue("webtag");var tid=PTC_getQueryStringValue("tid");var intLevel=(chkbox.value!=2)?2:1;chkbox.value=intLevel;PTButtonCmdAjax("/n/pfx/forum.aspx?template=commandResult&nav=iframe&webtag="+webtag,"",PT_ajaxShowAlert,"SetInterestLevel("+tid+","+intLevel+")","");}
