//<!--
//1@@m7

var errorURL_NoParentPage=cgiURLError+'&ErrorCode=10';var errorURL_NonValidParentPage=cgiURLError+'&ErrorCode=10';var keyedEnter=false;var saveAction="";var agt=navigator.userAgent.toLowerCase();var major=parseInt(navigator.appVersion);var nav=((agt.indexOf('mozilla')!=-1)&&((agt.indexOf('spoofer')==-1)&&(agt.indexOf('compatible')==-1)&&(agt.indexOf('webtv')==-1)));var nav4=(nav&&(major>=4)&&(major<5));if(!nav4&&!(is.mac&&is.ie)){var eInd=document.domain.indexOf(".ebay.");if(eInd!=-1){document.domain=new String(document.domain).substr(eInd+1);}}
var SITEID_TAIWAN=196;var SITEID_POLAND=212;var KEYEVENT_ENTER=13;ebaySYI.core.Registrar.register(new SuggestedCategories());var suggestedL2CReco=new Array;function SuggestedCategories(){_checkCompatible();_checkConfigured();config.checkDependencies(["syiForm"]);this.restrictedParams=new Array("item");this.PACKAGE="ebaySYI.syi";this.CLASS="SuggestedCategories";this.init=_init;this.evalParams=_evalParams;this.isRestrictedParam=_isRestrictedParam;this.setQuery=_setQuery;this.newQuery=_newQuery;this.selectionComplete=_selectionComplete;this.populateSuggestedCategory=_populateSuggestedCategory;this.checkResultsSubmit=_checkResultsSubmit;this.popSuggestionWindow=_popSuggestionWindow;this.setSecondCategory=_setSecondCategory;this.checkSellItemFormSubmit=_checkSellItemFormSubmit;this.isValidPage=_isValidPage;this.isEmptyQueryValue=_isEmptyQueryValue;this.writeErrorMessage=_writeErrorMessage;this.hasInvalidCharacter=_hasInvalidCharacter;this.specialEscape=_specialEscape;this.populateQueryFields=_populateQueryFields;this.updateCategorySelectionFields=_updateCategorySelectionFields;this.updateOptionalSecondaryFields=_updateOptionalSecondaryFields;this.isKeyPressed=_isKeyPressed;this.isAllSpaces=_isAllSpaces;this.siteIs=_siteIs;this.getElementById=_getElementById;this.throwConfigError=_throwConfigError;this.setL2CSuggestedCategories=_setL2CSuggestedCategories;var host=document.location.hostname;if(host.indexOf(".corp.")==-1){var v3index=host.indexOf((".V3.").toLowerCase());if(v3index!=-1){host=host.substring(v3index+3);}
else{host=host.substring(host.indexOf("."));}}
else{host=".ebay.com"}
this.resultsPopupURL="http://pages"+host+"/sugg_cat_popup.html?url=";this.validPages=new Array("PageSYI_CatMetaFixedPrice","PageSYI_CatMeta_Motors","PageRYI_CatMeta","PageSYI_CatMeta","PageSYI_CatLeafFixedPrice","PageSYI_CatLeaf_Motors","PageRYI_CatLeaf","PageSYI_CatLeaf");var SuggestedPrimaryCategory="";var SuggestedSecondaryCategory="";function _init()
{this.evalParams();}
function _setQuery(){if(Query){syiForm.getField("MainQuery").value=Query;}}
function _newQuery(pIsMain,pQuery){var pageHolder=pageName;if(this.isEmptyQueryValue(pQuery)){this.writeErrorMessage(pIsMain,errorMsg_NoKeywords);pageName+="_ErrorNoKeywords";ssDoRequest();}
else{if(this.hasInvalidCharacter(pQuery,invalidChars)){this.writeErrorMessage(pIsMain,errorMsg_InvalidChars);pageName+="_ErrorSymbols";ssDoRequest;}
else{var CategoryType=(pIsMain)?"1":"2";var URL=this.resultsPopupURL
+cgiURL
+"&Query="+this.specialEscape(pQuery)
+"&Format="+this.Format
+"&SiteId="+this.SiteId
+"&SaleMode="+this.SaleMode
+"&CategoryType="+CategoryType
+"&isRevised=true";if(typeof(SelectedCategoryLeafID)!="undefined"){URL+="&SelectedCategoryLeafID="+SelectedCategoryLeafID}
document.location.href=URL;}}
pageName=pageHolder;}
function _selectionComplete(pQueryField,pSaveSelection,pCategoryID){var query="";var opener=window.opener;if(opener&&!opener.closed){if(typeof(opener.pageName)!="string"||(!this.isValidPage(opener.pageName)&&pSaveSelection)){location.href=errorURL_NonValidParentPage;}
else{var ssAppend="Cancel";if(pSaveSelection){ssAppend="Cat";var radios=syiForm.getForm().Categories;var value;if(typeof(pCategoryID)!="undefined"){value=pCategoryID;}
else if(radios.length){for(var i=0,x=radios.length;i<x;i++){if(radios[i].checked){value=radios[i].value;if(i==0){ssAppend+="1";}
else if(i<3){ssAppend+="2.3";}
else{ssAppend+="4";}
break;}}}
else{value=radios.value
ssAppend+="1";}
if(typeof(document.CategorySuggestion.SecondaryCategoryQuery)!='undefined')
{query=document.CategorySuggestion.SecondaryCategoryQuery;}
else if(typeof(document.CategorySuggestion.PrimaryCategoryQuery)!='undefined')
{query=document.CategorySuggestion.PrimaryCategoryQuery;}
else
{query="";}
opener.setTimeout("ebaySYI.syi.SuggestedCategories.populateSuggestedCategory("
+(query.name=="PrimaryCategoryQuery"?true:false)+",'"
+value+"','"
+query.value+"',"
+"true);",250);}
pageName+=ssAppend;if(typeof(ssDoRequest)=="function"){ssDoRequest();}
setTimeout("window.close();",250);}}
else if(pSaveSelection){location.href=errorURL_NoParentPage;}
else{window.close();}}
function _populateSuggestedCategory(pIsMain,pCategoryPath,pQuery,pTrack){var currentNumber=(pIsMain)?"1":"2";var currentOrdinal=(pIsMain)?"Primary":"Secondary";var field_CurrentCategory=syiForm.getField("ShowCategory");var field_CategoryOptions=syiForm.getForm().elements["Category"+currentNumber+"Option"];var field_CategoryId=syiForm.getField("Category"+currentNumber);var field_SuggestedId=syiForm.getField("Suggested"+currentOrdinal+"CategoryMetaID");var field_SuggestedQuery=syiForm.getField(currentOrdinal+"CategoryQuery");var field_ConfirmSecond=syiForm.getForm().elements["SecondaryCategoryOption"];var metaId=pCategoryPath.substring(0,pCategoryPath.indexOf(":"));var leafId=pCategoryPath.substring(pCategoryPath.lastIndexOf(":")+1);if(!pIsMain){if(field_ConfirmSecond&&field_ConfirmSecond[0]){field_ConfirmSecond[0].checked=true;}}
this.populateQueryFields(pQuery,pIsMain);if(pTrack){field_SuggestedId.value=metaId;}
if(field_SuggestedQuery)
field_SuggestedQuery.value=pQuery;field_SuggestedId.value=metaId;if(currentNumber==field_CurrentCategory.value&&pIsMain){this.updateCategorySelectionFields(pCategoryPath,field_CategoryOptions,metaId,field_CategoryId,leafId,1);}
else{if(typeof(document.applets["CatApplet"])!="undefined")
this.updateCategorySelectionFields(pCategoryPath,field_CategoryOptions,metaId,field_CategoryId,leafId,2);else
this.updateOptionalSecondaryFields(metaId,leafId);}}
function _updateCategorySelectionFields(pCategoryPath,pMetaField,pMetaId,pLeafField,pLeafId,categoryNumber){var SELECTOR_IS_APPLET=(typeof(document.applets["CatApplet"])!="undefined");var SELECTOR_IS_JAVASCRIPT=(typeof(categoryCtrl)!="undefined");var SELECTOR_IS_RADIO=(!(SELECTOR_IS_APPLET||SELECTOR_IS_JAVASCRIPT));if(SELECTOR_IS_APPLET){if(document.applets["CatApplet"].length)
document.applets["CatApplet"][categoryNumber-1].populateCategories(pCategoryPath);else
document.applets["CatApplet"].populateCategories(pCategoryPath);}
else if(SELECTOR_IS_JAVASCRIPT){categoryCtrl.clearChildren(0,categoryCtrl.maxDepth);if(typeof(pMetaField)!="undefined"&&pMetaField.options[pMetaField.selectedIndex].value!=pMetaId){for(var i=0,x=pMetaField.options.length;i<x;i++){if(pMetaField.options[i].value==pMetaId){pMetaField.selectedIndex=i;i=x;}}
pLeafField.value=pLeafId;syiForm.setField("CurrentPage","SyiLeafCategory");syiForm.setField("ButtonLoad","1");syiForm.submit();}
else{categoryCtrl.reverseLoad(pLeafId);pLeafField.value=pLeafId;}}
else if(SELECTOR_IS_RADIO){for(var i=0,x=pMetaField.length;i<x;i++){if(pMetaField[i].value==pMetaId){pMetaField[i].checked=true;i=x;}}
pLeafField.value=pLeafId;syiForm.setField("CurrentPage","SyiLeafCategory");syiForm.setField("ButtonLoad","1");syiForm.submit();}}
function _updateOptionalSecondaryFields(pMetaId,pLeafId){var field_ListInSecond=syiForm.getForm().elements["Category2Option"];if(field_ListInSecond&&field_ListInSecond.options){if(field_ListInSecond.selectedIndex==-1||field_ListInSecond.options[field_ListInSecond.selectedIndex].value!=pMetaId){syiForm.setField("Category2",pLeafId);for(var i=0,x=field_ListInSecond.options.length;i<x;i++){if(field_ListInSecond.options[i].value==pMetaId){field_ListInSecond.selectedIndex=i
i=x;}}}}
syiForm.setField("ButtonLoad","1");syiForm.submit();}
function _checkResultsSubmit(pQueryField){if(typeof(keyedEnter)!="undefined"&&keyedEnter==true){keyedEnter=false;}
else{var version=_getRequestParam(document.location.search,"version");if(version=="v2")
{selComplete(pQueryField)}
else
{this.selectionComplete(pQueryField,true);}}
return false;}
function _keyDown(pEvent){keyedEnter=ebaySYI.syi.SuggestedCategories.isKeyPressed(pEvent,KEYEVENT_ENTER);if(keyedEnter){if(window.opener){ebaySYI.syi.SuggestedCategories.newQuery((this.name=="PrimaryCategoryQuery"),this.value);}
else{ebaySYI.syi.SuggestedCategories.popSuggestionWindow((this.name=="PrimaryCategoryQuery"),this.value);}}}
this.keyDown=_keyDown;function _popSuggestionWindow(pIsMain,pQuery){var width=675;var height=550;var left=(screen.width)?(screen.width-width)/2:0;var top=(screen.height)?(screen.height-height)/2:0;var selectedCategory;var leafCategoryField=(pIsMain)?syiForm.getField("Category2"):syiForm.getField("Category1");var sessionId;if(syiForm.getField("SessionId"))
sessionId=syiForm.getField("SessionId").value;else
sessionId="";if(this.isEmptyQueryValue(pQuery)){this.writeErrorMessage(pIsMain,errorMsg_NoKeywords);}
else if(this.hasInvalidCharacter(pQuery,invalidChars)){this.writeErrorMessage(pIsMain,errorMsg_InvalidChars);}
else{this.writeErrorMessage(pIsMain,"");if(leafCategoryField&&leafCategoryField.value!=""){selectedCategory=leafCategoryField.value;}
else{selectedCategory="-1";}
var CategoryType=(pIsMain)?"1":"2";var URL=this.resultsPopupURL
+cgiURL
+"&Query="+this.specialEscape(pQuery)
+"&Format="+saleFormat
+"&SiteId="+SiteId
+"&SaleMode="+SaleMode
+"&CategoryType="+CategoryType
+"&SessionId="+sessionId
+"&isRevised=false"
+"&SelectedCategoryLeafID="+selectedCategory
+"&downgradeDomain=true";if(!top.popWindow||top.popWindow.closed){var windowOptions="width="+width
+",height="+height
+",left="+left
+",top="+top
+",resizable=yes,menubar=no,toolbar=no,scrollbars=yes";top.popWindow=window.open(URL,"CategorySuggestionWindow",windowOptions);}
else{top.popWindow.location.href=URL;}}}
function _setSecondCategory(pValue,pCategoryPath,pMode){var MODE_SUGGESTED=2;var MODE_MANUAL=1;var MODE_NONE=0;var field_ModeOptions=syiForm.getForm().elements["SecondaryCategoryOption"];var field_SecondaryMeta=syiForm.getForm().elements["Category2Option"];var field_SecondaryLeaf=syiForm.getField("Category2");var metaId=pCategoryPath.substring(0,pCategoryPath.indexOf(":"));var leafId=pCategoryPath.substring(pCategoryPath.lastIndexOf(":")+1);if(leafId=="")
leafId=pValue;if(parseInt(pMode)==MODE_MANUAL&&pValue>0){field_ModeOptions[1].checked=true;}
for(var i=0,x=field_ModeOptions.length;i<x;i++){if(field_ModeOptions[i].checked){pMode=field_ModeOptions[i].value;i=x;}}
switch(parseInt(pMode)){case 0:field_SecondaryLeaf.value="";field_SecondaryMeta.selectedIndex=-1;break;case 1:if(field_SecondaryMeta.selectedIndex==-1){for(var i=0,x=field_SecondaryMeta.options.length;i<x;i++){if(field_SecondaryMeta.options[i].value==metaId){field_SecondaryMeta.selectedIndex=i;i=x;}}}
field_SecondaryLeaf.value="";break;case 2:field_SecondaryLeaf.value=leafId;field_SecondaryMeta.selectedIndex=-1;break;}}
function _checkSellItemFormSubmit(){if(typeof(keyedEnter)!="undefined"&&keyedEnter==true){keyedEnter=false;return false;}
return true;}
function _getRequestParam(pQuery,pParam){var params=pQuery.split("&");var param;for(var i=0,x=params.length;i<x;i++){param=params[i].split("=");if(param[0]&&param[1]&&param[0]==pParam){return param[1];}}
return"";}
function _evalParams(){var params=document.location.search.substr(1).split("&");for(var i=0;i<params.length;i++){var p=decodeURIComponent(params[i]).split("=");if(p[1]){if(!this.isRestrictedParam(p[0])){var eStr="this."+p[0]+"=";if((p[1]=="true")||(p[1]=="false"))
eStr+=p[1]+";";else
{var tmp="";for(var j=0;j<p[1].length;j++)
{if(p[1].charAt(j)=="'")
tmp+="\\'";else
tmp+=p[1].charAt(j);}
p[1]=tmp;eStr+="'"+p[1]+"';";}
eval(eStr);}}}}
function _isRestrictedParam(pName){for(var i=0,x=this.restrictedParams.length;i<x;i++){if(this.restrictedParams[i]==pName){return true;}}
return false;}
function _isEmptyQueryValue(pString){if(pString==""){return true;}
return(this.isAllSpaces(pString));}
function _isAllSpaces(pString){for(var i=0,x=pString.length;i<x;i++){if(pString.charAt(i)!=' '){return false;}}
return true;}
function _hasInvalidCharacter(pString,pInvalidChars){var currentChar;for(var i=0,x=pString.length;i<x;i++){currentChar=pString.charAt(i);for(var j=0,y=pInvalidChars.length;j<y;j++){if(currentChar==pInvalidChars[j]){return true;}}}
return false;}
function _specialEscape(pString){return encodeURIComponent(pString);}
function _populateQueryFields(pQuery,pIsMain){var primaryField=syiForm.getField("PrimaryCategoryQuery");var secondaryField=syiForm.getField("SecondaryCategoryQuery");if(primaryField&&pIsMain){primaryField.value=pQuery;if(secondaryField&&secondaryField.value==""){secondaryField.value=pQuery;}}
if(secondaryField&&!pIsMain){secondaryField.value=pQuery;if(primaryField&&primaryField.value==""){primaryField.value=pQuery;}}}
function _writeErrorMessage(pIsMain,pErrorString){var containerId="PrimaryCategoryQueryError";if(!pIsMain){containerId="SecondaryCategoryQueryError";}
var container=this.getElementById(containerId);if(container!=null){if(pErrorString!=""){container.innerHTML="<img src='"+errorImageURL+"'>&nbsp;"+pErrorString;}
else{container.innerHTML="&nbsp;";}}
else if(pErrorString!=""){outputString=pErrorString.substring((pErrorString.indexOf(">")+1),(pErrorString.lastIndexOf("<")-1))}}
function _isValidPage(pPageName){if(typeof(pPageName)=="string"){for(var i=0,x=this.validPages.length;i<x;i++){if(pPageName.substring(pPageName.length-this.validPages[i].length)==this.validPages[i]){return true;}}}
return false;}
function _siteIs(pSiteId){if(typeof(SiteId)!="undefined"&&SiteId==pSiteId){return true;}
else if(syiForm.getField("SiteId")&&syiForm.getField("SiteId").value==pSiteId){return true;}
return false;}
function _isKeyPressed(pEvent,pKeyId){if(document.all){return(event.keyCode==pKeyId);}
else{return(pEvent.which==pKeyId);}}
function _getElementById(pId){if(document.all&&document.all[pId]){return document.all[pId];}
if(document.getElementById&&document.getElementById(pId)!=null){return document.getElementById(pId);}
return null;}
function _checkCompatible(){return true;}
function _checkConfigured(){if(!document.eBayLoaded||!document.eBayLoaded.config){this.throwConfigError("config file not found");return false;}
if(config.VALID_FOR!="SYI"){this.throwConfigError("config file found for '"
+config.VALID_FOR
+"' rather than than 'SYI'");return false;}
return true;}
function _setL2CSuggestedCategories(radios,index){if(typeof(radios)=="undefined")
return;if(typeof(parent.opener.suggestedL2CReco)!="undefined"){var arrSuggestion=new Array;if(radios.length>3)
arrSuggestion.length=3;else
arrSuggestion.length=radios.length-1;var c=0;for(var i=0;i<arrSuggestion.length+1;i++){if(c>2)
break;if(i!=index){arrSuggestion[c]=i;c++;}}
if(arrSuggestion.length>0){var catTextElement=new Array;if(syiForm.getForm().Categories_Text)
catTextElement=syiForm.getForm().Categories_Text;for(var j=0;j<arrSuggestion.length;j++){var val,catVal,catPath;if(radios[arrSuggestion[j]]){val=radios[arrSuggestion[j]].value;catVal=val.substring(val.lastIndexOf(":")+1);}
if(catTextElement[arrSuggestion[j]])
catPath=catTextElement[arrSuggestion[j]].value;parent.opener.suggestedL2CReco[j]=catVal+"."+catPath;}}}}
function _throwConfigError(msg){var out="============================================================"
+"\n"
+"[configuration error]"
+"\n"
+"file:\tSuggestedCategories.js"
+"\n"
+"message:\t"+msg
+"\n"
+"============================================================";alert(out);}}
var cgiURLError='http://scat.ebay.com/ws/eBayISAPI.dll?SYIFindSuggestedCategories&currentpage=';var noParentErrorURL=cgiURLError+'&errorCode=10';var nonCatPageErrorURL=cgiURLError+'&errorCode=10';var validSYIPages=new Array("PageSYI_CatMetaFixedPrice","PageSYI_CatMeta_Motors","PageRYI_CatMeta","PageSYI_CatMeta","PageSYI_CatLeafFixedPrice","PageSYI_CatLeaf_Motors","PageRYI_CatLeaf","PageSYI_CatLeaf");function selComplete(pSave,pCat)
{var wo=window.opener;if(wo&&!wo.closed)
{var validPage=false;if(typeof(wo.pageName)=="string")
{for(var i=0;i<validSYIPages.length&&!validPage;i++)
{var name=wo.pageName.substr(wo.pageName.length-validSYIPages[i].length);if(name==validSYIPages[i])
validPage=true;}}
if(!validPage&&pSave)
location.href=nonCatPageErrorURL;else
{var str="Cancel";if(pSave)
{str="Cat";var radios=syiForm.getForm().Categories;if(pCat)
{val=pCat;}
else if(radios.length)
{for(var i=0;i<radios.length;i++)
{if(radios[i].checked)
{val=radios[i].value;if(i==0)
str+="1";else if(i<3)
str+="2.3";else
str+="4";i=radios.length;}}}
else
{val=radios.value;str+="1";}
query=document.CategorySuggestion.PrimaryCategoryQuery.value;wo.setTimeout("populateMainSuggestedCategory('"+val+"','"+query+"',true);",250);}
pageName+=str;if(typeof(ssDoRequest)=="function")
ssDoRequest();window.setTimeout("window.close();",250);}}
else if(pSave)
location.href=noParentErrorURL;else
window.close();}
// b=10633012 -->