
Runner.namespace('Runner.pages');Runner.pages.constants={PAGE_LIST:"list",PAGE_ADD:"add",PAGE_INLINE_ADD:"inline_add",PAGE_EDIT:"edit",PAGE_INLINE_EDIT:"inline_edit",PAGE_VIEW:"view",PAGE_SEARCH:"search",PAGE_REPORT:"report",PAGE_CHART:"chart",PAGE_PRINT:"print",PAGE_EXPORT:"export",PAGE_IMPORT:"import",PAGE_ADMIN_MEMBERS:"admin_members",PAGE_ADMIN_RIGHTS:"admin_rights",PAGE_MASTER_INFO_LIST:"masterlist",PAGE_MASTER_INFO_PRINT:"masterprint",PAGE_REGISTER:"register",PAGE_MENU:"menu",PAGE_REMIND:"remind",PAGE_CHANGEPASS:"changepass",PAGE_LOGIN:"login",LIST_SIMPLE:0,LIST_LOOKUP:1,LIST_DETAILS:3,LIST_AJAX:4,RIGHTS_PAGE:5,MEMBERS_PAGE:6,ADD_SIMPLE:0,ADD_INLINE:1,ADD_ONTHEFLY:2,ADD_MASTER:3,ADD_POPUP:4,EDIT_SIMPLE:0,EDIT_INLINE:1,EDIT_ONTHEFLY:2,EDIT_POPUP:3};Runner.pages.PageManager=function(){var tables={},beforeUnloadPool=[];if(window.onunload){beforeUnloadPool.push(window.onBeforeUnload,window,[]);}
window.onunload=function(){window.Runner.pages.PageManager.callUnload();}
return{register:function(pageController){if(!pageController){return false;}
var pageTable=pageController.tName;if(!tables[pageTable]){tables[pageTable]={};}
var pageId=pageController.pageId;tables[pageTable][pageId]=pageController;return true;},getAt:function(tName,pageId){if(!tables[tName]){return false;}
if(!tables[tName][pageId]){return false;}
return tables[tName][pageId];},unregister:function(tName,pageId){if(!tables[tName]){return false;}
if(!pageId){for(var id in tables[tName]){this.unregister(tName,id);}
delete tables[tName];}else{if(tables[tName][pageId].destructor){tables[tName][pageId].destructor();}
Runner.pages.PageControlsMap.removeMap(tName,tables[tName][pageId].pageType,pageId);delete tables[tName][pageId];}
return true;},initPages:function(){var controlsMap=Runner.pages.PageControlsMap.getMap(),cfg;for(var tName in controlsMap){for(var pageType in controlsMap[tName]){for(var pageId in controlsMap[tName][pageType]){cfg={tName:tName,pageType:pageType,pageId:pageId,controlsMap:controlsMap[tName][pageType][pageId],pageMode:Runner.pages.PageSettings.getTableData(tName,"pageMode",0)};this.initPage(cfg);}}}
this.initPages=Runner.emptyFn;stopLoading(1,0);},initPage:function(cfg){var page=Runner.pages.PageFabric(cfg);if(!page.fly){page.init();}else{page.initFlyPage();}},openPage:function(pageParams){if(this.getAt(pageParams.tName,pageParams.pageId)){var page=this.getAt(pageParams.tName,pageParams.pageId);page.show();return pageParams.pageId;}
pageParams.pageId=Runner.genId();var reqParams={rndval:Math.random(),id:pageParams.pageId,onFly:1,isNeedSettings:true};Runner.apply(reqParams,pageParams.baseParams);var pageManager=this,ajaxRequestUrl=Runner.pages.getUrl(pageParams.tName,pageParams.pageType,pageParams.keys,pageParams.keyPref);$.getJSON(ajaxRequestUrl,reqParams,function(ctrlsJSON){Runner.pages.PageSettings.addSettings('',ctrlsJSON.settings);Runner.pages.PageControlsMap.addMap(pageParams.tName,pageParams.pageType,pageParams.pageId,ctrlsJSON.controlsMap);var cfg={tName:pageParams.tName,pageType:pageParams.pageType,editType:pageParams.editType||pageParams.baseParams.editType,pageId:pageParams.pageId,controlsMap:ctrlsJSON.controlsMap[pageParams.tName][pageParams.pageType][pageParams.pageId],headerCont:ctrlsJSON.headerCont||"&nbsp;",bodyCont:ctrlsJSON.html||"&nbsp;",fotterCont:ctrlsJSON.fotterCont||"&nbsp;",fly:true,submitUrl:ajaxRequestUrl};Runner.apply(cfg,pageParams);pageManager.initPage(cfg);Runner.setIdCounter(ctrlsJSON.idStartFrom);});return reqParams.id},addUnloadHn:function(hn,scope,args){if(typeof hn!='function'){return false;}
beforeUnloadPool.push({fn:hn,scope:scope||window,args:args||[]});return true;},callUnload:function(){var scope,args;for(var i=0;i<beforeUnloadPool.length;i++){scope=beforeUnloadPool[i].scope;args=beforeUnloadPool[i].args;beforeUnloadPool[i].fn.apply(scope,args);}
for(var tName in tables){this.unregister(tName);}}}}();Runner.namespace('Runner.pages');Runner.pages.PageControlsMap=function(){window.controlsMap=JSON.parse(window.controlsMap)||{};return{addMap:function(tName,pageType,pageId,map){if(!tName||!pageType||typeof pageId=='undefined'){return false;}
if(!controlsMap[tName]){controlsMap[tName]={};}
if(!controlsMap[tName][pageType]){controlsMap[tName][pageType]={};}
controlsMap[tName][pageType][pageId]=map[tName][pageType][pageId];},getMap:function(tName,pageType,pageId){if(!tName){return controlsMap;}
if(!pageType){return controlsMap[tName];}
if(typeof pageId=='undefined'){return controlsMap[tName][pageType];}
return controlsMap[tName][pageType][pageId];},removeMap:function(tName,pageType,pageId){if(!tName||!pageType||typeof pageId=="undefined"){return false;}
if(!controlsMap[tName]){return false;}
if(!controlsMap[tName][pageType]){return false;}
delete controlsMap[tName][pageType][pageId];return true;}};}();Runner.pages.PageSettings=function(){window.settings=JSON.parse(window.settings)||{tables:{}};Runner.setIdCounter(settings['global'].idStartFrom);Runner.debugMode=settings['global'].debugMode;Runner.charSet=settings['global'].charSet;this.getSettings=function(tName,fName){if(!tName){return settings;}
if(!fName){return settings.tableSettings[tName];}
return settings.tableSettings[tName]['fieldSettings'][fName];};};Runner.pages.PageSettings=Runner.extend(Runner.pages.PageSettings,{checkSettings:function(tName,fName){var settings=this.getSettings(tName,fName);if(settings){return true;}else{return false;}},loadSettings:function(tName,pageType){},addPageEvent:function(tName,pType,evName,evHn){if(!settings.tableSettings[tName]){settings.tableSettings[tName]={};}
if(!settings.tableSettings[tName]["events"]){settings.tableSettings[tName]["events"]={};}
if(!settings.tableSettings[tName]["events"][pType]){settings.tableSettings[tName]["events"][pType]={};}
if(!settings.tableSettings[tName]["events"][pType][evName]){settings.tableSettings[tName]["events"][pType][evName]=[];}
settings.tableSettings[tName]["events"][pType][evName].push({hn:evHn});},addSettings:function(tName,addSettings,forceRewrite){if(!addSettings){return false;}
var settings=this.getSettings();Runner.setIdCounter(settings['global'].idStartFrom);Runner.apply(settings.global.shortTNames,addSettings.global.shortTNames);if(forceRewrite===true){settings.tableSettings[tName]=addSettings.tableSettings[tName];return;}
if(!tName){Runner.deepCopy(settings.tableSettings,addSettings.tableSettings);}else{settings.tableSettings[tName]=settings.tableSettings[tName]||{};Runner.deepCopy(settings.tableSettings[tName],addSettings.tableSettings[tName]);}
return true;},getViewType:function(tName,fName){if(typeof settings.tableSettings[tName]["fieldSettings"][fName]!='undefined'&&typeof settings.tableSettings[tName]["fieldSettings"][fName]["viewFormat"]!='undefined'){return settings.tableSettings[tName]["fieldSettings"][fName]["viewFormat"];}else{return settings.fieldDefSettings.ViewFormat||Runner.controls.constants.FORMAT_NONE;}},getEditFormat:function(tName,fName){if(typeof settings.tableSettings[tName]["fieldSettings"][fName]!='undefined'&&typeof settings.tableSettings[tName]["fieldSettings"][fName]["editFormat"]!='undefined'){return settings.tableSettings[tName]["fieldSettings"][fName]["editFormat"];}else{return settings.fieldDefSettings.EditFormat||Runner.controls.constants.EDIT_FORMAT_NONE;}},getShortTName:function(tName){if(!tName){return"";}
return settings.global.shortTNames[tName]||settings.tableSettings[tName].shortTName||"";},getValidations:function(tName,fName){if(typeof settings.tableSettings[tName]["fieldSettings"][fName]!='undefined'&&typeof settings.tableSettings[tName]["fieldSettings"][fName]["validation"]!='undefined'){return settings.tableSettings[tName]["fieldSettings"][fName]["validation"];}else{return settings.fieldDefSettings.validation||{validationArr:[],regExp:null};}},getDisabledStatus:function(tName,fName){if(typeof settings.tableSettings[tName]["fieldSettings"][fName]!='undefined'&&typeof settings.tableSettings[tName]["fieldSettings"][fName]["isDisabled"]!='undefined'){return settings.tableSettings[tName]["fieldSettings"][fName]["isDisabled"];}else{return settings.fieldDefSettings.isDisabled||false;}},getHiddenStatus:function(tName,fName){if(typeof settings.tableSettings[tName]["fieldSettings"][fName]!='undefined'&&typeof settings.tableSettings[tName]["fieldSettings"][fName]["isHidden"]!='undefined'){return settings.tableSettings[tName]["fieldSettings"][fName]["isHidden"];}else{return settings.fieldDefSettings.isHidden||false;}},getCategoryField:function(tName,fName){if(typeof settings.tableSettings[tName]["fieldSettings"][fName]!='undefined'&&typeof settings.tableSettings[tName]["fieldSettings"][fName]["categoryField"]!='undefined'){return settings.tableSettings[tName]["fieldSettings"][fName]["categoryField"];}else{return settings.fieldDefSettings.categoryField||false;}},getLookupTable:function(tName,fName){if(typeof settings.tableSettings[tName]["fieldSettings"][fName]!='undefined'&&typeof settings.tableSettings[tName]["fieldSettings"][fName]["lookupTable"]!='undefined'){return settings.tableSettings[tName]["fieldSettings"][fName]["lookupTable"];}else{return"";}},getLookupSize:function(tName,fName){if(typeof settings.tableSettings[tName]["fieldSettings"][fName]!='undefined'&&typeof settings.tableSettings[tName]["fieldSettings"][fName]["selectSize"]!='undefined'){return settings.tableSettings[tName]["fieldSettings"][fName]["selectSize"];}else{return settings.fieldDefSettings.selectSize||0;}},getLCT:function(tName,fName){if(typeof settings.tableSettings[tName]["fieldSettings"][fName]!='undefined'&&typeof settings.tableSettings[tName]["fieldSettings"][fName]["lcType"]!='undefined'){return settings.tableSettings[tName]["fieldSettings"][fName]["lcType"];}else{return settings.fieldDefSettings.lcType||Runner.controls.constants.LCT_DROPDOWN;}},getTableData:function(tName,key,defVal){if(typeof settings.tableSettings[tName]!='undefined'&&typeof settings.tableSettings[tName][key]!='undefined'){return settings.tableSettings[tName][key];}else{return settings.tableDefSettings[key]||defVal;}},getFieldData:function(tName,fName,key,defVal){if(typeof settings.tableSettings[tName]["fieldSettings"][fName]!='undefined'&&typeof settings.tableSettings[tName]["fieldSettings"][fName][key]!='undefined'){return settings.tableSettings[tName]["fieldSettings"][fName][key];}else{return defVal||settings.fieldDefSettings[key];}},getRTECKDim:function(tName){if(typeof settings.tableSettings[tName]!='undefined'){var fieldSet=settings.tableSettings[tName]["fieldSettings"];for(var field in fieldSet){if(fieldSet[field].RTEType=='RTECK'){return{nWidth:fieldSet[field].nWidth,nHeight:fieldSet[field].nHeight};}}}
return false;},getGlobalData:function(key,defVal){return settings['global'][key]||defVal;}});Runner.pages.PageSettings=new Runner.pages.PageSettings();Runner.pages.PageFabric=function(baseCfg){var cfg={};Runner.apply(cfg,baseCfg);switch(cfg.pageType){case Runner.pages.constants.PAGE_LIST:if(cfg.fly){return new Runner.pages.ListPageFly(cfg);}else if(cfg.pageMode==Runner.pages.constants.LIST_AJAX){return new Runner.pages.ListPageAjax(cfg);}else if(cfg.dp){return new Runner.pages.ListPageDP(cfg);}else if(cfg.pageMode==Runner.pages.constants.RIGHTS_PAGE){return new Runner.pages.RightsPage(cfg);}else if(cfg.pageMode==Runner.pages.constants.MEMBERS_PAGE){return new Runner.pages.MembersPage(cfg);}else{return new Runner.pages.ListPage(cfg);}
break;case Runner.pages.constants.PAGE_ADD:if(cfg.editType==Runner.pages.constants.ADD_ONTHEFLY){return new Runner.pages.AddPageFly(cfg);}else{return new Runner.pages.AddPage(cfg);}
break;case Runner.pages.constants.PAGE_EDIT:return new Runner.pages.EditPage(cfg);break;case Runner.pages.constants.PAGE_VIEW:return new Runner.pages.ViewPage(cfg);break;case Runner.pages.constants.PAGE_SEARCH:return new Runner.pages.SearchPage(cfg);break;case Runner.pages.constants.PAGE_REPORT:return new Runner.pages.ReportPage(cfg);break;case Runner.pages.constants.PAGE_CHART:return new Runner.pages.ChartPage(cfg);break;case Runner.pages.constants.PAGE_REGISTER:return new Runner.pages.RegisterPage(cfg);break;case Runner.pages.constants.PAGE_EXPORT:return new Runner.pages.ExportPage(cfg);break;case Runner.pages.constants.PAGE_IMPORT:return new Runner.pages.ImportPage(cfg);break;default:cfg.createAsDefault=true;return new Runner.pages.RunnerPage(cfg);break;}};Runner.pages.getUrl=function(tName,pageType,keys,keyPref){var url=Runner.pages.PageSettings.getShortTName(tName)+"_"+pageType+".php",i=0,key;keyPref=keyPref||"editid";for(key in keys){url+="?";break;}
for(key in keys){i++;url+=keyPref+i+"="+escape(keys[key])+"&";}
for(key in keys){url=url.substring(0,url.length-1);break;}
return url;};Runner.pages.RunnerPage=Runner.extend(Runner.util.Observable,{tName:'',pageType:'',parentPage:null,modal:false,pageId:-1,controlsMap:null,fly:false,headerCont:"",bodyCont:"",fotterCont:"",win:null,winDiv:null,createAsDefault:false,useAsGlobal:false,destroyOnClose:false,afterClose:null,shortTName:"",constructor:function(cfg){Runner.apply(this,cfg);Runner.pages.PageManager.register(this);this.addEvents('beforeInit','afterInit','filesLoaded','afterClose');this.id=this.pageId;this.shortTName=Runner.pages.PageSettings.getShortTName(this.tName);},destructor:function(){if(this.win){this.win.destroy();}
this.purgeListeners();Runner.controls.ControlManager.unregister(this.tName,this.pageId);},init:function(){this.fireEvent('beforeInit',this);if(Runner.pages.PageSettings.getTableData(this.tName,"isUseIbox",false)&&window.init_ibox){init_ibox();}
if(Runner.isChrome){$('span.buttonborder').removeClass('buttonborder');}
$('body').addClass("yui-skin-sam");window.MaxWindowPage=3;this.initMenu();s508pagination(this.id);this.initEvents();this.initControls();this.initLookups();if(this.createAsDefault){this.fireEvent('afterInit',this,this.id);}
setHoverForTR(false,this.id,Runner.pages.PageSettings.getTableData(this.tName,"isUseHighlite",false),Runner.pages.PageSettings.getTableData(this.tName,"listIcons",false),Runner.pages.PageSettings.getTableData(this.tName,"isUseResize",false));},initToolTips:function(toolTips,tName){tName=tName||this.tName;if(!Runner.pages.PageSettings.getTableData(this.tName,"isUseToolTips",false)){return false;}
if(!$('#shiny_box').length){var div=document.createElement('DIV');$(div).css('display','none').attr('id','shiny_box').addClass('shiny_box').addClass('_hintBox').appendTo(document.body);$(document.createElement('DIV')).addClass('shiny_box_body').appendTo(div);}
toolTips=toolTips||this.controlsMap.toolTips||[];var ctrls=Runner.controls.ControlManager.getAt(tName);for(var i=0;i<ctrls.length;i++){if(ctrls[i]&&typeof toolTips[ctrls[i].fieldName]=='string'){ctrls[i].initToolTip(toolTips[ctrls[i].fieldName],this);}}
return true;},initMenu:function()
{if($("div.Gmenu").length&&$($("div.Gmenu")[0]).attr("initialized")!="true")
{Gmenu();$($("div.Gmenu")[0]).attr("initialized","true");}
if($("div.Vmenu2").length&&$($("div.Vmenu2")[0]).attr("initialized")!="true")
{Vmenu2();openMenuItemsOnLoad();$($("div.Vmenu2")[0]).attr("initialized","true");}
if($("div.Vmenu1").length&&$($("div.Vmenu1")[0]).attr("initialized")!="true")
{Vmenu1();$($("div.Vmenu1")[0]).attr("initialized","true");}},initVideo:function(videoMap){if(!Runner.pages.PageSettings.getTableData(this.tName,"isUseVideo",false)){return false;}
videoMap=videoMap||this.controlsMap.video;for(var i=0;i<videoMap.length;i++){if($("#"+videoMap[i]).length){flowplayer(videoMap[i],"include/video/flowplayer-3.2.3.swf",{clip:{autoPlay:false,autoBuffering:false,url:escape($("#"+videoMap[i]).attr("href"))}});}}},initAudio:function(){if(!Runner.pages.PageSettings.getTableData(this.tName,"isUseAudio",false)){return false;}
this.preprocessAudioLinks();if(!YAHOO.mediaplayer.loadPlayerScript.bCalled){YAHOO.mediaplayer.loadPlayerScript();}else{if(this.lookupBaseParams){YAHOO.MediaPlayer.addTracks($("#grid_block"+this.lookupBaseParams.id).get(0),null,true);}
else if(this.id){if($("#fields_block"+this.id).length>0){YAHOO.MediaPlayer.addTracks($("#fields_block"+this.id).get(0));}else if($("#grid_block"+this.id).length>0){YAHOO.MediaPlayer.addTracks($("#grid_block"+this.id).get(0));}}}},preprocessAudioLinks:function(){var audioLinks=$(".htrack");var lastInd=document.location.href.lastIndexOf("/");var addHref=document.location.href.substr(0,lastInd+1);if(addHref.substr(7,9)=='localhost'){addHref=addHref.replace('localhost','127.0.0.1');}
for(var i=0;i<audioLinks.length;i++){var link=$(audioLinks[i]).attr("href");if(link.substr(0,4)=="http"){var fixedLink=link.replace('http://localhost','http://127.0.0.1');if(link!=fixedLink){$(audioLinks[i]).attr("href",fixedLink);}}
else{$(audioLinks[i]).attr("href",(addHref+link));}}
return audioLinks.length;},initFlyPage:function(){this.initFly();this.loadFiles();},loadFiles:function(){if(!this.fly){return false;}
this.initCustomButtons();if(Runner.pages.PageSettings.getTableData(this.tName,"isUseIbox",false)){Runner.util.ScriptLoader.addJS(["include/ibox.js"]);Runner.util.ScriptLoader.loadCSS(["include/ibox"]);}
if(Runner.pages.PageSettings.getTableData(this.tName,"isUseVideo",false)){Runner.util.ScriptLoader.addJS(["include/video/flowplayer-3.2.3.min.js"]);}
if(Runner.pages.PageSettings.getTableData(this.tName,"isUseAudio",false)){Runner.util.ScriptLoader.addJS(["http://mediaplayer.yahoo.com/js"]);}
if(Runner.pages.PageSettings.getTableData(this.tName,"isUseToolTips",false)){Runner.util.ScriptLoader.addJS(["include/jquery.dimensions.js"]);Runner.util.ScriptLoader.addJS(["include/jquery.inputhintbox.js"],"include/jquery.dimensions.js");Runner.util.ScriptLoader.loadCSS(["include/tooltip"]);}
var fSett=Runner.pages.PageSettings.getTableData(this.tName,"fieldSettings",{});for(var fName in fSett){if(fSett[fName].timePick){Runner.util.ScriptLoader.addJS(["include/ui.js"]);Runner.util.ScriptLoader.addJS(["include/jquery.utils.js"],"include/ui.js");Runner.util.ScriptLoader.addJS(["include/ui.dropslide.js"],"include/jquery.utils.js");Runner.util.ScriptLoader.addJS(["include/ui.timepickr.js"],"include/ui.dropslide.js");Runner.util.ScriptLoader.loadCSS(["include/ui.dropslide"]);}
if(fSett[fName].editFormat==Runner.controls.constants.EDIT_FORMAT_DATE&&(fSett[fName].dateEditType==Runner.controls.constants.EDIT_DATE_SIMPLE_DP||fSett[fName].dateEditType==Runner.controls.constants.EDIT_DATE_DD_DP))
{if(Runner.pages.PageSettings.getGlobalData("debugMode",false))
Runner.util.ScriptLoader.addJS(["include/yui/calendar.js"],"include/yui/container.js","include/yui/event.js");Runner.util.ScriptLoader.loadCSS(["include/yui/calendar"]);Runner.util.ScriptLoader.loadCSS(["include/yui/calendar-skin"]);Runner.util.ScriptLoader.loadCSS(["include/yui/container"]);Runner.util.ScriptLoader.loadCSS(["include/yui/container-skin"]);Runner.util.ScriptLoader.loadCSS(["include/yui/resize"]);}}
Runner.util.ScriptLoader.on('filesLoaded',this.init,this,{single:true});Runner.util.ScriptLoader.load();},calcPageDimensions:function(html)
{var divContainer=$('<div></div>');$(html).appendTo(divContainer);divContainer.css('position','absolute');divContainer.css('left','-10000px');divContainer.css('top','-10000px');divContainer.appendTo('body');var yuiPanelWidth=divContainer.width()+30;var yuiPanelHeight=divContainer.height()+70;divContainer.remove();var sizeRoot=getWindowDimensions();var minWidgetMargin=30;if(sizeRoot[0]-2*minWidgetMargin<yuiPanelWidth){yuiPanelWidth=sizeRoot[0]-2*minWidgetMargin;yuiPanelHeight+=15;}
if(sizeRoot[1]-2*minWidgetMargin<yuiPanelHeight){yuiPanelHeight=sizeRoot[1]-2*minWidgetMargin;yuiPanelWidth+=10;}
if(yuiPanelWidth<300)
yuiPanelWidth=300;if($.browser.msie){var ckDim=Runner.pages.PageSettings.getRTECKDim(this.tName);if(ckDim){if(yuiPanelHeight<yuiPanelHeight+ckDim.nHeight){yuiPanelHeight+=ckDim.nHeight;}}}
return{width:yuiPanelWidth,height:yuiPanelHeight};},initFly:function(){if(!this.fly){return false;}
if(this.afterClose){this.on({'afterClose':this.afterClose});}
var bodyContDOM=$(this.bodyCont);var styleDOM=bodyContDOM.filter('style');styleDOM.appendTo('head');var panelSize=this.calcPageDimensions(this.bodyCont);this.winDiv=document.createElement("DIV");this.win=new YAHOO.widget.Panel(this.winDiv,{draggable:true,height:panelSize.height+"px",width:panelSize.width+"px",autofillheight:"body",constraintoviewport:false,modal:this.modal,fixedcenter:true});this.win.setBody(this.bodyCont);this.win.setHeader(this.headerCont);this.win.setFooter(this.fotterCont);this.win.render(document.body);this.win.bringToTop();this.win.subscribe('drag',function(eventName,args,newScope){this.bringToTop();});var resize=new YAHOO.util.Resize(this.winDiv,{handles:["br"],autoRatio:false,minWidth:300,minHeight:100,status:false});resize.on("startResize",function(args){if(this.cfg.getProperty("constraintoviewport")){var D=YAHOO.util.Dom;var clientRegion=D.getClientRegion();var elRegion=D.getRegion(this.element);resize.set("maxWidth",clientRegion.right-elRegion.left-YAHOO.widget.Overlay.VIEWPORT_OFFSET);resize.set("maxHeight",clientRegion.bottom-elRegion.top-YAHOO.widget.Overlay.VIEWPORT_OFFSET);}else{resize.set("maxWidth",null);resize.set("maxHeight",null);}},this.win,true);resize.on("resize",function(args){var panelHeight=args.height;this.cfg.setProperty("height",panelHeight+"px");var panelWidth=args.width;this.cfg.setProperty("width",panelWidth+"px");},this.win,true);if(this.destroyOnClose){this.on('afterClose',function(e){var tName=this.tName,pageId=this.pageId;setTimeout(function(){Runner.pages.PageManager.unregister(tName,pageId);},5);},this);}
this.win.subscribe('hide',function(){this.fireEvent('afterClose',this);},this,this);return true;},show:function(){if(!this.win){return this.initFly();}
this.win.show();return true;},close:function(){if(!this.win){return false}
this.win.hide();return true;},initEvents:function(){var tName=this.tName;if(this.createAsDefault){tName='global';}
var events=Runner.pages.PageSettings.getTableData(tName,"events",{}),eventHnArr,i;for(var pType in events){if(pType!=this.pageType){continue;}
for(var evName in events[pType]){eventHnArr=events[pType][evName];for(i=0;i<eventHnArr.length;i++){this.on(evName,eventHnArr[i].hn,eventHnArr[i].scope||this);}}}},addSettings:function(settings){Runner.pages.PageSettings.addSettings(settings,this.tName,this.pageType);},initControls:function(){for(var i=0;i<this.controlsMap.controls.length;i++){this.controlsMap.controls[i].table=this.tName;var ctrl=Runner.controls.ControlFabric(this.controlsMap.controls[i]);}},initLookups:function(){var pageCtrls=Runner.controls.ControlManager.getAt(this.tName,this.pageId);for(var i=0;i<pageCtrls.length;i++){if(!pageCtrls[i].isLookupWizard){continue;}
if(pageCtrls[i].parentFieldName&&pageCtrls[i].skipDependencies!==true){var parentCtrl=Runner.controls.ControlManager.getAt(this.tName,this.pageId,pageCtrls[i].parentFieldName);pageCtrls[i].setParentCtrl(parentCtrl);if(parentCtrl&&parentCtrl.isLookupWizard){parentCtrl.addDependentCtrls([pageCtrls[i]]);}}}},initTabs:function(){if(!this.controlsMap.tabs||!this.controlsMap.sections){return false;}
this.tabs={};var tabs=this.controlsMap.tabs;for(var tabGroup in tabs){this.tabs[tabGroup]=new YAHOO.widget.TabView(tabGroup);}
var sections=this.controlsMap.sections;for(var secId in sections){(function(secId){$("#"+secId+"Butt").bind("click",function(e){if($(this).attr("src")=='include/img/minus.gif'){$("#"+secId).hide();$(this).attr("src",'include/img/plus.gif');}else{$("#"+secId).show();$(this).attr("src",'include/img/minus.gif');}});})(secId);}},initCustomButtons:function(){if(!Runner.pages.PageSettings.getTableData(this.tName,"isUseButtons",false)){return false;}
Runner.util.ScriptLoader.addJS(['include/json.js']);if(Runner.debugMode===true){Runner.util.ScriptLoader.addJS(['include/runnerJS/RunnerEvent.js']);Runner.util.ScriptLoader.addJS(['include/runnerJS/button.js'],'include/runnerJS/RunnerEvent.js');Runner.util.ScriptLoader.addJS(['include/runnerJS/events/pageevents_'+this.shortTName+'.js'],'include/runnerJS/button.js');}else{Runner.util.ScriptLoader.addJS(['include/runnerJS/RunnerControls.js']);Runner.util.ScriptLoader.addJS(['include/runnerJS/events/pageevents_'+this.shortTName+'.js'],'include/runnerJS/RunnerControls.js');}}});Runner.pages.SearchPage=Runner.extend(Runner.pages.RunnerPage,{constructor:function(cfg){Runner.pages.SearchPage.superclass.constructor.call(this,cfg);},init:function(){Runner.pages.SearchPage.superclass.init.call(this);this.initButtons();this.initSearch();this.fireEvent('afterInit',this,this.id);},initButtons:function(){var pageObj=this;$("input[@id=searchButton"+this.id+"]").bind("click",function(e){pageObj.searchController.submitSearch();});$("input[@id=resetButton"+this.id+"]").bind("click",function(e){pageObj.searchController.resetCtrls();});$("input[@id=backButton"+this.id+"]").bind("click",function(e){pageObj.searchController.returnSubmit();});},initSearch:function(){this.searchController=new Runner.search.SearchForm({id:this.pageId,tName:this.tName,fNamesArr:this.controlsMap.search.allSearchFields,shortTName:this.shortTName,usedSrch:this.controlsMap.search.isUsedSearch,searchType:'advanced',panelSearchFields:this.controlsMap.search.panelSearchFields,pageType:this.controlsMap.search.submitPageType,baseParams:this.controlsMap.search.baseParams||{},useSuggest:Runner.pages.PageSettings.getTableData(this.tName,"ajaxSuggest",false),shortTName:Runner.pages.PageSettings.getShortTName(this.tName)});this.searchController.init(this.controlsMap.search.searchBlocks);}});Runner.pages.ViewPage=Runner.extend(Runner.pages.RunnerPage,{keys:null,prevKeys:null,nextKeys:null,pageType:Runner.pages.constants.PAGE_VIEW,searchPanelEl:null,constructor:function(cfg){Runner.pages.ViewPage.superclass.constructor.call(this,cfg);this.keys=cfg.keys||Runner.pages.PageSettings.getTableData(this.tName,'keys',{});this.prevKeys=Runner.pages.PageSettings.getTableData(this.tName,'prevKeys',{});this.nextKeys=Runner.pages.PageSettings.getTableData(this.tName,'nextKeys',{});window.recKeysObj=this.keys;},init:function(){Runner.pages.ViewPage.superclass.init.call(this);this.initMap();this.initButtons();this.initDetails();this.initTabs();this.initAudio();this.initVideo();this.fireEvent('afterInit',this,this.id);},initFly:function(){if(Runner.pages.ViewPage.superclass.initFly.call(this)){var images=$(this.win.body).find('img[@src*="imager.php"]'),src;for(var j=0;j<images.length;j++){src=$(images[j]).attr('src');if(src&&src.indexOf('?')!=-1){$(images[j]).attr('src',(src+"&rndVal="+Math.random()));}else{$(images[j]).attr('src',(src+"?rndVal="+Math.random()));}}}},initButtons:function(){var pageObj=this;$("input[@id=nextButton"+this.id+"]").bind("click",function(e){UnlockRecord(pageObj.shortTName+'_'+pageObj.pageType+'.php',pageObj.nextKeys,'',function(){window.location.href=Runner.pages.getUrl(pageObj.tName,pageObj.pageType,pageObj.nextKeys);});});$("input[@id=prevButton"+this.id+"]").bind("click",function(e){UnlockRecord(pageObj.shortTName+'_'+pageObj.pageType+'.php',pageObj.prevKeys,'',function(){window.location.href=Runner.pages.getUrl(pageObj.tName,pageObj.pageType,pageObj.prevKeys);});});$("input[@id=backButton"+this.id+"]").bind("click",function(e){Runner.Event.prototype.stopEvent(e);UnlockRecord(pageObj.shortTName+'_'+pageObj.pageType+'.php',pageObj.keys,'',function(){window.location.href=Runner.pages.getUrl(pageObj.tName,Runner.pages.constants.PAGE_LIST,{})+"?a=return";});});},initMap:function(){if(!this.controlsMap.gMaps||!this.controlsMap.gMaps.isUseGoogleMap){return false;}
this.mapManager=new Runner.controls.MapManager(this.controlsMap.gMaps);this.mapManager.init();},initDetails:function(){if(Runner.pages.PageSettings.getTableData(this.tName,"isShowDetails",false)){window.dpObj=new dpInlineOnAddEdit({'showMasterInPopup':Runner.pages.PageSettings.getTableData(this.tName,"showViewInPopup",false),'mTableName':this.tName,'mPageType':Runner.pages.constants.PAGE_VIEW,'dCaptions':[],'mId':this.id});window.dpObj.init();}}});Runner.pages.EditorPage=Runner.extend(Runner.pages.RunnerPage,{baseParams:null,tabs:null,constructor:function(cfg){Runner.pages.EditorPage.superclass.constructor.call(this,cfg);this.baseParams=cfg.baseParams||{};this.baseParams['id']=this.id;this.baseParams["editType"]=this.baseParams["editType"]||this.editType;this.submitUrl=Runner.pages.PageSettings.getShortTName(this.tName)+"_"+this.pageType+".php";this.addEvents("beforeSave","afterSave");if(this.fly){this.baseParams['onFly']=1;}},init:function(){Runner.pages.EditorPage.superclass.init.call(this);if(this.beforeSave){this.on({'beforeSave':this.beforeSave});}
if(this.afterSave){this.on({'afterSave':this.afterSave});}
this.initButtons();this.initTabs();Runner.controls.ControlManager.getAt(this.tName,this.id)[0].setFocus();this.initToolTips();setTimeout(function(){$('div.shiny_box').hide();},0);},close:function(){Runner.pages.EditorPage.superclass.close.call(this);$('div.shiny_box').hide();},initButtons:function(){$("input[@id=saveButton"+this.id+"]").bind("click",{page:this},this.saveHn);},getForm:function(){return new Runner.form.BasicForm({submitUrl:this.submitUrl,standardSubmit:!this.fly,isFileUpload:true,method:'POST',id:this.pageId,baseParams:this.baseParams,fieldControls:Runner.controls.ControlManager.getAt(this.tName,this.pageId),useMultipart:true,successSubmit:{fn:function(respObj,formObj,fieldControls){var evRes=this.fireEvent("afterSave",respObj,formObj,fieldControls,this);if(evRes!==false){this.close();}
formObj.destructor();},scope:this},submitFailed:{fn:function(response,formObj,fieldControls){this.fireEvent("afterSave",{success:false,html:response},formObj,fieldControls,this);},scope:this},beforeSubmit:{fn:function(formObj){return this.fireEvent("beforeSave",formObj,formObj.fieldControls,this);},scope:this},validationFailed:{fn:function(formObj,fieldControls,failedControlsArr){var fNamesArr=[];for(var i=0;i<failedControlsArr.length;i++){fNamesArr.push(failedControlsArr[i].fieldName);}
this.openFieldTabsSections(fNamesArr);return false;},scope:this}});},saveHn:function(e){var page=e.data.page;var form=page.getForm();form.submit();},openFieldTabsSections:function(fNamesArr){if(!Runner.isArray(this.controlsMap.sections)){var sections=this.controlsMap.sections;for(var secId in sections){for(var i=0;i<fNamesArr.length;i++){if(sections[secId].isInArray(fNamesArr[i])){$("#"+secId).show();$("#"+secId+"Butt").attr("src",'include/img/minus.gif');break;}}}}
if(!Runner.isArray(this.controlsMap.tabs)){var tabs=this.controlsMap.tabs,tabInd=0,selected=false;for(var tabGroup in tabs){tabInd=0;selected=false;for(var tab in tabs[tabGroup]){for(var i=0;i<fNamesArr.length;i++){if(tabs[tabGroup][tab].isInArray(fNamesArr[i])){this.tabs[tabGroup].selectTab(tabInd);selected=true;break;}}
if(selected){break;}
tabInd++;}}}}});Runner.pages.AddPageFly=Runner.extend(Runner.pages.EditorPage,{pageType:Runner.pages.constants.PAGE_ADD,fName:"",parentFieldName:"",editType:Runner.pages.constants.ADD_ONTHEFLY,constructor:function(cfg){Runner.pages.AddPageFly.superclass.constructor.call(this,cfg);this.baseParams["a"]="added";},init:function(){Runner.pages.AddPageFly.superclass.init.call(this);this.fireEvent('afterInit',this,this.id);},initButtons:function(){Runner.pages.AddPage.superclass.initButtons.call(this);$("input[@id=cancelButton"+this.id+"]").bind("click",{page:this},function(e){Runner.Event.prototype.stopEvent(e);e.data.page.close();});}});Runner.pages.AddPage=Runner.extend(Runner.pages.EditorPage,{pageType:Runner.pages.constants.PAGE_ADD,baseParams:null,showInPopUp:false,constructor:function(cfg){Runner.pages.AddPage.superclass.constructor.call(this,cfg);this.baseParams['a']="added";this.showInPopUp=Runner.pages.PageSettings.getTableData(this.tName,"showAddInPopup",false);},init:function(){Runner.pages.AddPage.superclass.init.call(this);this.initDetails();this.fireEvent('afterInit',this,this.id);},initDetails:function(){if(Runner.pages.PageSettings.getTableData(this.tName,"isShowDetails",false)&&this.editType!=Runner.pages.constants.ADD_ONTHEFLY){window.dpObj=new dpInlineOnAddEdit({'showMasterInPopup':this.showInPopUp,'mShortTableName':Runner.pages.PageSettings.getShortTName(this.tName),'mTableName':this.tName,'mPageType':Runner.pages.constants.PAGE_ADD,'dMessages':'','dCaptions':[],'mMessage':'','parId':this.baseParams['parId'],'mId':this.pageId,'ext':Runner.pages.PageSettings.getGlobalData('ext',"")});window.dpObj.init();this.baseParams['editType']='addmaster';}},initButtons:function(){Runner.pages.AddPage.superclass.initButtons.call(this);$("input[@id=backButton"+this.id+"]").bind("click",{page:this},function(e){Runner.Event.prototype.stopEvent(e);window.location.href=Runner.pages.PageSettings.getShortTName(e.data.page.tName)+'_'+Runner.pages.constants.PAGE_LIST+'.php?a=return';});$("input[@id=cancelButton"+this.id+"]").bind("click",{page:this},function(e){Runner.Event.prototype.stopEvent(e);e.data.page.close();});},saveHn:function(e){Runner.Event.prototype.stopEvent(e);var page=e.data.page;var isShowDetails=Runner.pages.PageSettings.getTableData(page.tName,"isShowDetails",false);if(!window.dpObj||!window.dpObj.isSbmMaster){var form=page.getForm();form.standardSubmit=!isShowDetails&&!page.fly;if(isShowDetails&&page.editType!=Runner.pages.constants.ADD_ONTHEFLY){form.on('beforeSubmit',function(basicForm){var valRes=basicForm.validate();if(!valRes){return false;}
var ids=window.dpObj.dpParFromM['ids'],dTables=window.dpObj.dpParFromM['tableNames'],vRes=true;for(var i=0;i<ids.length;i++)
{var permis=Runner.pages.PageSettings.getTableData(dTables[i],"permissions",{});if(!Runner.pages.PageSettings.getTableData(dTables[i],"isInlineAdd",false)&&!permis['add']){continue;}
if(!window['dpInline'+ids[i]].inlineAddChangeContent){continue;}
if(!window['dpInline'+ids[i]].inlineAdd.validate()){vRes=false;}}
return vRes;},e.data.page);form.on('successSubmit',function(respObj,basicForm,fieldControls){basicForm.destructor();if(respObj.success){window.dpObj.isSbmMaster=true;window.dpObj.Opts.mSavedValues={};for(var i=0;i<respObj.fields.length;i++)
window.dpObj.Opts.mSavedValues[respObj.fields[i]]=respObj.vals[respObj.fields[i]];if(respObj.hideCaptha)
window.dpObj.hideCaptcha();window.dpObj.mKeys=respObj.mKeys;window.dpObj.saveAllDetail(e,respObj);}else{if(respObj.captha===false)
window.dpObj.showHideInvalidCaptcha('show');else{window.dpObj.Opts.mMessage=respObj.error;window.dpObj.showMessage();window.dpObj.showHideInvalidCaptcha('hide');}}},e.data.page);}
form.submit();}else if(isShowDetails){window.dpObj.saveAllDetail(e);}}});Runner.pages.EditPage=Runner.extend(Runner.pages.EditorPage,{keys:null,prevKeys:null,nextKeys:null,pageType:Runner.pages.constants.PAGE_EDIT,details:null,constructor:function(cfg){Runner.pages.EditPage.superclass.constructor.call(this,cfg);this.keys=cfg.keys||Runner.pages.PageSettings.getTableData(this.tName,'keys',{});this.sKeys=Runner.pages.PageSettings.getTableData(this.tName,"sKeys","");this.prevKeys=Runner.pages.PageSettings.getTableData(this.tName,'prevKeys',{});this.nextKeys=Runner.pages.PageSettings.getTableData(this.tName,'nextKeys',{});this.shortTName=Runner.pages.PageSettings.getShortTName(this.tName);this.baseParams['a']="edited";var i=0;for(var key in this.keys){i++;this.baseParams["editid"+i]=this.keys[key];}},init:function(){Runner.pages.EditPage.superclass.init.call(this);this.initCtrlEvents();this.initDetails();this.initLocking();this.fireEvent('afterInit',this,this.id);},initButtons:function(){Runner.pages.EditPage.superclass.initButtons.call(this);var pageObj=this;$("input[@id=resetButton"+this.id+"]").bind("click",function(e){$('#next'+pageObj.id).attr('style','').attr('disabled','');$('#prevButton'+pageObj.id).attr('style','').attr('disabled','');Runner.controls.ControlManager.resetControlsForTable(pageObj.tName);}).bind("mouseover",function(e){this.focus();});$("input[@id=nextButton"+this.id+"]").bind("click",function(e){UnlockRecord(pageObj.shortTName+'_'+pageObj.pageType+'.php',pageObj.sKeys,'',function(){window.location.href=Runner.pages.getUrl(pageObj.tName,pageObj.pageType,pageObj.nextKeys);});});$("input[@id=prevButton"+this.id+"]").bind("click",function(e){UnlockRecord(pageObj.shortTName+'_'+pageObj.pageType+'.php',pageObj.sKeys,'',function(){window.location.href=Runner.pages.getUrl(pageObj.tName,pageObj.pageType,pageObj.prevKeys);});});$("input[@id=backButton"+this.id+"]").bind("click",function(e){Runner.Event.prototype.stopEvent(e);UnlockRecord(pageObj.shortTName+'_'+pageObj.pageType+'.php',pageObj.sKeys,'',function(){window.location.href=pageObj.shortTName+'_'+Runner.pages.constants.PAGE_LIST+'.php?a=return';});});},initCtrlEvents:function(){var ctrls=Runner.controls.ControlManager.getAt(this.tName,this.pageId),cntrlType,eventName='change',singleFire=false,delay=0;for(var i=0;i<ctrls.length;i++){cntrlType=ctrls[i].getControlType(),eventName='change',singleFire=false,delay=0;if(cntrlType=='checkbox'||cntrlType=='radio'){eventName='click';}else if(cntrlType=='text'||cntrlType=='password'||cntrlType=='textarea'){eventName='keyup';delay=60;ctrls[i].on('change',this.prevNextButtonHandler,{single:true,timeout:0,scope:this});}else if(cntrlType=='RTE'){eventName='blur';delay=5000;}
ctrls[i].on(eventName,this.prevNextButtonHandler,{single:singleFire,timeout:delay,scope:this});}},prevNextButtonHandler:function(e){if(e&&(e.type=='keyup'||e.type=='keypress'||e.type=='keydown')){if(e.keyCode>=33&&e.keyCode<=40||e.keyCode==9)
return true;}
var prev=$('#prevButton'+this.id),next=$('#nextButton'+this.id);prev.css('background','#dcdcdc url(\"images/sortprev.gif\") center no-repeat').css('color','#dcdcdc').css('cursor','default').attr('disabled','disabled');next.css('background','#dcdcdc url("images/sortnext.gif") center no-repeat').css('color','#dcdcdc').css('cursor','default').attr('disabled','disabled');return true;},initDetails:function(){if(Runner.pages.PageSettings.getTableData(this.tName,"isShowDetails",false)){window.dpObj=new dpInlineOnAddEdit({'showMasterInPopup':Runner.pages.PageSettings.getTableData(this.tName,"showEditInPopup",false),'mTableName':this.tName,'mPageType':Runner.pages.constants.PAGE_EDIT,'dMessages':'','dCaptions':[],'rowId':this.baseParams['rowId'],'mId':this.id});window.dpObj.init();}},initLocking:function(){var pageObj=this;if(Runner.pages.PageSettings.getTableData(this.tName,"locking",false)){this.on("afterClose",function(e){UnlockRecord(pageObj.shortTName+'_'+pageObj.pageType+'.php',pageObj.sKeys,'','');},this);window['timeid'+this.id]=setInterval(function(){ConfirmLock(pageObj.shortTName+'_'+pageObj.pageType+'.php',pageObj.tName,pageObj.sKeys,pageObj.id,pageObj.pageMode);},Runner.pages.PageSettings.getTableData(pageObj.tName,"confirmTime",250)*1000);}},saveHn:function(e){var pageObj=e.data.page;if(Runner.pages.PageSettings.getTableData(pageObj.tName,"isShowDetails",false)){var masterCtrls=Runner.controls.ControlManager.getAt(e.data.page.tName,e.data.page.pageId),vRes,validationPassed=true,failedFNamesArr=[];for(var i=0;i<masterCtrls.length;i++){vRes=masterCtrls[i].validate();if(!vRes.result){failedFNamesArr.push(masterCtrls[i].fieldName);validationPassed=false;}}
if(validationPassed){window.dpObj.saveAllDetail(e);}else{pageObj.openFieldTabsSections(failedFNamesArr);}}else{Runner.pages.EditPage.superclass.saveHn.call(this,e);}}});Runner.pages.DataPageWithSearch=Runner.extend(Runner.pages.RunnerPage,{gridEl:null,searchController:null,shortTName:"",searchPanelEl:null,constructor:function(cfg){Runner.pages.DataPageWithSearch.superclass.constructor.call(this,cfg);this.shortTName=Runner.pages.PageSettings.getShortTName(this.tName);this.gridEl=$(getParentTableObj(this.id)).bind("click",this.gridClickHn.createDelegate(this,[],true));},init:function(){Runner.pages.DataPageWithSearch.superclass.init.call(this);this.initPagination();this.initSearch();this.initAudio();this.initVideo();this.initGridHover();this.initHeaderCheckBox();this.initSelectAll();},initHeaderCheckBox:function(pageId){pageId=pageId||this.id;$('#chooseAll_'+pageId).unbind("click").bind("click",function(e){var selBoxes=$('input[@type=checkbox][@id^=check'+pageId+'_]');for(var i=0;i<selBoxes.length;i++){selBoxes[i].checked=$(this).attr('checked');}
if(e.stopImmediatePropagation){e.stopImmediatePropagation();}});},initSelectAll:function(){var pageId=this.id,selectAll=$('#select_all'+this.id);if(!$('#select_all'+this.id).length){return false;}
$('#select_all'+this.id)[0].checkAllStatus=false;$('#select_all'+this.id).bind("click",function(e){this.checkAllStatus=!this.checkAllStatus;var selBoxes=$('input[@type=checkbox][@id^=check'+pageId+'_]');for(var i=0;i<selBoxes.length;i++){selBoxes[i].checked=this.checkAllStatus;}
if(e.stopImmediatePropagation){e.stopImmediatePropagation();}});},initGridHover:function(){var table=getTableObj(this.id);if(!table){return false;}
var isUseHighLite=Runner.pages.PageSettings.getTableData(this.tName,"isUseHighlite",false),isUseIcons=Runner.pages.PageSettings.getTableData(this.tName,"listIcons",false);table.bind('mouseover',function(e){var target=Runner.Event.prototype.getTarget(e);while(target.nodeName!="TABLE"){if(target.nodeName=="TR"){if(isUseHighLite){$(target).addClass('rowhighlited');}
if(isUseIcons){$(target).addClass('rowselected');}
break;}else{target=target.parentNode;}}});table.bind('mouseout',function(e){var target=Runner.Event.prototype.getTarget(e);while(target.nodeName!="TABLE"){if(target.nodeName=="TR"){if(isUseHighLite){$(target).removeClass('rowhighlited');}
if(isUseIcons){$(target).removeClass('rowselected');}
break;}else{target=target.parentNode;}}});},gridClickHn:function(e){this.largeTextOpenerDelegate(e);},largeTextOpenerDelegate:function(e){var target=Runner.Event.prototype.getTarget(e);if(target.nodeName!="A"||!$(target).attr("query")){return false;}
Runner.Event.prototype.stopEvent(e);var query=$(target).attr("query");var winId=Runner.genId();var fullTextWin=new YAHOO.widget.Panel("fullText"+winId,{draggable:true,height:"400px",width:"500px",fixedcenter:true});$.get(query,{id:this.id,rndVal:Math.random()},function(respObj){respObj=JSON.parse(respObj);if(respObj.success){fullTextWin.setBody(respObj.textCont);}else{fullTextWin.setBody(respObj.error||"Server error");}
fullTextWin.render(document.body);fullTextWin.bringToTop();fullTextWin.subscribe('drag',function(eventName,args,newScope){this.bringToTop();});var resize=new YAHOO.util.Resize("fullText"+winId,{handles:["br"],autoRatio:false,minWidth:300,minHeight:100,status:false});resize.on("startResize",function(args){if(this.cfg.getProperty("constraintoviewport")){var D=YAHOO.util.Dom;var clientRegion=D.getClientRegion();var elRegion=D.getRegion(this.element);resize.set("maxWidth",clientRegion.right-elRegion.left-YAHOO.widget.Overlay.VIEWPORT_OFFSET);resize.set("maxHeight",clientRegion.bottom-elRegion.top-YAHOO.widget.Overlay.VIEWPORT_OFFSET);}else{resize.set("maxWidth",null);resize.set("maxHeight",null);}},fullTextWin,true);resize.on("resize",function(args){var panelHeight=args.height;this.cfg.setProperty("height",panelHeight+"px");var panelWidth=args.width;this.cfg.setProperty("width",panelWidth+"px");},fullTextWin,true);});fullTextWin.setHeader("&nbsp;");fullTextWin.setFooter("&nbsp;");},initSearch:function(){this.searchController=new Runner.search.SearchController({id:this.pageId,tName:this.tName,fNamesArr:this.controlsMap.search.allSearchFields,shortTName:this.shortTName,usedSrch:this.controlsMap.search.usedSrch,panelSearchFields:this.controlsMap.search.panelSearchFields,useSuggest:Runner.pages.PageSettings.getTableData(this.tName,"ajaxSuggest",true),pageType:this.pageType});this.searchController.init(this.controlsMap.search.searchBlocks);},initPagination:function(){$("table[@name=paginationTable"+this.pageId+"]").bind("click",{pageObj:this},function(e){Runner.Event.prototype.stopEvent(e);var target=Runner.Event.prototype.getTarget(e);if(target.nodeName!="A"){return false;}
var pageNum=$(target).attr("pageNum"),pageObj=e.data.pageObj;var url=Runner.pages.getUrl(pageObj.tName,pageObj.pageType,{})+"?goto="+pageNum;window.location.href=url;});}});Runner.pages.ListPageFly=Runner.extend(Runner.pages.DataPageWithSearch,{lookupCtrl:null,lookupBaseParams:null,constructor:function(cfg){Runner.pages.ListPageFly.superclass.constructor.call(this,cfg);this.listFields=Runner.pages.PageSettings.getTableData(this.tName,'listFields',[]);this.on("afterInit",function(pageObj){this.lookupCtrl.lookupVals=this.controlsMap.lookupVals;this.lookupCtrl.initLinks(this.pageId);this.lookupCtrl.lookupSelectField=this.controlsMap.lookupSelectField;this.lookupCtrl.dispFieldAlias=this.controlsMap.dispFieldAlias;this.lookupCtrl.linkField=this.controlsMap.linkField;this.lookupCtrl.dispField=this.controlsMap.dispField;},this);var categoryValue='';if(this.lookupCtrl.parentCtrl){categoryValue=this.lookupCtrl.parentCtrl.getValue();}
this.lookupBaseParams={parId:this.lookupCtrl.pageId,table:this.lookupCtrl.table,field:this.lookupCtrl.fieldName,mode:"lookup",category:categoryValue,control:"control",editMode:this.lookupCtrl.mode,id:this.pageId};},destructor:function(){Runner.pages.ListPageFly.superclass.destructor.call(this);this.win=null;this.winDiv=null;this.lookupCtrl.pageId=-1;},init:function(){Runner.pages.ListPageFly.superclass.init.call(this);this.initInline();this.initButtons();this.initSorting(this.pageId);this.fireEvent('afterInit',this,this.id);},initSearch:function(){this.searchController=new Runner.search.SearchController({id:this.pageId,tName:this.tName,fNamesArr:this.controlsMap.search.allSearchFields,shortTName:this.shortTName,usedSrch:this.controlsMap.search.usedSrch,panelSearchFields:this.controlsMap.search.panelSearchFields,ajaxSubmit:true,useSuggest:false,pageType:this.pageType});this.searchController.init(this.controlsMap.search.searchBlocks);this.searchController.srchForm.baseParams=this.lookupBaseParams;this.searchController.srchForm.on("beforeSubmit",function(form){form.baseParams["id"]=Runner.genId();runLoading(this.id,this.win.body,1);this.lookupBaseParams.id=form.baseParams["id"];},this);this.searchController.on('afterSearch',function(respObj,srchController,srchForm){stopLoading(this.id,1);this.pageReloadHn(respObj);if(this.searchController.usedSrch){this.searchController.showShowAll();}else{this.searchController.hideShowAll();}},this);this.searchController.srchForm.on('submitFailed',function(){stopLoading(this.id,1);},this);},initInline:function(){var permis=Runner.pages.PageSettings.getTableData(this.tName,"permissions",{});if(Runner.pages.PageSettings.getTableData(this.tName,"isInlineAdd",true)&&permis['add']){this.inlineAdd=new Runner.util.inlineEditing.InlineAdd({tName:this.tName,shortTName:this.shortTName,id:this.pageId,fNames:this.listFields,rows:this.controlsMap.gridRows,inlineEditObj:this.inlineEdit,totalFields:[],lookupField:this.lookupCtrl.fieldName});if(this.lookupCtrl.parentCtrl){this.inlineAdd.categoryValue=this.lookupCtrl.parentCtrl.getValue();this.inlineAdd.lookupTable=this.lookupCtrl.parentCtrl.table;this.inlineAdd.loadSettings=true;}
this.inlineAdd.init();this.inlineAdd.on("beforeSetVals",function(row,fields,data){if(data[this.lookupCtrl.dispFieldAlias]){data[this.lookupCtrl.dispFieldAlias]='<a type="lookupSelect'+this.searchController.srchForm.baseParams.id+'">'+data[this.lookupCtrl.dispFieldAlias]+'</a>';}else if(data[this.lookupCtrl.dispField]){data[this.lookupCtrl.dispField]='<a type="lookupSelect'+this.searchController.srchForm.baseParams.id+'">'+data[this.lookupCtrl.dispField]+'</a>';}},this);this.inlineAdd.on("afterSubmit",function(vals,fields,keys){var newInd=this.lookupCtrl.addLookupVal(vals[this.lookupCtrl.linkField],vals[this.lookupCtrl.dispFieldAlias]||vals[this.lookupCtrl.dispField]);var links=$('a[@type="lookupSelect'+this.searchController.srchForm.baseParams.id+'"]');var link=$(links[0]);this.lookupCtrl.initLink(link,newInd);},this);}},initSorting:function(pageId){for(var i=0;i<this.listFields.length;i++){$("#order_"+Runner.goodFieldName(this.listFields[i])+"_"+pageId).bind("click",{pageObj:this},function(e){Runner.Event.prototype.stopEvent(e);runLoading(this.id,getParentTableObj(this.id),1);var pageObj=e.data.pageObj;$.ajax({url:this.href,type:"GET",success:function(respObj){pageObj.pageReloadHn.call(pageObj,respObj)},dataType:"json"});});}},initButtons:function(){},initPagination:function(pageId){if(typeof pageId=='undefined'){pageId=this.id;}
$("table[@name=paginationTable"+pageId+"]").bind("click",{pageObj:this},function(e){Runner.Event.prototype.stopEvent(e);runLoading(this.id,getParentTableObj(this.id),1);var target=Runner.Event.prototype.getTarget(e);if(target.nodeName!="A"){return false;}
var pageNum=$(target).attr("pageNum");pageObj=e.data.pageObj;var url=Runner.pages.getUrl(pageObj.tName,pageObj.pageType,{})+"?goto="+pageNum;pageObj.lookupBaseParams.id=Runner.genId();$.ajax({url:url,type:"GET",success:function(respObj){pageObj.pageReloadHn.call(pageObj,respObj)},dataType:"json",data:pageObj.lookupBaseParams});});},pageReloadHn:function(respObj){stopLoading(this.id,1);if(respObj.success){Runner.setIdCounter(respObj.idStartFrom);var gridCont=$("#grid_block"+this.lookupBaseParams.id,respObj.html).html();$("#grid_block"+this.pageId).html(gridCont);var messCont=$("#message_block"+this.lookupBaseParams.id,respObj.html).html();$("#message_block"+this.pageId).html(messCont);var paginationTable=$(respObj.html).find("#pagination_block"+this.lookupBaseParams.id).find('table');var pagTablesName=$("#pagination_block"+this.pageId).find('table').attr("name");var pagTables=$("table[@name="+pagTablesName+"]").replaceWith(paginationTable);this.initPagination(this.lookupBaseParams.id);this.initSorting(this.lookupBaseParams.id);this.lookupCtrl.lookupVals=respObj.controlsMap[this.tName][this.pageType][this.lookupBaseParams.id].lookupVals;this.lookupCtrl.initLinks(this.lookupBaseParams.id);this.controlsMap.gridRows=respObj["controlsMap"][this.tName][this.pageType][this.lookupBaseParams.id].gridRows;if(this.inlineAdd){this.inlineAdd.reInit(this.lookupBaseParams.id,this.controlsMap.gridRows);}
this.searchController.usedSrch=respObj.controlsMap[this.tName][this.pageType][this.lookupBaseParams.id].search.usedSrch;if(this.searchController.usedSrch)
this.searchController.showShowAll();else
this.searchController.hideShowAll();var audioLinksCount=this.preprocessAudioLinks();if(YAHOO.mediaplayer&&YAHOO.mediaplayer.loadPlayerScript.bCalled&&audioLinksCount>0){if(this.lookupBaseParams){YAHOO.MediaPlayer.addTracks($("#grid_block"+this.lookupBaseParams.id).get(0),null,true);}else if(this.id){if($("#fields_block"+this.id).length>0){YAHOO.MediaPlayer.addTracks($("#fields_block"+this.id).get(0));}else if($("#grid_block"+this.id).length>0){YAHOO.MediaPlayer.addTracks($("#grid_block"+this.id).get(0));}}}}else{this.win.setBody("REQUEST FAILED");}}});Runner.pages.ListPage=Runner.extend(Runner.pages.DataPageWithSearch,{inlineEdit:null,pageType:Runner.pages.constants.PAGE_LIST,mapManager:null,constructor:function(cfg){Runner.pages.ListPage.superclass.constructor.call(this,cfg);this.listFields=Runner.pages.PageSettings.getTableData(this.tName,'listFields',[]);if(Runner.pages.PageSettings.getTableData(this.tName,"locking",false))
showErrorLockDelRec(this.id,Runner.pages.PageSettings.getTableData(this.tName,'lockRecIds',[]));},init:function(){this.initResize();Runner.pages.ListPage.superclass.init.call(this);this.initInline();this.initButtons();this.initSorting();this.initMaps();this.initDetails();this.fireEvent('afterInit',this,this.id);},initMaps:function(){if(!this.controlsMap.gMaps||!this.controlsMap.gMaps.isUseGoogleMap){return false;}
this.mapManager=new Runner.controls.MapManager(this.controlsMap.gMaps);this.mapManager.init();if(this.inlineEdit){this.inlineEdit.on('afterSubmit',function(vals,fields,keys,recId){for(var i=0;i<fields.length;i++){if(this.isFieldIsMap(fields[i])){var mapDiv=this.getMapDiv("FIELD_MAP",recId,fields[i]);var span=$("#edit"+recId+"_"+fields[i]);$(mapDiv).appendTo(span);this.initMap(mapDiv.id);}else if(this.isFieldCenterLink(fields[i])){var mapCenterLink=this.getCenterLink(recId,vals[fields[i]],this.isFieldCenterLink(fields[i]));var span=$("#edit"+recId+"_"+fields[i]);$(mapCenterLink).appendTo(span);this.initCenterLink($(mapCenterLink));}}
this.updateAfterEdit(recId,vals);},this.mapManager);}
if(this.inlineAdd){this.inlineAdd.on('afterSubmit',function(vals,fields,keys,recId){var j=0,viewQuery="";for(key in keys){j++;viewQuery+="editid"+i+"="+keys[key];}
var recordVals={viewKey:viewQuery,recId:recId};Runner.apply(recordVals,vals);this.updateAfterAdd(recId,vals);for(var i=0;i<fields.length;i++){if(this.isFieldIsMap(fields[i])){var mapDiv=this.getMapDiv("FIELD_MAP",recId,fields[i]);var span=$("#edit"+recId+"_"+fields[i]);$(mapDiv).appendTo(span);this.initMap(mapDiv.id);this.refreshMaps(recId,viewQuery);}else if(this.isFieldCenterLink(fields[i])){var mapCenterLink=this.getCenterLink(recId,vals[fields[i]],this.isFieldCenterLink(fields[i]));var span=$("#edit"+recId+"_"+fields[i]);$(mapCenterLink).appendTo(span);this.initCenterLink($(mapCenterLink));}}},this.mapManager);}},initInline:function(){var permis=Runner.pages.PageSettings.getTableData(this.tName,"permissions",{}),showEditInPopup=Runner.pages.PageSettings.getTableData(this.tName,"showEditInPopup",false),showViewInPopup=Runner.pages.PageSettings.getTableData(this.tName,"showViewInPopup",false);if((Runner.pages.PageSettings.getTableData(this.tName,"isInlineEdit",false)&&permis['edit'])||showEditInPopup||showViewInPopup){this.inlineEdit=new Runner.util.inlineEditing.InlineEdit({tName:this.tName,shortTName:this.shortTName,id:this.pageId,fNames:this.listFields,rows:this.controlsMap.gridRows,totalFields:Runner.pages.PageSettings.getTableData(this.tName,"totalFields",[]),showEditInPopup:showEditInPopup,showViewInPopup:showViewInPopup,loadSettings:true,isUseEdit:this.tName!='admin_users'});this.inlineEdit.init();}
if((Runner.pages.PageSettings.getTableData(this.tName,"isInlineAdd",false)&&permis['add'])||showEditInPopup||showViewInPopup){this.inlineAdd=new Runner.util.inlineEditing.InlineAdd({tName:this.tName,shortTName:this.shortTName,id:this.pageId,fNames:this.listFields,rows:this.controlsMap.gridRows,inlineEditObj:this.inlineEdit,totalFields:Runner.pages.PageSettings.getTableData(this.tName,"totalFields",[]),showEditInPopup:showEditInPopup,showViewInPopup:showViewInPopup,loadSettings:true,isUseEdit:this.tName!='admin_users'});this.inlineAdd.init();this.inlineAdd.on("afterSubmit",function(vals,fields,keys,id,response){if(response.noKeys!==true){this.inlineAdd.linksAfterInlineAdd(id,response.detKeys,this.tName);}},this);}},initDetails:function(id){if(typeof id=="undefined"){id=this.pageId;}
if(Runner.pages.PageSettings.getTableData(this.tName,"isUseDP",false)){window["dpInline"+id]=new detailsPreviewInline({'pageId':id,'mSTable':Runner.pages.PageSettings.getShortTName(this.tName),'mTable':this.tName,'mPageType':this.pageType,'mainMPageType':Runner.pages.PageSettings.getTableData(this.tName,"mainMPageType",this.pageType),'mode':'list_details','ext':Runner.pages.PageSettings.getGlobalData('ext',"")});}},initResize:function(id,pageId){if(typeof pageId=="undefined"){pageId=this.pageId;}
if(typeof id=="undefined"){id=Runner.pages.PageSettings.getTableData(this.tName,"recIdStart",0);}
if(Runner.pages.PageSettings.getTableData(this.tName,"isUseResize",false)){var permis=Runner.pages.PageSettings.getTableData(this.tName,"permissions",{});prepareForCreateTable({'id':pageId,'recId':id,'tName':Runner.pages.PageSettings.getShortTName(this.tName),'firstTime':(Runner.pages.PageSettings.getTableData(this.tName,"pageMode",false)!=Runner.pages.constants.LIST_AJAX?1:0),'useInlineAdd':(Runner.pages.PageSettings.getTableData(this.tName,"isInlineAdd",false)?1:0),'showAddInPopup':(Runner.pages.PageSettings.getTableData(this.tName,"showAddInPopup",false)?1:0),'permisAdd':(permis.add?1:0),'numRows':(Runner.pages.PageSettings.getTableData(this.tName,"numRows",0)?1:0)});}},initDeleteButton:function(id){var submitUrl=this.shortTName+"_"+this.pageType+".php";if(typeof id=="undefined"){id=this.id;}
var pageObj=this;$("#delete_selected"+this.id).unbind("click").bind("click",function(e){var selBoxes=$('input[@type=checkbox][@checked][@id^=check'+id+'_]');if(selBoxes.length==0||!confirm(Runner.lang.constants.TEXT_DELETE_CONFIRM)){return false;}
var form=new Runner.form.BasicForm({standardSubmit:true,submitUrl:submitUrl,method:'POST',id:pageObj.id,baseParams:{"a":'delete'},addElems:cloneElements(selBoxes)});form.submit();form.destructor();});},initExportLink:function(id){var submitUrl=this.shortTName+"_"+Runner.pages.constants.PAGE_EXPORT+".php";if(typeof id=="undefined"){id=this.id;}
$("#export_selected"+this.id).unbind("click").bind("click",function(e){var selBoxes=$('input[@type=checkbox][@checked][@id^=check'+id+'_]');if(selBoxes.length==0){return false;}
var form=new Runner.form.BasicForm({standardSubmit:true,submitUrl:submitUrl,target:'_blank',method:'POST',id:this.id,addElems:cloneElements(selBoxes),baseParams:{a:"export"}});form.submit();form.destructor();});},initPrintLink:function(id){var submitUrl=this.shortTName+"_"+Runner.pages.constants.PAGE_PRINT+".php";if(typeof id=="undefined"){id=this.id;}
$("#print_selected"+this.id).unbind("click").bind("click",function(e){var selBoxes=$('input[@type=checkbox][@checked][@id^=check'+id+'_]');if(selBoxes.length==0){return false;}
var form=new Runner.form.BasicForm({standardSubmit:true,submitUrl:submitUrl,target:'_blank',method:'POST',id:this.id,addElems:cloneElements(selBoxes),baseParams:{a:"print"}});form.submit();form.destructor();});},initRecordBlock:function(){var submitUrl=Runner.pages.getUrl(this.tName,this.pageType,{});$("#recordspp"+this.id).bind("change",function(e){document.location=submitUrl+'?pagesize='+this.options[this.selectedIndex].value;});},initAddButton:function(){if(Runner.pages.PageSettings.getTableData(this.tName,"showAddInPopup",false)){var page=this;$("#addButton"+this.id).unbind("click").bind("click",function(e){var eventParams={tName:page.tName,pageType:Runner.pages.constants.PAGE_ADD,pageId:-1,destroyOnClose:true,parentPage:page,modal:true,editType:Runner.pages.constants.ADD_POPUP,baseParams:{parId:page.id,table:page.tName,editType:Runner.pages.constants.ADD_POPUP},afterSave:{fn:function(respObj,formObj,fieldControls,page){if(respObj.success){if(!Runner.pages.PageSettings.getTableData(this.tName,"isShowDetails",false)){this.inlineAdd.addRowToGrid(respObj);}else{return false;}}else
{if(respObj.message!=undefined)
{$('#message_block'+page.id+' div.message').html(respObj.message);}
else
{page.win.setBody(respObj.html);}
$('div.bd').animate({scrollTop:0});return false;}},scope:page}};Runner.Event.prototype.stopEvent(e);Runner.pages.PageManager.openPage(eventParams);});}else{var page=this;$("#addButton"+this.id).bind("click",function(e){document.location=Runner.pages.getUrl(page.tName,Runner.pages.constants.PAGE_ADD,{});});}},initButtons:function(){this.initDeleteButton();this.initRecordBlock();this.initExportLink();this.initPrintLink();this.initAddButton();},initSorting:function(){for(var i=0;i<this.listFields.length;i++){$("#order_"+Runner.goodFieldName(this.listFields[i])+"_"+this.id).bind("mouseout",delspan).bind("mousemove",movespan).bind("mouseover",addspan).bind("mousedown",function(e){sort(e,this.href,false,1);});}}});Runner.pages.ListPageAjax=Runner.extend(Runner.pages.ListPage,{ajaxBaseParams:null,constructor:function(cfg){Runner.pages.ListPageAjax.superclass.constructor.call(this,cfg);this.listFields=Runner.pages.PageSettings.getTableData(this.tName,'listFields',[]);this.ajaxBaseParams={mode:"ajax",id:this.pageId};},initSearch:function(){Runner.pages.ListPageAjax.superclass.initSearch.call(this);this.searchController.ajaxSubmit=true;this.searchController.srchForm.standardSubmit=false;this.searchController.srchForm.baseParams=this.ajaxBaseParams;this.searchController.srchForm.on("beforeSubmit",function(form){form.baseParams["id"]=Runner.genId();runLoading(this.id,getParentTableObj(this.id),4);this.ajaxBaseParams.id=form.baseParams["id"];},this);this.searchController.on('afterSearch',function(respObj,srchController,srchForm){stopLoading(this.id,4);this.pageReloadHn(respObj);if(this.searchController.usedSrch){this.searchController.showShowAll();}else{this.searchController.hideShowAll();}},this);this.searchController.srchForm.on('submitFailed',function(){stopLoading(this.id,4);},this);},initRecordBlock:function(pageId){if(typeof pageId=='undefined'){pageId=this.id;}
$("#recordspp"+pageId).bind("change",{pageObj:this},function(e){var recsPP=$("#recordspp"+pageId).val();pageObj=e.data.pageObj;runLoading(pageObj.id,getParentTableObj(pageObj.id),1);var url=Runner.pages.getUrl(pageObj.tName,pageObj.pageType,{})+"?pagesize="+recsPP;pageObj.ajaxBaseParams.id=Runner.genId();$.ajax({url:url,type:"GET",success:function(respObj){pageObj.pageReloadHn.call(pageObj,respObj);},dataType:"json",data:pageObj.ajaxBaseParams});});},initSorting:function(pageId){if(typeof pageId=='undefined'){pageId=this.id;}
var pageObj=this;for(var i=0;i<this.listFields.length;i++){$("#order_"+Runner.goodFieldName(this.listFields[i])+"_"+pageId).bind("mouseout",delspan).bind("mousemove",movespan).bind("mouseover",addspan).bind("mousedown",function(e){Runner.Event.prototype.stopEvent(e);var href=sort(e,this.href,true,1)||this.href;pageObj.ajaxBaseParams.id=Runner.genId();runLoading(pageObj.id,getParentTableObj(pageObj.id),4);$.ajax({url:href,type:"GET",success:function(respObj){pageObj.pageReloadHn.call(pageObj,respObj)},dataType:"json",data:pageObj.ajaxBaseParams});}).bind("click",function(e){Runner.Event.prototype.stopEvent(e);});}},initPagination:function(pageId){if(typeof pageId=='undefined'){pageId=this.id;}
$("table[@name=paginationTable"+pageId+"]").bind("click",{pageObj:this},function(e){Runner.Event.prototype.stopEvent(e);runLoading(this.id,getParentTableObj(this.id),4);var target=Runner.Event.prototype.getTarget(e);if(target.nodeName!="A"){return false;}
var pageNum=$(target).attr("pageNum");pageObj=e.data.pageObj;var url=Runner.pages.getUrl(pageObj.tName,pageObj.pageType,{})+"?goto="+pageNum;pageObj.ajaxBaseParams.id=Runner.genId();$.ajax({url:url,type:"GET",success:function(respObj){pageObj.pageReloadHn.call(pageObj,respObj)},dataType:"json",data:pageObj.ajaxBaseParams});});},pageReloadHn:function(respObj){stopLoading(this.id,1);if(respObj.success){Runner.setIdCounter(respObj.idStartFrom);var tableObj=getTableObj(this.pageId);var gridObj=getGridBlock(this.pageId);var resizeCell=$("#resize_cell"+this.pageId);if(resizeCell.length)
gridObj=resizeCell[0];$(gridObj).html(respObj.html.grid);var pagTablesName=$("#pagination_block"+this.pageId).find('table').attr("name");if(respObj.html.pagination){if(pagTablesName){var pagTables=$("table[@name="+pagTablesName+"]").replaceWith($('table',respObj.html.pagination));}else{$("#pagination_block"+this.pageId).html(respObj.html.pagination);}}else{var pagTables=$("table[@name="+pagTablesName+"]").replaceWith("");}
$("#message_block"+this.pageId).html(respObj.html.message);$("#detFound"+this.pageId).html(respObj.html.details);$("#pageOf"+this.pageId).html(respObj.html.pages);this.controlsMap.gridRows=respObj["controlsMap"][this.tName][this.pageType][this.ajaxBaseParams.id].gridRows;if(this.controlsMap.gridRows.length){$("span[@name=notfound_message"+this.pageId+"]").hide();var rowIdStartFrom=this.controlsMap.gridRows[0].id;}else{$("span[@name=notfound_message"+this.pageId+"]").show();}
this.initResize(rowIdStartFrom,this.ajaxBaseParams.id);this.initDetails(this.ajaxBaseParams.id);if(this.inlineAdd){this.inlineAdd.reInit(this.ajaxBaseParams.id,this.controlsMap.gridRows);}
if(this.inlineEdit){this.inlineEdit.reInit(this.ajaxBaseParams.id,this.controlsMap.gridRows);}
this.initHeaderCheckBox(this.ajaxBaseParams.id)
this.initPagination(this.ajaxBaseParams.id);this.initSorting(this.ajaxBaseParams.id);this.initDeleteButton(this.ajaxBaseParams.id);this.initExportLink(this.ajaxBaseParams.id);this.initPrintLink(this.ajaxBaseParams.id);this.initGridHover();this.searchController.usedSrch=respObj.controlsMap[this.tName][this.pageType][this.ajaxBaseParams.id].search.usedSrch;if(this.searchController.usedSrch){this.searchController.showShowAll();}
var gMaps=respObj.controlsMap[this.tName][this.pageType][this.ajaxBaseParams.id].gMaps;if(this.mapManager&&gMaps&&gMaps.isUseGoogleMap){this.mapManager.init(gMaps.mapsData);}
if(Runner.pages.PageSettings.getTableData(this.tName,"isUseIbox",false)&&this.pageType!=Runner.pages.constants.PAGE_ADD&&this.pageType!=Runner.pages.constants.PAGE_EDIT&&this.pageType!=Runner.pages.constants.PAGE_REGISTER){init_ibox();}
var audioLinksCount=this.preprocessAudioLinks();if(YAHOO.mediaplayer&&YAHOO.mediaplayer.loadPlayerScript.bCalled&&audioLinksCount>0){if(this.ajaxBaseParams){YAHOO.MediaPlayer.addTracks($("#grid_block"+this.ajaxBaseParams.id).get(0),null,true);}else if(this.id){if($("#fields_block"+this.id).length>0){YAHOO.MediaPlayer.addTracks($("#fields_block"+this.id).get(0));}else if($("#grid_block"+this.id).length>0){YAHOO.MediaPlayer.addTracks($("#grid_block"+this.id).get(0));}}}
this.initVideo(respObj.controlsMap[this.tName][this.pageType][this.ajaxBaseParams.id].video);}else{$("#message_block"+this.pageId).html("Submit failed!");}}});Runner.pages.ReportPage=Runner.extend(Runner.pages.DataPageWithSearch,{pageType:Runner.pages.constants.PAGE_REPORT,init:function(){Runner.pages.ReportPage.superclass.init.call(this);this.fireEvent('afterInit',this,this.id);},constructor:function(cfg){Runner.pages.ReportPage.superclass.constructor.call(this,cfg);this.writePagination(Runner.pages.PageSettings.getTableData(this.tName,"pageNumber",0),Runner.pages.PageSettings.getTableData(this.tName,"maxPages",0));},getPaginationLink:function(pageNum,linkText,cls){return'<a href="#" pageNum="'+pageNum+'" '+(cls?'class="pag_n"':'')+' style="TEXT-DECORATION: none;">'+linkText+'</a>';},writePagination:function(mypage,maxpages){var paginationHTML="";if(maxpages>1&&mypage<=maxpages){paginationHTML+='<table rows="1" cols="1" align="center" width="auto" border="0" name="paginationTable'+this.id+'">';paginationHTML+='<tr valign="center"><td align="center">';var counterstart=mypage-9;if(mypage%10)
counterstart=mypage-(mypage%10)+1;var counterend=counterstart+9;if(counterend>maxpages)
counterend=maxpages;if(counterstart!=1)
paginationHTML+=this.getPaginationLink(1,Runner.lang.constants.TEXT_FIRST,false)+'&nbsp;:&nbsp;'+
this.getPaginationLink(counterstart-1,Runner.lang.constants.TEXT_PREVIOUS,false)+'&nbsp;';paginationHTML+='<b>[</b>';var pad='';var counter=counterstart;for(;counter<=counterend;counter++)
{if(counter!=mypage)
paginationHTML+='&nbsp;'+this.getPaginationLink(counter,pad+counter,true);else
paginationHTML+='&nbsp;<b>'+pad+counter+'</b>';}
paginationHTML+='&nbsp;<b>]</b>';if(counterend!=maxpages)
paginationHTML+='&nbsp;'+this.getPaginationLink(counterend+1,Runner.lang.constants.TEXT_NEXT,false)+'&nbsp;:&nbsp;'+
this.getPaginationLink(maxpages,Runner.lang.constants.TEXT_LAST,false);paginationHTML+='</td></tr></table>';$('div.reportPagination').html(paginationHTML);}}});Runner.pages.ChartPage=Runner.extend(Runner.pages.DataPageWithSearch,{pageType:Runner.pages.constants.PAGE_CHART,init:function(){Runner.pages.ChartPage.superclass.init.call(this);this.fireEvent('afterInit',this,this.id);},constructor:function(cfg){Runner.pages.ChartPage.superclass.constructor.call(this,cfg);}});Runner.pages.MembersPage=Runner.extend(Runner.pages.ListPage,{pageType:Runner.pages.constants.PAGE_ADMIN_MEMBERS,constructor:function(cfg){Runner.pages.MembersPage.superclass.constructor.call(this,cfg);this.submitUrl="admin_members_list.php";},init:function(){Runner.pages.MembersPage.superclass.init.call(this);this.initButtons();this.fireEvent('afterInit',this,this.id);},initButtons:function(){Runner.pages.MembersPage.superclass.initButtons.call(this);var pageObj=this;$("#saveButton"+this.id).bind("click",function(e){Runner.Event.prototype.stopEvent(e);var form=new Runner.form.BasicForm({isFileUpload:false,submitUrl:pageObj.submitUrl,standardSubmit:true,method:'POST',baseParams:{a:"save"},id:pageObj.pageId,addElems:cloneElements($("input","#grid_block"+pageObj.pageId))});form.submit();});$("#records_block"+pageObj.pageId).wrap('<form id="resetForm'+pageObj.pageId+'"/>');}});Runner.pages.RightsPage=Runner.extend(Runner.pages.ListPage,{pageType:Runner.pages.constants.PAGE_ADMIN_RIGHTS,constructor:function(cfg){Runner.pages.RightsPage.superclass.constructor.call(this,cfg);},init:function(){this.initOldCode();this.fireEvent('afterInit',this,this.id);},initOldCode:function(){window.TEXT_AA_ADD_NEW_GROUP='Add new group';window.TEXT_AA_RENAMEGROUP='Rename group';window.renameidx=-1;window.tables=Runner.pages.PageSettings.getTableData(this.tName,"rightsTables",false);window.groups=Runner.pages.PageSettings.getTableData(this.tName,"rightsGroups",false);window.fillboxes=function(group)
{var add_uncheck=false;var edt_uncheck=false;var del_uncheck=false;var lst_uncheck=false;var exp_uncheck=false;var imp_uncheck=false;var adm_uncheck=false;for(var g=0;g<groups.length;g++)
{for(var t=0;t<tables.length;t++)
{var disp='none';if(groups[g]==group)
{var tbl_uncheck=false;disp='';if((!tbl_uncheck||!add_uncheck)&&!document.getElementById('cbadd_'+tables[t]+'_'+groups[g]).checked)
{tbl_uncheck=true;add_uncheck=true;}
if((!tbl_uncheck||!edt_uncheck)&&!document.getElementById('cbedt_'+tables[t]+'_'+groups[g]).checked)
{tbl_uncheck=true;edt_uncheck=true;}
if((!tbl_uncheck||!del_uncheck)&&!document.getElementById('cbdel_'+tables[t]+'_'+groups[g]).checked)
{tbl_uncheck=true;del_uncheck=true;}
if((!tbl_uncheck||!lst_uncheck)&&!document.getElementById('cblst_'+tables[t]+'_'+groups[g]).checked)
{tbl_uncheck=true;lst_uncheck=true;}
if((!tbl_uncheck||!exp_uncheck)&&!document.getElementById('cbexp_'+tables[t]+'_'+groups[g]).checked)
{tbl_uncheck=true;exp_uncheck=true;}
if((!tbl_uncheck||!imp_uncheck)&&!document.getElementById('cbimp_'+tables[t]+'_'+groups[g]).checked)
{tbl_uncheck=true;imp_uncheck=true;}
if((!tbl_uncheck||!adm_uncheck)&&!document.getElementById('cbadm_'+tables[t]+'_'+groups[g]).checked)
{tbl_uncheck=true;adm_uncheck=true;}
document.getElementById(tables[t]).checked=!tbl_uncheck;}
document.getElementById('cbadd_'+tables[t]+'_'+groups[g]).style.display=disp;document.getElementById('cbedt_'+tables[t]+'_'+groups[g]).style.display=disp;document.getElementById('cbdel_'+tables[t]+'_'+groups[g]).style.display=disp;document.getElementById('cblst_'+tables[t]+'_'+groups[g]).style.display=disp;document.getElementById('cbexp_'+tables[t]+'_'+groups[g]).style.display=disp;document.getElementById('cbimp_'+tables[t]+'_'+groups[g]).style.display=disp;document.getElementById('cbadm_'+tables[t]+'_'+groups[g]).style.display=disp;}}
document.getElementById('add').checked=!add_uncheck;document.getElementById('edt').checked=!edt_uncheck;document.getElementById('del').checked=!del_uncheck;document.getElementById('lst').checked=!lst_uncheck;document.getElementById('exp').checked=!exp_uncheck;document.getElementById('imp').checked=!imp_uncheck;document.getElementById('adm').checked=!adm_uncheck;if(group<0)
{document.getElementById('delgroup').disabled=true;document.getElementById('delgroup').className='button_dis button';document.getElementById('rengroup').disabled=true;document.getElementById('rengroup').className='button_dis button';}
else
{document.getElementById('delgroup').disabled=false;document.getElementById('delgroup').className='button';document.getElementById('rengroup').disabled=false;document.getElementById('rengroup').className='button';var gr=document.getElementById('group');renameidx=gr.selectedIndex;$('#groupname').val(gr.options[gr.selectedIndex].text);}}
var gsel=document.getElementById('group');if(gsel.selectedIndex<0)
gsel.selectedIndex=0;fillboxes(gsel.options[gsel.selectedIndex].value);window.deletegroup=function()
{var gr=document.getElementById('group');var disp=gr.options[gr.selectedIndex].text;var idx=gr.selectedIndex;var id=gr.options[idx].value;if(!confirm('Do you really want to delete group'+disp+'?'))
return;$.get('ug_group.php',{rndval:Math.random(),id:id,a:'del'},function(ret){if(ret!='ok')
{alert('Error deleting record!');return;}
for(var i=0;i<groups.length;i++)
if(groups[i]==id)
groups.splice(i,1);gr.selectedIndex--;gr.onchange();$('input[@type=checkbox][@id$=_'+id+']').each(function(){this.parentNode.removeChild(this);});gr.remove(idx);gr.size=gr.size-1;});}
window.makename=function(group)
{var n=1;var i;tgroup=group;var gr=document.getElementById('group');while(1)
{for(i=0;i<gr.options.length;i++)
{if(tgroup==gr.options[i].text)
break;}
if(i==groups.length)
{return tgroup;}
tgroup=group+n;n++;}}
window.save=function(name)
{if(renameidx==-1)
{$.get('ug_group.php',{rndval:Math.random(),name:name,a:'add'},function(ret)
{if(ret.substring(0,2)!='ok')
{alert('Error adding group!');return;}
var id=ret.substring(2);var gr=document.getElementById('group');$('#addarea').hide();$('input[@type=checkbox][@id$=_-1]').each(function()
{var cbid=$(this)[0].id;$(this.parentNode).append('<input type=checkbox  id="'+cbid.substring(0,cbid.length-2)+id+'" name="'+cbid.substring(0,cbid.length-2)+id+'">');});groups[groups.length]=id;gr.options[gr.options.length]=new Option(name,id);gr.selectedIndex=gr.options.length-1;gr.onchange();gr.size=gr.size+1;$('#groupname').val('');});}
else
{var idx=renameidx;renameidx=-1;var gr=document.getElementById('group');$.get('ug_group.php',{rndval:Math.random(),id:gr.options[idx].value,name:name,a:'rename'},function(ret){if(ret.substring(0,2)!='ok')
{alert('Error renaming group!');return;}
$('#addarea').hide();gr.options[idx].text=name;$('#groupname').val('');});}};}});Runner.pages.ExportPage=Runner.extend(Runner.pages.RunnerPage,{pageType:Runner.pages.constants.PAGE_IMPORT,constructor:function(cfg){Runner.pages.ExportPage.superclass.constructor.call(this,cfg);this.submitUrl=Runner.pages.getUrl(this.tName,this.pageType,{});},init:function(){Runner.pages.ExportPage.superclass.init.call(this);this.initButtons();this.fireEvent('afterInit',this,this.id);},initButtons:function(){var pageObj=this;$("#saveButton"+this.id).bind("click",function(e){Runner.Event.prototype.stopEvent(e);pageObj.form=new Runner.form.BasicForm({submitUrl:pageObj.submitUrl,standardSubmit:true,method:'POST',id:pageObj.pageId,baseParams:{type:$('input[@type=radio][@name=type][@checked]').val(),records:$('input[@type=radio][@name=records][@checked]').val()}});pageObj.form.submit();pageObj.form.destructor();pageObj.form=null;});}});Runner.pages.ImportPage=Runner.extend(Runner.pages.RunnerPage,{pageType:Runner.pages.constants.PAGE_IMPORT,constructor:function(cfg){Runner.pages.ImportPage.superclass.constructor.call(this,cfg);this.submitUrl=Runner.pages.getUrl(this.tName,this.pageType,{});},init:function(){Runner.pages.ImportPage.superclass.init.call(this);this.initButtons();this.fireEvent('afterInit',this,this.id);},initButtons:function(){var pageObj=this;$("#saveButton"+this.id).bind("click",function(e){Runner.Event.prototype.stopEvent(e);var path=$("#file_ImportFileName"+pageObj.id).val();if(!path){return false;}
var wpos=path.lastIndexOf('\\');var upos=path.lastIndexOf('/');var pos=wpos;if(upos>wpos){pos=upos;}
baseParams={a:"added",id:pageObj.pageId};baseParams["value_ImportFileName"+pageObj.id]=path.substr(pos+1);baseParams["type_ImportFileName"+pageObj.id]='upload2';var form=new Runner.form.BasicForm({submitUrl:pageObj.submitUrl,standardSubmit:true,isFileUpload:true,method:'POST',baseParams:baseParams,id:pageObj.pageId,addElems:[$("#file_ImportFileName"+pageObj.id)]});form.submit();});$("#backButton"+this.id).bind("click",function(e){Runner.Event.prototype.stopEvent(e);window.location.href=Runner.pages.getUrl(pageObj.tName,Runner.pages.constants.PAGE_LIST,{})+"?a=return";});$("a[@linkType=debugOpener]").bind("click",function(e){Runner.Event.prototype.stopEvent(e);$("#importDebugInfoTable"+this.recId).toggle();});}});Runner.pages.RegisterPage=Runner.extend(Runner.pages.RunnerPage,{submitUrl:"",passFieldName:'password',useAsGlobal:true,constructor:function(cfg){Runner.pages.RegisterPage.superclass.constructor.call(this,cfg);this.submitUrl="register.php";this.passFieldName=Runner.pages.PageSettings.getTableData(this.tName,"passFieldName",'password');},init:function(){Runner.pages.RegisterPage.superclass.init.call(this);this.initButtons();this.initControlEvents();var controls=Runner.controls.ControlManager.getAt(this.tName,this.id);if(controls.length)
controls[0].setFocus();this.fireEvent('afterInit',this,this.id);},initButtons:function(){var pageObj=this;$("#saveButton"+this.id).bind("click",function(e){Runner.Event.prototype.stopEvent(e);var arrcntrl=Runner.controls.ControlManager.getAt(pageObj.tName);for(var i=0;i<arrcntrl.length;i++){if(arrcntrl[i].invalid()===true||!arrcntrl[i].validate().result){return false;}}
var form=new Runner.form.BasicForm({isFileUpload:true,submitUrl:pageObj.submitUrl,standardSubmit:true,method:'POST',baseParams:{'btnSubmit':"Register"},id:pageObj.pageId,fieldControls:Runner.controls.ControlManager.getAt(pageObj.tName)});form.submit();});},initControlEvents:function(){var passctrl=Runner.controls.ControlManager.getAt(this.tName,this.id,this.passFieldName),confctrl=Runner.controls.ControlManager.getAt(this.tName,this.id,'confirm');if(confctrl)
{passctrl.on('blur',function(e,confctrl){if(confctrl.getValue()!=this.getValue()&&confctrl.getValue()!=""){confctrl.markInvalid([Runner.lang.constants.PASSWORDS_DONT_MATCH]);}else{confctrl.clearInvalid();this.clearInvalid();}},{args:[confctrl]});confctrl.on('blur',function(e,passctrl){if(passctrl.getValue()!=this.getValue()){this.markInvalid([Runner.lang.constants.PASSWORDS_DONT_MATCH]);}else{passctrl.clearInvalid();this.clearInvalid();}},{args:[passctrl]});}
var ctrls=Runner.controls.ControlManager.getAt(this.tName,this.id);for(var i=0;i<ctrls.length;i++){if(ctrls[i].fieldName=='confirm'||ctrls[i].fieldName==this.passFieldName){continue;}
ctrls[i].on('blur',function(e,fName){var ctrl=this,params={id:this.id,rndval:Math.random(),field:this.fieldName,val:this.getValue(),table:this.table};$.get('registersuggest.php',params,function(resp){if(resp){ctrl.markInvalid([resp],true);}
else{ctrl.clearInvalid();}});});}}});Runner.search.SearchForm=Runner.extend(Runner.util.Observable,{smplSrchBox:null,simpleSrchTypeCombo:null,simpleSrchFieldsCombo:null,usedSrch:false,id:-1,tName:"",searchType:"panel",conditionRadioTop:null,srchForm:null,ctrlsShowMap:null,ajaxSubmit:false,baseParams:null,optCombosArr:null,constructor:function(cfg){this.ctrlsShowMap={};this.baseParams={};this.optCombosArr=[];Runner.apply(this,cfg);Runner.search.SearchForm.superclass.constructor.call(this,cfg);this.conditionRadioTop=$('input:radio[name=srchType]');this.smplSrchBox=$('#ctlSearchFor'+this.id);this.simpleSrchTypeCombo=$('#simpleSrchTypeCombo'+this.id);this.simpleSrchFieldsCombo=$('#simpleSrchFieldsCombo'+this.id);this.addEvents('beforeSearch','afterSearch');},init:function(ctrlsBlocks){this.initControlBlocks(ctrlsBlocks);this.initForm();this.initSuggest();this.initButtons();},initForm:function(){var method="GET";if(this.ajaxSubmit){var method="POST";}
if(this.pageType==Runner.pages.constants.PAGE_LIST||this.pageType==Runner.pages.constants.PAGE_REPORT||this.pageType==Runner.pages.constants.PAGE_CHART||this.pageType==Runner.pages.constants.PAGE_PRINT){var submitUrl=Runner.pages.getUrl(this.tName,this.pageType,{});}else{var submitUrl=this.pageType+".php";}
this.srchForm=new Runner.form.BasicForm({standardSubmit:!this.ajaxSubmit,initImmediately:true,submitUrl:submitUrl,method:method,id:this.id,addRndVal:false,baseParams:this.baseParams||{}});this.srchForm.on('successSubmit',function(respObj){this.fireEvent('afterSearch',respObj,this,this.srchForm);},this);},initCombo:function(recId,fName,map){$("#"+this.getComboId(fName,recId)).bind("change",{tName:this.tName,recId:recId,fName:fName,map:map},function(e){if(typeof e.data.map[1]=="undefined"){return false;}
var ctrl=Runner.controls.ControlManager.getAt(e.data.tName,e.data.recId,e.data.fName,e.data.map[1]);if(!ctrl){return false;}
if(this.value=='Between'||this.value=='NOT Between'){ctrl.show();}else{ctrl.hide();};});this.optCombosArr.push($("#"+this.getComboId(fName,recId)));$("#"+this.getComboId(fName,recId)).get(0).defVal=$("#"+this.getComboId(fName,recId)).val();},initButtons:function(){var searchController=this;$("#searchButtTop"+this.id).bind("click",function(e){Runner.Event.prototype.stopEvent(e);searchController.submitSearch();});$("#showAll"+this.id).bind("click",function(e){Runner.Event.prototype.stopEvent(e);searchController.showAllSubmit();});},initControlBlocks:function(ctrlsBlocks){for(var i=0;i<ctrlsBlocks.length;i++){this.addRegCtrlsBlock(ctrlsBlocks[i].fName,ctrlsBlocks[i].recId,ctrlsBlocks[i].ctrlsMap);}},initSuggest:function(){if(!this.useSuggest){return false;}
var ctrls,i,searchController=this;for(var fName in this.ctrlsShowMap){for(var recId in this.ctrlsShowMap[fName]){ctrls=Runner.controls.ControlManager.getAt(this.tName,recId);for(i=0;i<ctrls.length;i++){if(ctrls[i].isLookupWizard){continue;}
ctrls[i].on('keyup',function(e,argsArr){var srchTypeComboId=searchController.getComboId(searchController.tName,searchController.id);var srchTypeCombo=$('#'+srchTypeComboId);var suggestUrl='searchsuggest.php?table='+searchController.shortTName;return searchSuggest_new(e,this,srchTypeCombo,'advanced',suggestUrl);},{buffer:200});ctrls[i].on('keydown',function(e,argsArr){return listenEvent(e,this.valueElem.get(0),searchController);});}
if(ctrls.length>2){return true;}}}},submitSearch:function(){this.fireEvent('beforeSearch',this,this.srchForm);this.srchForm.clearForm();this.srchForm.addToForm("a",'integrated');this.srchForm.addToForm('ctlSearchFor',this.smplSrchBox.val());this.srchForm.addToForm('simpleSrchFieldsComboOpt',this.simpleSrchFieldsCombo.val()||"");var simpleSrchTypeComboVal=this.simpleSrchTypeCombo.val();if(simpleSrchTypeComboVal&&simpleSrchTypeComboVal.indexOf('NOT')==0){simpleSrchTypeComboVal=simpleSrchTypeComboVal.substr(4);this.srchForm.addToForm('simpleSrchTypeComboNot','on');}else{this.srchForm.addToForm('simpleSrchTypeComboNot','');}
this.srchForm.addToForm('simpleSrchTypeComboOpt',simpleSrchTypeComboVal||"");for(var i=0;i<this.conditionRadioTop.length;i++){if(this.conditionRadioTop[i].checked==true){this.srchForm.addToForm('criteria',this.conditionRadioTop[i].value);break;}}
var j=1,notVal='';for(var fName in this.ctrlsShowMap){for(var ind in this.ctrlsShowMap[fName]){var fMap=this.ctrlsShowMap[fName][ind];var ctrl1=Runner.controls.ControlManager.getAt(this.tName,ind,fName,fMap[0]);var srchCombo=$('#'+this.getComboId(fName,ind));var comboVal=srchCombo.val();if(ctrl1.isEmpty()&&comboVal.indexOf('Empty')==-1){continue;}
this.srchForm.addToForm('type'+j,ctrl1.ctrlType);var ctrl1Val=ctrl1.getStringValue();this.srchForm.addToForm('value'+j+'1',ctrl1Val);this.srchForm.addToForm('field'+j,fName);if(srchCombo.val().indexOf('NOT')==0){comboVal=comboVal.substr(4);}
this.srchForm.addToForm('option'+j,comboVal);var srchCheckBox=$('#'+this.getCheckBoxId(fName,ind));notVal='';if(srchCheckBox.length){notVal=srchCheckBox[0].checked?'on':'';}else{notVal=srchCombo.val().indexOf('NOT')==0?'on':'';}
this.srchForm.addToForm('not'+j,notVal);if(srchCombo.val().toLowerCase().indexOf('between')!==-1&&fMap[1]){var ctrl2=Runner.controls.ControlManager.getAt(this.tName,ind,fName,fMap[1]);var ctrl2Val=ctrl2.getStringValue();this.srchForm.addToForm('value'+j+'2',ctrl2Val);}
j++;}}
this.usedSrch=true;this.srchForm.submit();},addToShowMap:function(fName,ind,ctrlIndArr){!this.ctrlsShowMap[fName]?this.ctrlsShowMap[fName]={}:'';!this.ctrlsShowMap[fName][ind]?this.ctrlsShowMap[fName][ind]={}:'';this.ctrlsShowMap[fName][ind]=ctrlIndArr;},addRegCtrlsBlock:function(fName,ind,ctrlIndArr){ctrlIndArr?this.addToShowMap(fName,ind,ctrlIndArr):'';this.initCombo(ind,fName,ctrlIndArr);},getComboId:function(fName,ind){return"srchOpt_"+ind+"_"+Runner.goodFieldName(fName);},getCheckBoxId:function(fName,ind){return"not_"+ind+"_"+Runner.goodFieldName(fName);},showAllSubmit:function(){this.srchForm.clearForm();this.srchForm.addToForm("a",'showall');this.usedSrch=false;this.smplUsed=true;if(this.smplSrchBox)
this.smplSrchBox.val("");this.srchForm.submit();},returnSubmit:function(){this.srchForm.clearForm();this.srchForm.addToForm('a','return');this.srchForm.submit();},resetCtrls:function(){Runner.controls.ControlManager.resetControlsForTable(this.tName);var val;for(var i=0;i<this.optCombosArr.length;i++){val=this.optCombosArr[i].get(0).defVal;this.optCombosArr[i].val(val);this.optCombosArr[i].change();}
return false;}});Runner.search.SearchFormWithUI=Runner.extend(Runner.search.SearchForm,{srchOptShowStatus:false,srchWinShowStatus:false,ctrlChooseMenuStatus:false,ctrlTypeComboStatus:false,srchOptDiv:null,srchOptExpander:null,srchWinExpander:null,srchBlock:null,showAll:null,showAllButtStatus:false,srchCtrlsBlock:null,srchBlockStatus:true,topCritCont:null,ctrlChooseMenuDiv:null,srchPanelHeader:null,panelContainer:null,bottomPanelRound:null,bottomSearchButt:null,hideOptSrc:"images/search/hideOptions.gif",showOptSrc:"images/search/showOptions.gif",showOptText:"Show search options",hideOptText:"Hide search options",showComboText:'Show options',hideComboText:'Hide options',searchTypeCombosArr:null,searchTypeCombosWinArr:null,srchFilterRowArr:null,srchFilterRowWinArr:null,fNamesArr:null,ctrlsShowMap:null,showHideSearchComboButton:null,iframe:null,hider:null,winDiv:null,recBlockMargChange:false,moveBlockPadding:'padding-left',moveGridDiv:null,constructor:function(cfg){this.searchTypeCombosArr=[];this.searchTypeCombosWinArr=[];this.fNamesArr=[];this.srchFilterRowArr=[];this.srchFilterRowWinArr=[];Runner.search.SearchFormWithUI.superclass.constructor.call(this,cfg);this.srchOptDiv=$("#searchOptions"+this.id);this.srchOptExpander=$("#showOptPanel"+this.id);this.srchWinExpander=$("#showSrchWin"+this.id);var srchBlockId='search_block'+this.id;this.srchBlock=$("#"+srchBlockId);var srchCtrlsBlockId='controlsBlock_'+this.id;this.srchCtrlsBlock=$("#"+srchCtrlsBlockId);var srchCtrlsBlockWinId='controlsBlock_'+this.id+'_win';this.srchCtrlsBlockWin=$("#"+srchCtrlsBlockWinId);var srchPanelHeaderId='searchPanelHeader'+this.id;this.srchPanelHeader=$("#"+srchPanelHeaderId);var showHideSearchComboButtonId='showHideSearchType'+this.id;this.showHideSearchComboButton=$('#'+showHideSearchComboButtonId);var panelContainerId='searchPanelContainer'+this.id;this.panelContainer=$('#'+panelContainerId);var bottomPanelRoundId='searchPanelBottomRound'+this.id;this.bottomPanelRound=$('#'+bottomPanelRoundId);var showAllId="showall"+this.id;this.showAll=$('#'+showAllId);this.showAllButtStatus=this.usedSrch;this.moveGridDiv=$("div[@moveforsearch='move"+this.id+"']");if(Runner.isIE){if($(document.html).attr('dir').toLowerCase()=='rtl'){this.moveBlockPadding='padding-right';}}else{if($("html[@dir=RTL]").length){this.moveBlockPadding='padding-right';}}
var mrgLeft=this.moveGridDiv.css(this.moveBlockPadding);if($('#mainmenu_block').length==0&&$('#menu_block'+this.id).length==0){this.recBlockMargChange=true;}
this.addDelegatedEvents();},addDelegatedEvents:function(){var controller=this;this.srchCtrlsBlock.bind('mouseover',function(e){var target=Runner.Event.prototype.getTarget(e);while(target&&target.id!=controller.srchCtrlsBlock.attr('id')){if(target.id&&target.id.indexOf('filter_')!=-1){$(target).find('img[@class=searchPanelButton]').css('visibility','visible');$(target).removeClass('blockBorder').addClass('blockBorderHovered');break;}else{target=target.parentNode;}}});this.srchCtrlsBlock.bind('mouseout',function(e){var target=Runner.Event.prototype.getTarget(e);while(target&&target.id!=controller.srchCtrlsBlock.attr('id')){if(target.id&&target.id.indexOf('filter_')!=-1){$(target).find('img[@class=searchPanelButton]').css('visibility','hidden');$(target).removeClass('blockBorderHovered').addClass('blockBorder');break;}else{target=target.parentNode;}}});this.srchCtrlsBlockWin.bind('mouseover',function(e){var target=Runner.Event.prototype.getTarget(e);while(target.id!=controller.srchCtrlsBlockWin.attr('id')){if(target.nodeName=="TD"){var tr=$(target).parent();tr.find('img[@class=searchPanelButton]').css('visibility','visible');var tds=tr.children();if($(tds[0]).hasClass('srchWinCell')){var lastVisible=tds.length-1;if($(tds[tds.length-1]).children().length===0||$(tds[tds.length-1]).find('*:first-child').css('display')=='none'){lastVisible--;}
$(tds[0]).removeClass('cellBorderCenter').removeClass('cellBorderLeft').addClass('cellBorderCenterHovered').addClass('cellBorderLeftHovered');for(var i=0;i<lastVisible;i++){$(tds[i]).removeClass('cellBorderCenter').removeClass('cellBorderRightHovered').addClass('cellBorderCenterHovered');}
$(tds[lastVisible]).removeClass('cellBorderCenter').removeClass('cellBorderRight').addClass('cellBorderCenterHovered').addClass('cellBorderRightHovered');}
break;}else{target=target.parentNode;}}});this.srchCtrlsBlockWin.bind('mouseout',function(e){var target=Runner.Event.prototype.getTarget(e);while(target.id!=controller.srchCtrlsBlockWin.attr('id')){if(target.nodeName=="TD"){var tr=$(target).parent();tr.find('img[@class=searchPanelButton]').css('visibility','hidden');var tds=tr.children();if($(tds[0]).hasClass('srchWinCell')){var lastVisible=tds.length-1;if($(tds[tds.length-1]).children().length===0||$(tds[tds.length-1]).find('*:first-child').css('display')=='none'){lastVisible--;}
$(tds[0]).removeClass('cellBorderCenterHovered').removeClass('cellBorderLeftHovered').addClass('cellBorderCenter').addClass('cellBorderLeft');for(var i=0;i<lastVisible;i++){$(tds[i]).removeClass('cellBorderCenterHovered').addClass('cellBorderCenter');}
$(tds[lastVisible]).removeClass('cellBorderCenterHovered').removeClass('cellBorderRightHovered').addClass('cellBorderCenter').addClass('cellBorderRight');}
break;}else{target=target.parentNode;}}});},getComboContId:function(fName,ind,isWin){return"searchType_"+ind+"_"+Runner.goodFieldName(fName)+(isWin?'_win':'');},getComboId:function(fName,id){return"srchOpt_"+id+"_"+Runner.goodFieldName(fName);},getFilterDivId:function(fName,ind,isWin){return"filter_"+ind+"_"+Runner.goodFieldName(fName)+(isWin?'_win':'');},showSearchWin:function(e){this.hideCtrlChooseMenu();var x=50,y=50;if(Runner.isIE&&e){y=e.y;x=e.x;}else if(e){y=e.clientY;x=e.clientX;}
this.winDiv=document.createElement("DIV");var width="500px",height;if(e&&e.w&&e.h){height=e.h+"px";width=e.w+"px";}
var winCfg={draggable:true,width:width,autofillheight:"body",constraintoviewport:true,xy:[x,y]};if(height){winCfg.height=height;}
this.win=new YAHOO.widget.Panel(this.winDiv,winCfg);this.win.setHeader('<span style="color: black;">Search for:&nbsp;</span>');this.win.setBody("&nbsp;");this.win.setFooter("&nbsp;");this.win.render(document.body);this.win.bringToTop();Runner.setZindex(this.win.cfg.getProperty('zindex'));this.win.subscribe('hide',function(eventName,args,newScope){this.hideSearchWin();},this,true);this.win.subscribe('drag',function(eventName,args,newScope){this.bringToTop();Runner.setZindex(this.cfg.getProperty('zindex'));});var resize=new YAHOO.util.Resize(this.winDiv,{handles:["br"],autoRatio:false,minWidth:300,minHeight:100,status:false});resize.on("startResize",function(args){if(this.cfg.getProperty("constraintoviewport")){var D=YAHOO.util.Dom;var clientRegion=D.getClientRegion();var elRegion=D.getRegion(this.element);resize.set("maxWidth",clientRegion.right-elRegion.left-YAHOO.widget.Overlay.VIEWPORT_OFFSET);resize.set("maxHeight",clientRegion.bottom-elRegion.top-YAHOO.widget.Overlay.VIEWPORT_OFFSET);}else{resize.set("maxWidth",null);resize.set("maxHeight",null);}},this.win,true);resize.on("resize",function(args){var panelHeight=args.height;this.cfg.setProperty("height",panelHeight+"px");var panelWidth=args.width;this.cfg.setProperty("width",panelWidth+"px");},this.win,true);this.win.appendToBody(this.srchPanelHeader.get(0));this.win.appendToBody(this.srchOptDiv.get(0));this.srchCtrlsBlock.hide();this.moveCtrlsToTable();this.srchCtrlsBlockWin.show();this.showSearchOptions();this.srchWinShowStatus=true;if(this.recBlockMargChange){this.moveGridDiv.css(this.moveBlockPadding,0);}
this.initWinDelButtons();},moveCtrlsToTable:function(){for(var i=0;i<this.srchFilterRowArr.length;i++){var divRowId=this.srchFilterRowArr[i].attr('id');var tableRowId=divRowId+'_win';var tableRow=$('#'+tableRowId);if(this.srchFilterRowArr[i].css('display')!='none'){tableRow.show();}else{tableRow.css('display','none');}
this.moveCtrlsToTableRow(this.srchFilterRowArr[i],tableRow);}},moveCtrlsToTableRow:function(divRow,tableRow){var divCells=divRow.children();var tds=tableRow.children();for(var i=0;i<divCells.length;i++){var divCellChildren=$(divCells[i]).children();divCellChildren.find('script').remove();divCellChildren.appendTo($(tds[i]));if($(divCells[i]).css('display')=='none'){$(tds[i]).hide();}else{$(tds[i]).show();}}
$(tds[1]).html($(divCells[1]).html());},moveCtrlsToDiv:function(){for(var i=0;i<this.srchFilterRowWinArr.length;i++){var tableRowId=this.srchFilterRowWinArr[i].attr('id');var divRowId=tableRowId.substr(0,tableRowId.lastIndexOf('_'));var divRow=$('#'+divRowId);if(this.srchFilterRowWinArr[i].css('display')!='none'){divRow.show();}else{divRow.css('display','none');}
this.moveCtrlsToDivRow(this.srchFilterRowWinArr[i],divRow);}},moveCtrlsToDivRow:function(tableRow,divRow){var divCells=divRow.children();var tds=tableRow.children();for(var i=0;i<tds.length;i++){var tableCellChildren=$(tds[i]).children();tableCellChildren.find('script').remove();tableCellChildren.appendTo($(divCells[i]));if($(tds[i]).css('display')=='none'){$(divCells[i]).hide();}else{$(divCells[i]).show();}}
$(divCells[1]).html($(tds[1]).html());},hideShowAll:function(){this.showAll.hide();this.showAllButtStatus=false;},showShowAll:function(){this.showAll.parent().show();this.showShowAll=function(){this.showAll.show();this.showAllButtStatus=true;};this.showShowAll();},toggleShowAll:function(){this.showAllButtStatus?this.hideShowAll():this.showShowAll();},hideSearchWin:function(id){this.hideCtrlChooseMenu();this.srchOptDiv.prependTo(this.panelContainer);this.corGridDiv();this.srchCtrlsBlockWin.hide();this.moveCtrlsToDiv();this.srchCtrlsBlock.show();this.srchPanelHeader.prependTo($("#searchform"+this.id));var win=this.win
setTimeout(function(){win.destroy();},5);this.srchWinShowStatus=false;},toggleSearchWin:function(e){this.srchWinShowStatus?this.hideSearchWin():this.showSearchWin(e);this.hideCtrlChooseMenu();},showSearchBlock:function(){this.srchBlock.show();this.srchBlockStatus=true;},hideSearchBlock:function(){this.srchBlock.hide();this.srchBlockStatus=false;},toggleSearchBlock:function(){(this.srchBlockStatus&&!this.srchWinShowStatus)?this.hideSearchBlock():this.showSearchBlock();},corGridDiv:function(){var mrgLeft=this.moveGridDiv.css(this.moveBlockPadding);if(mrgLeft=='auto'||mrgLeft=='0px'){this.recBlockMargChange=true;this.moveGridDiv.css(this.moveBlockPadding,203);}},showSearchOptions:function(){if(this.srchOptDiv.length)
this.corGridDiv();this.srchOptDiv.show();this.bottomPanelRound.css('display','');this.srchOptExpander.css("background-image",'url("'+this.hideOptSrc+'")');this.srchOptExpander.attr('alt',this.hideOptText);this.srchOptExpander.attr('title',this.hideOptText);this.srchOptShowStatus=true;},hideSearchOptions:function(){if(this.recBlockMargChange){this.moveGridDiv.css(this.moveBlockPadding,0);}
this.srchOptDiv.hide();this.bottomPanelRound.css('display','none');this.srchOptExpander.css("background-image",'url("'+this.showOptSrc+'")');this.srchOptExpander.attr('alt',this.showOptText);this.srchOptExpander.attr('title',this.showOptText);this.srchOptShowStatus=false;},toggleSearchOptions:function(){(this.srchOptShowStatus&&!this.srchWinShowStatus)?this.hideSearchOptions():this.showSearchOptions();this.hideCtrlChooseMenu();},showCtrlChooseMenu:function(){if(!this.ctrlChooseMenuDiv){this.ctrlChooseMenuDiv=$("#controlChooseMenu"+this.id);this.ctrlChooseMenuDiv.appendTo(document.body);}
var controller=this;var hideHandler=function(){controller.showCtrlChooseMenu();}
var hideTask=new Runner.util.DelayedTask(hideHandler);controller.ctrlChooseMenuDiv.bind('mouseover',function(e){showTask.cancel();hideTask.delay(50,hideHandler,null,[e]);});var showHandler=function(){controller.hideCtrlChooseMenu();}
var showTask=new Runner.util.DelayedTask(showHandler);controller.ctrlChooseMenuDiv.bind('mouseout',function(e){hideTask.cancel();showTask.delay(50,showHandler,null,[e]);});if(Runner.isIE6){this.iframe=new Runner.util.IEHelper.iframe();this.hider=new Runner.util.IEHelper.selectsHider(this.ctrlChooseMenuDiv[0]);}
this.showCtrlChooseMenu=function(){var posObj=findPos($("#showHideControlChooseMenu"+this.id)[0]);var divT=posObj[1]+posObj[3],divL=posObj[0];this.ctrlChooseMenuDiv.css('top',divT).css('left',divL);this.ctrlChooseMenuDiv.show();this.ctrlChooseMenuDiv[0].offsetWidth<80?this.ctrlChooseMenuDiv.css('width','65px'):'';if(Runner.isIE6&&!this.srchWinShowStatus){this.iframe.reset({l:divL,t:divT,h:this.ctrlChooseMenuDiv[0].offsetHeight,w:this.ctrlChooseMenuDiv[0].offsetWidth});}else if(Runner.isIE6&&this.srchWinShowStatus){this.hider.showSels();this.hider.getSelects();this.hider.hideSels();}
Runner.getZindex(this.ctrlChooseMenuDiv);this.ctrlChooseMenuStatus=true;}
this.showCtrlChooseMenu();},hideCtrlChooseMenu:function(){if(!this.ctrlChooseMenuDiv){this.ctrlChooseMenuDiv=$("#controlChooseMenu"+this.id);this.ctrlChooseMenuDiv.appendTo(document.body);}
this.ctrlChooseMenuDiv.hide();this.ctrlChooseMenuStatus=false;if(Runner.isIE6&&!this.srchWinShowStatus&&this.iframe){this.iframe.hide();}else if(Runner.isIE6&&this.srchWinShowStatus&&this.iframe){this.hider.showSels();}},toggleCtrlChooseMenu:function(){this.ctrlChooseMenuStatus?this.hideCtrlChooseMenu():this.showCtrlChooseMenu();},showCtrlTypeCombo:function(){for(var i=0;i<this.searchTypeCombosArr.length;i++){this.searchTypeCombosArr[i].show();this.searchTypeCombosArr[i].find('select').show();}
for(var i=0;i<this.searchTypeCombosWinArr.length;i++){this.searchTypeCombosWinArr[i].show();this.searchTypeCombosWinArr[i].find('select').show();}
this.showHideSearchComboButton.html(this.hideComboText);this.showHideSearchComboButton.attr('title',this.hideComboText);this.ctrlTypeComboStatus=true;},hideCtrlTypeCombo:function(){for(var i=0;i<this.searchTypeCombosArr.length;i++){this.searchTypeCombosArr[i].hide();this.searchTypeCombosArr[i].find('select').hide();}
for(var i=0;i<this.searchTypeCombosWinArr.length;i++){this.searchTypeCombosWinArr[i].hide();this.searchTypeCombosWinArr[i].find('select').hide();}
this.showHideSearchComboButton.html(this.showComboText);this.showHideSearchComboButton.attr('title',this.showComboText);this.ctrlTypeComboStatus=false;},toggleCtrlTypeCombo:function(){this.ctrlTypeComboStatus?this.hideCtrlTypeCombo():this.showCtrlTypeCombo();},toggleCrit:function(ctrlsCount){var topCritContId='srchCritTop'+this.id;this.topCritCont=$('#'+topCritContId);var bottomSearchButtId='bottomSearchButt'+this.id;this.bottomSearchButt=$('#'+bottomSearchButtId);this.toggleCrit=function(ctrlsCount){ctrlsCount>1?this.topCritCont.show():this.topCritCont.hide();ctrlsCount>0?this.bottomSearchButt.show():this.bottomSearchButt.hide();}
this.toggleCrit(ctrlsCount);}});Runner.search.SearchController=Runner.extend(Runner.search.SearchFormWithUI,{panelStateExpires:'',ajaxSearchUrl:"",styleDispNoneText:'display: none;',shortTName:"",constructor:function(cfg){Runner.search.SearchController.superclass.constructor.call(this,cfg);this.ajaxSearchUrl=this.shortTName+'_search.php';Runner.pages.PageManager.addUnloadHn(this.rememberPanelState,this,[]);},init:function(ctrlsBlocks){Runner.search.SearchController.superclass.init.call(this,ctrlsBlocks);this.remindPanelState();this.initFastSearch();this.initAddLinks();this.initDelButtons();},initFastSearch:function(){var controller=this;if(!this.usedSrch){$("#ctlSearchFor"+this.id).bind('focus',function(e){if(controller.smplUsed!=true){this.value='';controller.smplUsed=true;$(this).css('color','');$(this).unbind(e);}});}else{$("#ctlSearchFor"+this.id).focus();}
if(this.useSuggest){$("#ctlSearchFor"+this.id).bind('keyup',function(e){searchSuggest(e,this,'ordinary','searchsuggest.php?table='+controller.shortTName,1);});$("#ctlSearchFor"+this.id).bind('keydown',function(e){return listenEvent(e,this,controller);});}},initAddLinks:function(){var controller=this;for(var i=0;i<this.fNamesArr.length;i++){$("#addSearchControl_"+Runner.goodFieldName(this.fNamesArr[i])).bind("click",{fName:this.fNamesArr[i]},function(e){Runner.Event.prototype.stopEvent(e);controller.addFilter(e.data.fName);controller.hideCtrlChooseMenu();});};},initDelButtons:function(){var srchController=this;this.srchCtrlsBlock.bind('click',function(e){var target=Runner.Event.prototype.getTarget(e);if(target&&target.nodeName!="IMG"||!$(target).attr("fName")){return;}
Runner.Event.prototype.stopEvent(e);var fName=$(target).attr("fName"),ctrlId=parseInt($(target).attr("ctrlId"));for(var i=0;i<srchController.fNamesArr.length;i++){if(fName==Runner.goodFieldName(srchController.fNamesArr[i])){fName=srchController.fNamesArr[i];break;}}
srchController.delCtrl(fName,ctrlId);});},initWinDelButtons:function(){var srchController=this;$(this.win.body).bind('click',function(e){var target=Runner.Event.prototype.getTarget(e);if(target&&target.nodeName!="IMG"||!$(target).attr("fName")){return;}
Runner.Event.prototype.stopEvent(e);var fName=$(target).attr("fName"),ctrlId=parseInt($(target).attr("ctrlId"));for(var i=0;i<srchController.fNamesArr.length;i++){if(fName==Runner.goodFieldName(srchController.fNamesArr[i])){fName=srchController.fNamesArr[i];break;}}
srchController.delCtrl(fName,ctrlId);});},initButtons:function(){Runner.search.SearchController.superclass.initButtons.call(this);var searchController=this;$("#showOptPanel"+this.id).bind("click",function(e){searchController.toggleSearchOptions();});$("#showSrchWin"+this.id).bind("click",function(e){searchController.toggleSearchWin();});$("#searchButton"+this.id).bind("click",function(e){searchController.submitSearch();});$("#showHideSearchType"+this.id).bind("click",function(e){Runner.Event.prototype.stopEvent(e);searchController.toggleCtrlTypeCombo();});$("#showHideControlChooseMenu"+this.id).bind("click",function(e){Runner.Event.prototype.stopEvent(e);searchController.toggleCtrlChooseMenu();});},hideShowAll:function(){Runner.search.SearchController.superclass.hideShowAll.call(this);this.smplSrchBox.val("");},getLastAddedInd:function(filterName){if(!this.ctrlsShowMap[filterName]){return false;}
var maxInd=0,beforeMaxInd=false,i=0;for(var ind in this.ctrlsShowMap[filterName]){ind=parseInt(ind);if(maxInd<ind){beforeMaxInd=maxInd;maxInd=ind;}
if(i===0){beforeMaxInd=maxInd;}
i++;}
return beforeMaxInd;},getLastAdded:function(filterName){var beforeMaxInd=this.getLastAddedInd(filterName);if(!beforeMaxInd){return false;}
var filterObj=$('#'+this.getFilterDivId(filterName,beforeMaxInd,this.srchWinShowStatus));if(filterObj.length){return filterObj;}else{return false;}},addCtrlsHtml:function(fName,ind,blockHTML){this.addPanelHtml(fName,ind,blockHTML);this.addTableHtml(fName,ind);var rowCont=$('#'+this.getFilterDivId(fName,ind,this.srchWinShowStatus))
var cells=rowCont.children();$(cells[0]).html(blockHTML.delButt);$(cells[2]).html(blockHTML.comboHtml);$(cells[3]).html(blockHTML.control1);$(cells[4]).html(blockHTML.control2);eval(blockHTML.jsCode);},addTableHtml:function(fName,ind){var newSrchCtrlContId=this.getFilterDivId(fName,ind,true);var filterRowHtml=this.createTableRow(newSrchCtrlContId,'winRow',this.styleDispNoneText,'');this.srchCtrlsBlockWin.append(filterRowHtml);var newSrchCtrlCont=$("#"+newSrchCtrlContId);newSrchCtrlCont.append(this.createTableCell('','srchWinCell','',''));var fNameCellHtml=this.createTableCell('','srchWinCell','',fName+':&nbsp;');newSrchCtrlCont.append(fNameCellHtml);var comboHtml=this.createTableCell(this.getComboContId(fName,ind,true),'srchWinCell',(this.ctrlTypeComboStatus?'':this.styleDispNoneText),'');newSrchCtrlCont.append(comboHtml);newSrchCtrlCont.append(this.createTableCell('','srchWinCell','',''));newSrchCtrlCont.append(this.createTableCell('','srchWinCell','',''));return newSrchCtrlCont;},addPanelHtml:function(fName,ind,blockHTML){var newSrchCtrlContId=this.getFilterDivId(fName,ind);var filterDivHtml=this.createDivCont(newSrchCtrlContId,'srchPanelRow blockBorder',this.styleDispNoneText,'');this.srchCtrlsBlock.append(filterDivHtml);var newSrchCtrlCont=$("#"+newSrchCtrlContId);newSrchCtrlCont.append(this.createDivCont('','srchPanelCell','',''));var fNameDivHtml=this.createDivCont('','srchPanelCell','',blockHTML.fLabel+':&nbsp;');newSrchCtrlCont.append(fNameDivHtml);var comboHtml=this.createDivCont(this.getComboContId(fName,ind),'srchPanelCell srchPanelCell2',(this.ctrlTypeComboStatus?'':this.styleDispNoneText),'');newSrchCtrlCont.append(comboHtml);newSrchCtrlCont.append(this.createDivCont('','srchPanelCell srchPanelCell2','',''));newSrchCtrlCont.append(this.createDivCont('','srchPanelCell srchPanelCell2','',''));return newSrchCtrlCont;},addRegCtrlsBlock:function(fName,ind,ctrlIndArr,blockHTML){blockHTML?this.addCtrlsHtml(fName,ind,blockHTML):"";Runner.search.SearchController.superclass.addRegCtrlsBlock.call(this,fName,ind,ctrlIndArr);var ctrl=Runner.controls.ControlManager.getAt(this.tName,ind,fName);if(!ctrl.hidden){this.setDependences(ctrl);}
this.searchTypeCombosArr.push($("#"+this.getComboContId(fName,ind)));this.searchTypeCombosWinArr.push($("#"+this.getComboContId(fName,ind,true)));this.srchFilterRowArr.push($("#"+this.getFilterDivId(fName,ind)));this.srchFilterRowWinArr.push($("#"+this.getFilterDivId(fName,ind,true)));this.toggleCrit(this.getVisibleBlocksCount());},createDivCont:function(id,cssClass,style,innerHtml){return'<div class="'+cssClass+'" id="'+id+'" style="'+style+'">'+innerHtml+'</div>';},createTableRow:function(id,cssClass,style,innerHtml){return'<tr class="'+cssClass+'" id="'+id+'" style="'+style+'">'+innerHtml+'</tr>';},createTableCell:function(id,cssClass,style,innerHtml){return'<td class="'+cssClass+'" id="'+id+'" style="'+style+'">'+innerHtml+'</td>';},putCachedBlock:function(filterName,cachedInd,parentFieldName){var cachedRow=$("#"+this.getFilterDivId(filterName,cachedInd,this.srchWinShowStatus));var lastAdded=this.getLastAdded(filterName);if(parentFieldName&&this.getLastAdded(parentFieldName)){cachedRow.insertAfter(this.getLastAdded(parentFieldName));}else if(lastAdded){cachedRow.insertBefore(lastAdded);}else{if(this.srchWinShowStatus){this.srchCtrlsBlockWin.prepend(cachedRow);}else{this.srchCtrlsBlock.prepend(cachedRow);}}
cachedRow.show();},createLoadingBox:function(filterName){var loadingTxt='&nbsp;&nbsp;'+filterName+':&nbsp;loading&nbsp;...&nbsp;';if(!this.srchWinShowStatus){var loadDiv=document.createElement('DIV');$(loadDiv).addClass('blockBorderHovered').html(loadingTxt);return loadDiv;}else{var loadTr=document.createElement('TR');var loadTd=document.createElement('TD');$(loadTd).attr('colspan','4').addClass('cellBorderRightHovered').addClass('cellBorderLeftHovered').addClass('cellBorderCenterHovered').html(loadingTxt);$(loadTr).addClass('winRow').append(loadTd);return loadTr;}},putLoadingBox:function(loadBox,filterName){var lastAdded=this.getLastAdded(filterName);if(lastAdded){$(loadBox).insertBefore(lastAdded);}else{if(this.srchWinShowStatus){this.srchCtrlsBlockWin.append($(loadBox));}else{this.srchCtrlsBlock.append($(loadBox));}}},setDependences:function(ctrl,triggerReload){if(!ctrl.isLookupWizard){return false;}
if(!ctrl.parentFieldName)
return false;if(!ctrl.parentFieldName||!this.ctrlsShowMap[ctrl.parentFieldName]){ctrl.reload();return false;}
var parentInd=this.getLastAddedInd(ctrl.parentFieldName);if(!this.ctrlsShowMap[ctrl.parentFieldName][parentInd]){return false;}
var parentCtrl=Runner.controls.ControlManager.getAt(this.tName,parentInd,ctrl.parentFieldName,this.ctrlsShowMap[ctrl.parentFieldName][parentInd][0]);if(parentCtrl.showStatus&&parentCtrl.isLookupWizard){ctrl.setParentCtrl(parentCtrl);parentCtrl.addDependentCtrls([ctrl]);if(triggerReload===true){parentCtrl.fireEvent('change');}else{ctrl.preload(ctrl.preloadData.vals,ctrl.preloadData.fVal);}}else{ctrl.reload();}
return true;},getShownFilterNames:function(){var fNamesArr=[];for(var fName in this.ctrlsShowMap){var cachedInd=0;for(var ind in this.ctrlsShowMap[fName]){ind=parseInt(ind);if($("#"+this.getFilterDivId(fName,ind,this.srchWinShowStatus)).css('display')!='none'){fNamesArr.push(fName);}}}
return fNamesArr;},showCached:function(filterName){if(!this.ctrlsShowMap[filterName]){return false;}
var cachedInd=0;for(var ind in this.ctrlsShowMap[filterName]){ind=parseInt(ind);cachedInd=cachedInd<ind?ind:cachedInd;}
if($("#"+this.getFilterDivId(filterName,cachedInd,this.srchWinShowStatus)).css('display')!='none'){return false;}
var cachedCtrlIndArr=this.ctrlsShowMap[filterName][cachedInd];var objIndForCM,parentFieldName,parentCtrl=null,parentInd=false,ctrl1;for(var i=0;i<cachedCtrlIndArr.length;i++){objIndForCM=cachedCtrlIndArr[i];var ctrlFromCache=Runner.controls.ControlManager.getAt(this.tName,cachedInd,filterName,objIndForCM);if(i===0){ctrl1=ctrlFromCache;ctrl1.show();}
parentFieldName=ctrlFromCache.parentFieldName;this.setDependences(ctrlFromCache,true);ctrlFromCache.spanContElem.find('script').remove();}
this.putCachedBlock(filterName,cachedInd,parentFieldName);if(this.ctrlTypeComboStatus){$("#"+this.getComboContId(filterName,cachedInd)).show();}
if(!this.srchWinShowStatus){ctrl1.setFocus();}
return true;},addFilter:function(filterName){var isShown=this.showCached(filterName);if(!isShown){var loadBox=this.createLoadingBox(filterName);this.putLoadingBox(loadBox,filterName);}else{this.ctrlTypeComboStatus?this.showCtrlTypeCombo():this.hideCtrlTypeCombo();}
var ajaxParams={searchControllerId:this.id,rndval:Math.random(),mode:"inlineLoadCtrl",ctrlField:filterName,id:Runner.genId(),isNeedSettings:!Runner.pages.PageSettings.checkSettings(this.tName,filterName)};var controller=this;$.getJSON(this.ajaxSearchUrl,ajaxParams,function(ctrlJSON,queryStatus){controller.addRegCtrlsBlock(filterName,ctrlJSON.divInd,(ctrlJSON.control2?[0,1]:[0]),ctrlJSON);if(!Runner.pages.PageSettings.checkSettings(controller.tName,filterName)){Runner.pages.PageSettings.addSettings(controller.tName,ctrlJSON.settings);}
var ctrl;for(var i=0;i<ctrlJSON.ctrlMap.length;i++){ctrl=Runner.controls.ControlFabric(ctrlJSON.ctrlMap[i]);if(controller.useSuggest){ctrl.on('keyup',function(e,argsArr){var srchTypeComboId=controller.getComboId(controller.tName,controller.id);var srchTypeCombo=$('#'+srchTypeComboId);var suggestUrl='searchsuggest.php?table='+controller.shortTName;return searchSuggest_new(e,this,srchTypeCombo,'advanced',suggestUrl);},{buffer:200});ctrl.on('keydown',function(e,argsArr){return listenEvent(e,this.valueElem.get(0),controller);});}}
if(!isShown){controller.showCached(filterName);$(loadBox).remove();controller.toggleCrit(controller.getVisibleBlocksCount());controller.ctrlTypeComboStatus?controller.showCtrlTypeCombo():controller.hideCtrlTypeCombo();}});},delCtrl:function(fName,ctrlId){var objIndForCM,ctrl;for(var i=0;i<this.ctrlsShowMap[fName][ctrlId].length;i++){objIndForCM=this.ctrlsShowMap[fName][ctrlId][i];ctrl=Runner.controls.ControlManager.getAt(this.tName,ctrlId,fName,objIndForCM);if(ctrl.isLookupWizard){ctrl.clearChildrenLinks(true);}
Runner.controls.ControlManager.unregister(this.tName,ctrlId,fName,objIndForCM);}
this.removeComboById(this.getComboContId(fName,ctrlId));this.removeFilterById(this.getFilterDivId(fName,ctrlId));this.toggleCrit(this.getVisibleBlocksCount());delete this.ctrlsShowMap[fName][ctrlId];},removeFilterById:function(id){var isUseWinId=(id.lastIndexOf('_win')!=-1);id=(isUseWinId?id.substr(0,id.lastIndexOf('_')):id);var elemInd=this.srchFilterRowArr.getIndexOfElem(id,function(val,elem){return elem.attr('id')==val;});if(elemInd!==-1){this.srchFilterRowArr[elemInd].remove();this.srchFilterRowArr.splice(elemInd,1);}
id+='_win';var elemInd=this.srchFilterRowWinArr.getIndexOfElem(id,function(val,elem){return elem.attr('id')==val;});if(elemInd!==-1){this.srchFilterRowWinArr[elemInd].remove();this.srchFilterRowWinArr.splice(elemInd,1);}},removeComboById:function(id){var isUseWinId=(id.lastIndexOf('_win')!=-1);id=(isUseWinId?id.substr(0,id.lastIndexOf('_')):id);var elemInd=this.searchTypeCombosArr.getIndexOfElem(id,function(val,elem){return elem.attr('id')==val;});if(elemInd!==-1){this.searchTypeCombosArr.splice(elemInd,1);}
id+='_win';var elemInd=this.searchTypeCombosWinArr.getIndexOfElem(id,function(val,elem){return elem.attr('id')==val;});if(elemInd!==-1){this.searchTypeCombosWinArr.splice(elemInd,1);}},getVisibleBlocksCount:function(){var visCount=0;var rowArr=(this.srchWinShowStatus?this.srchFilterRowWinArr:this.srchFilterRowArr);for(var i=0;i<rowArr.length;i++){if(rowArr[i].css('display')!='none'){visCount++;}}
return visCount;},submitSearch:function(){this.rememberPanelState();if(!this.usedSrch&&!this.smplUsed){this.smplSrchBox.val('');}
Runner.search.SearchController.superclass.submitSearch.call(this);},resetCtrls:function(){var objIndForCM;for(var fName in this.ctrlsShowMap){for(var ind in this.ctrlsShowMap[fName]){for(var i=0;i<this.ctrlsShowMap[fName][ind].length;i++){objIndForCM=this.ctrlsShowMap[fName][ind][i];var ctrl=Runner.controls.ControlManager.getAt(this.tName,this.id,fName,objIndForCM);ctrl.reset();}}}
return false;},rememberPanelState:function(){var cutFrom=document.location['pathname'].lastIndexOf('/',1);var cookieRoot=document.location['pathname'].substr(0,(cutFrom+1));var panelStateObj={srchPanelOpen:this.srchOptShowStatus,srchCtrlComboOpen:this.ctrlTypeComboStatus,srchWinOpen:this.srchWinShowStatus,openFilters:[]};if(this.srchWinShowStatus){panelStateObj.winState={x:this.win.cfg.getProperty("x"),clientX:this.win.cfg.getProperty("x"),clientY:this.win.cfg.getProperty("y"),y:this.win.cfg.getProperty("y"),h:parseInt(this.win.cfg.getProperty("height")),w:parseInt(this.win.cfg.getProperty("width"))};}
if(!this.usedSrch){panelStateObj.openFilters=this.getShownFilterNames();}
var searchPanel={};searchPanel['panelState_'+this.shortTName+'_'+this.id]=panelStateObj;var panelStateString=JSON.stringify(searchPanel);set_cookie('searchPanel',panelStateString,this.panelStateExpires,cookieRoot,'','');},remindPanelState:function(){var panelStateString=get_cookie('searchPanel');var panelStateObj=null;if(panelStateString&&panelStateString.length)
{var searchPanel=JSON.parse(panelStateString);if(searchPanel['panelState_'+this.shortTName+'_'+this.id]!=undefined)
panelStateObj=searchPanel['panelState_'+this.shortTName+'_'+this.id];}
if(!panelStateObj){if(this.panelSearchFields.length){this.showSearchOptions();}
return;}
if(panelStateObj.srchWinOpen){this.hideSearchOptions();this.showSearchWin(panelStateObj.winState);}else if(panelStateObj.srchPanelOpen){this.showSearchOptions();}
if(panelStateObj.srchCtrlComboOpen){this.showCtrlTypeCombo();}else{this.hideCtrlTypeCombo();}
if(!this.usedSrch){for(var i=0;i<this.panelSearchFields.length;i++){var elemIndex=panelStateObj.openFilters.getIndexOfElem(this.panelSearchFields[i]);if(elemIndex!=-1){panelStateObj.openFilters.splice(elemIndex,1);}}
for(var i=0;i<panelStateObj.openFilters.length;i++){this.addFilter(panelStateObj.openFilters[i]);}}},getFieldIds:function(fName){var idsArr=[];if(this.ctrlsShowMap[fName]){for(var id in this.ctrlsShowMap[fName]){idsArr.push(id);}}
return idsArr;},getFieldControls:function(fName){var ctrlsArr=[],ctrl=null,idsArr=this.getFieldIds(fName);for(var i=0;i<idsArr.length;i++){ctrl=Runner.controls.ControlManager.getAt(this.tName,idsArr[i],fName);ctrlsArr.push(ctrl);}
return ctrlsArr;},getSecondControl:function(fName,id){return Runner.controls.ControlManager.getAt(this.tName,id,fName,1);},getFieldOptions:function(fName){var optsArr=[],opt=null,idsArr=this.getFieldIds(fName);for(var i=0;i<idsArr.length;i++){opt=$('#'+this.getComboId(fName,idsArr[i])).get(0);optsArr.push(opt);}
return optsArr;}});Runner.namespace('Runner.form');Runner.form.BasicForm=function(cfg){this.fieldControls=[];this.fields=[];this.addElems=[];this.ajaxForm={};this.baseParams={};Runner.apply(this,cfg);this.addEvents('beforeSubmit','successSubmit','submitFailed','validationFailed');if(this.beforeSubmit){this.on({'beforeSubmit':this.beforeSubmit});}
if(this.successSubmit){this.on({'successSubmit':this.successSubmit});}
if(this.submitFailed){this.on({'submitFailed':this.submitFailed});}
if(this.validationFailed){this.on({'validationFailed':this.validationFailed});}
Runner.form.BasicForm.superclass.constructor.call(this.cfg);if(cfg.initImmediately){this.initForm();}};Runner.form.BasicForm=Runner.extend(Runner.form.BasicForm,Runner.util.Observable,{fields:null,fieldControls:null,addElems:null,isFileUpload:false,standardSubmit:false,formEl:null,ioEl:null,ioElId:'',submitUrl:'',method:'GET',id:-1,baseParams:null,tName:'',shortTName:'',target:'',ajaxForm:null,autoValidation:true,addRndVal:true,useMultipart:false,initControls:function(){},destructor:function(leaveControls){if(leaveControls===true){for(var i=0;i<this.fieldControls.length;i++){this.fieldControls[i].unregister();}}
if(this.ioEl){$(this.ioEl).remove();}
if(this.formEl){$(this.formEl).remove();}},submit:function(){if(!this.validate()){return false;};var beforeSubmitRes=this.fireEvent('beforeSubmit',this);if(beforeSubmitRes===false){return false;}
if(this.isFileUpload||this.standardSubmit){this.initForm();this.addFormSubmit();this.formEl.submit();}else{this.addFormSubmit();var formObj=this;$.ajax({url:this.submitUrl,type:this.method,data:this.ajaxForm,success:function(data,textStatus,XMLHttpRequest){var respObj=JSON.parse(data);formObj.fireEvent("successSubmit",respObj,formObj,formObj.fieldControls);},error:function(XMLHttpRequest,textStatus,errorThrown){formObj.fireEvent("successFailed",respObj,formObj,formObj.fieldControls);}});}
return true;},initForm:function(){if(this.isFormReady){return;}
if(this.isFileUpload&&!this.standardSubmit){this.createIFrame();this.createForm();}else if(this.standardSubmit){this.createForm();}
this.isFormReady=true;},clearForm:function(){if(this.formEl){$(this.formEl).children().remove();}
this.ajaxForm={};return true;},addFormSubmit:function(){if(this.addRndVal){this.baseParams["rndVal"]=Math.random();}
if(this.formEl){var arrClns;for(var i=0;i<this.fieldControls.length;i++){arrClns=this.fieldControls[i].getForSubmit();for(var j=0;j<arrClns.length;j++){$(arrClns[j]).appendTo(this.formEl);}}
for(var param in this.baseParams){this.addToForm(param,this.baseParams[param]);}
for(var i=0;i<this.addElems.length;i++){$(this.addElems[i]).appendTo(this.formEl);}}else{this.ajaxForm=Runner.apply(this.ajaxForm,this.baseParams);for(var i=0;i<this.fieldControls.length;i++){this.ajaxForm[this.fieldControls[i].fieldName]=this.fieldControls[i].getStringValue();}}
return true;},addToForm:function(id,val){if(typeof val=='undefined'||typeof id=='undefined'||val===null||id===null){return false;}
if(this.isFileUpload||this.standardSubmit){if(!this.formEl){this.initForm();}
var formElem=document.createElement('INPUT');$(formElem).attr('type','hidden').attr('name',id).attr('id',id).val(val.toString()).appendTo(this.formEl);}else{this.ajaxForm[id]=val;}},addElemToForm:function(el){if(!el){return false;}
if($(el).attr("id")===""){return false;}
if(this.isFileUpload||this.standardSubmit){if(!this.formEl){return false;}
$(el).appendTo(this.formEl);}else{this.ajaxForm[$(el).attr("id")]=$(el).val();}},validate:function(){if(!this.autoValidation){return true;}
var vRes,controlsArr=[];for(var i=0;i<this.fieldControls.length;i++){vRes=this.fieldControls[i].validate();if(!vRes.result){controlsArr.push(this.fieldControls[i]);}}
if(controlsArr.length){controlsArr[0].setFocus();this.fireEvent("validationFailed",this,this.fieldControls,controlsArr);return false;}else{return true;}},createIFrame:function(){if(this.ioEl){return false;}
var frameId='uploadFrame_'+this.id;if(Runner.isIE){this.ioEl=document.createElement('<iframe id="'+frameId+'" name="'+frameId+'" />');if(Runner.isSecure){this.ioEl.src='javascript:false';}}
else{this.ioEl=document.createElement('iframe');this.ioEl.id=frameId;this.ioEl.name=frameId;}
this.ioEl.style.position='absolute';this.ioEl.style.top='-1000px';this.ioEl.style.left='-1000px';document.body.appendChild(this.ioEl);var basicForm=this;$(this.ioEl).bind('load',function(e){var iframeNode=$("#"+frameId)[0],ioDoc;if(iframeNode.contentDocument){ioDoc=iframeNode.contentDocument;}else if(iframeNode.contentWindow){ioDoc=iframeNode.contentWindow.document;}else{ioDoc=iframeNode.document;}
if(ioDoc.body.innerHTML!=''){try{var response=$(ioDoc.body.innerHTML).text()
var responseObj=JSON.parse(response);}catch(e){basicForm.fireEvent('submitFailed',ioDoc.body.innerHTML,basicForm,basicForm.fieldControls);return;}
basicForm.fireEvent('successSubmit',responseObj,basicForm,basicForm.fieldControls);}else{basicForm.fireEvent('submitFailed',{},basicForm,basicForm.fieldControls);}});this.ioElId=frameId;return this.ioEl;},createForm:function(){if(this.formEl){return false;}
this.formEl=document.createElement('FORM');this.formEl.action=this.submitUrl;this.formEl.method=this.method;if(this.target){this.formEl.target=this.target;}
$(this.formEl).css('display','none');if(this.isFileUpload||this.useMultipart){$(this.formEl).attr('encoding','multipart/form-data');}
if(this.ioEl){$(this.formEl).attr('target',this.ioElId);}
document.body.appendChild(this.formEl);return this.formEl;}});