var SearchAccountGlobals;function CreateSearchAccountGlobals(){this.accountSearchRunning=false;this.newSearchTriggered=true;this.accountSearchSucceed=false;this.calledFromRedrawDevice=false;this.devTable=null;this.ajaxManager=null;this.scrollElementGlobal=null;this.scrollApiGlobal=null;this.getRowDetailURL=null;} function fnGetRowDetails(sender,callBackFn){var rowIndex=SearchAccountGlobals.devTable.fnGetPosition(sender);var oSettings=SearchAccountGlobals.devTable.fnSettings();var id=oSettings.aoData[rowIndex]._aData[0];$.ajax({url:SearchAccountGlobals.getRowDetailURL,data:{id:id},cache:false,async:true,type:'Post',success:function(result){callBackFn(sender,SearchAccountGlobals.devTable,result,ToggleLoadingRowAnimation,CallBackGetScrollElementOverlay);}});} function ToggleLoadingRowAnimation(show){if(show) $('#searchOverlayLoadingRowBar').show();else $('#searchOverlayLoadingRowBar').hide();} function InitializeAccountSearchOverlay(settings){SearchAccountGlobals=new CreateSearchAccountGlobals();var searchCount=0;var container=getContainer(settings);InitializeNotificationArea('#AccountSearchDialogNotification');$('#AccountSearchLoadingBar').bind("ajaxStart",function(){$(this).show();});$('#AccountSearchLoadingBar').bind("ajaxStop",function(){$(this).hide();});$(container).find('.SearchAccountDialog').eBusinessLayover({modal:true,width:"870px",position:{"top":"200px","left":"44px"},downBorder:true,upBorder:true,Downbuttons:{"ApplySearchResult":""},headerText:_CockpitAccountSearchHeader});$(container).find('.SearchAccountDialog').find('input').bind('change',function(){ControlSearchAccountButton(container);});$(container).find('.SearchAccountDialog').find('input').bind('keyup',function(){ControlSearchAccountButton(container);});$(container).find('.SearchAccountDialog').keypress(function(e){if(e.keyCode==13){$(container).find('.SearchDialogSearchButton').click();return false;}});$(container).find('.SearchAccountDialog').bind("layoverCancel",function(event){ResetAccountSearchDialog(container);CheckIfIScanFrameAvailable();});$(container).find('.SearchDialogSearchButton').eBusinessButton({readonly:true});$(container).find('.SearchDialogSearchButton').bind("click",function(){if(ValidateForm('AccountSearchDialogForm','AccountSearchDialogNotification')){onSearchDialogSearchButtonClicked(settings);}});$(container).find('.ApplySearchResult').eBusinessButton({readonly:true});SearchAccountGlobals.ajaxManager=$.manageAjax.create('ajaxManager',{queue:'clean',cacheResponse:false,abortOld:true,maxRequests:1,abortIsNoSuccess:false});SearchAccountGlobals.getRowDetailURL=settings.GetRowDetailURL;} function CreateCallBackObject(container){var selectedTR=$(container).find('tr.selected')[0];var rowIndex=SearchAccountGlobals.devTable.fnGetPosition(selectedTR);var oSettings=SearchAccountGlobals.devTable.fnSettings();var soldto=oSettings.aoData[rowIndex]._aData[1];var shipto=oSettings.aoData[rowIndex]._aData[2];var description=oSettings.aoData[rowIndex]._aData[5];var data=new Object();data.SoldTo=soldto;data.ShipTo=shipto;data.Description=description;return data;} function getContainer(settings){var container=document;if(settings&&settings.Container)container=settings.Container;return container;} function onSearchDialogSearchButtonClicked(settings){var container=getContainer(settings);$.ajax({type:"Post",url:settings.SearchHandlerUrl,cache:false,success:function(data){$(container).find('.SearchAccountResultContainer').html(data);SearchAccountGlobals.newSearchTriggered=true;InitializeSearchAccountDataTable(settings);UpdateSearchAccountDataTable();$(container).find('.ApplySearchResult').eBusinessButton({readonly:true});$(container).find('.ApplySearchResult').unbind('click').bind('click',function(){var data=CreateCallBackObject(container);ResetAccountSearchDialog(container);settings.ApplySearchResultCall.call(this,data);});}});} function ControlSearchAccountButton(container){var textEntered=false;$(container).find('.SearchAccountDialog').find('input.textBox').each(function f(e){if($(this).val()!="") textEntered=true;});if(textEntered){$(container).find('.SearchDialogSearchButton').eBusinessButton({readonly:false});} else $(container).find('.SearchDialogSearchButton').eBusinessButton({readonly:true});} function ResetAccountSearchDialog(container){$(container).find('.SearchAccountResultContainer').html('');$(container).find('.SearchAccountNumber').val('');$(container).find('.SearchCompanyName').val('');$(container).find('.SearchZipCode').val('');$(container).find('.SearchCity').val('');HideNotificationArea('#AccountSearchDialogNotification');$(container).find('.SearchDialogSearchButton').eBusinessButton({readonly:true});$(container).find('.ApplySearchResult').eBusinessButton({readonly:true});} function aaDataWrapper(){this.aaData=new Array();this.sColumns=null;this.iTotalDisplayRecords=0;this.iTotalRecords=0;this.filterExp="";this.sLanguage="";} function AccountSearchDialogModel(searchAccountNumber,searchCompanyName,searchZipCode,searchCity,searchAccountPageId){this.SearchAccountNumber=searchAccountNumber;this.SearchCompanyName=searchCompanyName;this.SearchZipCode=searchZipCode;this.SearchCity=searchCity;this.SearchAccountPageId=searchAccountPageId;} function CreateAccountSearchParameterSet(container){var searchAccountNumber=htmlEncodeEbiz($(container).find('.SearchAccountNumber').val());var searchCompanyName=htmlEncodeEbiz($(container).find('.SearchCompanyName').val());var searchZipCode=htmlEncodeEbiz($(container).find('.SearchZipCode').val());var searchCity=htmlEncodeEbiz($(container).find('.SearchCity').val());var searchAccountPageId=$(container).find('.SearchAccountPageId').val();var searchParameterSet=new AccountSearchDialogModel(searchAccountNumber,searchCompanyName,searchZipCode,searchCity,searchAccountPageId);return searchParameterSet;} function InitializeSearchAccountDataTable(settings){var container=getContainer(settings);var columnDefinitons=settings.ColumnDefinitions;var url=_AccountSearchOverlayGetRows;var searchArea=$('.SearchAccountDialog');var htmlTable=$('#AccountListTable');var tempTable=$(htmlTable).dataTable({"bDestroy":true,"sDom":'Ert',"sAjaxSource":url,"bServerSide":true,"bAutoWidth":true,"aaSorting":[[0,"desc"]],"bProcessing":true,"fnServerData":function(url,data,callback){if(!SearchAccountGlobals.accountSearchRunning){SearchAccountGlobals.accountSearchRunning=true;var searchParameterSet=$.toJSON(CreateAccountSearchParameterSet(container));data.push({"name":"NewSearchTriggered","value":SearchAccountGlobals.newSearchTriggered});data.push({"name":"SearchParameterSet","value":searchParameterSet});SearchAccountGlobals.newSearchTriggered=false;documentSearchSucceed=false;SearchAccountGlobals.ajaxManager.abort();SearchAccountGlobals.ajaxManager.add({"url":url,"data":data,"async":true,"success":function(data){SearchAccountGlobals.accountSearchSucceed=true;callback.call(tempTable.fnSettings(),data);if(SearchAccountGlobals.calledFromRedrawDevice){SearchAccountGlobals.calledFromRedrawDevice=false;if(!allTableScrollInitializedCorrectly){SearchAccountGlobals.scrollElementGlobal=$(searchArea).find('.dataTables_scrollBody').jScrollPane({showArrows:true,verticalGutter:0});allTableScrollInitializedCorrectly=true;tempTable.fnAdjustColumnSizing(false);}}},"contentType":"application/x-www-form-urlencoded; charset=utf-8","dataType":"json","type":"POST","cache":false,"error":function(e){if(e.statusText=='abort') $.event.global.ajaxError=false;},"complete":function(){SearchAccountGlobals.accountSearchRunning=false;if(!SearchAccountGlobals.accountSearchSucceed){var aaData=new aaDataWrapper();callback.call(tempTable.fnSettings(),aaData);} $.event.global.ajaxError=true;}});}},"bScrollInfinite":true,"iDisplayLength":100,"iScrollLoadGap":40,"fnDrawCallback":function(oSettings){if(SearchAccountGlobals.scrollElementGlobal!=null){SearchAccountGlobals.scrollApiGlobal=SearchAccountGlobals.scrollElementGlobal.data('jsp');if(SearchAccountGlobals.scrollApiGlobal!=null){SearchAccountGlobals.scrollApiGlobal.reinitialise();tempTable.fnAdjustColumnSizing(false);}} $(htmlTable).find('tbody tr.odd,tbody tr.even').unbind('click');$(htmlTable).find('tbody tr.odd,tbody tr.even').bind('click',function(){if(!$(this).hasClass('dataTables_empty')&&!$(this).hasClass('selected')){$(searchArea).find('.selected').removeClass('selected');$(this).addClass('selected');$('.ApplySearchResult').eBusinessButton({readonly:false});}});$(htmlTable).find('tbody tr.odd,tbody tr.even').unbind('dblclick');$(htmlTable).find('tbody tr.odd,tbody tr.even').bind('dblclick',function(){if(!$(this).hasClass('dataTables_empty')&&!$(this).hasClass('selected')){$(searchArea).find('.selected').removeClass('selected');$(this).addClass('selected');$('.ApplySearchResult').eBusinessButton({readonly:false});} $(container).find('.ApplySearchResult').click();});$(htmlTable).find('div.plus').unbind("click");$(htmlTable).find('div.plus').click(function(e){$(this).closest('tr').removeClass('collapsed').addClass('expanded');onDetailRowClickEvents($(this).closest('tr')[0],SearchAccountGlobals.devTable,fnGetRowDetails,ToggleLoadingRowAnimation,CallBackGetScrollElementOverlay);});$(htmlTable).find('div.minus').unbind("click");$(htmlTable).find('div.minus').click(function(e){$(this).closest('tr').removeClass('expanded').addClass('collapsed');onDetailRowClickEvents($(this).closest('tr')[0],SearchAccountGlobals.devTable,fnGetRowDetails,ToggleLoadingRowAnimation,CallBackGetScrollElementOverlay);});},"fnRowCallback":function(row,data,index){if(!$(row).hasClass('collapsed')&&!$(row).hasClass('expanded'))$(row).addClass('collapsed');$('td',row).eq(0).html('
').css('padding-right: 5px;');return row;},"bSort":true,"aoColumnDefs":columnDefinitons,"oLanguage":{"sProcessing":_Processing,"sZeroRecords":_NoAccountAvailableTitle},"fnInitComplete":function(){if(SearchAccountGlobals.accountSearchSucceed){SearchAccountGlobals.scrollElementGlobal=$(searchArea).find('.dataTables_scrollBody').jScrollPane({showArrows:true,verticalGutter:0});allTableScrollInitializedCorrectly=true;tempTable.fnAdjustColumnSizing(false);}},"sScrollY":"100px"});$(htmlTable).parent().unbind('scroll');$(htmlTable).parent().scroll(function(){var oSettings=tempTable.fnSettings();if(!oSettings.bDrawing){if(-parseInt($(this).find('.jspPane').css('top'))+$(this).height()>$(oSettings.nTable).height()-oSettings.oScroll.iLoadGap){if(oSettings.fnDisplayEnd()