//<!--
//\include\js\finding\encode_url_e375.js@@\main\e379_caboose\4

var URL_ENCODING_ENABLED=true;var TITLE_NAME='satitle';var CATEGORY_NAME='sacategory';var VCS_NAME='povcs';var SEARCH_TITLE='poqry';var searchTerm='';var pfAttributes='';var isSubmitFromProductPages='false';var DisplayProductFinderValues='false';var AccentSymbol=['Á','á','À','à','Â','â','Ä','ä','Ã','ã','Å','å','Æ','æ','Ç','ç','É','é','È','è','Ê','ê','Ë','ë','ƒ','Ì','ì','Î','î','Ï','ï','í','í','Ñ','ñ','Ó','ó','Ô','ô','Ö','ö','Õ','õ','ò','ò','ß','Ú','ú','Ù','ù','Û','û','Ü','ü','Ý','ý'];var AsciiSymbol=['A','a','A','a','A','a','A','a','A','a','A','a','E','e','C','c','E','e','E','e','E','e','E','e','f','I','i','I','i','I','i','i','i','N','n','o','o','O','o','O','o','O','o','o','o','s','U','u','U','u','U','u','U','u','Y','y'];var excludeOptionValues=new Array();function isEncodingEnabled()
{return URL_ENCODING_ENABLED;}
function encodeUrl(pHost,pForm,pSiteId,pReturnUrl)
{if(typeof isAttributePage!='undefined'&&typeof pForm.sofocus!='undefined'&&pForm.sofocus.value=='pf')
{DisplayProductFinderValues='true';}
searchTerm=pForm.elements[TITLE_NAME].value;var catObj=pForm.elements[CATEGORY_NAME];var catName='';var catValue='';var si='';var index=-1;if(catObj!=null&&typeof catObj.type!='undefined')
{if(catObj.type=='select-one')
{si=catObj.selectedIndex;if(si>=0){catValue=catObj.options[si].value;index=catValue.indexOf("&");if(index!=-1)
catValue=catValue.substring(0,index);if((catValue.length>0)&&(catValue!=-1)&&(catValue!=6000))
if(catValue==-100)
catName=catObj.options[si+1].text;else
catName=catObj.options[si].text;}}}
var umlauts=false;var params=getFormElementArray(pForm);if(DisplayProductFinderValues=='true')
{pfAttributes=getPFElementsArray(pForm);}
var exclude=new Array(TITLE_NAME,"query2","cgiurl","siteid","ebaytag1code_tmp","ebaytag1_tmp","worldlocation");excludeOptionValues['ebaycurr']='999';excludeOptionValues['ht']='1';var buttonObj='';for(var i=0;i<pForm.elements.length;i++)
{buttonObj=pForm.elements[i];if(buttonObj.type=='button'||buttonObj.type=='submit')
exclude=addToExclude(buttonObj.name,exclude);}
if(pSiteId==16||pSiteId==77||pSiteId==193)
umlauts=true;return encodeEbayUrl(pHost,searchTerm,catName,pfAttributes,params,exclude,umlauts,pReturnUrl);}
function encodeProductUrl(pHost,pForm,pSiteId,pReturnUrl)
{var pageFromProdPage=pForm.elements['optprodpage'];if(typeof pageFromProdPage!='undefined')
{isSubmitFromProductPages='true';}
searchTerm=pForm.elements[SEARCH_TITLE].value;var catObj=pForm.elements[VCS_NAME];var catName='';var catValue='';var si='';var index=-1;if(catObj!=null&&typeof catObj.type!='undefined'&&catObj.type!='hidden')
{if(catObj.type=='select-one')
{si=catObj.selectedIndex;if(si>=0){catValue=catObj.options[si].value;index=catValue.indexOf("&");if(index!=-1)
catValue=catValue.substring(0,index);if((catValue.length>0)&&(catValue!=-1)&&(catValue!=6000))
catName=catObj.options[si].text;}}}
else
{catName=pForm.elements.popnm.value;}
var umlauts=false;var params=getFormElementArray(pForm);var exclude=new Array(TITLE_NAME,"query2","cgiurl","siteid","ebaytag1code_tmp","ebaytag1_tmp","worldlocation");excludeOptionValues['ebaycurr']='999';excludeOptionValues['ht']='1';var buttonObj='';for(var i=0;i<pForm.elements.length;i++)
{buttonObj=pForm.elements[i];if(buttonObj.type=='button'||buttonObj.type=='submit')
exclude=addToExclude(buttonObj.name,exclude);}
if(pSiteId==16||pSiteId==77||pSiteId==193)
umlauts=true;return encodeEbayUrl(pHost,searchTerm,catName,pfAttributes,params,exclude,umlauts,pReturnUrl);}
function encodeEbayUrl(pHost,pSearchTerm,pCategoryName,pPFAttributes,pParams,pExclude,pUmlauts,pReturnUrl)
{if(pReturnUrl==null)pReturnUrl=false;var myEbayUrl=new ebayUrl(pHost,pSearchTerm,pCategoryName,pPFAttributes,pParams,pExclude,pUmlauts);if(isValidUrl(myEbayUrl.encodedUrl))
{if(pReturnUrl)
{return myEbayUrl.encodedUrl;}
else
{window.location.href=myEbayUrl.encodedUrl;return false;}}
else{return true;}}
function ebayUrl(pHost,pSearchTerm,pCategoryName,pPFAttributes,pParams,pExclude,pUmlauts)
{this.addTitle=false;this.urlHost=pHost;this.searchTerm=pSearchTerm;this.categoryName=pCategoryName;this.params=pParams;this.exclude=pExclude;this.umlauts=pUmlauts;this.formattedUrlHost=this.formatHost(this.urlHost);this.encodedSearchTerm=this.encodeSearchTerm(this.searchTerm,this.umlauts,true);this.encodedCategoryName=this.encodeCategoryName(this.categoryName,this.umlauts);this.encodedParams=this.encodeParams(this.params,this.exclude,this.addTitle);if(DisplayProductFinderValues=='true')
{this.pfAttributes=pPFAttributes;this.encodedPFAttributes=this.encodePFAttributes(this.pfAttributes,this.umlauts);this.encodedUrl=this.formattedUrlHost+this.encodedSearchTerm+this.encodedCategoryName+this.encodedPFAttributes+this.encodedParams;}
else
this.encodedUrl=this.formattedUrlHost+this.encodedSearchTerm+this.encodedCategoryName+this.encodedParams;}
ebayUrl.prototype.formatHost=checkHost;ebayUrl.prototype.encodeSearchTerm=convertSearchTerm;ebayUrl.prototype.encodeCategoryName=convertCategoryName;ebayUrl.prototype.encodeParams=convertParams
ebayUrl.prototype.encodeSeoString=convertToSeoString;ebayUrl.prototype.encodePFAttributes=convertPFAttributes;function checkHost(pStr)
{var str=pStr;if(typeof str!='string')
str='/';else if(!(str.charAt(str.length-1)=='/'))
str+='/';return str;}
function convertSearchTerm(pStr,pUmlauts,pTitle)
{var str=pStr;var newStr='';if(str==''||str==null)return'';else
{newStr=this.encodeSeoString(str,pUmlauts,pTitle);}
return newStr;}
function convertCategoryName(pStr,pUmlauts)
{var str=pStr;var newStr='';if(str==''||str==null)return'';else
{newStr=this.encodeSeoString(str,pUmlauts);if(newStr!='')newStr='_'+newStr;}
return newStr;}
function convertPFAttributes(pfArray,pUmlauts)
{var newStr='';for(i=0;i<pfArray.length;i++){var str=pfArray[i];if(str!=''&&str!=null)
{if(i==0)
newStr=this.encodeSeoString(str,pUmlauts);else
newStr+='-'+this.encodeSeoString(str,pUmlauts);}}
if(newStr!='')newStr='_'+newStr;return newStr;}
function convertToSeoString(pStr,pUmlauts,pTitle)
{var str=pStr;var umlauts=pUmlauts;var spaceOnly=true;var convStr='';var skipping=false;var pos=0;var c='';if(str==null||(typeof str.length=='undefined'||1>str.length))
return'';str=str.trim();for(var i=0;i<str.length;i++)
{c=str.charAt(i);if(c.match(/[A-Za-z0-9]/))
{convStr+=c;skipping=false;}
else if((pos=charAsciiReplace(c))>=0)
{convStr+=AsciiSymbol[pos];if(umlauts&&(c=='ä'||c=='ö'||c=='ü'))
convStr+='e';else if(umlauts&&(c=='ß'))
convStr+='s';skipping=false;spaceOnly=false;}
else if(c=='\'')
spaceOnly=false;else if(!skipping)
{if(c!=' ')spaceOnly=false;convStr+='-';skipping=true;}
else
if(c!=' ')spaceOnly=false;}
if(convStr.charAt(0)=='-')
convStr=convStr.substring(1);if(convStr.charAt(convStr.length-1)=='-')
convStr=convStr.substring(0,convStr.length-1);if(pTitle)
{if(!spaceOnly)
{if(typeof this.addTitle!='undefined')
this.addTitle=true;}}
return convStr;}
function convertParams(pParams,pExclude)
{var paramList='';var defaultForm=document.forms[0];var exclude=pExclude;if(this.addTitle)
exclude=removeFromExclude(TITLE_NAME,exclude);if(pParams=='')
{var tempArray=getFormElementArray(defaultForm);paramList+=convertFormElementArray(tempArray,exclude);}
else if(isArray(pParams))
paramList+=convertFormElementArray(pParams,exclude);else
paramList='';if(paramList!='')paramList='_W0'+paramList;return(paramList);}
function convertFormElementArray(pArray,pExclude)
{var convertedString='';var excludeStr=pExclude.toString();var excludePattern='';for(var i=0;i<pArray.length;i++)
{var obj=pArray[i];var objName='';var objValue='';if((isArray(obj)&&(typeof obj.type=='undefined')))
{for(var j=0;j<obj.length;j++)
{objName=obj[j].name;excludePattern=new RegExp(objName);if(excludeStr.search(excludePattern)==-1)
{objValue=getElementValue(obj[j]);if(objValue!=null&&objValue.length>0&&typeof objValue!='undefined')
{convertedString+=encodeParam(objName,objValue);}}}}
else
{objName=obj.name;excludePattern=new RegExp(objName);if(excludeStr.search(excludePattern)==-1)
{objValue=getElementValue(obj);if(objValue!=null&&objValue.length>0&&typeof objValue!='undefined')
{convertedString+=encodeParam(obj.name,getElementValue(obj));}}}}
return convertedString;}
function encodeParam(pName,pValue)
{var strName=escape(pName);var strValue=escape(pValue);var strParam='';strName=strName.replace(/[Z]/g,'%5A');strName=strName.replace(/[Q]/g,'%51');strValue=strValue.replace(/[Z]/g,'%5A');strValue=strValue.replace(/[Q]/g,'%51');strParam='QQ'+strName+'Z'+strValue;strParam=strParam.replace(/[%]/g,'Q');return strParam;}
function escapeParams(pStr)
{var str=pStr;str=escape(str);str=str.replace(/[%]/g,"Q");return str;}
function removeFromExclude(pName,pExclude)
{var pos=null;var exclude=new Array();if(!isArray(pExclude))
return null;for(var i=0;i<pExclude.length;i++)
{if(pName==pExclude[i])pos=i;}
if(pos!=null)
{if(!(pExclude.length==1&&pos==0))
{if(pos==0)
exclude=pExclude.slice(1);else if(pos==pExclude.length-1)
exclude=pExclude.slice(0,pExclude.length-1);else
{for(var i=0;i<pExclude.length;i++)
{if(pos!=i)
exclude[exclude.length]=pExclude[i];}}}}
return exclude;}
function addToExclude(pName,pExclude)
{var exclude=new Array();if(!isArray(pExclude))
return null;if(typeof pName!='string')
return null;if(pName!='')
{exclude=pExclude;exclude[exclude.length]=pName;return exclude;}
else
{return pExclude;}}
function getFormElementArray(pForm)
{var elementName='';var elementArray=new Array();var currentElement='';for(var i=0;i<pForm.elements.length;i++)
{currentElement=pForm.elements[i];if(currentElement.name!=elementName&&currentElement.name!='')
{elementName=currentElement.name;elementArray[elementArray.length]=pForm.elements[currentElement.name];}}
return elementArray;}
function getPFElementsArray(pForm)
{var alist=pForm.elements.alist.value;var elementArray=new Array();var pfArray=new Array();elementArray=alist.split(",");for(var i=0;i<pForm.elements.length;i++)
{for(j=0;j<elementArray.length-1;j++)
{if(pForm.elements[i].name==elementArray[j])
{si=pForm.elements[i].selectedIndex;if(si>0){pfArray[pfArray.length]=pForm.elements[i].options[si].text;}}}}
return pfArray;}
function getElementValue(pObj)
{switch(pObj.type)
{case"button":case"submit":case"reset":case"text":case"textarea":case"hidden":case"file":return pObj.value;break;case"checkbox":case"radio":if(pObj.checked)return pObj.value;break;case"select-one":if(pObj.selectedIndex<0)
return null;else
{var excludeValue=excludeOptionValues[pObj.name]
if(excludeValue!=null)
{var paramValue=pObj.options[pObj.selectedIndex].value;var index=paramValue.indexOf("&");if(index!=-1)
paramValue=paramValue.substring(0,index);if(paramValue==excludeValue)
return null;}
else if(pObj.name=='saavailabletocountry')
{if(pObj.options[pObj.selectedIndex].value==0)
{pObj.options[pObj.selectedIndex].value='999';return pObj.options[pObj.selectedIndex].value;}}
else if(pObj.name=='salocatedincountry')
{if(pObj.options[pObj.selectedIndex].value==0)
{pObj.options[pObj.selectedIndex].value='-15';return pObj.options[pObj.selectedIndex].value;}}
else if(pObj.name=='sacqtyop')
{return pObj.options[pObj.selectedIndex].value;}
else if(pObj.name=='sosortproperty')
{return pObj.options[pObj.selectedIndex].value;}
else if(pObj.name=='sorecordsperpage')
{return pObj.options[pObj.selectedIndex].value;}
else if(pObj.name=='sadistance')
{return pObj.options[pObj.selectedIndex].value;}
else if(pObj.name=='sotr')
{return pObj.options[pObj.selectedIndex].value;}
else if(pObj.name=='saslop')
{return pObj.options[pObj.selectedIndex].value;}
else if(pObj.name=='sacategory')
{return pObj.options[pObj.selectedIndex].value;}
else if(pObj.name=='sosellercombine')
{return pObj.options[pObj.selectedIndex].value;}
else if(pObj.selectedIndex==0&&isSubmitFromProductPages=='false')
return null;}
return pObj.options[pObj.selectedIndex].value;break;case"select-multiple":var multiArray=new Array();for(var i=0;i<pObj.options.length;i++)
{if(pObj.options[i].selected)
multiArray[multiArray.length]=pObj.options[i].value;}
return multiArray.join(',');break;}}
function getElementInFormByName(pForm,pName)
{var myForm=document.forms[pForm];for(var i=0;i<myForm.elements.length;i++)
{if(myForm.elements[i].name==pName)
return myForm.elements[i];}
return null;}
function isArray(pObj)
{if(typeof pObj=='object')
return(typeof pObj.length=='undefined')?false:true;else return false;}
function isValidUrl(pUrl)
{if(typeof pUrl=='undefined')return false;else if(pUrl=='')return false;else if(pUrl==null)return false;else return true;}
function charAsciiReplace(pChar)
{var c=pChar;for(var i=0;i<AccentSymbol.length;i++)
{if(c==AccentSymbol[i])return i;}
return-1;}
function debugEbayUrl(pObj)
{alert('OBJECT INFO:\n'+'urlHost: '+pObj.urlHost+'\nsearchTerm: '+pObj.searchTerm+'\ncategoryName: '+pObj.categoryName+'\nparams length: '+pObj.params.length+'\nformattedUrlHost: '+pObj.formattedUrlHost+'\nencodedSearchTerm: '+pObj.encodedSearchTerm+'\nencodedCategoryName: '+pObj.encodedCategoryName+'\nencodedParams: '+pObj.encodedParams+'\nencodedUrl: '+pObj.encodedUrl)}
function debugObject(pObj)
{alert('Type: '+pObj.type+'\nName: '+pObj.name+'\nValue: '+pObj.value+'\nLength: '+pObj.length+'\nTypeofLength: '+typeof pObj.length);}
function strLTrim()
{return this.replace(/^\s+/,'');}
function strRTrim()
{return this.replace(/\s+$/,'');}
function strTrim()
{return this.replace(/^\s+/,'').replace(/\s+$/,'');}
String.prototype.lTrim=strLTrim;String.prototype.rTrim=strRTrim;String.prototype.trim=strTrim;
// -->
