                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                if(!window.__td){window.__MT=100;window.__ti=0;window.__td=[];window.__td.length=window.__MT;window.__noTrace=false;

}



if(!vp)
{
var vp={};
}

if(!vp.gallery)
{
vp.gallery={};
}







vp.gallery.typeAhead=function(){};

vp.gallery.typeAhead.SEARCH_LOCATION_ALL="All";
vp.gallery.typeAhead.SEARCH_LOCATION_GALLERY="Gallery";
vp.gallery.typeAhead.SEARCH_LOCATION_STUDIO="Studio";




vp.gallery.typeAhead.menus={};




vp.gallery.typeAhead.cache={};




vp.gallery.typeAhead.initTypeAhead=function $vpfn_Q$JqK3w4tHHnU7MHnIhNkg42$37(sTextFieldId,iProductGroupId,sPfId,sSearchLocation,fnOnMenuItemSelect)
{if(!window.__noTrace){__td[__ti]=arguments;__ti=__ti>=__MT?0:__ti+1;}
if(!sSearchLocation)
{
sSearchLocation=vp.gallery.typeAhead.SEARCH_LOCATION_ALL;
}
var oMenu=new vp.widget.AutoSuggestMenu(sTextFieldId);



vp.gallery.typeAhead.menus[sTextFieldId]=oMenu;

oMenu.Context={};
oMenu.Context.SearchLocation=sSearchLocation;
oMenu.Context.ProductGroupId=iProductGroupId;
oMenu.Context.PfId=sPfId;


var fnPopulate=function $vpfn_$tPzVLc3g7QESSpWxldx4Q60$21(e)
{if(!window.__noTrace){__td[__ti]=arguments;__ti=__ti>=__MT?0:__ti+1;}
vp.gallery.typeAhead.populateMenu(e,sTextFieldId);
};
oMenu.ondelaychange.addHandler(fnPopulate);


var fnSelect=function $vpfn_HvaRoZamq2Qz0BUCao2khQ67$19(e)
{if(!window.__noTrace){__td[__ti]=arguments;__ti=__ti>=__MT?0:__ti+1;}
document.getElementById(sTextFieldId).value=e.elementText;
fnOnMenuItemSelect();
};
oMenu.onselectsuggestion.addHandler(fnSelect);

oMenu.prefillTextBoxOnKeyActions=true;
oMenu.dropDownDelay=50;
oMenu.maxHeight=212;



oMenu.menuWidth=vp.ui.getRect(document.getElementById(sTextFieldId)).width;


oMenu.itemStyle={
textAlign:"left",
fontSize:"12px",
fontWeight:"bold"
};


oMenu.prefixStyle={
fontWeight:"normal"
};
};




vp.gallery.updateTypeAheadContext=function $vpfn_F_FgiF2qPPtpwxHhKYiArg98$36(sTextFieldId,iProductGroupId,sPfId,sSearchLocation)
{if(!window.__noTrace){__td[__ti]=arguments;__ti=__ti>=__MT?0:__ti+1;}
var oMenu=new vp.widget.AutoSuggestMenu(sTextFieldId);
if(oMenu)
{
oMenu.Context={};
oMenu.Context.SearchLocation=sSearchLocation;
oMenu.Context.ProductGroupId=iProductGroupId;
oMenu.Context.PfId=sPfId;
vp.gallery.typeAhead.cache={};
}
};




vp.gallery.typeAhead.populateMenu=function $vpfn_gQixcAStYHoF_$nIewQqgA114$36(e,sTextFieldId)
{if(!window.__noTrace){__td[__ti]=arguments;__ti=__ti>=__MT?0:__ti+1;}


var sSearchTerm=e.value;
var oMenu=vp.gallery.typeAhead.menus[sTextFieldId];

if(vp.gallery.typeAhead.cache[sSearchTerm])
{
oMenu.setData(vp.gallery.typeAhead.cache[sSearchTerm],sSearchTerm);
return;
}

var oRequest=new vp.gallery.WebRequest();
oRequest.addParameter("request_type",8);
if(oMenu.Context.PfId)
{
oRequest.addParameter("pf_id",oMenu.Context.PfId);
}
if(typeof(oMenu.Context.ProductGroupId)!="undefined")
{
oRequest.addParameter("pg",oMenu.Context.ProductGroupId);
}
if(oMenu.Context.ProductGroupId===0)
{
oRequest.addParameter("location",oMenu.Context.SearchLocation);
}

oRequest.addParameter("prefix",encodeURI(sSearchTerm));

var fnSuccessHandler=function $vpfn_Laa7zCRuxsUiwavx2s3XxA144$27(oContent)
{if(!window.__noTrace){__td[__ti]=arguments;__ti=__ti>=__MT?0:__ti+1;}
if(oContent.rc<0)
{
return;
}

var oData=oContent.suggestions;
vp.gallery.typeAhead.cache[sSearchTerm]=oData;
oMenu.setData(oData,sSearchTerm);
};

var fnErrorHandler=function(e)
{
};


oRequest.callbackFunction=fnSuccessHandler;
oRequest.errorHandlerFunction=fnErrorHandler;


try
{
oRequest.executeAsync();
}
catch(e)
{
fnErrorHandler(e);
}
};
