var ss_machine = "http://include.ebay.com/"; // machine these files are hosted on
var ss_path = "aw/pics/js/"; //  and path to the files
var cbc;
function ReadCookie(name){
	var allCookie, cookieVal, length, start, end;
	cookieVal="";
	name=name+"=";
	allCookie=document.cookie;
	length=allCookie.length;
	if (length>0){
		start=allCookie.indexOf(name, 0);
		if (start!=-1){
			start+=name.length;
			end=allCookie.indexOf(";",start);
			if (end==-1) {
				end=length;
			}
			cookieVal=unescape(allCookie.substring(start,end));
		}
	}
	return(cookieVal);
}
function WriteCookie(name,value,domain,path,expires,secure){ 
	var CookieVal, CookError;
	CookieVal=CookError="";
	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();
	}
	if (secure){
		CookieVal=CookieVal+"; secure="+secure;
	}
	else{
		CookError=CookError+"Write failure";
	}
	document.cookie=CookieVal;  // sets the cookie
}
function DeleteCookie (name,domain,path){
   var expireDate=new Date(1);
   if (ReadCookie(name)){
      WriteCookie(name, " ", domain, path, expireDate);
   }
}
function writeStatsCode(){
	document.write("<SCRIPT SRC=\"" + ss_machine + ss_path + "stats/ss_main.js\"></SCRIPT>");
}
var CookieDomain = ".ebay.com";
var thisHost = location.hostname.toLowerCase();
if (thisHost.indexOf(".ebay") > 0){
	CookieDomain = thisHost.substring(thisHost.indexOf(".ebay"));
}
var x = ReadCookie('lucky');
if (x.length < 1){
	x = new Date();
	x = x.getTime() % 100000;
	if(location.href.indexOf('.qa.ebay.com') > 0)x=10;
	var expires = new Date();
	expires.setYear(expires.getYear() + 5);//expire in 5 years; we're not worried about y2k here
	WriteCookie("lucky",x,CookieDomain,"/",expires);
}
if (x > 100 && x <= 200){
		writeStatsCode();
}