
var AgatEngine={globals:Array(),dynamicExpressions:Array(),initialize:function(readonly){try{AgatEngine.setupFormLayout();$(document.parentWindow).bind('resize',AgatEngine.setupFormLayout);if(!readonly){$(document).bind('click',AgatEngine.onclickEvent);$(document).bind('contextmenu',AgatEngine.oncontextmenuEvent);AgatValidator.initialize();this.handleBoundControls();}
AgatWizard.setupWizard();this.setupBackgroundUrl();AgatEvents.windowOnLoadUser();$("body").show();AgatSubmitPopup.close();}catch(e){$("body").show();AgatSubmitPopup.close();}},setupFormLayout:function(){var OuterDiv=document.getElementById("OuterDiv");var scrolldiv=document.getElementById("scrolldiv");var mainDiv=document.getElementById("mainDiv");if(!OuterDiv||!scrolldiv||!mainDiv){return;}
var footer_height=0;if(showFooter){footer_height=25;var footerhtml='<table class=tfsFooter id="agat_footer" _agat_transient="1"'+' style="position: absolute;width:100%;direction:rtl; height: '+footer_height+'px; bottom: 0 ; background-color: ButtonFace" border=1 bordercolorlight=White>'+'<tr>'+'<td><SPAN id=formname>'+AgatEngine.getGeneralAttribute("tfsFormName")+'</SPAN></td>'+'<td>'+AgatEngine.getString("VERSION_TITLE","WINDOW_TITLE")+'<SPAN id=Formversion>'+AgatEngine.getGeneralAttribute("tfsVersion")+'</SPAN></td>'+'<td width=30></td>'+'<td></td>'+'</tr></table>';$("#agat_footer").remove();$("#OuterDiv").after(footerhtml);}
$("#scrolldiv")[0].style.width="";document.body.style.overflow="hidden";if(document.body.clientHeight>0){var toolbarheight;if($("#_form_DivToolbar")[0].style.display!="none"){toolbarheight=$("#_form_DivToolbar")[0].style.height.toString().toLowerCase().replace("px","");}
else toolbarheight=0;$("#scrolldiv")[0].style.height=document.body.clientHeight-toolbarheight-footer_height;}
if($("#mainDiv")[0].clientWidth>document.body.clientWidth&&document.body.clientWidth>0){$("#scrolldiv")[0].style.width=document.body.clientWidth-2;}},getGeneralAttribute:function(name){var elem=$("#GeneralAttributes");if(elem){return elem.attr(name)||"";}else{return"";}},getString:function(idstr,section,arg){var result;switch(section){case"TOOLTIP":result=AgatStrings.tooltips[idstr];break;case"WINDOW_TITLE":result=AgatStrings.titles[idstr];break;default:return"";}
if(arg!=null){result=result.toString().replace(/@@@/,"\u202b"+arg);}
return result;},displayMsgBox:function(idstr,args){var msg=null;msg="\u202b"+AgatStrings.messages[idstr];if(args){args=args.split(";");while(args.length){if(msg.indexOf("@@@")!=-1)
msg="\n"+msg.toString().replace("@@@","\u202b"+args.shift());else
msg+="\n"+args.toString().replace("@@@","\u202b"+args.shift());}}
if(msg!=null){this.VBMsgBox(msg);}
else this.VBMsgBox("Unknow error!");},userMsgBox:function(msg,title){msg="\u202b"+msg;title="\u202b"+title;if(msg!=null){this.VBMsgBox(title+"\n"+msg);}
else this.VBMsgBox("Unknow error!");},VBMsgBox:function(prompt){alert("\u202b"+prompt);return;},getWindowProperty:function(property){if(AgatEngine.globals[property]!=null){return AgatEngine.globals[property];}
else return"";},setWindowProperty:function(property,value){AgatEngine.globals[property]=value;},onclickEvent:function(evt1){var evt=evt1.originalEvent;if(evt.button!=0)return;var target=$(evt1.target);if(target.tfsAction()!=""){var handlers={"*addtablerow":AgatTables.userAddTableRow,"*deltablerow":AgatTables.delTableRow,"*submit":AgatToolbar.submitForm,"*print":AgatToolbar.printForm};var func=handlers['*'+target.tfsAction()];if(func)
func(evt1.target);}
else if(target.prev().tfsDataType()=="date"&&!target.attr("disabled")){AgatCalendar.show(evt1);}
else return;},oncontextmenuEvent:function(evt1){if($(evt1.target).is(":file")){AgatAttachment.show(evt1);return false;}
else return;},addDynamicExpression:function(id,expr,callback){this.dynamicExpressions['*'+id]={expr:expr,callback:callback};},evalInContentContext:function(expr,type){try{return type(eval(expr));}
catch(e){return null;}},handleBoundControls:function(){$("input[tfsbind],select[tfsbind],select[tfsdatatype='LookUpWindow']").each(function(){AgatBind.handleBoundControl(this);AgatLookupWindow.attachLookupPic(this);});},setupBackgroundUrl:function(){$("[tfsbackgroundurl]").each(function(){$(this).css("background-image","url("+userAttachmentsPath+"/"+$(this).attr("tfsbackgroundurl")+")");});}};