//<!--
//\include\js\popout\epoll_determine.js@@\main\1

var NOREG="NONREG";var INACT="INACTIVE";var ACTIV="ACTIVE";var ALL="ALL";var gSurveys;var gTokens;function readMultiCookie(cook,cooklet){cook+="=";if(cooklet)cooklet+="=";var thisCookie=document.cookie;if(!cooklet)return"";var pos1=thisCookie.indexOf(cook);if(pos1!=-1){var start1=pos1+(cook.length);var end1=thisCookie.indexOf(";",start1);if(end1==-1)end1=thisCookie.length;var value=unescape(thisCookie.substring(start1,end1));var pos2=value.indexOf(cooklet);if((pos2!=-1)){var start2=pos2+(cooklet.length);var end2=value.indexOf("^",start2);if(end2==-1)end2=value.length;value=unescape(value.substring(start2,end2));return value;}}
else return'';}
function writeMultiCookie(name,cooklet,value,domain,path,expires){if(ReadCookie(name)){var curContent=ReadCookie(name);if(curContent.indexOf("^")==-1){var curStart=curContent.indexOf("=");if(curContent.indexOf("^")!=curStart+1)curContent=curContent.substring(0,curStart)+"^";}}
else curContent="^";if(cooklet){var pre,post,end;var pos2=curContent.indexOf(cooklet);if(pos2==-1){pos2=curContent.length;post=curContent.substring(curContent.lastIndexOf("^",pos2)+1);}
else post=curContent.substring(curContent.indexOf("^",pos2)+1);pre=curContent.substring(0,pos2);if(pre==post)post="";value=pre+post+cooklet+"="+value+"^";}
else value=curContent;var CookieVal="";if(name)CookieVal=CookieVal+escape(name)+"=";if(value)CookieVal=CookieVal+escape(value);if(domain)CookieVal=CookieVal+"; domain="+domain;if(path)CookieVal=CookieVal+"; path="+path;if(expires)CookieVal=CookieVal+"; expires="+expires.toGMTString();document.cookie=CookieVal;}
function epShown(){if(ReadCookie("exitpoll")=="shown"||ReadCookie("surveySays")=="shown")
{return true;}
else
{return false;}}
function epIsFromPartner()
{if(lastPageURL.indexOf("google")>-1)
return true;}
function epPop(url){epSetCookie();window.open(url,"epSurvey","height=480,width=640,location=yes,scrolling=auto,status=yes");}
function epSetCookie(){var today=new Date();today.setMonth(today.getMonth()+3);WriteCookie("exitpoll","shown",CookieDomain,"/",today);}
function determineToLoadSurvey()
{var loadedSurveys=false;var loadedLibrary=false;var file="";if(!epShown()&&!epIsFromPartner())
{loadedLibrary=true;if(loadedLibrary)
{gSurveys=new SurveyHolder();var x=getURLParam("config");if(x!="")
{file=includeDir+"popout/"+x+".js";document.write(scriptOpen+file+scriptClose);}
else
{file=countryIncludeDir+"popout/exitsurveys.js";document.write(scriptOpen+file+scriptClose);}}}}
function wait()
{}
function getURLParam(name)
{var searchString=unescape(document.location.search.substring(1,document.location.search.length));var param=searchString.split("&");var spotName="";for(i=0;i<param.length;i++)
{tempParam=param[i].split("=");if(tempParam[0].toLowerCase()==name)
{spotName=tempParam[1];}}
return spotName;}
function epUser()
{this.segGeneric;this.buyerSeg="";this.sellerSeg="";this.determineSegment=_epSegment;}
function _epSegment()
{var CC1=readMultiCookie("reg","bibo");if(!((CC1=="")||(CC1==null)||(typeof(CC1)=='undefined')))
{var x=CC1.split("#");for(var i=0;i<x.length;i++)
{var supersegment=x[i].substring(0,1);var subsegment=parseInt(x[i].substring(1,x[i].length));if(supersegment=="B")
{this.buyerSeg=subsegment;}
else if(supersegment=="S")
{this.sellerSeg=subsegment;}
if(x[i]=="B0")
{this.segGeneric=INACT;}
else if(supersegment=="B"&&subsegment>0)
{this.segGeneric=ACTIV;}}}
else
{this.segGeneric=NOREG;}}
function SurveyHolder()
{this.eBaySurveys=new Array(1);this.addSurvey=b_addSurvey;this.getSurvey=b_getSurvey;this.dWhichSurvey=_dSurveyToShow;}
function _dSurveyToShow(user)
{for(var i=1;i<this.eBaySurveys.length;i++)
{var s=this.eBaySurveys[i];if(s.getOnOff())
{if(isInSegment(user,s)&&s.determineIsInSample())
{return s;}}}
return false;}
function isInSegment(user,survey)
{var supersegment=survey.targetSegment.substring(0,1);var subsegment=parseInt(survey.targetSegment.substring(1,survey.targetSegment.length));if(survey.targetSegment==ALL)
{return true;}
else if(supersegment=="B"&&user.buyerSeg==subsegment)
{return true;}
else if(supersegment=="S"&&user.sellerSeg==subsegment)
{return true;}
else if(survey.targetSegment==NOREG&&user.segGeneric==NOREG)
{return true;}
else if(survey.targetSegment==ACTIV&&user.segGeneric==ACTIV)
{return true;}
else if(survey.targetSegment==INACT&&user.segGeneric==INACT)
{return true;}
else
{return false;}}
function b_getSurvey(id)
{return this.eBaySurveys[id];}
function b_addSurvey(targetSegment,samplingRate,surveyType,linkTemplate,startDate,expDate,linkGif)
{var x=new Survey();x.setSurveyID(this.eBaySurveys.length)
x.setTargetSegment(targetSegment);x.setSamplingRate(samplingRate);x.setSurveyType(surveyType);x.setLinkTemplate(linkTemplate);x.setStartDate(startDate);x.setExpDate(expDate);x.setLinkGif(linkGif);x.determineIsOn();this.eBaySurveys[this.eBaySurveys.length++]=x;}
function Survey()
{this.surveyID;this.targetSegment;this.samplingRate;this.surveyType;this.linkTemplate;this.startDate;this.expDate;this.onoff;this.linkgif;this.getSurveyID=g_SurveyID;this.setSurveyID=s_SurveyID;this.getTargetSegment=g_TargetSegment;this.setTargetSegment=s_TargetSegment;this.getSamplingRate=g_SamplingRate;this.setSamplingRate=s_SamplingRate;this.getSurveyType=g_SurveyType;this.setSurveyType=s_SurveyType;this.getLinkTemplate=g_LinkTemplate;this.setLinkTemplate=s_LinkTemplate;this.getStartDate=g_StartDate;this.setStartDate=s_StartDate;this.getExpDate=g_ExpDate;this.setExpDate=s_ExpDate;this.getOnOff=g_OnOff;this.setLinkGif=s_LinkGif;this.getLinkGif=g_LinkGif;this.determineIsOn=b_IsOn;this.determineIsInSample=_dIsInSample;this.showSurvey=_showSurvey;}
function outputStringToDisplay(str){if(is.nav==true&&is.ver==4)
{with(document.displayID.document){open();str='<SPAN STYLE="position: relative;">'+str+'</SPAN>';write(str);close();}}
else if(is.nav&&is.ver>=5){document.getElementById("displayID").innerHTML=str;}
else if(document.all)
{document.all.foundSoFar.innerHTML=str;}
else(document.getElementById())
{divel=document.createElement("DIV");hitxt=document.createTextNode(str);}}
function _showSurvey(bPopup)
{if(typeof(gSurveys)=='undefined'||typeof(gSurveys.getSurvey(1))=='undefined')
{return false;}
var user=new epUser();user.determineSegment();var popup=gSurveys.dWhichSurvey(user);if(!popup)
{return false;}
gTokens=new URLTokenHolder();gTokens.addToken('SBR',(typeof(SBR)!='undefined'?SBR:''));gTokens.addToken('SITEID',(typeof(SiteId)!='undefined'?SiteId:''));gTokens.addToken('SEGMENT',(typeof(popup.getTargetSegment())!='undefined'?popup.getTargetSegment():''));gTokens.addToken('SURVEYTYPE',(typeof(popup.getSurveyType())!='undefined'?popup.getSurveyType():''));gTokens.addToken('COMPLETED_SURVEY',(readMultiCookie('exitpoll','shown')!=''?readMultiCookie('exitpoll','shown'):''));gTokens.replaceTokens(popup);if(!bPopup)
{if(popup.getSurveyType()=="LINK"||popup.getSurveyType()=="LINKPOPUP")
{var str="";if(pageName.indexOf("PageViewSellersOtherItems")!=-1)
{str="<a href=\"#\" onclick=\"epPop('"+popup.getLinkTemplate()+"');return false;\" target=\"_new\"><img border=\"0\" src=\"http:\/\/pics.ebay.com\/aw\/pics\/exitpolls\/"+country+"_SOI_exitPoll_88x31.gif\"><\/a>";outputStringToDisplay(str);return true;}
else
{str="<a href=\"#\" onclick=\"epPop('"+popup.getLinkTemplate()+"');return false;\" target=\"_new\"><img src=\"http:\/\/pics.ebay.com/aw/pics/exitpolls/"+country+"_exitPollBanner_580x60.gif\" border=\"0\"></a>";document.write(str);return true;}}
return false;}
else if(bPopup)
{var type=popup.getSurveyType();if(type=="LINKPOPUP"||type=="POPUP")
{showExitPollSurveyWindow(popup.getLinkTemplate(),480,640);return true;}}
return false;}
function showSideSurveyUI()
{var s=new Survey();return s.showSurvey(false);}
function checkForSurvey()
{if(!is.nav)
{var s=new Survey();s.showSurvey(true);}}
function _dIsInSample()
{var max=this.samplingRate;var x=Math.round(Math.random()*(max-1));var y=x==(max-1);return y;}
function s_SurveyID(a){this.surveyID=a;}
function g_SurveyID(){return this.surveyID;}
function g_TargetSegment(){return this.targetSegment;}
function s_TargetSegment(a){this.targetSegment=a;}
function g_SamplingRate(){return this.samplingRate;}
function s_SamplingRate(a){this.samplingRate=a;}
function g_SurveyType(){return this.surveyType;}
function s_SurveyType(a){this.surveyType=a;}
function g_LinkTemplate(){return this.linkTemplate;}
function s_LinkTemplate(a){this.linkTemplate=a;}
function g_StartDate(){return this.startDate;}
function s_StartDate(a){this.startDate=new Date(a);}
function g_ExpDate(){return this.expDate;}
function s_ExpDate(a){this.expDate=new Date(a);}
function g_OnOff(){return this.onoff;}
function g_LinkGif(){return this.linkGif;}
function s_LinkGif(a){this.linkGif=a}
function b_IsOn()
{var today=new Date();if(this.startDate-today>0)
{this.onoff=false;}
else if(this.expDate-today<0)
{this.onoff=false;}
else
{this.onoff=true;}}
function URLTokenHolder()
{this.eBayURLParamArray=new Array();this.addToken=b_addToken;this.replaceTokens=rTokens;}
function URLTokens(name,value)
{this.name=name;this.value=value;}
function eBayEncodeURL(strURL)
{var newURL=escape(strURL);return newURL;}
function b_addToken(name,value)
{this.eBayURLParamArray[name]=new URLTokens(name,value);}
function rTokens(survey)
{var temp=survey.linkTemplate;for(j in this.eBayURLParamArray)
{temp=eBayReplace(temp,"["+this.eBayURLParamArray[j].name+"]",this.eBayURLParamArray[j].value);}
survey.linkTemplate=temp;}
function eBayReplace(s,t,u)
{i=s.indexOf(t);r="";if(i==-1)return s;r+=s.substring(0,i)+u;if(i+t.length<s.length)
r+=eBayReplace(s.substring(i+t.length,s.length),t,u);return r;}
// -->
