jQuery(document).ready(function(){jQuery("#"+Dea.ClientIds.StartTime+", #"+Dea.ClientIds.EndTime).timePicker({increment:timeIncrement});jQuery("button, input:submit, input:reset").button();jQuery("#otabs").tabs();Dea.Get("Title").focus();var a={};a[cancelTxt]=function(){_eventId=-1;jQuery(this).dialog("close")};a[doneTxt]=function(){Dea.AddEvent.setLocation()&&jQuery(this).dialog("close")};Dea.iPopup("LocationHolderDiv",{width:400,height:_useSubLocations=="1"?200:150,title:locationsTxt,buttons:a});_useSubLocations=="1"&&jQuery("select[id*=LocationsList]").bind("change",function(){Dea.AddEvent.loadSubLocations($(this).val())})});Dea.emsData={};Dea.AddEvent={};var oStartBox=null,oEndBox,locationUrl_array=[],customFieldNum,_locationId=-1,_subLocationId=-1,_eventUdfs=[];function loadEventUdfs(c){_eventUdfs.length=0;if(c!=="")for(var d=c.split("||"),b=0;b<d.length;b++){var a=d[b].split("|");_eventUdfs.push(new udf(a[0],a[1],a[2],a[3],a[4]))}}function udf(a,e,c,b,d){a=a.replace('"',"");b=b.replace("*60*","|");this.UdqId=a;this.Box=Dea.Get(e);this.IsRequired=c;this.Question=b;this.UdfType=d}Dea.pageHandleCallback=function(a,b){if(a.success&&a.success==="0"){Dea.setAlert(a.msg);return true}switch(b){case"loadUdqs":Dea.setHtml("udqHolder",a.udqResults);if(a.hasUDQs==="1"){loadEventUdfs(a.udqIds);Dea.setDisplay("udqContainer","")}else{loadEventUdfs("");Dea.setDisplay("udqContainer","none")}eval(a.wireUpScript);return true;case"removeAttachment":mcAttachment.fileHtml=a.attachmentHolder;attachedFile();Dea.setDisplay("AttachmentFilesHolder","");return true;case"removeImage":mcAttachment.fileHtml=a.attachmentHolder;Dea.setDisplay("ImageAttachmentHolder","none");Dea.setDisplay("imageAttachContainer","");return true;case"submitEvent":if(a.forgeryErr){Dea.setAlert(a.forgeryErr);Dea.setDisabled(sSubmitButton,false);return true}if(a.phrasePassed=="1")a.redirectUrl&&a.redirectUrl!==""&&goTo(a.redirectUrl);else{Dea.setAlert(validPhraseMsg);Dea.Get(_sab629athId+"_TB_I").focus();Dea.setDisabled(sSubmitButton,false)}return true;case"previewEvent":Dea.iDialog("PreviewEvent.aspx","PreviewEventIFrame",{title:eventDetailstxt+" - "+Dea.getValue("Title"),width:650,height:600});Dea.setDisplay(customFieldLookupId,"none");return true;case"loadSubLocations":Dea.Get("sublocationContainer").innerHTML=a.subLocations;return true}return false};var mcEvent={Title:"",TitleUrl:"",Description:"",CalendarIds:"",EventTypeId:0,StatusId:2,ContactName:"",ContactPhone:"",ContactEmail:"",LocationId:0,SubLocationId:0,Location:"",LocationUrl:"",DepartmentId:-1,Department:"",TimeZoneId:0,CustomType1:-1,CustomField1:"",CustomFieldDescription1:"",CustomFieldUrl1:"",CustomType2:-1,CustomField2:"",CustomFieldDescription2:"",CustomFieldUrl2:"",Emails:"",hasRecurrence:false,Dates:"",EventDate:"",HideContactName:false,HideContactEmail:false,HideContactPhone:false,calendarNames:"",Cancel:false,PostDate:"",Phrase:"",H842KIT981MJ89:""};if(typeof departmentId==="undefined"||null===departmentId)var departmentId=-1;Dea.AddEvent.submitEvent=function(l){var a=document.getElementsByTagName("input"),c=document.getElementsByTagName("select"),t=Dea.Get("Title",a),q=Dea.Get("TitleUrl",a),C=Dea.Get("Calendars",c),f=Dea.Get("EventType",c),y=Dea.Get("EventTimeType",c),F=Dea.Get("Timezone",c),M=Dea.Get("Status",c),o=Dea.Get("ContactName",a),j=Dea.Get("ContactEmail",a),n=Dea.Get("ContactPhone",a),m=Dea.Get("LocationBox",a),B=Dea.Get("LocationUrl",a),k=Dea.Get("Department",a),g=Dea.Get("CustomFieldName1",a),w=Dea.Get("CustomFieldDescription1",a),r=Dea.Get("CustomFieldUrl1",a),h=Dea.Get("CustomFieldName2",a),x=Dea.Get("CustomFieldDescription2",a),s=Dea.Get("CustomFieldUrl2",a),L=Dea.Get("Emails",a),z=Dea.Get("CustomLink1",c),A=Dea.Get("CustomLink2",c),E=Dea.Get("PostDate",a),D=Dea.Get("EventDate",a),p=Dea.Get("startTime",a),H=Dea.Get("endTime",a);mcEvent.H842KIT981MJ89=Dea.Get("H842KIT981MJ89").value;if(_usePhrase)mcEvent.Phrase=Dea.Get(_sab629athId+"_TB_I").value;mcEvent.Title=Dea.getValue(t);mcEvent.TitleUrl=Dea.getValue(q);mcEvent.CalendarIds=mcCalendars;if(Dea.getValue(f)!=="")mcEvent.EventTypeId=Dea.getValue(f);mcEvent.Description=htmlEditor.GetHtml();mcEvent.TimeZoneId=Dea.getValue(F);if(Dea.Get("Status")&&Dea.getValue("Status")!=="")mcEvent.StatusId=Dea.getValue(M);mcEvent.ContactName=Dea.getValue(o);mcEvent.ContactEmail=Dea.getValue(j);mcEvent.ContactPhone=Dea.getValue(n);if(_locationId!=""&&_locationId>0)mcEvent.LocationId=_locationId;if(_subLocationId!=""&&_subLocationId>0)mcEvent.SubLocationId=_subLocationId;if(departmentId!=""&&departmentId>0)mcEvent.DepartmentId=departmentId;mcEvent.PostDate=Dea.Get("PostDate").value;mcEvent.EventDate=Dea.Get("EventDate").value;mcEvent.Location=Dea.getValue(m);mcEvent.LocationUrl=Dea.getValue(B);if(Dea.Get("Department")&&Dea.getValue("Department")!=="")mcEvent.Department=Dea.getValue(k);if(showCustomFields){mcEvent.CustomType1=Dea.getValue(z);mcEvent.CustomField1=Dea.getValue(g);mcEvent.CustomFieldDescription1=Dea.getValue(w);mcEvent.CustomFieldUrl1=mcEvent.CustomType1==-1?"":Dea.getValue(r);mcEvent.CustomType2=Dea.getValue(A);mcEvent.CustomField2=Dea.getValue(h);mcEvent.CustomFieldDescription2=Dea.getValue(x);mcEvent.CustomFieldUrl2=mcEvent.CustomType2==-1?"":Dea.getValue(s)}mcEvent.Emails=Dea.getValue(L);mcEvent.StartTime=Dea.getValue("startTime");mcEvent.EndTime=Dea.getValue("endTime");mcEvent.NoEndTime=Dea.Get("NoEndTime").checked;mcEvent.NextDay=Dea.Get("NextDay").checked;mcEvent.HideContactName=Dea.Get("HideContactName").checked;mcEvent.HideContactEmail=Dea.Get("HideContactEmail").checked;mcEvent.HideContactPhone=Dea.Get("HideContactPhone").checked;mcEvent.EventTimeType=Dea.getValue(y);mcEvent.hasRecurrence=mcRecurrence.hasRecurrence;if(Dea.Get("Cancel"))mcEvent.Cancel=Dea.Get("Cancel").checked;if(l)mcEvent.calendarNames=mcCalendarNames;if(mcRecurrence.hasRecurrence)mcEvent.Dates=mcRecurrence.dates;if(!Dea.validate(t,mcEvent.Title,null))return false;if(!Dea.validate(q,mcEvent.TitleUrl,null))return false;if(!Dea.validate(E,mcEvent.PostDate,null))return false;if(mcEvent.CalendarIds===""){Dea.showError(C,c,null);return false}if(jQuery("#EventTypeHolder").is(":visible")&&f.isRequired)if(mcEvent.EventTypeId==="-1"){Dea.showError(f,c,null);return false}if(editMode==0){if(!Dea.validate(o,mcEvent.ContactName,null))return false;if(!Dea.validate(j,mcEvent.ContactEmail,null)||!Dea.isValidEmail(j,invalidContactMsg,null))return false;if(!Dea.validate(n,mcEvent.ContactPhone,null))return false}if(m.isRequired)if(!Dea.validate(m,mcEvent.Location,null))return false;if(jQuery("#departmentHolder").is(":visible")&&Dea.Get("Department").disabled==false&&k.isRequired)if(!Dea.validate(k,mcEvent.Department,null))return false;if(!mcRecurrence.hasRecurrence&&!Dea.validate(D,mcEvent.EventDate,null))return false;if(!mcRecurrence.hasRecurrence&&mcEvent.EventDate!=""){evtDateArr=[];evtDateArr=Dea.getDateParts(mcEvent.EventDate);var K=new Date(evtDateArr[0],evtDateArr[1]-1,evtDateArr[2]);lastDateArr=[];lastDateArr=Dea.getDateParts(_lastDate);var G=new Date(lastDateArr[0],lastDateArr[1]-1,lastDateArr[2]);if(K>G){Dea.setAlert(lastDateViolationMsg);return false}}if(!Dea.validate(p,mcEvent.StartTime,null))return false;if(!Dea.Get("NoEndTime").checked)if(!Dea.validate(H,mcEvent.EndTime,null))return false;if(!mcEvent.NextDay&&!Dea.Get("NoEndTime").checked){var J=new Date("1/1/2007 "+mcEvent.StartTime),N=new Date("1/1/2007 "+mcEvent.EndTime),v=N-J;if(v<0){Dea.setAlert(starttimeInvalidmsg);!mcRecurrence.hasRecurrence&&p.focus();return false}}for(var b=0;b<_eventUdfs.length;b++){var u="mcEvent.udqId_"+_eventUdfs[b].UdqId,O="mcEvent.udqQuestion_"+_eventUdfs[b].UdqId,I="mcEvent.udqType_"+_eventUdfs[b].UdqId;if(l&&_eventUdfs[b].Box.tagName==="SELECT"){for(var i=0;i<_eventUdfs[b].Box.options.length;i++)if(_eventUdfs[b].Box.options[i].value==_eventUdfs[b].Box.value)eval(u+" = "+Dea.JSON.stringify(_eventUdfs[b].Box.options[i].text.trim()))}else eval(u+" = "+Dea.JSON.stringify(_eventUdfs[b].Box.value.trim()));eval(O+" = "+Dea.JSON.stringify(_eventUdfs[b].Question));eval(I+" = "+Dea.JSON.stringify(_eventUdfs[b].UdfType));var d=_eventUdfs[b].Box.getAttribute("errorMsg");if(d===null)d=_eventUdfs[b].Box.errorMsg;if(d!==undefined)d=Dea.htmlDecode(d);if(_eventUdfs[b].IsRequired==="True")if(_eventUdfs[b].Box.tagName==="SELECT"){if(_eventUdfs[b].Box.value==="0"){Dea.ctsm(null,d,_eventUdfs[b].Box);return false}}else if(_eventUdfs[b].Box.value===""){Dea.ctsm(null,d,_eventUdfs[b].Box);return false}}if(showCustomFields){var e="tabCustom";if(mcEvent.CustomFieldDescription1!==""&&mcEvent.CustomField1===""){Dea.showError(g,a,e);g.focus();return false}if(mcEvent.CustomFieldDescription2!==""&&mcEvent.CustomField2===""){Dea.showError(h,a,e);h.focus();return false}if(mcEvent.CustomType1!=-1){if(mcEvent.CustomField1===""){Dea.showError(g,a,e);return false}if(mcEvent.CustomFieldUrl1===""){Dea.showError(r,a,e);return false}}if(mcEvent.CustomType2!=-1){if(mcEvent.CustomField2===""){Dea.showError(h,a,e);return false}if(mcEvent.CustomFieldUrl2===""){Dea.showError(s,a,e);return false}}}if(l)Dea.makeCallback("previewEvent",mcEvent);else{if(_usePhrase&&Dea.Get(_sab629athId+"_TB_I").value==""){Dea.setAlert(validPhraseMsg);Dea.Get(_sab629athId+"_TB_I").focus();return false}Dea.setDisabled(sSubmitButton,true);Dea.makeCallback("submitEvent",mcEvent)}return false};Dea.AddEvent.openLocation=function(){if(_locationId>0)Dea.Get("LocationsList").value=_locationId>0?_locationId:"";if(_subLocationId>0)Dea.Get("SubLocations").value=_subLocationId>0?_subLocationId:"";jQuery("#LocationHolderDiv").dialog("option","position",[Dea.Mouse.X+10,Dea.Mouse.Y+10]);jQuery("#LocationHolderDiv").dialog("open");return false};Dea.AddEvent.loadSubLocations=function(a){if(a!=""){Dea.emsData.locationId=a;Dea.makeCallback("loadSubLocations",Dea.emsData)}else{Dea.Get("SubLocations").value="";Dea.emsData.locationId=-1;Dea.makeCallback("loadSubLocations",Dea.emsData)}return false};Dea.AddEvent.setLocation=function(){_locationId=jQuery("select[id*=LocationsList]").val()==""?-1:jQuery("select[id*=LocationsList]").val();_subLocationId=jQuery("select[id*=SubLocations]").val()==""?-1:jQuery("select[id*=SubLocations]").val();if(_locationId>0){Dea.setValue("LocationBox",jQuery("select[id*=LocationsList] option[value="+_locationId+"]").text());Dea.setValue("LocationUrl",Dea.AddEvent.getLocationUrl(_locationId))}if(_subLocationId>0)Dea.Get("LocationBox").value=Dea.Get("LocationBox").value+" "+jQuery("select[id*=SubLocations] option[value="+_subLocationId+"]").text();return true};Dea.AddEvent.getLocationUrl=function(c){for(var a=0;a<locationUrl_array.length;a++){var b=locationUrl_array[a].split("|");if(b[0]==c)return b[1]}return""};function displaySelectBoxes(){Dea.setDisplay(customFieldLookupId,"none");Dea.displaySelectBoxes()}var mcAttachment={fileHtml:"",isImage:false};function attachedFile(){jQuery("#EventAttachmentIFrame").remove();var a=mcAttachment.fileHtml.split(","),b="";if(mcAttachment.isImage){b='<div class="row">'+a[0]+' <a href="#" onclick="return removeImage('+a[0]+');">remove</a></div>';b+='<div class="spacer"></div>';Dea.setHtml("ImageAttachmentHolder",b);Dea.setDisplay("ImageAttachmentHolder","");Dea.setDisplay("imageAttachContainer","none")}else if(a.length>0&&a.toString()!==""){for(var c=0;c<a.length;c++)b+='<div class="row">'+a[c]+' <a href="#" onclick="return removeAttachment('+a[c]+');">remove</a></div>';b+='<div class="spacer"></div>';Dea.setHtml("AttachmentFilesHolder",b);Dea.setDisplay("AttachmentFilesHolder","");if(a.length>0){Dea.setDisplay("attachFileContainer","none");Dea.setDisplay("attachAnotherFileContainer","")}else{Dea.setDisplay("attachAnotherFileContainer","none");Dea.setDisplay("attachFileContainer","")}}else{Dea.setDisplay("AttachmentFilesHolder","none");Dea.setHtml("AttachmentFilesHolder","")}return false}function attachImage(){var a="";a='<div class="row">'+imageName+' <a href="#" onclick="return removeImage('+imageName+');">remove</a></div>';a+='<div class="spacer"></div>';Dea.setHtml("ImageAttachmentHolder",a);Dea.setDisplay("ImageAttachmentHolder","");Dea.setDisplay("imageAttachContainer","none");return false}function removeAttachment(a){Dea.emsData.fileName=a;Dea.emsData.isImage=false;Dea.makeCallback("removeAttachment",Dea.emsData);return false}function removeImage(a){Dea.emsData.fileName=a;Dea.emsData.isImage=true;Dea.makeCallback("removeImage",Dea.emsData);return false}function showFileDiag(b){typeof customFieldLookupId!="undefined"&&Dea.setDisplay(customFieldLookupId,"none");var a=0;if(b)a=1;var c=PathToRoot+"EventAttachment.aspx?im="+a;Dea.iDialog(c,"EventAttachmentIFrame",{title:uploadAttachmentTitle,width:400,height:200});return false}function setCustomFieldValue(a){customFieldName=a.options[a.selectedIndex].text;return}function applyCustomFieldLookup(){hideCustomFieldLookupFilters();if(typeof customFieldName==="undefined")return false;if(customFieldNum===1)Dea.setValue("CustomFieldName1",customFieldName);else Dea.setValue("CustomFieldName2",customFieldName);return false}function applyCalendars(){hideCalendarFilters();removeSelectValue(calendarDDId,-2);if(mcCalendars=="")selectValueSet(calendarDDId,"");else if(mcCalendars.indexOf(",")<=0&&mcCalendars>0)selectValueSet(calendarDDId,mcCalendars);else addMultipleSelected(calendarDDId,multipleSelectedItem);Dea.emsData.calIds=mcCalendars;Dea.makeCallback("loadUdqs",Dea.emsData);return false}Dea.AddEvent.loadCalendarDetails=function(a){var b=Dea.Get(calendarsDiv);removeSelectValue(calendarDDId,-2);if(a.value==0){SetCurrentPos(calendarsDiv);b.style.visibility="visible"}else if(a.value==-1){clearCalendars();mcCalendars="";hideCalendarFilters()}else{clearCalendars();mcCalendars="";mcCalendarNames="";addCalPopId(a.value);addCalName(a.options[a.selectedIndex].text);hideCalendarFilters()}Dea.emsData.calIds=mcCalendars;Dea.makeCallback("loadUdqs",Dea.emsData);return false};function showRecurrence(){Dea.setDisplay(customFieldLookupId,"none");var a=PathToRoot+"Recurrence.aspx";if(mcRecurrence.hasRecurrence===false){a+="?sd="+Dea.Get("EventDate").value;a+="&st="+Dea.Get("startTime").value;a+="&et="+Dea.Get("endTime").value;a+="&nd="+Dea.Get("NextDay").checked;a+="&net="+Dea.Get("NoEndTime").checked;a+="&ett="+Dea.getValue("EventTimeType")}Dea.iDialog(a,"RecurrenceIFrame",{title:recurrenceTitle,width:650,height:475});return false}function applyRecurrence(){jQuery("#RecurrenceIFrame").remove();Dea.setDisplay(customFieldLookupId,"none");if(mcRecurrence.RecurrenceClicked==false)return;else mcRecurrence.RecurrenceClicked=false;var a=Dea.Get("recurrenceText"),b=Dea.Get("dateTimeContainer"),d=Dea.Get("timeOptionsContainer"),c=Dea.Get("eventTimeTypeContainer");if(mcRecurrence.startTime!=="")Dea.Get("startTime").value=mcRecurrence.startTime;if(mcRecurrence.endTime!=="")Dea.Get("endTime").value=mcRecurrence.endTime;if(mcRecurrence.eventTimeType!==""){Dea.setValue("EventTimeType",mcRecurrence.eventTimeType);Dea.AddEvent.showTimeFields(Dea.Get("EventTimeType"))}if(mcRecurrence.noEndTime===false)Dea.Get("endTime").disabled=false;Dea.Get("NoEndTime").checked=mcRecurrence.noEndTime;Dea.Get("NextDay").checked=mcRecurrence.nextDay;if(mcRecurrence.hasRecurrence){Dea.setHtml(a,mcRecurrence.text);Dea.setDisplay(a,"");Dea.setDisplay(b,"none");Dea.setDisplay(d,"none");Dea.setDisplay(c,"none");Dea.setValue("mc_dates",mcRecurrence.dates);Dea.setDisplay("timeContainer","none")}else{Dea.setValue("EventTimeType",2);Dea.setDisplay("timeContainer","");Dea.setDisplay(a,"none");Dea.setDisplay(b,"");Dea.setDisplay(d,"");Dea.setDisplay(c,"");Dea.setValue("mc_dates","")}}var mcRecurrence={RecurrenceClicked:false,text:"",dates:"",hasRecurrence:false,startTime:"",endTime:"",noEndTime:false,nextDay:false,eventTimeType:""};Dea.AddEvent.showTimeFields=function(a){if(a.value==2){Dea.setDisplay("timeOptionsContainer","");Dea.setDisplay("timeContainer","")}else{Dea.setDisplay("timeOptionsContainer","none");Dea.setDisplay("timeContainer","none");Dea.Get("NextDay").checked=false;Dea.Get("NoEndTime").checked=false}};Dea.AddEvent.hideTimeFields=function(){Dea.setDisplay("timeOptionsContainer","none");Dea.setDisplay("timeContainer","none");Dea.Get("NextDay").checked=false;Dea.Get("NoEndTime").checked=false};Dea.AddEvent.checkUncheckNextDay=function(a){if(a.checked){Dea.Get("NoEndTime").checked=false;Dea.Get("NoEndTime").disabled=true}else Dea.Get("NoEndTime").disabled=false};Dea.AddEvent.checkUncheckEndTime=function(a){if(a.checked){Dea.Get("NextDay").checked=false;Dea.setDisabled("NextDay",true);Dea.Get("endTime").value="";Dea.setDisabled("endTime",true);jQuery("img[id*=EndTime_box]").attr("disabled","disabled")}else{Dea.setDisabled("NextDay",false);Dea.setDisabled("endTime",false);jQuery("img[id*=EndTime_box]").removeAttr("disabled")}};Dea.AddEvent.ChangeCusomType=function(a,b){if(b!=-1){Dea.setDisplay(a==1?"CustomUrl1Holder":"CustomUrl2Holder","inline");if(b>0){var c=Dea.Get(a==1?"CustomLink1":"CustomLink2").selectedIndex;Dea.setValue(a==1?"CustomFieldName1":"CustomFieldName2",Dea.Get(a==1?"CustomLink1":"CustomLink2").options[c].text);Dea.setDisabled(a==1?"CustomFieldName1":"CustomFieldName2",true);Dea.setDisplay(a==1?"helpIcon1Holder":"helpIcon2Holder","none")}else{arguments.length<3&&Dea.setValue(a==1?"CustomFieldName1":"CustomFieldName2","");Dea.setDisabled(a==1?"CustomFieldName1":"CustomFieldName2",false);Dea.setDisplay(a==1?"helpIcon1Holder":"helpIcon2Holder","inline")}}else{Dea.setDisplay(a==1?"CustomUrl1Holder":"CustomUrl2Holder","none");Dea.setValue(a==1?"CustomFieldName1":"CustomFieldName2","");Dea.setDisabled(a==1?"CustomFieldName1":"CustomFieldName2",false);Dea.setDisplay(a==1?"helpIcon1Holder":"helpIcon2Holder","inline")}return false};function cancelAction(){window.location.href=mcCancelLink;return false}Dea.AddEvent.hideTabs=function(f,g,c){for(var d=f.split(","),e=g.split(","),b=0;b<d.length;b++)Dea.setDisplay(d[b],"none");for(var a=0;a<e.length;a++)jQuery("#"+e[a]).css("display","none");c>1&&jQuery("#otabs").tabs({selected:c-1});return false}
