(function(){var Base=function(options){this.setOptions(options);this.tooltips();this.setLoadingIndicator();this.buildWindowAlert();this.buildWindowConfirm();if(typeof YAHOO.com.webucator.Form!="undefined"){this.form=new YAHOO.com.webucator.Form("bd")}};Base.prototype={constructor:Base,init:function(){},setOptions:function(options){this.options={dialogWidth:600,dialogController:"dialog",dialogAddOperation:"form-add"};YAHOO.lang.augmentObject(this.options,options||{},true)},attachScript:function(src,callback,scope){var objTransaction=YAHOO.util.Get.script(src,{onSuccess:callback,onFailure:function(){this.notify("There was an error loading a necessary file, please reload your browser.","error")},scope:scope})},evalScripts:function(responseText){var scriptStart=responseText.indexOf("<script");while(scriptStart!=-1){var scriptEnd=responseText.indexOf("<\/script",scriptStart);scriptStart=responseText.indexOf(">",scriptStart)+1;if(scriptEnd!=-1&&scriptStart!=0){eval(responseText.substr(scriptStart,scriptEnd-scriptStart));scriptStart=responseText.indexOf("<script",scriptEnd)}else{scriptStart=-1}}},setLoadingIndicator:function(){this.loadingIndicator=new YAHOO.widget.Panel("loadingIndicicator",{width:"300px",fixedcenter:true,close:true,draggable:false,modal:false,zIndex:20,visible:false});this.loadingIndicator.setHeader("Loading, please wait...");this.loadingIndicator.setBody('<img src="/images/thurber/rel_interstitial_loading.gif" style="display: block; margin-left: auto; margin-right: auto;"/><br />');this.loadingIndicator.render(document.body)},getLoadingIndicator:function(){return this.loadingIndicator},buildWindowAlert:function(){this.windowAlert=new YAHOO.widget.SimpleDialog("widget_alert",{visible:false,width:"34em",close:false,fixedcenter:true,modal:true,draggable:false,zindex:10,icon:YAHOO.widget.SimpleDialog.ICON_WARN,buttons:[{text:"OK",handler:function(){this.hide()},isDefault:true}]});this.windowAlert.setHeader("Attention Necessary");this.windowAlert.setBody("Alert body passed to window.alert");this.windowAlert.render(document.body);this.windowAlert.cfg.queueProperty("keylisteners",new YAHOO.util.KeyListener(document,{keys:32},{fn:function(){this.hide()},scope:this.windowAlert,correctScope:true}));window.alert=function(text){window.webucator.windowAlert.setBody('<span class="yui-icon warnicon"> </span><p style="margin-top: 0; margin-left: 30px; text-align:left;">'+text+"</p>");window.webucator.windowAlert.bringToTop();window.webucator.windowAlert.show()}},buildWindowConfirm:function(){var handleConfirm=function(){this.hide();var callbackFn=window.webucator.windowConfirm.callback;var scope=window.webucator.windowConfirm.scope;if(typeof callback=="function"){if(typeof scope=="undefined"||scope==null){callbackFn()}else{callbackFn.call(scope)}}};var handleCancel=function(){this.hide();return false};this.windowConfirm=new YAHOO.widget.SimpleDialog("widget_confirm",{visible:false,width:"34em",close:true,fixedcenter:true,modal:true,draggable:false,icons:YAHOO.widget.SimpleDialog.ICON_HELP,buttons:[{text:"OK",handler:handleConfirm,isDefault:true},{text:"Cancel",handler:handleCancel}]});this.windowConfirm.setHeader("Are you sure?");this.windowConfirm.setBody("Alert body passed to window.alert");this.windowConfirm.render(document.body);window.wconfirm=function(str,callback,scope){window.webucator.windowConfirm.setBody('<p style="margin-top: 0; margin-left: 30px;">'+str+"</p>");window.webucator.windowConfirm.show();window.webucator.windowConfirm.callbackScope=scope;window.webucator.windowConfirm.callback=callback}},tooltips:function(id){if(typeof id!="undefined"&&id!=null){var helpLinks=YAHOO.util.Dom.getElementsByClassName("help","a",id);new YAHOO.widget.Tooltip("helpTooltip",{context:helpLinks,container:id})}else{var helpLinks=YAHOO.util.Dom.getElementsByClassName("help","a");new YAHOO.widget.Tooltip("helpTooltip",{context:helpLinks})}},purge:function(element){var d=$(element);var a=d.attributes,i,l,n;if(a){l=a.length;for(i=0;i<l;i+=1){n=a[i].name;if(typeof d[n]==="function"){d[n]=null}}}a=d.childNodes;if(a){l=a.length;for(i=0;i<l;i+=1){this.purge(d.childNodes[i])}while(d.hasChildNodes()){d.removeChild(d.lastChild)}}else{d.parentNode.removeChild(d)}},filterAuthentication:function(rt){var loggedIn=true;if(rt.toString().indexOf('name="authenticate"')>0||rt.toString().indexOf("It doesn't appear that you have permission to access this resource")>0){loggedIn=false}if(!loggedIn){window.alert("Please authenticate.");setTimeout("window.location.reload()",1500)}},ajaxDialogHandler:function(e,controller,operation,dialog,params){if(e!=null){YAHOO.util.Event.stopEvent(e)}var dialog=new YAHOO.com.webucator.TabviewDialog(controller,operation,dialog,params);dialog.show()},showSimpleDialog:function(url,parameters,header,options,callback,scope){var config={width:"600px",height:"400px",fixedcenter:true,close:true,draggable:true,modal:true,constraintoviewport:true};YAHOO.lang.augmentObject(config,options||{},true);var now=new Date();var id="WebucatorSimpleDialog-"+now.getTime();this.simpleDialog=new YAHOO.widget.SimpleDialog(id,config);this.simpleDialog.setHeader(header);this.loadingIndicator.show();YAHOO.util.Connect.asyncRequest("GET",url+"?"+parameters,{success:function(t){this.loadingIndicator.hide();this.simpleDialog.setBody(t.responseText);this.simpleDialog.render(document.body);var bd=YAHOO.util.Dom.getElementsByClassName("bd","div",id);for(var i=0;i<bd.length;i++){bd[i].style.overflow="scroll";bd[i].style.height=config.height;bd[i].style.textAlign="left"}if(typeof callback=="function"){if(typeof scope!="undefined"&&typeof scope!=null){callback.call(scope)}else{callback()}}new YAHOO.com.webucator.Form(id);this.evalScripts(t.responseText)},failure:function(){this.loadingIndicator.hide();alert("There was a problem loading the content.  Please try again.")},scope:this})},dialogSubmit:function(e,form,dialogName,parameters,formName){var form=$(form);YAHOO.util.Event.stopEvent(e);if(typeof formName=="undefined"||formName==null){formName=dialogName}YAHOO.util.Connect.setForm(form);YAHOO.util.Connect.asyncRequest("POST",this.options.dialogController+dialogName+"/form-submit.cfm?formName="+formName+"&"+parameters,{success:function(t){var html=YAHOO.lang.trim(t.responseText);form.parentNode.innerHTML=html;this.form=new YAHOO.com.webucator.Form(YAHOO.util.Dom.generateId(form));this.evalScripts(t.responseText)},failure:function(){window.alert("There was an error submitting the form, please try again.")},scope:this});if(typeof this.form!="undefined"){this.form.destroyEditors()}},dialogAddSubmit:function(e,form,dialogName,parameters,dialogConfig){var showDialog=false;var form=$(form);var container=$(form).parentNode;YAHOO.util.Event.stopEvent(e);if(typeof dialogConfig=="object"&&typeof dialogConfig.dialogName!="undefined"){showDialog=true}YAHOO.util.Connect.setForm(form);YAHOO.util.Connect.asyncRequest("POST",this.options.dialogController+dialogName+"/form-add-submit.cfm?"+parameters,{success:function(t){if(showDialog&&YAHOO.lang.trim(t.responseText).length==0){if(dialogConfig.pkValue==null||dialogConfig.pkValue=="undefined"){for(var i=0;i<form.elements.length;i++){if(form.elements[i].name==dialogConfig.pkColumn){dialogConfig.pkValue=form.elements[i].value}}}this.showDialog(dialogConfig.dialogName,dialogConfig.pkColumn,dialogConfig.pkValue)}else{var html=YAHOO.lang.trim(t.responseText);container.innerHTML=html;this.form=new YAHOO.com.webucator.Form(YAHOO.util.Dom.generateId(container))}},failure:function(){window.alert("There was an error submitting the form, please try again.")},scope:this});if(typeof this.form!="undefined"){this.form.destroyEditors()}},deleteBean:function(beanName,pkColumn,pkValue,hideContainer,callback,scope){YAHOO.util.Connect.asyncRequest("GET",this.options.dialogController+beanName+"/delete.cfm?beanName="+beanName+"&pkColumn="+pkColumn+"&pkValue="+pkValue,{success:function(t){var status=t.status;if(typeof hideContainer!="undefined"&&hideContainer!=null){if(hideContainer.length>0){var effect=new YAHOO.widget.Effects.BlindUp(hideContainer)
}}if(typeof callback=="function"){if(typeof scope!="undefined"&&scope!=null){callback.call(scope)}else{callback()}}},failure:function(t){window.alert("There wan an error deleting the record.  Please try again.<br/><hr/>Details:<p>"+t.statusText+"</p>")},scope:this})},throttle:function(method,scope){clearTimeout(method._tId);method._tId=setTimeout(function(){method.call(scope)},100)},trim:function(str){return str.replace(/^\s+|\s+$/g,"")},unCamelize:function(s){return YAHOO.lang.trim(s.replace(/([A-Z])/g," $1"))},addSelectListOption:function(selectList,value,label){var s=$(selectList);if(arguments.length>=3){var selected=true}else{var selected=false}if(s){var n=document.createElement("option");n.text=label;n.innerHTML=label;n.value=value;try{s.add(n,null)}catch(ex){s.add(n)}if(selected){s.selectedIndex=s.options.length-1}}},removeSelectListOption:function(selectList,value){var s=$(selectList);var o=s.options;if(s){for(var i=0;i<o.length;i++){if(o[i].value==value){s.remove(i)}}}},removeSelectListOptions:function(selectList){var s=$(selectList);var o=s.options;for(var i=0;i<o.length;i++){s.remove(i)}},checkCourseRadioButtons:function(input,form,CategoryID){var input=$(input);var form=$(form);var level=input.value;var checked=input.checked;var radioNodes=YAHOO.util.Dom.getElementsByClassName("Category-"+CategoryID,"input",form);for(var i=0;i<radioNodes.length;i++){if(radioNodes[i].value==level){radioNodes[i].checked=checked}}}};YAHOO.com.webucator.Base=Base})();