function Reapfield(){this.G_API=new reapfieldAPI();this.G_ViewMgr=new Object();this.G_EventMgr=new Object();this.closePrintViewID="closePrintView";this.G_API.loginDefaultUser();this.hashTag=""}Reapfield.prototype.Load=function(a){this.G_EventMgr=new RFEventManager();this.G_ViewMgr=new RFViewManager();this.G_ViewMgr.LoadView(a);window.document.onmousemove=reapfield.mouseMoveHandler};Reapfield.prototype.loadDefault=function(){if(this.G_ViewMgr.LayoutMgr.activeLayout!="landing"){this.G_ViewMgr.loadDefaultViews();this.hashTag=""}};Reapfield.prototype.hashChangeHandler=function(a){if(!a){return}var c={};this.hashTag=a.replace("#","");if(this.hashTag=="home"){this.loadDefault();return}if(this.hashTag.indexOf("view")>=0){c.moduleId=this.getModuleId(this.hashTag);if(c.moduleId==43||c.moduleId==44){c.detailId=this.infoObj||{}}if(this.hashTag.indexOf("subview")>=0){var b=this.hashTag.split("subview/");if(b.length>0){c.detailId=b[1]}}}else{if(this.isNumber(this.hashTag)){c.moduleId=42}else{c.moduleId=41}c.detailId=this.hashTag}reapfield.G_ViewMgr.loadNewModule(c)};Reapfield.prototype.getModuleId=function(b){var a=b.split("&"),c=a[0].split("/");return c[1]};Reapfield.prototype.updateHash=function(a){var b="";if(a.moduleId==42||a.moduleId==41){if(a.moduleId==42){b=a.detailId}else{if(a.moduleId==41){b=a.detailId}}}else{var b="view/"+a.moduleId;if(a.detailId){this.infoObj={};if(typeof(a.detailId)!="object"){b+="&subview/"+a.detailId}else{this.infoObj=a.detailId;if(a.moduleId==43){this.G_ViewMgr.loadNewModule(a)}}}}if(b!=this.hashTag){$.history.load(b)}};Reapfield.prototype.mouseMoveHandler=function(a){if(!a){a=window.event}reapfield.G_ViewMgr.mouseMoveHandler(a)};Reapfield.prototype.AttachEvent=function(d,b,e,a){var c=this.GetBrowserType();if(c=="NIE"){d.addEventListener(b,e,a)}else{d.attachEvent("on"+b,e)}};Reapfield.prototype.DetachEvent=function(d,b,e,a){var c=this.GetBrowserType();if(c=="NIE"){d.removeEventListener(b,e,a)}else{d.detachEvent("on"+b,e)}};Reapfield.prototype.GetBrowserType=function(){if(typeof(window.innerWidth)=="number"){return"NIE"}else{if(document.documentElement&&(document.documentElement.clientWidth||document.documentElement.clientHeight)){return"IE6"}else{if(document.body&&(document.body.clientWidth||document.body.clientHeight)){return"IE4"}}}};Reapfield.prototype.changeMode=function(a){if(a=="print"){document.getElementById("mainStyleCSSFileLink").href="css/print.css";this.addClosePrintViewLink();window.print()}else{this.removeClosePrintViewLink();document.getElementById("mainStyleCSSFileLink").href="css/styles.css"}};Reapfield.prototype.addClosePrintViewLink=function(){var a=document.getElementById(this.closePrintViewID);if(!a){var b=document.createElement("div");b.id=this.closePrintViewID;b.innerHTML="<a href='#'>Close</a>";this.AttachEvent(b,"click",function(){reapfield.changeMode()},false);document.body.appendChild(b)}else{a.style.display="block"}};Reapfield.prototype.removeClosePrintViewLink=function(){var a=document.getElementById(this.closePrintViewID);if(a){a.style.display="none"}};Reapfield.prototype.addCommas=function(b){var a=/(\d+)(\d{3})/;while(a.test(b)){b=b.replace(a,"$1,$2")}return b};Reapfield.prototype.isNumber=function(c){if(!c){return}var b="0123456789.";var d=true;var a;for(i=0;i<c.length&&d==true;i++){a=c.charAt(i);if(b.indexOf(a)==-1){d=false}}return d};Reapfield.prototype.ChangePhoto=function(c,b,e,d){if(!c||c==""){document.getElementById(b).parentNode.innerHTML="";return}var a=new Image();a.onload=function(){var j=a.width,h=a.height;var m=(e?e:100);var l=(d?d:100);if(j>=h){var g=h*m/j;if(g<=l){l=g}else{m=j*l/h}}else{tmpx=j*l/h;if(tmpx<=m){m=tmpx}else{l=h*m/j}}a.id=b;a.style.height=l+"px";a.style.width=m+"px";var k=document.getElementById(b);if(k){var f=k.parentNode;f.innerHTML="";f.appendChild(a);f.style.backgroundColor="transparent";f.style.height=l+"px"}};if(c.indexOf("http://")>=0){a.src=c}else{a.src=reapfield.G_API.webServiceURL+c}};