Ext.core.Element.addMethods(function(){var XMASKED=Ext.baseCSSPrefix+"masked",XMASKEDRELATIVE=Ext.baseCSSPrefix+"masked-relative",data=Ext.core.Element.data
return{positionMaskMessage:function(){if(this.isMasked())
{var me=this,mask=data(me.dom,'mask'),maskMsg=data(me.dom,'maskMsg'),regionView=Ext.getBody().getViewRegion(),regionMask=mask.getViewRegion(),visibleTop=regionView.top>regionMask.top?regionView.top:regionMask.top,visibleBot=regionView.bottom<regionMask.bottom?regionView.bottom:regionMask.bottom,visibleHeight=visibleBot-visibleTop
if(regionMask.bottom<regionView.top)
maskMsg.center(me)
else if(regionView.bottom<regionMask.top)
maskMsg.center(me)
else if(visibleHeight<=maskMsg.getHeight())
maskMsg.setY(visibleTop)
else
maskMsg.setY(visibleTop+(visibleHeight/2)-(maskMsg.getHeight()/2))}}}}())
Ext.namespace('mdc')
Ext.namespace('mdc.pages.cart')
Ext.namespace('mdc.pages.changePassword')
Ext.namespace('mdc.pages.dynamicform')
Ext.namespace('mdc.pages.forgotPassword')
Ext.namespace('mdc.pages.login')
Ext.namespace('mdc.pages.login_conversion')
Ext.namespace('mdc.pages.mediaroom')
Ext.namespace('mdc.pages.ordersearch')
Ext.namespace('mdc.pages.productalternates')
Ext.namespace('mdc.pages.productcomparison')
Ext.namespace('mdc.pages.productdetail')
Ext.namespace('mdc.pages.productlisttoolbox')
Ext.namespace('mdc.pages.productoverview')
Ext.namespace('mdc.pages.resetPassword')
Ext.namespace('mdc.pages.searchbox')
Ext.namespace('mdc.pages.systemMessages')
Ext.namespace('mdc.pages.sitesearch')
Ext.namespace('mdc.search.typeAhead')
Ext.namespace('mdc.pages.loginfrm')
mdc.addOnLoad=function(onloadValue)
{if(Ext.isString(onloadValue))
{Ext.onReady
(function()
{eval(onloadValue)})}
else if(Ext.isFunction(onloadValue))
{Ext.onReady(onloadValue)}}
mdc.associativeArraySize=function(theArray)
{var count=0
for(var e in theArray)
{if(theArray.hasOwnProperty(e))count++}
return count}
mdc.associativeArrayKeysToCommaDelimitedList=function(theArray)
{var skuMaterialNumbers=''
for(var e in theArray)
{if(theArray.hasOwnProperty(e))
{if(skuMaterialNumbers)skuMaterialNumbers+=','
skuMaterialNumbers+=e}}
return skuMaterialNumbers}
mdc.click=function(id)
{Ext.fly(id).dom.click()
return false}
mdc.every=function(theArray,theFunction)
{if(theArray)
{for(var i=0;i<theArray.length;i++)
{if(!theFunction(theArray[i]))
{return false}}}
return true}
mdc.executeJavascriptInHtml=function(html)
{var scriptsFinder=/<script[^>]*>([\s\S]+)<\/script>/gi;while(scripts=scriptsFinder.exec(html))
{eval(scripts[1])}}
mdc.expandCollapse=function(itemId,collapseFlag)
{if(collapseFlag)
{Ext.fly('shown_'+itemId).setStyle('display','')
Ext.fly('hidden_'+itemId).setStyle('display','none')}
else
{Ext.fly('shown_'+itemId).setStyle('display','none')
Ext.fly('hidden_'+itemId).setStyle('display','')}
return false}
mdc.getCached_Elements=new Array()
mdc.getCached=function(id)
{var ele=mdc.getCached_Elements[id]
if(ele)
{}
else
{ele=Ext.get(id)
if(ele)mdc.getCached_Elements[id]=ele}
return ele}
mdc.getDomCached=function(id)
{var ele=mdc.getCached(id)
if(ele)return ele.dom
else return null}
mdc.getContextPath=function()
{return this._contextPath}
mdc.getWidget=function(id)
{return med.WidgetManager.get(id)}
mdc.isFalse=function(flag)
{return((flag==false)||(flag=='false'))}
mdc.isTrue=function(flag)
{return((flag==true)||(flag=='true'))}
mdc.notImplemented=function()
{alert(_mdc.NOT_IMPLEMENTED_YET)
return false}
mdc.setContextPath=function(contextPath)
{this._contextPath=contextPath}
mdc.setCookieProperty=function(cookieName,propertyName,propertyValue)
{var cookieValue=Ext.util.Cookies.get(cookieName)||''
var finalCookie=''
var added=false
if(cookieValue.length>0)
{var cookieValues=cookieValue.split('|')
for(var i=0;i<cookieValues.length;i++)
{var valueArray=cookieValues[i].split('=')
var name=valueArray[0]
var value=valueArray[1]
if(name==propertyName)
{value=propertyValue
added=true}
if(finalCookie.length>0)finalCookie+='|'
finalCookie+=name+'='+value}}
if(!added)
{if(finalCookie.length>0)finalCookie+='|'
finalCookie+=propertyName+'='+propertyValue}
var now=new Date()
Ext.util.Cookies.set(cookieName,finalCookie,new Date(now.getFullYear()+1,now.getMonth(),now.getDay()));}
mdc.setFocus=function(fieldIdOrFormName,fieldName)
{if(fieldName)
{mdc.addOnLoad('document.'+fieldIdOrFormName+'.'+fieldName+'.focus()')}
else if(fieldIdOrFormName)
{mdc.addOnLoad('Ext.fly( "'+fieldIdOrFormName+'" ).focus()')}}
mdc.showErrors=function(errors,destId)
{if(errors&&errors.length>0)
{if(errors.length==1)
{Ext.fly(destId).update(errors[0])}
else
{var output='<ul>'
for(var i=0;i<errors.length;i++)
{output+='<li>'+errors[i]+'</li>'}
output+='</ul>'
Ext.fly(destId).update(output)}
Ext.fly(destId).removeCls('mdcHidden')}
else
{Ext.fly(destId).addCls('mdcHidden')}}
mdc.submit=function(id)
{Ext.fly(id).dom.submit()
return false}
mdc.toggleCls=function(itemId,itemClass)
{Ext.fly(itemId).toggleCls(itemClass)
return false}
mdc.xhrPost=function(xhrPostArgs)
{if(!('timeout'in xhrPostArgs))xhrPostArgs.timeout=600000
if(!('disableCaching'in xhrPostArgs))xhrPostArgs.disableCaching=true
if(!('handleAs'in xhrPostArgs))xhrPostArgs.handleAs='text'
xhrPostArgs.method='POST'
if(xhrPostArgs.content)
{xhrPostArgs.params=xhrPostArgs.content}
var thisPlace=xhrPostArgs
xhrPostArgs.success=function(response,options)
{var responseValue
if(thisPlace.handleAs=='json')
responseValue=Ext.JSON.decode(response.responseText,true)
else
responseValue=response.responseText
thisPlace.load(responseValue)}
xhrPostArgs.failure=function(response,options)
{thisPlace.error()}
return Ext.Ajax.request(xhrPostArgs)}
mdc.xhrPostHTML=function(xhrPostArgs)
{xhrPostArgs.handleAs='text'
return mdc.xhrPost(xhrPostArgs)}
mdc.xhrPostJSON=function(xhrPostArgs)
{xhrPostArgs.handleAs='json'
return mdc.xhrPost(xhrPostArgs)}
mdc.xhrGet=function(xhrGetArgs)
{if(!('timeout'in xhrGetArgs))xhrGetArgs.timeout=600000
if(!('disableCaching'in xhrGetArgs))xhrGetArgs.disableCaching=true
if(!('handleAs'in xhrGetArgs))xhrGetArgs.handleAs='text'
xhrGetArgs.isRequestAborted='false'
xhrGetArgs.method='GET'
if(xhrGetArgs.content)
{xhrGetArgs.params=xhrGetArgs.content}
var thisPlace=xhrGetArgs
xhrGetArgs.success=function(response,options)
{var responseValue
if(thisPlace.handleAs=='json')
responseValue=Ext.JSON.decode(response.responseText,true)
else
responseValue=response.responseText
thisPlace.load(responseValue)}
xhrGetArgs.failure=function(response,options)
{if(xhrGetArgs.isRequestAborted=='false')
{thisPlace.error()}
else
{thisPlace.abort()}}
return Ext.Ajax.request(xhrGetArgs)}
mdc.xhrGetHTML=function(xhrGetArgs)
{xhrGetArgs.handleAs='text'
return mdc.xhrGet(xhrGetArgs)}
mdc.xhrGetJSON=function(xhrGetArgs)
{xhrGetArgs.handleAs='json'
return mdc.xhrGet(xhrGetArgs)}
mdc.xblur=function(obj)
{if(obj.blur)obj.blur()}
mdc.print=function(obj)
{window.print()
return false}
mdc.pages.changePassword.validate=function(form)
{var errors=new Array()
var focusOn
if(form.oldpassword.value.length<1)
{errors[errors.length]=_mdc.ENTER_OLD_PASSWORD
focusOn='oldpassword'}
if(form.password.value.length<1)
{errors[errors.length]=_mdc.ENTER_NEW_PASSWORD
if(errors.length<1)
{focusOn='password'}}
if(form.confirmpassword.value.length<1)
{errors[errors.length]=_mdc.CONFIRM_PASSWORD
if(errors.length<1)
{focusOn='confirmpassword'}}
if(form.password.value!=form.confirmpassword.value)
{errors[errors.length]=_mdc.PASSWORD_MISMATCH
if(errors.length<1)
{focusOn='confirmpassword'}}
if(errors.length>0)
{mdc.showErrors(errors,'changePasswordErrorBox')
mdc.setFocus('changePasswordForm',focusOn)
Ext.fly('changePasswordErrorBox').addCls('medError')
return false}
Ext.fly('changePasswordErrorBox').addCls('mdcHidden')
return true}
mdc.pages.resetPassword.validate=function(form)
{var errors=new Array()
var focusOn
if(form.password.value.length<1)
{errors[errors.length]=_mdc.ENTER_NEW_PASSWORD
focusOn='password'}
if(form.confirmpassword.value.length<1)
{errors[errors.length]=_mdc.CONFIRM_PASSWORD
if(!focusOn)
{focusOn='confirmpassword'}}
if(form.password.value!=form.confirmpassword.value)
{errors[errors.length]=_mdc.PASSWORD_MISMATCH
if(!focusOn)
{focusOn='confirmpassword'}}
if(errors.length>0)
{mdc.showErrors(errors,'resetPasswordErrorBox')
mdc.setFocus('resetPasswordForm',focusOn)
Ext.fly('resetPasswordErrorBox').addCls('medError')
return false}
Ext.fly('resetPasswordErrorBox').addCls('mdcHidden')
return true}
mdc.pages.forgotPassword.validate=function(form)
{var errors=new Array()
if(form.email.value.length<1)
{errors[errors.length]=_mdc.ENTER_EMAILADDRESS}
if(errors.length>0)
{mdc.showErrors(errors,'forgotPasswordErrorBox')
mdc.setFocus('forgotPasswordForm','email')
Ext.fly('forgotPasswordErrorBox').addCls('medError')
return false}
Ext.fly('forgotPasswordErrorBox').addCls('mdcHidden')
return true}
mdc.pages.login.validate=function(form)
{var errors=new Array()
if(form.login.value.length<1)
{errors[errors.length]=_mdc.ENTER_EMAILADDRESS_AND_PASSWORD}
else if(form.password.value.length<1)
{errors[errors.length]=_mdc.ENTER_PASSWORD}
if(errors.length>0)
{mdc.showErrors(errors,'loginErrorBox')
mdc.setFocus('loginForm','login')
Ext.fly('loginErrorBox').addCls('medError')
return false}
Ext.fly('loginErrorBox').addCls('mdcHidden')
return true}
mdc.pages.login_conversion.validate=function(form)
{var errors=new Array()
if(form.newLogin.value.length<1)
{errors[errors.length]=_mdc.ENTER_EMAILADDRESS_AND_PASSWORD}
else if(form.password.value.length<1)
{errors[errors.length]=_mdc.ENTER_PASSWORD}
if(errors.length>0)
{mdc.showErrors(errors,'loginErrorBox')
mdc.setFocus('loginForm','newLogin')
Ext.fly('loginErrorBox').addCls('medError')
return false}
Ext.fly('loginErrorBox').addCls('mdcHidden')
return true}
mdc.pages.mediaroom.changeSpotlightArticlePreview=function(current,total,imageURL)
{for(i=1;i<=total;i++)
{if(i==current)
{Ext.fly('article_'+i).setStyle('display','');Ext.fly('picker_'+i).addCls('medNcArticleCurrent');}
else
{Ext.fly('article_'+i).setStyle('display','none');Ext.fly('picker_'+i).removeCls('medNcArticleCurrent');}}
mdc.getWidget('cropperMainImage').load(imageURL)}
mdc.pages.systemMessages.closeCriticalSystemMessage=function()
{mdc.pages.systemMessages.registerClosedSysMsgIdInSession()
Ext.fly('medMsgHeaderBackground').setStyle('display','none');return false}
mdc.pages.systemMessages.closeEmergencySystemMessage=function()
{mdc.pages.systemMessages.registerClosedSysMsgIdInSession()
mdc.getWidget('sysMsgDialog').hide()
return false}
mdc.pages.systemMessages.registerClosedSysMsgIdInSession=function()
{mdc.xhrGetHTML({url:mdc.getContextPath()+"/system-messages/ajax/register-closed-system-messages.jsp",content:{"closedSysMsgID":Ext.getDom('closedSysMsgID').value},load:function(data)
{},error:function(error)
{alert(_mdc.ERROR+":"+error)}})}
mdc.pages.ordersearch.showHideDateFields=function(dateRangeSelector)
{if(dateRangeSelector.options[dateRangeSelector.selectedIndex].value=='SelectDateRange')
{Ext.fly('dateRangeTR').setStyle('display','')}
else
{Ext.fly('dateRangeTR').setStyle('display','none')
Ext.getDom('dateTo').value=''
Ext.getDom('dateFrom').value=''
document.getElementsByName('dateFrom')[0].value=''
document.getElementsByName('dateTo')[0].value=''}}
mdc.pages.ordersearch.showHideSearchOption=function(showHideFlag)
{if(mdc.isTrue(showHideFlag))
{if(Ext.fly('moreSearchOptionRow1'))Ext.fly('moreSearchOptionRow1').setStyle('display','')
if(Ext.fly('moreSearchOptionRow2'))Ext.fly('moreSearchOptionRow2').setStyle('display','')
if(Ext.fly('moreSearchLnk'))Ext.fly('moreSearchLnk').setStyle('display','none')
if(Ext.fly('lessSearchLnk'))Ext.fly('lessSearchLnk').setStyle('display','')}
else if(mdc.isFalse(showHideFlag))
{if(Ext.fly('moreSearchOptionRow1'))Ext.fly('moreSearchOptionRow1').setStyle('display','none')
if(Ext.fly('moreSearchOptionRow2'))Ext.fly('moreSearchOptionRow2').setStyle('display','none')
if(Ext.fly('moreSearchLnk'))Ext.fly('moreSearchLnk').setStyle('display','')
if(Ext.fly('lessSearchLnk'))Ext.fly('lessSearchLnk').setStyle('display','none')}
else
{alert('passed argument is neither true nor false')}
return false}
mdc.pages.ordersearch.expandCollapseLineItem=function(collapseFlag)
{if(collapseFlag)
{Ext.fly('expandLineItemLink').setStyle('display','')
Ext.fly('collapseLineItemLink').setStyle('display','none')}
else
{Ext.fly('expandLineItemLink').setStyle('display','none')
Ext.fly('collapseLineItemLink').setStyle('display','')}
Ext.get('searchResultTable').select('tr').each(function(item,arr,idx)
{if((item.id!='searchResultTableHeader')&&(!item.hasCls('medOdd')))
{if(collapseFlag)
{item.setStyle('display','none')}
else
{item.setStyle('display','')}}})
return false}
mdc.pages.ordersearch.showHideSearchInputs=function()
{Ext.select('input[name=orderType]').each(function(item,arr,idx)
{if(item.id=='orderTypeOrders')
{var disabled=(item.dom.checked?false:true)
if(Ext.fly('orderState'))Ext.fly('orderState').dom.disabled=disabled
if(Ext.fly('clinicianName'))Ext.fly('clinicianName').dom.disabled=disabled
if(Ext.fly('patientName'))Ext.fly('patientName').dom.disabled=disabled
if(Ext.fly('orderChannel'))Ext.fly('orderChannel').dom.disabled=disabled}
else if(item.id=='orderTypeReturns')
{var disabled=(item.dom.checked?false:true)
if(Ext.fly('returnStatus'))Ext.fly('returnStatus').dom.disabled=disabled}})}
mdc.pages.ordersearch.validateSearchRequest=function()
{Ext.getDom('dateFrom').value=Ext.getDom('dateFromHidden').value
Ext.getDom('dateTo').value=Ext.getDom('dateToHidden').value
document.getElementsByName('dateFrom')[0].value=Ext.getDom('dateFromHidden').value
document.getElementsByName('dateTo')[0].value=Ext.getDom('dateToHidden').value
mdc.pages.ordersearch.showHideSearchInputs()
var dateSelector=Ext.getDom('dateSelector')
if(dateSelector.options[dateSelector.selectedIndex].value=='SelectDateRange'){Ext.fly('dateRangeTR').setStyle('display','')}}
mdc.pages.productoverview.resetProductStylesListView=function(totalcount,isProductAlternatePage)
{for(i=1;i<=totalcount;i++)
{if(!(isProductAlternatePage&&i==1))
{if(Ext.getDom('ShadowWrap1_'+i)!=undefined)
{Ext.fly("ShadowWrap1_"+i).removeCls('ShadowWrap1')
Ext.fly("ShadowWrap2_"+i).removeCls('ShadowWrap2')
Ext.fly("ShadowWrap3List_"+i).removeCls('ShadowWrap3List')}}
if(Ext.getDom('shown_'+i)!=undefined)
{Ext.fly('shown_'+i).setStyle('display','none')
Ext.fly('hidden_'+i).setStyle('display','')
Ext.fly('skuDivision_'+i).setStyle('display','none')}}
return true}
mdc.pages.productoverview.expandCollapseSkuDivisionListView=function(repositoryId,count,collapseFlag,hasViewItemAvailabilityPriv,hasViewItemPricePriv,isProductAlternatePage,searchClickId,srchMaterialIds)
{var totalcount=parseInt(Ext.getDom("totalcount").value);mdc.pages.productoverview.resetProductStylesListView(totalcount,isProductAlternatePage)
if(!collapseFlag)
{if(!(isProductAlternatePage&&count==1))
{Ext.fly("ShadowWrap1_"+count).addCls('ShadowWrap1')
Ext.fly("ShadowWrap2_"+count).addCls('ShadowWrap2')
Ext.fly("ShadowWrap3List_"+count).addCls('ShadowWrap3List')}
Ext.fly('shown_'+count).setStyle('display','')
Ext.fly('hidden_'+count).setStyle('display','none')
Ext.fly('skuDivision_'+count).setStyle('display','')
mdc.pages.productoverview.getProductSkus(repositoryId,'skuDivision_'+count,'medGridViewSkuList',hasViewItemPricePriv,hasViewItemAvailabilityPriv,count,searchClickId,srchMaterialIds)}
return false}
mdc.pages.productoverview.getProductSkusData={}
mdc.pages.productoverview.getProductSkus=function(productId,destId,skuTableClass,hasViewItemPricePriv,hasViewItemAvailabilityPriv,count,searchClickId,srchMaterialIds)
{var loaded=mdc.pages.productoverview.getProductSkusData[productId]
if(Ext.String.trim(productId).length>0&&!loaded)
{var mask=Ext.get(destId+'_mask')
if(mask)
{mask.mask('Loading...')
mask.positionMaskMessage()}
mdc.xhrGetHTML({url:mdc.getContextPath()+"/catalog/ajax/sku-accordion.jsp",content:{'itemId':productId,'skuTableClass':skuTableClass,'count':count,'searchClickId':searchClickId,'srchMaterialIds':srchMaterialIds},load:function(data)
{mdc.pages.productoverview.getProductSkusData[productId]=true
if(data!=null)
{Ext.fly(destId).update(data)
med.WidgetManager.parse()
mdc.pages.productoverview.getProductSkusData(productId,hasViewItemPricePriv,hasViewItemAvailabilityPriv,count)}
else
{Ext.fly(destId).update('<div class="wipSkuDivisionLookupError">'+_mdc.pages.productoverview.ERROR_RETRIEVING_SKU_DATA+'</div>')}
if(mask)mask.unmask()},error:function(error)
{Ext.fly(destId).update('<div class="wipSkuDivisionLookupError">'+_mdc.pages.productoverview.ERROR_RETRIEVING_SKU_DATA+'</div>')
if(mask)mask.unmask()}})}}
mdc.pages.productoverview.getProductSkusData=function(productId,hasViewItemPricePriv,hasViewItemAvailabilityPriv,count)
{if(hasViewItemPricePriv||hasViewItemAvailabilityPriv)
{var skuCount=Ext.getDom('product_sku_container_'+productId+'_skucount').value
if(hasViewItemPricePriv)
{mdc.pages.productoverview.getCustomerPricing(count,skuCount)}
if(hasViewItemAvailabilityPriv)
{mdc.pages.productoverview.getAvailabilityMessages(count,skuCount)}}}
mdc.pages.productoverview.skuDivisionTracker=0
mdc.pages.productoverview.resetProductStylesGridView=function(count,totalcount,currentRow,totalRows,gridViewRowSize)
{var skuDivisionTracker=mdc.pages.productoverview.skuDivisionTracker;if(skuDivisionTracker!=0)
{Ext.fly('skuDivision_temp_'+skuDivisionTracker).update('');Ext.getDom('skuDivision_temp_'+skuDivisionTracker).appendChild(Ext.getDom('skuDivision_'+skuDivisionTracker));mdc.pages.productoverview.skuDivisionTracker=0;}
for(j=1;j<=totalRows;j++)
{Ext.fly('skuDivisionPlaceHolder_Full_'+j).setStyle('display','none')
Ext.fly('skuDivisionPlaceHolder_Empty_'+j).setStyle('display','')
Ext.fly('skuDivisionValueHolder_'+j).update('')}
var actualSize=totalcount
if(totalcount%gridViewRowSize!=0)
{actualSize=totalcount+(gridViewRowSize-(totalcount%gridViewRowSize))}
for(i=1;i<=actualSize;i++)
{if(Ext.getDom('shown_'+i)!=undefined)
{Ext.fly('shown_'+i).setStyle('display','none')
Ext.fly('hidden_'+i).setStyle('display','')}
Ext.fly("grid_"+i).removeCls('medGridSelected')
Ext.fly("grid_"+i).removeCls('medGridSelectedRight')
Ext.fly("grid_"+i).removeCls('medGridNext')}}
mdc.pages.productoverview.expandCollapseSkuDivisionGridView=function(repositoryId,count,currentRow,gridViewRowSize,totalRows,collapseFlag,hasViewItemAvailabilityPriv,hasViewItemPricePriv,searchClickId,srchMaterialIds)
{var totalcount=parseInt(Ext.getDom("totalcount").value);mdc.pages.productoverview.resetProductStylesGridView(count,totalcount,currentRow,totalRows,gridViewRowSize)
if(!collapseFlag)
{Ext.fly('shown_'+count).setStyle('display','')
Ext.fly('hidden_'+count).setStyle('display','none')
Ext.fly('skuDivisionPlaceHolder_Full_'+currentRow).setStyle('display','')
Ext.fly('skuDivisionPlaceHolder_Empty_'+currentRow).setStyle('display','none')
Ext.getDom('skuDivisionValueHolder_'+currentRow).appendChild(Ext.getDom('skuDivision_'+count));mdc.pages.productoverview.skuDivisionTracker=count;if(count%gridViewRowSize==0)
{Ext.fly("grid_"+count).addCls('medGridSelectedRight')}
else
{Ext.fly("grid_"+count).addCls('medGridSelected')}
mdc.pages.productoverview.setSupportingStylesGridView(count,gridViewRowSize)
mdc.pages.productoverview.getProductSkus(repositoryId,'skuDivision_'+count,'medGridViewSkuList',hasViewItemPricePriv,hasViewItemAvailabilityPriv,count,searchClickId,srchMaterialIds)}
return false}
mdc.pages.productoverview.setSupportingStylesGridView=function(count,gridViewRowSize)
{var start=0
var end=0
if(count%gridViewRowSize==0)
{start=count-gridViewRowSize+1}
else
{start=count-(count%gridViewRowSize)+1}
end=start+gridViewRowSize-1
for(i=start;i<=end;i++)
{if(i!=count)
{Ext.fly("grid_"+i).removeCls('medGridSelected')
Ext.fly("grid_"+i).removeCls('medGridSelectedRight')
Ext.fly("grid_"+i).addCls('medGridNext')}}}
mdc.pages.productoverview.expandCollapseFacetDivision=function(itemId,collapseFlag)
{if(collapseFlag)
{Ext.fly('shown_'+itemId).setStyle('display','')
Ext.fly('hidden_'+itemId).setStyle('display','none')}
else
{Ext.fly('shown_'+itemId).setStyle('display','none')
Ext.fly('hidden_'+itemId).setStyle('display','')}
return false}
mdc.pages.productlisttoolbox.toggleGridOrListView=function(gridViewFlag)
{if(gridViewFlag)
{Ext.fly('gridViewLink').replaceCls('BtnGrid','BtnGridActive')
Ext.fly('listViewLink').replaceCls('BtnListActive','BtnList')
Ext.getDom('listView').value='false'}
else
{Ext.fly('gridViewLink').replaceCls('BtnGridActive','BtnGrid')
Ext.fly('listViewLink').replaceCls('BtnList','BtnListActive')
Ext.getDom('listView').value='true'}
mdc.setCookieProperty("CatalogUserSettings",'listView',Ext.getDom('listView').value)
mdc.submit('searchResultsForm')
return false}
mdc.pages.productlisttoolbox.changePageSize=function()
{Ext.getDom('pageSize').value=Ext.getDom('itemsPerPage').value
Ext.getDom('goToPage').value='1'
mdc.setCookieProperty("CatalogUserSettings",'pageSize',Ext.getDom('pageSize').value)
mdc.submit('searchResultsForm')
return false}
mdc.pages.productlisttoolbox.gotoPage=function(pageNumber)
{Ext.getDom('goToPage').value=pageNumber
mdc.submit('searchResultsForm')
return false}
mdc.pages.productlisttoolbox.sort=function()
{var val=parseInt(Ext.getDom('sortBy').value)
if(val==-1)
{Ext.getDom('sortProp').value=''
Ext.getDom('sortOrder').value=''}
else
{if(val==1)
{Ext.getDom('sortProp').value='displayName'
Ext.getDom('sortOrder').value='ascending'}
if(val==2)
{Ext.getDom('sortProp').value='displayName'
Ext.getDom('sortOrder').value='descending'}
if(val==3)
{Ext.getDom('sortProp').value='childSKUsFilteredExceptFormularyAndContract.skuDetails.manufacturer'
Ext.getDom('sortOrder').value='ascending'}
if(val==4)
{Ext.getDom('sortProp').value='childSKUsFilteredExceptFormularyAndContract.skuDetails.manufacturer'
Ext.getDom('sortOrder').value='descending'}}
Ext.getDom('goToPage').value='1'
mdc.setCookieProperty("CatalogUserSettings",'sortProp',Ext.getDom('sortProp').value)
mdc.setCookieProperty("CatalogUserSettings",'sortOrder',Ext.getDom('sortOrder').value)
mdc.submit('searchResultsForm')
return true}
mdc.pages.productlisttoolbox.viewFormContItems=function(viewType,viewFlag)
{var formFlag,contFlag,viewOnId,viewOffId
if(viewType=='form')
{viewOnId='formulary_on'
viewOffId='formulary_off'
formFlag=viewFlag
contFlag=null}
else if(viewType=='cont')
{viewOnId='contract_on'
viewOffId='contract_off'
contFlag=viewFlag
formFlag=null;}
if(viewFlag)
{Ext.fly(viewOnId).setStyle('display','')
Ext.fly(viewOffId).setStyle('display','none')}
else
{Ext.fly(viewOffId).setStyle('display','')
Ext.fly(viewOnId).setStyle('display','none')}
Ext.Ajax.request({url:mdc.getContextPath()+'/search/ajax/update-viewIdFilter.jsp',method:'GET',params:{formFilter:formFlag,contFilter:contFlag},success:function(response,options)
{var pageNumberObj=Ext.getDom('goToPage')
pageNumberObj.value=1
mdc.submit('searchResultsForm')},failure:function(response,options)
{}})
return false}
mdc.pages.searchbox.watermark=''
mdc.pages.searchbox.addSearchTypeHandlers=function()
{Ext.fly('search-popup').addListener('keypress',mdc.pages.searchbox.searchTypeHandlerKeypress)
Ext.fly('searchTypeCatalogRadio').addListener('keypress',mdc.pages.searchbox.searchTypeHandlerKeypress)
Ext.fly('searchTypeCatalogRadioText').addListener('keypress',mdc.pages.searchbox.searchTypeHandlerKeypress)
Ext.fly('searchTypeSiteRadio').addListener('keypress',mdc.pages.searchbox.searchTypeHandlerKeypress)
Ext.fly('searchTypeSiteRadioText').addListener('keypress',mdc.pages.searchbox.searchTypeHandlerKeypress)}
mdc.pages.searchbox.searchTypeHandlerKeypress=function(e)
{if(e.getKey()==Ext.EventObject.ENTER)
{e.stopEvent()
if(mdc.pages.searchbox.validate())
{Ext.getDom('searchForm').submit()}}}
mdc.pages.searchbox.setWatermark=function(watermark)
{mdc.pages.searchbox.watermark=watermark}
mdc.pages.searchbox.validate=function()
{mdc.search.typeAhead.abortActiveRequest()
var obj=document.getElementById('searchQuestion')
if(obj.value==mdc.pages.searchbox.watermark||Ext.String.trim(obj.value).length==0)
{return false}
return true}
mdc.pages.searchbox.onBlurTask=null
mdc.pages.searchbox.onFocus=function(question)
{if(mdc.pages.searchbox.onBlurTask)clearTimeout(mdc.pages.searchbox.onBlurTask)
if(question.value==mdc.pages.searchbox.watermark)
{question.value=''}}
mdc.pages.searchbox.onBlur=function()
{mdc.pages.searchbox.onBlurTask=setTimeout(mdc.pages.searchbox.onBlurAction,150)}
mdc.pages.searchbox.onBlurAction=function()
{mdc.pages.searchbox.onBlurTask=null
var searchbox=Ext.getDom('searchQuestion')
if(searchbox.value=='')
{searchbox.value=mdc.pages.searchbox.watermark}}
mdc.pages.searchbox.selectSearchType=function(searchType)
{if(searchType=='catalog')
{Ext.getDom('searchTypeCatalogRadio').src='/media/appresources/images/radioButtonChecked.png'
Ext.getDom('searchTypeSiteRadio').src='/media/appresources/images/radioButtonUnchecked.png'
Ext.getDom('searchForm').action=mdc.getContextPath()+'/search/search.jsp'
Ext.get('type-ahead-results-wrapper').removeCls('x-hide-display')
mdc.search.typeAhead.submit()}
else
{Ext.getDom('searchTypeSiteRadio').src='/media/appresources/images/radioButtonChecked.png'
Ext.getDom('searchTypeCatalogRadio').src='/media/appresources/images/radioButtonUnchecked.png'
Ext.getDom('searchForm').action=mdc.getContextPath()+'/search/site-search.jsp'
Ext.get('type-ahead-results-wrapper').addCls('x-hide-display')}
mdc.getWidget('searchQuestion').resize()
mdc.setFocus('searchQuestion')
return false}
mdc.pages.ordersearch.handleGroupBy=function(groupByValue)
{document.getElementsByName('dateFrom')[0].value=Ext.getDom('dateFromHidden').value
document.getElementsByName('dateTo')[0].value=Ext.getDom('dateToHidden').value
mdc.click('groupByButton')}
mdc.pages.productdetail.productColorData={window:null,colorCode:null,color:null,colorImageURL:null}
mdc.pages.productdetail.sizeChartData={window:null,chart:null}
mdc.pages.productdetail.activateTab=function(currentTab,totalTabs)
{for(i=1;i<=totalTabs;i++)
{if(i==currentTab)
{Ext.fly("tab"+i).replaceCls('medInactiveTab','medActiveTab')
Ext.fly('tabView'+i).setStyle('display','')}
else
{Ext.fly("tab"+i).replaceCls('medActiveTab','medInactiveTab')
Ext.fly('tabView'+i).setStyle('display','none')}}
return false}
mdc.pages.productdetail.activateTabAjax=function(currentTab,totalTabs,productId,tabId,contentId,loadingMessage)
{mdc.pages.productdetail.activateTab(currentTab,totalTabs)
if(Ext.getDom(contentId).dataLoaded)return false
var loading=Ext.create('med.Loading',{id:Ext.id(),maskId:contentId,showOnClick:false,autoShow:true,msg:loadingMessage})
Ext.Ajax.request({url:mdc.getContextPath()+"/catalog/ajax/product-detail-tab.jsp",method:'GET',params:{productId:productId,tabId:tabId},success:function(response,options)
{Ext.getDom(contentId).dataLoaded=true
Ext.fly(contentId).update(response.responseText)
loading.hide()},failure:function(response,options)
{Ext.fly(contentId).update('Error loading data.')}})
return false}
mdc.pages.productdetail.confirmSelectProductColor=function()
{var data=mdc.pages.productdetail.productColorData
return mdc.pages.productdetail.selectProductColor(data.colorCode,data.color,data.colorImageURL,true)}
mdc.pages.productdetail.selectProductColor=function(colorCode,color,colorImageURL,confirmed)
{var rowClassPrefix='skuRowColorCode_'
var anchorClassPrefix='swatchAnchorColorCode_'
var data=mdc.pages.productdetail.productColorData
if(confirmed)
{Ext.getBody().select('tr[class^='+rowClassPrefix+'] .skuRowInputCheck').each(function(item,arr,idx)
{item.dom.value=''})
data.window.hide()}
else
{var enteredValues=0
Ext.getBody().select('tr[class^='+rowClassPrefix+'] .skuRowInputCheck').each(function(item,arr,idx)
{if(!item.hasCls(rowClassPrefix+colorCode))
{var value=item.dom.value
if(value&&Ext.isString(value)&&Ext.String.trim(value).length>0)
{enteredValues++}}})
if(enteredValues>0)
{if(!data.window)
{var windowId=Ext.id()
var windowDiv=Ext.core.DomHelper.append(Ext.getBody(),{tag:'div','class':'x-hide-display',id:windowId},true)
var text=_mdc.pages.productdetail
var s=''
s+='<div class="medAddtoOrderDiv">'
s+=' <div class="medAddtoOrderMsg">'
s+='  <h2>'+text.CONFIRM_COLOR_SWITCH_HEADER+':</h2>'
s+='  <p>'+text.CONFIRM_COLOR_SWITCH_BODY+'</p>'
s+='  <div style="float:left;"><a href="#" class="medSecondaryButton" onclick="return mdc.pages.productdetail.confirmSelectProductColor()"><span>'+text.CONFIRM_COLOR_SWITCH+'</span></a></div>'
s+='  <div style="float:right;"><a href="#" class="medSecondaryButton" onclick="mdc.pages.productdetail.productColorData.window.hide(); return false"><span>'+text.CONFIRM_COLOR_NO_SWITCH+'</span></a></div>'
s+='  <div class="medClear"></div>'
s+=' </div>'
s+='</div>'
windowDiv.update(s)
data.window=Ext.create('med.Window',{id:windowId,modal:true})}
data.colorCode=colorCode
data.color=color
data.colorImageURL=colorImageURL
data.window.show()
return false}}
Ext.fly('medOrderingInfoContent').removeCls('x-hide-display')
Ext.fly('medOrderingInfoColorMessage').addCls('x-hide-display')
Ext.get('medColorArea').select('a[class^='+anchorClassPrefix+']').each(function(item,arr,idx)
{if(item.hasCls(anchorClassPrefix+colorCode))
item.addCls('selected')
else
item.removeCls('selected')})
Ext.getBody().select('tr[class^='+rowClassPrefix+']').each(function(item,arr,idx)
{if(item.hasCls(rowClassPrefix+colorCode))
item.removeCls('x-hide-display')
else
item.addCls('x-hide-display')})
var productViewer=mdc.getWidget('productImageViewer')
if(productViewer)productViewer.setSelectedImage(colorImageURL,colorImageURL,colorImageURL)
var productColorSelected=Ext.get('productColorSelected')
if(productColorSelected)
{if(color)
{productColorSelected.removeCls('x-hide-display')
productColorSelected.update('('+color+' selected)')}
else
{productColorSelected.addCls('x-hide-display')}}
return false}
mdc.pages.productdetail.showSizeChart=function(url)
{var data=mdc.pages.productdetail.sizeChartData
if(data.window)
{data.window.show()}
else
{data.chart=new Image()
Ext.fly(data.chart).on('load',function(){mdc.pages.productdetail.showSizeChartCreateWindow(url)})
data.chart.src=url}
return false}
mdc.pages.productdetail.showSizeChartCreateWindow=function(url)
{var data=mdc.pages.productdetail.sizeChartData
if(!data.window)
{var windowId=Ext.id()
var windowDiv=Ext.core.DomHelper.append(Ext.getBody(),{tag:'div','class':'x-hide-display',id:windowId},true)
var text=_mdc.pages.productdetail
var s=''
s+='<div class="medSizeChartDiv">'
s+=' <p><img src="'+url+'" width="'+data.chart.width+'" height="'+data.chart.height+'"></p>'
s+=' <div style="float:right;"><a href="#" class="medSecondaryButton" onclick="mdc.pages.productdetail.sizeChartData.window.hide(); return false"><span>'+text.CLOSE_SIZE_CHART+'</span></a></div>'
s+=' <div class="medClear"></div>'
s+='</div>'
windowDiv.update(s)
data.window=Ext.create('med.Window',{id:windowId,modal:true})}
data.window.show()
return false}
mdc.pages.productoverview.getCustomerPricing=function(count)
{var materialToIndexArray=mdc.pages.productoverview.getSkuMaterialNumbersIndexArray(count)
var skuCount=mdc.associativeArraySize(materialToIndexArray)
for(cnt=1;cnt<=skuCount;cnt++)
{if(Ext.util.Format.trim(mdc.getDomCached("skuDivision_"+count+"_price_"+cnt).innerHTML)!='')
{return false;}}
mdc.getCached("skuDivision_"+count+"_price_1").replaceCls('medGridSkuPrice','medAvailability')
var skuMaterialNumbers=mdc.associativeArrayKeysToCommaDelimitedList(materialToIndexArray)
for(cnt=1;cnt<=skuCount;cnt++)
{mdc.getCached("skuDivision_"+count+"_contractItem_"+cnt).update('')}
mdc.xhrPostJSON({url:mdc.getContextPath()+"/catalog/ajax/product-pricing.jsp",content:{"productNumbers":skuMaterialNumbers},load:function(data)
{mdc.getCached("skuDivision_"+count+"_price_1").replaceCls('medAvailability','medGridSkuPrice')
if(data!=null)
{for(i=0;i<data.length;i++)
{var price=data[i].price
if(price!=null)
{var productNumber=data[i].productNumber
var currency=data[i].currency
var contractItem=data[i].contractItem
{if(productNumber in materialToIndexArray)
{var cnt=materialToIndexArray[productNumber]
var priceCurr=price
if(currency!=null)
{if(currency=='$')
priceCurr=currency+price
else
priceCurr=currency+" "+price}
mdc.getCached("skuDivision_"+count+"_price_"+cnt).update(priceCurr)
if(contractItem=='Yes')
{mdc.getCached("skuDivision_"+count+"_price_"+cnt).replaceCls('medGridSkuPrice','medGridSkuPriceBold');var onContractIndicator='<img src="/media/appresources/css/images/check-icon.png" alt="" width="18" height="19" />';mdc.getCached("skuDivision_"+count+"_contractItem_"+cnt).update(onContractIndicator)}}}}}}},error:function(error)
{alert(_mdc.PRICING_ERROR)
mdc.getCached("skuDivision_"+count+"_price_1").replaceCls('medAvailability','medGridSkuPrice')}})}
mdc.pages.productoverview.getAvailabilityMessages=function(count)
{var materialToIndexArray=mdc.pages.productoverview.getSkuMaterialNumbersIndexArray(count)
var skuCount=mdc.associativeArraySize(materialToIndexArray)
for(cnt=1;cnt<=skuCount;cnt++)
{if(Ext.util.Format.trim(mdc.getDomCached("skuDivision_"+count+"_availability_link_"+cnt).innerHTML)!='')
{return false;}}
mdc.getCached("skuDivision_"+count+"_availability_1").addCls('medAvailability')
var skuMaterialNumbers=mdc.associativeArrayKeysToCommaDelimitedList(materialToIndexArray)
mdc.xhrPostJSON({url:mdc.getContextPath()+"/catalog/ajax/product-availability-messages.jsp",content:{"productNumbers":skuMaterialNumbers},load:function(data)
{mdc.getCached("skuDivision_"+count+"_availability_1").removeCls('medAvailability')
if(data!=null)
{for(i=0;i<data.length;i++)
{var productNumber=data[i].productNumber
{if(productNumber in materialToIndexArray)
{var cnt=materialToIndexArray[productNumber]
var availabilityMessage=data[i].shortAvailabilityMessage;if(availabilityMessage!=null)
{var stockOverviewDiv='';stockOverviewDiv+="<div class='medAvailabilityMsg'>";stockOverviewDiv+="<h2>Availability Details</h2>";stockOverviewDiv+="<p>"+data[i].longAvailabilityMessage+"</p>";stockOverviewDiv+="<div id='skuDivision_"+count+"_stockInfo_"+cnt+"'></div>";stockOverviewDiv+="</div>";mdc.getCached("skuDivision_"+count+"_availability_popup_"+cnt).update(stockOverviewDiv);availabilityMessage='<a href="#" onclick="return mdc.pages.productoverview.getStockAvailabilityDetails('+count+','+cnt+')">'+availabilityMessage+'</a>';mdc.getCached("skuDivision_"+count+"_availability_link_"+cnt).update(availabilityMessage);}}}}}},error:function(error)
{alert(_mdc.AVAILABILITY_ERROR)
mdc.getCached("skuDivision_"+count+"_availability_1").removeCls('medAvailability')}})}
mdc.pages.productoverview.getSkuMaterialNumbersIndexArray=function(count)
{var materialToIndexArray=new Array()
for(var i=1;true;i++)
{var skuMaterialNumberContainer=mdc.getDomCached("skuDivision_"+count+"_materialNum_"+i)
if(skuMaterialNumberContainer)
{var skuMaterialNumber=skuMaterialNumberContainer.innerHTML
materialToIndexArray[skuMaterialNumber]=i}
else
{break;}}
return materialToIndexArray}
var activeStockAvailabilityAjaxRequestIds=new Array();mdc.pages.productoverview.getStockAvailabilityDetails=function(count,cnt)
{if(Ext.util.Format.trim(Ext.getDom("skuDivision_"+count+"_stockInfo_"+cnt).innerHTML)!='')
{return false;}
var loadingImg='<img src="/media/appresources/css/images/load-anim.gif" />';Ext.fly("skuDivision_"+count+"_stockInfo_"+cnt).update(loadingImg);var skuMaterialNumbers=Ext.getDom("skuDivision_"+count+"_materialNum_"+cnt).innerHTML;var counter=activeStockAvailabilityAjaxRequestIds.length;for(i=0;i<counter;i++)
{var previousRequestId=activeStockAvailabilityAjaxRequestIds.pop();if(previousRequestId!=undefined)
{previousRequestId.options.isRequestAborted='true'
Ext.Ajax.abort(previousRequestId);}}
var requestId=mdc.xhrGetJSON({url:mdc.getContextPath()+"/catalog/ajax/product-stock-availability-details.jsp",content:{"productNumbers":skuMaterialNumbers},load:function(data)
{var plantStockDiv='';if(data!=null&&data.length==1)
{var uom='';if(data[0].salesUom!=null)
{uom=' '+data[0].salesUom;}
var stockOverviews=data[0].stockOverviews;if(stockOverviews!=null&&stockOverviews.length>0)
{plantStockDiv+="<table>";plantStockDiv+="<tbody>";for(j=0;j<stockOverviews.length;j++)
{if(j==0)
{plantStockDiv+="<tr>";plantStockDiv+="<th>";plantStockDiv+=_mdc.PLANT;plantStockDiv+="</th>";plantStockDiv+="<th>";plantStockDiv+=_mdc.PLANT_LOC;plantStockDiv+="</th>";plantStockDiv+="<th>";plantStockDiv+=_mdc.PLANT_AVLBL_QTY;plantStockDiv+="</th>";plantStockDiv+="</tr>";}
plantStockDiv+="<tr>";plantStockDiv+="<td>";plantStockDiv+=stockOverviews[j].plantCode;plantStockDiv+="</td>";plantStockDiv+="<td>";plantStockDiv+=stockOverviews[j].plantLocation;plantStockDiv+="</td>";plantStockDiv+="<td>";plantStockDiv+=stockOverviews[j].plantAvailableQty+uom;plantStockDiv+="</td>";plantStockDiv+="</tr>";}
plantStockDiv+="</tbody>";plantStockDiv+="</table>";}
var disclaimers=data[0].disclaimers;if(disclaimers!=null&&disclaimers.length>0)
{for(j=0;j<disclaimers.length;j++)
{plantStockDiv+="<p>"+disclaimers[j]+"</p>";}}}
Ext.fly("skuDivision_"+count+"_stockInfo_"+cnt).update(plantStockDiv);var widget=mdc.getWidget("skuDivision_"+count+"_availability_link_"+cnt);if(widget.isVisible())
{widget.resize();}},error:function(error)
{alert(_mdc.AVAILABILITY_ERROR)
Ext.fly("skuDivision_"+count+"_stockInfo_"+cnt).update('')},abort:function()
{Ext.fly("skuDivision_"+count+"_stockInfo_"+cnt).update('')}})
activeStockAvailabilityAjaxRequestIds.push(requestId);}
Ext.onReady(function()
{Ext.create('med.Widget')
med.WidgetManager.parse()})
mdc.pages.productcomparison.updateProductComparisonList=function(productNumber,action)
{var comparedProductIDCount=parseInt(Ext.fly('comparedProductIDCount').getValue());if(action=='add'||action=='addAndView')
{if(comparedProductIDCount==3)
{alert(_mdc.PROD_COMPARISON_LIMIT_REACHED);return false;}}
var updateComparisonListAction=action;if(action=='addAndView')
{updateComparisonListAction='add';}
else if(action=='removeAndView')
{updateComparisonListAction='remove';}
mdc.xhrGetJSON({url:mdc.getContextPath()+"/catalog/ajax/update-product-comparison-list.jsp",content:{"productNumber":productNumber,"action":updateComparisonListAction},load:function(data)
{if(action=='remove')
{if(data.length==0)
{history.go(-1);}
else
{location.reload(true);}
return false;}
else if(action=='removeAndView'||action=='addAndView'||action=='view')
{Ext.getDom("comparedProductIDCount").value=data.length;mdc.pages.productoverview.refreshComparisonArea();mdc.pages.productoverview.refreshSelectToCompareLink(data);}},error:function(error)
{alert(_mdc.PROD_COMPARISON_ERROR)}})
return false;}
mdc.pages.productoverview.refreshSelectToCompareLink=function(data)
{var totalcount=Ext.getDom("totalcount").value;for(cnt=1;cnt<=totalcount;cnt++)
{if(Ext.getDom('productRepositoryId_'+cnt)!=undefined)
{var prodFound=false;if(data!=null)
{for(i=0;i<data.length;i++)
{if(data[i]==Ext.getDom('productRepositoryId_'+cnt).innerHTML)
{prodFound=true;}}}
var div1=Ext.get("compare_"+cnt+"_1");var div2=Ext.get("compare_"+cnt+"_2");var div3=Ext.get("compare_"+cnt+"_3");if(prodFound)
{var comparedProductIDCount=parseInt(Ext.fly("comparedProductIDCount").getValue());if(comparedProductIDCount>1)
{div1.setStyle('display','none');div2.setStyle('display','none');div3.setStyle('display','');}
else
{div1.setStyle('display','none');div2.setStyle('display','');div3.setStyle('display','none');}}
else
{div1.setStyle('display','');div2.setStyle('display','none');div3.setStyle('display','none');}}}}
mdc.pages.productoverview.refreshComparisonArea=function()
{mdc.xhrGetHTML({url:mdc.getContextPath()+"/catalog/ajax/view-product-comparison-list.jsp",load:function(data)
{if(data!=null)
{Ext.fly('comparisonArea').update(data);}
else
{Ext.fly('comparisonArea').update('');}},error:function(error)
{alert(_mdc.PROD_COMPARISON_ERROR)}})
return false;}
mdc.pages.productalternates.retrieveProductAlternates=function(itemId,scenario)
{mdc.xhrGetHTML({url:mdc.getContextPath()+"/catalog/ajax/product-alternate-details.jsp",content:{"itemId":itemId,"scenario":scenario},load:function(data)
{if(data!=null)
{Ext.fly('showAlternates').update(data);med.WidgetManager.parse()
var totalcount=parseInt(Ext.getDom('totalcount').value);var totalAlternatesCount=parseInt(Ext.getDom('totalAlternatesCount').value);Ext.getDom('totalcount').value=totalcount+totalAlternatesCount;}
mdc.getWidget("showAlternatesWidget").hide();},error:function(error)
{alert(_mdc.PROD_ALTERNATE_ERROR)
mdc.getWidget("showAlternatesWidget").hide();}})
return false;}
function reloadCaptcha()
{var obj=document.getElementById("captchaimg");var src=obj.src;var pos=src.indexOf('&v=');if(pos>=0)
{src=src.substr(0,pos);}
var date=new Date();obj.src=src+'&v='+date.getTime();return false;}
mdc.pages.dynamicform.validate=function(form)
{var formId=document.getElementById("formId").value
if(Ext.getDom('j_captcha_response_'+formId)==undefined||Ext.getDom('j_captcha_response_'+formId)==null)
{return true;}
var captchaText=document.getElementById("j_captcha_response_"+formId).value
var urlx=mdc.getContextPath()+'/content/ajax/validate-captcha.jsp?formId='+formId+"&j_captcha_response_"+formId+"="+(captchaText==null?"":captchaText)
var retValue=false;Ext.Ajax.request({url:urlx,async:false,success:function(response,options)
{var newText=response.responseText
if(newText.indexOf('INVALID')>=0)
{var errors=new Array()
var focusOn
captchaObj=document.getElementById("j_captcha_response_"+formId)
captchaObj.value=""
focusOn="j_captcha_response_"+formId
errors[0]=_mdc.INVALID_CAPTCHA
mdc.showErrors(errors,'dynamicFormErrorBox')
mdc.setFocus('dynamicforms',focusOn)
Ext.fly('dynamicFormErrorBox').addCls('medError')
reloadCaptcha()
retValue=false;}
else
{retValue=true;}},failure:function(result,request){retValue=false;}})
return retValue;}
mdc.pages.cart.addToCartWindowDivId=null
mdc.pages.cart.addToCartWindowDiv=null
mdc.pages.cart.addToCartWindow=null
mdc.pages.cart.addToCartLoading=null
mdc.pages.cart.addToCart=function(formName)
{if(mdc.pages.cart.addToCartLoading==null)
{mdc.pages.cart.addToCartLoading=Ext.create('med.Loading',{id:Ext.id(),showOnClick:false})}
mdc.pages.cart.addToCartLoading.show()
Ext.Function.defer(mdc.pages.cart._addToCart,1,this,[formName])
return false}
mdc.pages.cart.addToCartOnEnter=function(formName,domEvent)
{e=Ext.EventObject.setEvent(domEvent)
if(Ext.EventObject.ENTER==e.getKey())
{e.stopEvent()
var submittoisa=Ext.getDom("submittoisa")
if(submittoisa)
return mdc.pages.cart.submitToISA(formName)
else
return mdc.pages.cart.addToCart(formName)}}
mdc.pages.cart._addToCart=function(formName)
{var formObject=document.getElementById(formName)
if(formObject==null||formObject==undefined)
{return false;}
var paramItemSku=""
var paramQuantity=""
var paramUom=""
var skuCount=document.getElementById(formName+"_skucount")
var firstSku=true;var hasQtyEntered=false;for(i=1;i<=skuCount.value;i++)
{var strQty=document.getElementById(formName+"_qty_"+i).value
var qty=parseInt(strQty)
if(qty>0)
{var skuId=Ext.getDom(formName+"_sku_id_"+i).value
var salesUOM=Ext.getDom(formName+"_sku_uom_"+i).value
if(firstSku==true)
{paramItemSku=skuId
paramQuantity=""+qty
paramUom=salesUOM
firstSku=false
hasQtyEntered=true}
else
{paramItemSku+=(";"+skuId)
paramQuantity+=(";"+qty)
paramUom+=(";"+salesUOM)}}
document.getElementById(formName+"_qty_"+i).value=""}
if(hasQtyEntered)
{var postURL=mdc.getContextPath()+"/isaintegration/ajax/add-to-cart.jsp"
var viewOrderURL=Ext.getDom('viewOrderURL').value
var urlx=postURL
Ext.Ajax.request({url:urlx,async:false,params:{"paramItemSku":paramItemSku,"paramQuantity":paramQuantity,"paramUom":paramUom},success:function(response,options)
{var newText=response.responseText
if(newText.indexOf('ERROR')>=0)
{alert(_mdc.ADDTOCART_ERROR)}
else
{var medTopLoginButtons=Ext.getDom("medTopLoginButtons")
if(medTopLoginButtons)
{medTopLoginButtons.innerHTML='<a href="'+viewOrderURL+'"><img width="124" height="23" src="/media/appresources/css/images/top-view-order-btn.png"></a>'}
if(!mdc.pages.cart.addToCartWindowDiv)
{mdc.pages.cart.addToCartWindowDivId=Ext.id()
mdc.pages.cart.addToCartWindowDiv=Ext.core.DomHelper.append(Ext.getBody(),{tag:'div','class':'x-hide-display',id:mdc.pages.cart.addToCartWindowDivId},true)
var orderResponse='';var punchoutsession=Ext.getDom('punchoutsession')
if(punchoutsession)
{orderResponse+="<div class=\"medAddtoOrderDiv\"><div class=\"medAddtoOrderMsg\"><h2>Your Requisition:</h2><p>Items were sucessfully added to your requisition</p>"
orderResponse+="<div style=\"float:left;\"> <a href='"+viewOrderURL+"' class=\"medSecondaryButton\"><span>View Requisition</span></a></div>"
orderResponse+="<div style=\"float:right;\"> <a href=\"#\" class=\"medSecondaryButton\" onclick=\"mdc.pages.cart.addToCartWindow.hide(); return false\" id=\"continueShoppingBtn\"><span>Continue Shopping</span></a></div>"
orderResponse+="<div class=\"medClear\"></div></div></div>"}
else
{orderResponse+="<div class=\"medAddtoOrderDiv\"><div class=\"medAddtoOrderMsg\"><h2>Your order:</h2><p>Items were sucessfully added to your order</p>"
orderResponse+="<div style=\"float:left;\"> <a href='"+viewOrderURL+"' class=\"medSecondaryButton\"><span>View Order</span></a></div>"
orderResponse+="<div style=\"float:right;\"> <a href=\"#\" class=\"medSecondaryButton\" onclick=\"mdc.pages.cart.addToCartWindow.hide(); return false\" id=\"continueShoppingBtn\"><span>Continue Shopping</span></a></div>"
orderResponse+="<div class=\"medClear\"></div></div></div>"}
mdc.pages.cart.addToCartWindowDiv.update(orderResponse)
mdc.pages.cart.addToCartWindow=Ext.create('med.Window',{id:mdc.pages.cart.addToCartWindowDivId,modal:true})}
mdc.pages.cart.addToCartWindow.show()
mdc.setFocus("continueShoppingBtn")}},failure:function(result,request){alert(_mdc.ADDTOCART_ERROR)}})}
else
alert(_mdc.ADDTOCART_NOQTY_ERROR)
mdc.pages.cart.addToCartLoading.hide()
return false;}
mdc.pages.cart.submitToISA=function(formName)
{var formObject=document.getElementById(formName)
if(formObject==null||formObject==undefined)
{return false;}
var paramItemSku=""
var paramQuantity=""
var paramUom=""
var skuCount=document.getElementById(formName+"_skucount")
var firstSku=true;var hasQtyEntered=false;for(i=1;i<=skuCount.value;i++)
{var strQty=document.getElementById(formName+"_qty_"+i).value
var qty=parseInt(strQty)
if(qty>0)
{var skuId=Ext.getDom(formName+"_sku_id_"+i).value
var salesUOM=Ext.getDom(formName+"_sku_uom_"+i).value
if(firstSku==true)
{paramItemSku=skuId
paramQuantity=""+qty
paramUom=salesUOM
firstSku=false
hasQtyEntered=true;}
else
{paramItemSku+=(";"+skuId)
paramQuantity+=(";"+qty)
paramUom+=(";"+salesUOM)}}}
if(hasQtyEntered)
{var currentUrl=window.location.href
var postURL=Ext.getDom('consignmentPostURL').value
var queryString="?paramItemSku="+paramItemSku+"&paramQuantity="+paramQuantity+"&paramUom="+paramUom
if(currentUrl!=null)
{var encodedUrl=encodeURIComponent(currentUrl)
queryString+="&atgReferer="+encodedUrl}
var urlx=postURL+queryString
window.location.href=urlx;}}
function medline_relaxDomain(input)
{if(input!="medline.com"){if(input.search(/^\d+\.\d+\.\d+\.\d+$/)>=0){return input;}
var lnDotPos=input.indexOf(".");return(lnDotPos>=0)?input.substr(lnDotPos+1):input;}
return input;}
var result=medline_relaxDomain(document.domain);if(result!=document.domain)
document.domain=result;function keepISAAlive()
{var viewOrderURL=Ext.getDom('viewOrderURL')
if(!viewOrderURL)
{return}
Ext.Ajax.request
({url:mdc.getContextPath()+'/isaintegration/ajax/keep-alive-isa.jsp',success:function(response,options)
{var newText=response.responseText
if(newText.indexOf("ERROR"))
{}},failure:function(result,request){}})}
mdc.pages.sitesearch.gotoPage=function(pageNumber)
{Ext.getDom('goToPage').value=pageNumber
mdc.submit('siteSearchResultsForm')
return false}
mdc.search.typeAhead.activeRequest=null
mdc.search.typeAhead.lastQuestion=null
mdc.search.typeAhead.submitTask=null
mdc.search.typeAhead.abortActiveRequest=function()
{if(mdc.search.typeAhead.activeRequest!=null)
{Ext.Ajax.abort(mdc.search.typeAhead.activeRequest)
mdc.search.typeAhead.activeRequest=null}
return true}
mdc.search.typeAhead.go=function()
{if(mdc.search.typeAhead.submitTask==null)
{mdc.search.typeAhead.submitTask=new Ext.util.DelayedTask(function(){mdc.search.typeAhead.submit()})}
mdc.search.typeAhead.submitTask.delay(250)}
mdc.search.typeAhead.submit=function()
{var srhQuestion=Ext.String.trim(Ext.get('searchQuestion').getValue())
var widget=mdc.getWidget('searchQuestion')
if(widget==null)
{return false}
if(srhQuestion.length>2)
{if(srhQuestion==mdc.search.typeAhead.lastQuestion)
{if(!widget.isVisible())widget.show()
return false}
mdc.search.typeAhead.abortActiveRequest()
mdc.search.typeAhead.activeRequest=Ext.Ajax.request({url:mdc.getContextPath()+'/search/ajax/search-type-ahead.jsp',method:'GET',params:{question:srhQuestion},success:function(response,options)
{if(mdc.search.typeAhead.activeRequest!=null)
{mdc.search.typeAhead.activeRequest=null
var newText=response.responseText
if(newText.indexOf('Product Categories')>=0)
{mdc.search.typeAhead.updatePopup(newText,srhQuestion)}
else
{mdc.search.typeAhead.updatePopup('',null)}}},failure:function(response,options)
{mdc.search.typeAhead.activeRequest=null
mdc.search.typeAhead.updatePopup('',null)}})}
else
{mdc.search.typeAhead.updatePopup('',null)}
return false}
mdc.search.typeAhead.updatePopup=function(text,srhQuestion)
{if(text)
{Ext.get('type-ahead-results').update(text)
Ext.get('type-ahead-results').removeCls('x-hide-display')
mdc.search.typeAhead.lastQuestion=srhQuestion}
else
{Ext.get('type-ahead-results').addCls('x-hide-display')
Ext.get('type-ahead-results').update('')
mdc.search.typeAhead.lastQuestion=null}
mdc.getWidget('searchQuestion').resize()}
mdc.pages.loginfrm.onFocusWMCheck=function(obj,noWMClassName)
{obj.className=noWMClassName
obj.setAttribute("className",noWMClassName);}
mdc.pages.loginfrm.onBlurWMCheck=function(obj,WMClassName)
{if(obj.value=="")
{obj.className=WMClassName}}
Ext.namespace('_mdc')
Ext.namespace('_mdc.pages.productdetail')
Ext.namespace('_mdc.pages.productoverview')
_mdc.CONFIRM_PASSWORD='Please confirm the new Password'
_mdc.ENTER_NEW_PASSWORD='Please enter a new Password'
_mdc.ENTER_OLD_PASSWORD='Please enter your old Password'
_mdc.ENTER_PASSWORD='Please enter a Password'
_mdc.ENTER_EMAILADDRESS='Please enter your Email Address'
_mdc.ENTER_EMAILADDRESS_AND_PASSWORD='Please enter your Email Address and Password'
_mdc.NOT_IMPLEMENTED_YET='Not implemented yet'
_mdc.ERROR='Error'
_mdc.PASSWORD_MISMATCH='Please retype the Password correctly'
_mdc.MIN_SEARCH_TEXT_LENGTH='Please enter at least 4 characters in the search box'
_mdc.AVAILABILITY_ERROR='Error occurred while retrieving availabilty details. Please refresh the page and try again. If the problem persists, please contact customer support.'
_mdc.PRICING_ERROR='Error occurred while retrieving pricing details. Please refresh the page and try again. If the problem persists, please contact customer support.'
_mdc.PROD_COMPARISON_ERROR='Unexpected error occurred. Please refresh the page and try again. If the problem persists, please contact customer support.'
_mdc.PROD_COMPARISON_LIMIT_REACHED='You can compare only three products, please unselect any one of the product before proceeding'
_mdc.PLANT='Plant'
_mdc.PLANT_LOC='Plant Location'
_mdc.PLANT_AVLBL_QTY='Plant Available QTY'
_mdc.PROD_ALTERNATE_ERROR='Unexpected error occurred while retrieving product alternates. Please refresh the page and try again. If the problem persists, please contact customer support.'
_mdc.INVALID_CAPTCHA='Invalid security text. please retype it'
_mdc.ADDTOCART_ERROR='Unexpected error occurred while additing item to cart. Please refresh the page and try again. If the problem persists, please contact customer support.'
_mdc.ADDTOCART_NOQTY_ERROR='To add an item to your cart, please enter numbers only (1-999) into the quantity box.'
_mdc.pages.productdetail.CONFIRM_COLOR_SWITCH_HEADER='Cart not Saved'
_mdc.pages.productdetail.CONFIRM_COLOR_SWITCH_BODY='If you switch colors, values not saved to the cart will be discarded.'
_mdc.pages.productdetail.CONFIRM_COLOR_SWITCH='Switch Colors'
_mdc.pages.productdetail.CONFIRM_COLOR_NO_SWITCH='Do Not Switch Colors'
_mdc.pages.productdetail.CLOSE_SIZE_CHART='Close Size Chart'
_mdc.pages.productoverview.ERROR_RETRIEVING_SKU_DATA='<b>Error:</b> Unable to retrieve Sku data.'
Ext.define('med.Widget',{_thisEl:null,constructor:function(config)
{this.initConfig(config)
this.create()
return this},create:function()
{},get:function()
{if(!this._thisEl)this._thisEl=Ext.get(this.id)
return this._thisEl},initConfig:function(config)
{if(!config)config={}
if(config.id&&!config.domNode)config.domNode=Ext.getDom(config.id)
for(var attrName in config)
{if(attrName!='type')
{this[attrName]=config[attrName]}}
return this}})
Ext.define('med.WidgetManager',{singleton:true,_widgets:new Array(),get:function(id)
{return this._widgets[id]},parse:function()
{var thisWidget=this
var startTime=new Date().getTime()
Ext.core.Element.select('[medDeclare*=type:]').each(function(item,arr,idx)
{try
{if(item.dom.medWidgetLoaded)
{}
else
{var props=Ext.JSON.decode(item.getAttribute('medDeclare'))
if(props.type)
{var id=props.id||item.id
if(!id)
{id=Ext.id('med-widget')
item.set({id:id})}
props.id=id
var widget=Ext.create(props.type,props)
if(widget)thisWidget._widgets[id]=widget
item.dom.medWidgetLoaded=true}}}
catch(e)
{alert('widget creation exception:\n\n'+e)}})
var totalTime=new Date().getTime()-startTime}})
Ext.define('med.CheckboxGroup',{extend:'med.Widget',attrName:'medCBAction',create:function()
{this.toggleCheckboxes=this.get().select('input['+this.attrName+'=toggle][type=checkbox]')
this.checkCheckboxes=this.get().select('input['+this.attrName+'=check][type=checkbox]')
var thisWidget=this
this.toggleCheckboxes.each(function(item,arr,idx)
{item.addListener('click',thisWidget._toggleAll,thisWidget)})
this.checkCheckboxes.each(function(item,arr,idx)
{item.addListener('click',thisWidget._toggleOne,thisWidget)})
this._checkTogglers()},_toggleAll:function(e)
{var checked=e.getTarget().checked
this.toggleCheckboxes.each(function(item,arr,idx)
{item.dom.checked=checked})
this.checkCheckboxes.each(function(item,arr,idx)
{item.dom.checked=checked})},_toggleOne:function(e)
{this._checkTogglers()},_checkTogglers:function()
{if(this.toggleCheckboxes.getCount()<1)return
var allChecked=mdc.every(this.checkCheckboxes.elements,function(checkbox){return checkbox.checked})
if(allChecked)
{this.toggleCheckboxes.each(function(item,arr,idx)
{item.dom.checked=true})
return}
var allNotChecked=mdc.every(this.checkCheckboxes.elements,function(checkbox){return!checkbox.checked})
if(allNotChecked)
{this.toggleCheckboxes.each(function(item,arr,idx)
{item.dom.checked=false})
return}
var firstChecked=this.toggleCheckboxes.first().dom.checked
this.toggleCheckboxes.each(function(item,arr,idx)
{item.dom.checked=firstChecked})}})
Ext.define('med.Cropper',{extend:'med.Widget',mainImageId:'cropperMainImage',pickerId:'cropperPicker',previewGlassSize:150,previewScale:2.52,previewGlassHoverable:true,previewHoverable:true,previewResizeable:true,previewOpacity:0.35,previewMoveOnClick:true,_preview:null,create:function()
{var thisWidget=this
var previewOptions={id:this.mainImageId,glassSize:this.previewGlassSize,scale:this.previewScale,glassHoverable:this.previewGlassHoverable,previewHoverable:this.previewHoverable,resizeable:this.previewResizeable,opacity:this.previewOpacity,moveOnClick:this.previewMoveOnClick}
this._preview=Ext.create('med.Preview',previewOptions)
var previewImages=Ext.get(this.pickerId).select('img')
Ext.get(this.pickerId).addListener('click',function(e)
{e.preventDefault()
var et=e.getTarget()
var src=et.parentNode.href||et.href
var srcPreviewSmall=et.parentNode.srcPreviewSmall||et.srcPreviewSmall||src
var srcPreviewLarge=et.parentNode.srcPreviewLarge||et.srcPreviewLarge||src
previewImages.each(function(item,arr,idx)
{item.removeCls('selected')})
Ext.fly(et).addCls('selected')
thisWidget.setSelectedImage(src,srcPreviewSmall,srcPreviewLarge)})},setSelectedImage:function(src,srcPreviewSmall,srcPreviewLarge)
{if(src&&this._preview.image.src!=src)
{this._preview.setImage(src,srcPreviewSmall,srcPreviewLarge)
var downLoadLink=document.getElementById("downloadlink");if(downLoadLink)
{downLoadLink.href=srcPreviewLarge;}}}})
Ext.define('med.FormEnterClick',{extend:'med.Widget',clickId:'',create:function()
{this.textboxes=this.get().select('input[type=text]')
this.passwordboxes=this.get().select('input[type=password]')
var thisWidget=this
this.textboxes.each(function(item,arr,idx)
{item.addListener('keypress',thisWidget._keypress,thisWidget)})
this.passwordboxes.each(function(item,arr,idx)
{item.addListener('keypress',thisWidget._keypress,thisWidget)})},_keypress:function(e)
{if(e.getKey()==Ext.EventObject.ENTER)
{e.stopEvent()
mdc.click(this.clickId)}}})
Ext.define('med.Image',{extend:'med.Widget',height:null,src:null,srcPreviewSmall:null,srcPreviewLarge:null,width:null,wrap:false,_image:null,_wrapper:null,create:function()
{this.get().dom.srcPreviewSmall=this.srcPreviewSmall
this.get().dom.srcPreviewLarge=this.srcPreviewLarge
if(this.src)
{this.load(this.src)}},load:function(src)
{var thisWidget=this
this.src=src
if(!this.width)this.width=this.get().getWidth()
if(!this.height)this.height=this.get().getHeight()
if(this.wrap&&!this._wrapper)
{this._wrapper=this.get().wrap({tag:'div',style:{width:this.width+'px',height:this.height+'px'}})}
this._image=Ext.get(new Image())
this._image.on('load',function(){thisWidget.onLoad()})
this._image.dom.src=this.src},onLoad:function()
{var imgWidth=this._image.dom.width
var imgHeight=this._image.dom.height
var useWidth=imgWidth
var useHeight=imgHeight
var top=0
var left=0
if(useWidth<=this.width&&useHeight<=this.height)
{top=((this.height-useHeight)/2)
left=((this.width-useWidth)/2)}
else
{if(useWidth>this.width)
{var ratio=imgWidth/this.width
useWidth=imgWidth/ratio
useHeight=imgHeight/ratio
top=((this.height-useHeight)/2)}
if(useHeight>this.height)
{var ratio=imgHeight/this.height
useWidth=imgWidth/ratio
useHeight=imgHeight/ratio
top=0
left=((this.width-useWidth)/2)}}
this.get().dom.width=useWidth
this.get().dom.height=useHeight
this.get().dom.src=this.src
if(this.wrap)
{this.get().setStyle('position','relative')
this.get().setStyle('left',left+'px')
this.get().setStyle('top',top+'px')}
else
{this.get().setStyle('margin',top+'px '+left+'px '+top+'px '+left+'px ')}}})
Ext.define('med.Loading',{extend:'med.Widget',showOnClick:true,autoShow:false,maskId:'medWrapperBody',msg:'Loading...',create:function()
{if(this.autoShow)this.show()
if(this.showOnClick)this.get().addListener('click',this.show,this)},hide:function()
{Ext.fly(this.maskId).unmask()},show:function()
{Ext.fly(this.maskId).mask(this.msg,'mdcLoadingIndicator')
Ext.fly(this.maskId).positionMaskMessage()}})
Ext.define('med.Menu',{extend:'med.Widget',create:function()
{}})
Ext.define('med.Popup',{extend:'med.Widget',connectId:'',manage:true,slide:true,slideDuration:150,openClass:null,baseClass:'wipMainMenu',anchorPosition:'tl-bl?',addClickListener:true,addShowOnClickListener:false,addKeypressListener:true,autoShow:false,autoShowHideDelay:250,autoShowShowDelay:0,onShowFocusId:'',onTabFocusId:'',controlBoxAdjustmentX:0,controlBoxAdjustmentY:0,menuOffset:[0,0],_popup:null,_autoShowTask:null,_autoShowShowTask:null,create:function()
{var thisWidget=this
if(this.addClickListener)
{this.get().addListener('click',thisWidget._toggle,thisWidget)}
else if(this.addShowOnClickListener)
{this.get().addListener('click',thisWidget.show,thisWidget)}
if(this.addKeypressListener)Ext.getDoc().addListener('keypress',thisWidget._keypress,thisWidget)
if(this.autoShow)
{this.get().addListener('mouseenter',thisWidget._autoShowShow,thisWidget)
this._autoShowShowTask=new Ext.util.DelayedTask(thisWidget.show,thisWidget)
this._autoShowTask=new Ext.util.DelayedTask(thisWidget.hide,thisWidget)}
if(this.onTabFocusId)Ext.getDoc().addListener('keypress',thisWidget._tabpress,thisWidget)
if(this.manage)med.Popup.popupManager.add(thisWidget)},getControlBox:function()
{return this.get().getBox(true)},getPopupBox:function()
{return this._getPopup().getBox(true)},hide:function()
{this.slide?this._slideOut():this._hide()
if(this.openClass)this.get().removeCls(this.openClass)
this._autoShowReset()},isMouseOver:function(e)
{return(this._isMouseOverControl(e)||this._isMouseOverPopup(e))},isVisible:function()
{if(!this._popup)return false;return this._getPopup().isVisible()},resize:function()
{this._show()
Ext.Function.defer(this._resize,1,this,[3])},show:function()
{if(this.manage)med.Popup.popupManager.hideAll()
this.slide?this._slideIn():this._show()
if(this.openClass)this.get().addCls(this.openClass)},toggle:function()
{if(this.isVisible())
this.hide()
else
this.show()},_autoShowHideCheck:function(e)
{var thisWidget=this
if(this.isVisible())
{if(this._isMouseOverControl(e)||this._isMouseOverPopup(e))
{this._autoShowTask.cancel()}
else
{this._autoShowTask.delay(this.autoShowHideDelay)}}
else
{if(this._isMouseOverControl(e))
{this._autoShowTask.cancel()}
else
{this._autoShowReset()}}},_autoShowReset:function()
{if(this.autoShow)
{var thisWidget=this
this.get().addListener('mouseenter',thisWidget._autoShowShow,thisWidget)
Ext.get(document).removeListener('mousemove',thisWidget._autoShowHideCheck,thisWidget)
this._autoShowTask.cancel()
this._autoShowShowTask.cancel()}},_autoShowShow:function()
{if(!this.isVisible())
{this._autoShowShowTask.delay(this.autoShowShowDelay)
var thisWidget=this
this.get().removeListener('mouseenter',thisWidget._autoShowShow,thisWidget)
Ext.get(document).addListener('mousemove',thisWidget._autoShowHideCheck,thisWidget)}},_getPopup:function()
{if(!this._popup)
{this._popup=Ext.create('widget.panel',{renderTo:med.Popup.popupManager.getPanelTargetId(),autoHeight:true,floating:true,contentEl:this.connectId,minWidth:0,baseCls:this.baseClass,focusOnToFront:false})
this._popup.alignTo(this.get(),this.anchorPosition,this.menuOffset).hide()}
return this._popup},_hide:function()
{this._getPopup().hide()
this._autoShowReset()},_isMouseOverControl:function(e)
{var popupBox=this.getControlBox()
if(e.getX()>=popupBox.x-this.controlBoxAdjustmentX&&e.getX()<=popupBox.x+popupBox.width+this.controlBoxAdjustmentX)
{if(e.getY()>=popupBox.y-this.controlBoxAdjustmentY&&e.getY()<=popupBox.y+popupBox.height+this.controlBoxAdjustmentY)
{return true}}
return false},_isMouseOverPopup:function(e)
{var popupBox=this.getPopupBox()
if(e.getX()>=popupBox.x&&e.getX()<=popupBox.x+popupBox.width)
{if(e.getY()>=popupBox.y&&e.getY()<=popupBox.y+popupBox.height)
{return true}}
return false},_keypress:function(e)
{if(e.getKey()==Ext.EventObject.ESC)
{e.stopEvent()
this.hide()}},_resize:function(count)
{this._show()
if(count)
{Ext.Function.defer(this._resize,1,this,[--count])}},_show:function()
{Ext.fly(this.connectId).addCls('mdcInvisible')
this._getPopup().show().setCalculatedSize(null,null).alignTo(this.get(),this.anchorPosition,this.menuOffset)
Ext.fly(this.connectId).removeCls('mdcInvisible')
if(this.onShowFocusId)mdc.setFocus(this.onShowFocusId)},_slideIn:function()
{this._getPopup().show()
this._getPopup().setCalculatedSize(null,null)
this._getPopup().alignTo(this.get(),this.anchorPosition,this.menuOffset)
var toWidth=this._getPopup().getWidth()
var toHeight=this._getPopup().getHeight()
this._getPopup().setCalculatedSize(toWidth,0)
this._getPopup().animate({from:{width:toWidth,height:0},to:{width:toWidth,height:toHeight},easing:'easeIn',duration:this.slideDuration,listeners:{afteranimate:function(){this._slideInDone();},scope:this}})},_slideInDone:function()
{if(this.onShowFocusId)mdc.setFocus(this.onShowFocusId)},_slideOut:function()
{var thisWidget=this
this._getPopup().animate({from:{width:this._getPopup().getWidth(),height:this._getPopup().getHeight()},to:{width:this._getPopup().getWidth(),height:0},easing:'easeOut',duration:this.slideDuration,listeners:{afteranimate:function(){thisWidget._getPopup().hide()},scope:thisWidget}})},_tabpress:function(e)
{if(this.isVisible())
{if(e.getKey()==Ext.EventObject.TAB)
{e.stopEvent()
Ext.fly(this.onTabFocusId).focus()}}},_toggle:function(e)
{e.stopEvent()
this.toggle()}})
Ext.namespace('med.Popup.manager')
med.Popup.manager=function()
{this.popups=new Array()
this.windowListenerCreated=false
this._panelTargetId=Ext.id()}
med.Popup.manager.prototype.add=function(popup)
{if(this.windowListenerCreated==false)
{var thisWidget=this
Ext.getDoc().addListener('click',thisWidget._checkWindowClick,thisWidget)}
this.popups[this.popups.length]=popup}
med.Popup.manager.prototype._checkWindowClick=function(e)
{var insidePopup=false
for(var i=0;i<this.popups.length;i++)
{if(this.popups[i].isVisible())
{if(this.popups[i].isMouseOver(e))
{insidePopup=true
break}}}
if(!insidePopup)this.hideAll()}
med.Popup.manager.prototype.getPanelTargetId=function()
{if(!Ext.fly(this._panelTargetId))
{Ext.core.DomHelper.append(Ext.getBody(),{tag:'div',id:this._panelTargetId})}
return this._panelTargetId}
med.Popup.manager.prototype.hideAll=function()
{for(var i=0;i<this.popups.length;i++)
{if(this.popups[i].isVisible())this.popups[i].hide()}}
med.Popup.popupManager=new med.Popup.manager()
Ext.define('med.Preview',{extend:'med.Widget',glassSize:150,glassHoverable:false,previewHoverable:false,resizeable:true,opacity:0.35,moveOnClick:false,animDuration:250,_isVisible:false,_isDragging:false,create:function()
{var mb=this.get().getBox()
this.container=this.get().wrap({tag:'div'})
this.container.setBox(mb)
this.picker=Ext.core.DomHelper.insertBefore(this.get(),{tag:'div',id:Ext.id(),'class':'cropperPreviewImageDragger',style:{width:this.glassSize+"px",height:this.glassSize+"px"}})
Ext.fly(this.picker).setOpacity(this.glassHoverable?0:this.opacity)
this.preview=Ext.core.DomHelper.append(Ext.getBody(),{tag:'div','class':'cropperPreviewExpandedImage',style:{position:"absolute",overflow:"hidden",width:Math.floor(this.glassSize*this.scale)+"px",height:Math.floor(this.glassSize*this.scale)+"px",zIndex:9999}})
Ext.fly(this.preview).addCls('mdcHidden')
var n=this._wrap(Ext.core.DomHelper.createDom({tag:'img',style:{position:"absolute"},src:this.altSrc||this.domNode.src},this.preview),'div')
n.setStyle('position','relative')
this.get().setStyle('position','absolute')
var thisWidget=this
this.image=Ext.get(this.preview).query('img')[0]
Ext.fly(this.image).addListener('load',function()
{Ext.callback(thisWidget._adjustImageLoad,thisWidget)})
this._positionPicker()
this.mover=Ext.create('Ext.dd.DD',{id:this.picker})
this.mover.constrainTo(this.get())
this.mover.onDrag=function(e){thisWidget._whileMoving(true)}
if(this.resizeable){this._handle=Ext.create('Ext.resizer.Resizer',{el:this.picker,handles:'se',minWidth:40,minHeight:40,constrainTo:this.id,preserveRatio:true,pinned:true})
this._handle.addListener('resizedrag',function(scope,width,height,e,options)
{thisWidget._adjustImageResize(e)
thisWidget._whileMoving(true)},thisWidget)}
Ext.isIE&&(this.image.src=this.image.src)
Ext.EventManager.onWindowResize(this._positionPicker,this)
if(this.glassHoverable||this.previewHoverable)
{if(this.moveOnClick)
this.connect(this.container,"click","_enterClick")
else
this.connect(this.container,"click","_enter")
this.connect(this.container,"mouseleave","_leave")}
if(this.moveOnClick)
{this.connect(this.container,"click","_click")}
Ext.callback(this._positionPicker,this,null,125)},setImage:function(src,srcPreviewSmall,srcPreviewLarge)
{var thisWidget=this
var image=Ext.get(new Image())
image=Ext.get(new Image())
image.on('load',function(){thisWidget._setImage(image,Ext.get(thisWidget.domNode),srcPreviewSmall,srcPreviewLarge)})
image.dom.src=src},_setImage:function(image,targetImage,srcPreviewSmall,srcPreviewLarge)
{var imgWidth=image.dom.width
var imgHeight=image.dom.height
var useWidth=imgWidth
var useHeight=imgHeight
var top=0
var left=0
this.width=300
this.height=300
if(useWidth<=this.width&&useHeight<=this.height)
{top=((this.height-useHeight)/2)
left=((this.width-useWidth)/2)}
else
{if(useWidth>this.width)
{var ratio=imgWidth/this.width
useWidth=imgWidth/ratio
useHeight=imgHeight/ratio
top=((this.height-useHeight)/2)}
if(useHeight>this.height)
{var ratio=imgHeight/this.height
useWidth=imgWidth/ratio
useHeight=imgHeight/ratio
top=0
left=((this.width-useWidth)/2)}}
targetImage.setStyle('width',useWidth+'px')
targetImage.setStyle('height',useHeight+'px')
targetImage.dom.src=srcPreviewSmall
if(this.wrap)
{targetImage.setStyle('position','relative')
targetImage.setStyle('left',left+'px')
targetImage.setStyle('top',top+'px')}
else
{targetImage.setStyle('margin',top+'px '+left+'px '+top+'px '+left+'px ')}
this.image.src=srcPreviewLarge
if(this.glassSize<useWidth)useWidth=this.glassSize
if(this.glassSize<useHeight)useHeight=this.glassSize
Ext.fly(this.picker).setStyle('width',(useWidth-4)+'px')
Ext.fly(this.picker).setStyle('height',(useHeight-4)+'px')},_adjustImageLoad:function(e)
{this._adjustImage(e,'load')},_adjustImageResize:function(e)
{this._adjustImage(e,'resize')},_adjustImage:function(e,type)
{var tc=Ext.fly(this.domNode).getBox()
var s=this.scale
if(type=='resize')
{var xy=Ext.fly(this.picker).getBox(true)
this.scale=Ext.fly(this.preview).getBox(true).width/xy.width}
this.mover.constrainTo(this.get())
Ext.fly(this.image).setStyle('height',Math.floor(tc.height*s)+'px')
Ext.fly(this.image).setStyle('width',Math.floor(tc.width*s)+'px')},_positionPicker:function(e)
{var tc=this.coords=Ext.fly(this.domNode).getBox()
Ext.fly(this.preview).setStyle('left',tc.x+tc.width+10+'px')
Ext.fly(this.preview).setStyle('top',tc.y+'px')},_whileMoving:function(dragging)
{var xy=this._lastXY=Ext.fly(this.picker).getBox()
var tc=Ext.fly(this.domNode).getBox()
var r=this.image.width/tc.width
var x=Math.floor((xy.x-tc.x)*r)
var y=Math.floor((xy.y-tc.y)*r)
Ext.fly(this.image).setStyle('top',-1*y+'px')
Ext.fly(this.image).setStyle('left',-1*x+'px')
this.mover.constrainTo(this.get())
if(dragging)this._isDragging=true},imageReady:function()
{},connect:function(target,eventAction,callee)
{target.addListener(eventAction,eval('this.'+callee),this)},_click:function(e)
{if(!this._isDragging)
{var pickerBox=Ext.fly(this.picker).getBox()
var x=e.getX()-pickerBox.width/2
var y=e.getY()-pickerBox.height/2
var previewBox=this.get().getBox()
if(x<previewBox.x)x=previewBox.x
else if(x+pickerBox.width>previewBox.x+previewBox.width)x=previewBox.x+previewBox.width-pickerBox.width
if(y<previewBox.y)y=previewBox.y
else if(y+pickerBox.height>previewBox.y+previewBox.height)y=previewBox.y+previewBox.height-pickerBox.height
Ext.fly(this.picker).moveTo(x,y)
this._whileMoving(false)}
this._isDragging=false},_enterClick:function(e)
{if(this._isVisible)return
this._enter(e)},_enter:function(e)
{this._isVisible=true
if(this.glassHoverable)
{Ext.fly(this.picker).setOpacity(this.opacity,{duration:this.animDuration})}
if(this.previewHoverable)
{Ext.fly(this.preview).setOpacity(0)
Ext.fly(this.preview).removeCls('mdcHidden')
Ext.fly(this.preview).setOpacity(1,{duration:this.animDuration})}},_leave:function(e)
{this._isVisible=false
var thisWidget=this
if(this.glassHoverable)
{Ext.fly(this.picker).setOpacity(0,{duration:this.animDuration})}
if(this.previewHoverable)
{Ext.fly(this.preview).setOpacity(0,{duration:this.animDuration,callback:function()
{if(!thisWidget._isVisible)
{Ext.fly(thisWidget.preview).addCls('mdcHidden')}}})}},_wrap:function(node,withTag)
{return Ext.fly(node).wrap({tag:withTag})}})
Ext.define('med.Ticker',{extend:'med.Widget',switchDelay:5000,switchDuration:500,_task:null,_items:new Array(),_itemIndex:0,create:function()
{var thisWidget=this
this.get().setStyle('overflow','hidden')
this.get().addListener('mouseenter',thisWidget._stop,thisWidget)
this.get().addListener('mouseout',thisWidget._start,thisWidget)
var item=this.get().first('div')
var firstItem=true
while(item)
{item.setStyle('position','relative')
if(firstItem)
{this.get().setHeight(item.getHeight())
firstItem=false}
else
{item.setOpacity(0)}
this._items[this._items.length]=item
item=item.next('div')}
this._task={interval:this.switchDelay,scope:this,run:this._next}
Ext.TaskManager.start(this._task)},_next:function()
{if(this._task.taskRunCount==1)return
var thisWidget=this
var lastIndex=this._itemIndex
var currIndex=this._itemIndex+1
if(currIndex>=this._items.length)currIndex=0
this._itemIndex=currIndex
var lastItem=this._items[lastIndex]
var currItem=this._items[currIndex]
lastItem.fadeOut({duration:this.switchDuration/3,useDisplay:true,callback:function()
{lastItem.addCls('x-hide-display')
currItem.removeCls('x-hide-display')
Ext.get(thisWidget.id).setHeight(currItem.getHeight(),{duration:this.switchDuration/3,callback:function()
{currItem.fadeIn({duration:thisWidget.switchDuration/3,useDisplay:true})}})}})},_start:function()
{Ext.TaskManager.start(this._task)},_stop:function()
{Ext.TaskManager.stop(this._task)}})
Ext.define('med.Tooltip',{extend:'med.Widget',contentId:'',position:'below',showDelay:1,create:function()
{var anchor=(this.position=='left'?'right':this.position=='right'?'left':this.position=='above'?'bottom':'top')
Ext.create('Ext.tip.ToolTip',{anchor:anchor,showDelay:this.showDelay,target:this.id,constrainPosition:true,dismissDelay:86400000,contentEl:this.contentId})}})
Ext.define('med.Window',{extend:'med.Widget',autoSlideIn:false,baseCls:'',modal:false,slideDuration:750,slideTo:null,toFrontOnShow:true,_window:null,create:function()
{if(this.autoSlideIn&&Ext.isNumeric(this.slideTo))this.show()},hide:function()
{if(this.isVisible())
{if(Ext.isNumeric(this.slideTo))
{this._getWindow().animate({to:{y:0-this._getWindow().getHeight()},duration:this.slideDuration,listeners:{afteranimate:function(){this._getWindow().hide()},scope:this}})}
else
{this._getWindow().hide()}}},isVisible:function()
{return(this._getWindow().isVisible())},setPagePosition:function(x,y)
{this._getWindow().setPagePosition(x,y)},show:function(recenter)
{if(!this.isVisible())
{if(Ext.isNumeric(this.slideTo))
{this._getWindow().show().setPagePosition(null,0-this._getWindow().getHeight())
this._getWindow().animate({to:{y:this.slideTo},duration:this.slideDuration})}
else
{this._getWindow().show()
if(recenter)this._getWindow().center()}}},toggle:function()
{if(this.isVisible())
this.hide()
else
this.show()},_getWindow:function()
{if(!this._window)
{this._window=Ext.create('Ext.window.Window',{layout:'fit',baseCls:this.baseCls,contentEl:this.id,closeAction:'hide',closable:false,draggable:false,frame:false,modal:this.modal,preventHeader:true,minHeight:0,minWidth:0,resizable:false,shadow:false,toFrontOnShow:this.toFrontOnShow,hideMode:'offsets'})}
return this._window}})
Ext.define('med.form.DatePicker',{extend:'med.Widget',requires:['Ext.Date','Ext.EventManager','Ext.EventObject','Ext.panel.Panel','Ext.picker.Date'],dateFormat:'n/j/Y',_datePicker:null,_datePickerPanel:null,create:function()
{Ext.getDoc().addListener('click',this._handleClick,this)
this.get().addListener('focus',this.show,this)},getValue:function()
{return Ext.Date.format(this._getDatePicker().getValue(),this.dateFormat)},hide:function()
{if(this.isVisible())
{this._getDatePickerPanel().hide()
Ext.getDoc().removeListener('keypress',this._handleKeypress,this)
this.get().removeListener('blur',this._handleControllerBlur,this)
Ext.EventManager.removeResizeListener(this._handleWindowResize,this)}},isVisible:function()
{return(this._datePickerPanel&&this._getDatePickerPanel().isVisible())},show:function()
{if(!this.isVisible())
{this._getDatePickerPanel().show().alignTo(this.id)
Ext.getDoc().addListener('keypress',this._handleKeypress,this)
this.get().addListener('blur',this._handleControllerBlur,this)
Ext.EventManager.onWindowResize(this._handleWindowResize,this)}},toggle:function()
{if(this.isVisible())
this.hide()
else
this.show()},_getDatePicker:function()
{if(!this._datePicker)
{var thisWidget=this
this._datePicker=new Ext.picker.Date({format:this.dateFormat,value:Ext.Date.parse(this.get().dom.value,this.dateFormat)||Ext.Date.clearTime(new Date()),handler:function(picker,date)
{thisWidget.get().dom.value=Ext.Date.format(date,thisWidget.dateFormat)
thisWidget.get().focus()
Ext.defer(thisWidget.hide,1,thisWidget)}})}
return this._datePicker},_getDatePickerPanel:function()
{if(!this._datePickerPanel)
{this._datePickerPanel=new Ext.panel.Panel({renderTo:Ext.getBody(),floating:true,items:[this._getDatePicker()],focusOnToFront:false})}
return this._datePickerPanel},_handleClick:function(e)
{if(this.isVisible())
{if(e.within(this.id,false,true)||e.within(this._getDatePicker(),false,true)||this._isInWidget(e.getX(),e.getY()))
{e.stopEvent()}
else
{this.hide()}}
else
{if(e.within(this.id,false,true))
{this.show()
e.stopEvent()}}},_handleControllerBlur:function(e)
{},_handleKeypress:function(e)
{if(e.getKey()==Ext.EventObject.ESC)
{e.stopEvent()
this.hide()}},_handleWindowResize:function(e)
{this._getDatePickerPanel().alignTo(this.id)},_isInElement:function(element,x,y)
{var box=element.getBox()
return(x>=box.x&&x<=box.x+box.width&&y>=box.y&&y<=box.y+box.height)},_isInWidget:function(x,y)
{return(this._isInElement(this.get(),x,y)||this._isInElement(this._getDatePickerPanel(),x,y))}})
Ext.define('med.form.TextListEditor',{extend:'med.Widget',classPrefix:'form',maxValues:1000,minValues:0,unique:true,_rowIndex:0,_rowTemplate:null,create:function()
{var thisWidget=this
this.get().select('.'+this.classPrefix+'Row').each(function(item,arr,idx)
{item=Ext.get(item.dom)
if(!item.getAttribute('id'))
{item.set({'id':thisWidget.id+'_row_'+thisWidget._rowIndex++})}
thisWidget._connect(thisWidget._getByClass(item.getAttribute('id'),thisWidget.classPrefix+'RowRemover'),'click',function(evt){thisWidget._removeRow(evt,item)})
thisWidget._connect(thisWidget._getByClass(item.getAttribute('id'),thisWidget.classPrefix+'RowEnterValue'),'change',function(evt){thisWidget._validateRow(evt,item,true)})})
this._connect(this._getByClass(this.id,this.classPrefix+'RowAdder'),'click',function(evt){thisWidget._addRow(evt)})
var rowTemplate=this._getByClass(this.id,this.classPrefix+'RowTemplate')
this._rowTemplate=Ext.clone(rowTemplate)
if(!rowTemplate.getAttribute('id'))
{rowTemplate.set({'id':thisWidget.id+'_rowTemplate'})}
this._getByClass(rowTemplate.getAttribute('id'),this.classPrefix+'RowSubmitValue').remove()
this._getByClass(rowTemplate.getAttribute('id'),this.classPrefix+'RowEnterValue').remove()
this._getByClass(rowTemplate.getAttribute('id'),this.classPrefix+'RowRemover').remove()
var thisDomNode=Ext.fly(thisWidget.id)
Ext.select('form').each(function(item,arr,idx)
{if(item.contains(thisWidget.get()))
{thisWidget._connect(item,'submit',function(){thisWidget._prepareForSubmit()})}})
this._checkShowAdder()},_addRow:function(evt)
{var newRow=Ext.clone(this._rowTemplate)
newRow.replaceCls(this.classPrefix+'RowTemplate',this.classPrefix+'Row')
newRow.set({'id':this.id+'_row_'+this._rowIndex++})
newRow.insertBefore(this._getByClass(this.id,this.classPrefix+'RowAdder').dom)
this._connect(this._getByClass(newRow.getAttribute('id'),this.classPrefix+'RowRemover'),'click',function(evt){this._removeRow(evt,newRow)})
this._connect(this._getByClass(newRow.getAttribute('id'),this.classPrefix+'RowEnterValue'),'change',function(evt){this._validateRow(evt,newRow,true)})
newRow.removeCls('mdcHidden')
this._getByClass(newRow.getAttribute('id'),this.classPrefix+'RowEnterValue').focus()
this._checkShowAdder()
evt.stopEvent()},_connect:function(target,eventAction,fnc)
{Ext.fly(target).addListener(eventAction,fnc,this)},_removeRow:function(evt,row)
{row.remove()
this._checkShowAdder()
evt.stopEvent()},_validateRow:function(evt,rowToValidate,isOnchange)
{var thisWidget=this
if(this.unique)
{var rowToValidateValue=thisWidget._getByClass(rowToValidate.getAttribute('id'),thisWidget.classPrefix+'RowEnterValue').dom
if(rowToValidateValue&&rowToValidateValue.value&&rowToValidateValue.value.length>0)
{var duplicateFound=false
this.get().select('.'+this.classPrefix+'Row').each(function(item,arr,idx)
{if(rowToValidate.dom!=item.dom)
{var enterValue=thisWidget._getByClass(item.getAttribute('id'),thisWidget.classPrefix+'RowEnterValue').dom
if(enterValue&&enterValue.value)
{if(rowToValidateValue.value==enterValue.value)
{duplicateFound=true}}}})
if(duplicateFound)
{alert('not unique')}}}},_checkShowAdder:function()
{if(this.get().select('.'+this.classPrefix+'Row').getCount()<this.maxValues)
{this._getByClass(this.id,this.classPrefix+'RowAdder').removeCls('mdcHidden')}
else
{this._getByClass(this.id,this.classPrefix+'RowAdder').addCls('mdcHidden')}},_prepareForSubmit:function()
{var thisWidget=this
this.get().select('.'+this.classPrefix+'Row').each(function(item,arr,idx)
{item=Ext.get(item.dom)
var enterValue=thisWidget._getByClass(item.getAttribute('id'),thisWidget.classPrefix+'RowEnterValue').dom
var submitValue=thisWidget._getByClass(item.getAttribute('id'),thisWidget.classPrefix+'RowSubmitValue').dom
if(enterValue&&enterValue.value)
{submitValue.value=enterValue.value}
else if(enterValue)
{item.remove()}})},_getByClass:function(scopeId,className)
{return Ext.fly(scopeId).down('.'+className)}})
