/****************************************************************************************************
** JS Cobrand (cobrand_top.js)
** Anna Baum for DE 3/2001: Tim Michaels (tmichaels) 11/16/00
** Description: Allows a single page to display cobranded elements based on current and previous
** URL and, in some cases, parameters passed by the ISAPI code.  Cobranded elements include headers
** and footers, promos, links, forms actions, and certain form attributes.  SSI vars are defined    
** in localdefs.  Available functions: ReadCookie(name); DeleteCookie (name,domain,path);
** WriteCookie(name,value,domain,path,expires,secure); cobrandLinks(); cobrandFormRedirect(chosen);
** cobrandForms(); searchAttribs(); writeRegCookie(); writeHeader(); writeHeaderNoATC(); writeFooter()
*****************************************************************************************************/
var machine = "http://include.ebay.com/"; // machine these files are hosted on
var path = "aw/pics/uk/js/cobrand/"; //  and path to the files -- leave thse two blank for relative paths 
var cobrandID = "0"; // set site to IT
var partnerID = "0";
var thisPage = location.href.toLowerCase();
var lastPage = document.referrer.toLowerCase();
// the following code finds out what site we're on, and sets cobrandID for the current page
if ((thisPage.indexOf(".bt.") > 0) || (lastPage.indexOf(".bt.") > 0) || (thisPage.indexOf("ht=47") > 0) || (thisPage.indexOf("s_partnerid=47") > 0) || (thisPage.indexOf("co_partnerid=47") > 0)){
	cobrandID = "1";// bt
	partnerID = "47";
}
if ((thisPage.indexOf(".ebayshops.") > 0) || (lastPage.indexOf(".ebayshops.") > 0)){
	cobrandID = "0";// do not cobrand ebay Shops pages
}
if (thisPage.indexOf("arribada.") > 0){
	cobrandID = "0";// do not cobrand
}
// cookie functions
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);
   }
}
if (cobrandID != "0"){
	document.write("<SCRIPT SRC=\"" + machine + path + "cobrand_functions.js\"></SCRIPT>");
}
function writeHeader(){ // writes the, um, header
		if (cobrandID == "1"){
			document.write("<SCRIPT SRC=\"" + machine + path + "headers/header.bt.js\"></SCRIPT>");
		}
}

function writeBrow(){
	document.write("<SCRIPT SRC=\"" + machine + path + "headers/brow.js\"></SCRIPT>");
}

function writeFooter(){ // writes the cobrand footer
	if (cobrandID == "1"){
		document.write("<SCRIPT SRC=\"" + machine + path + "footers/footers.bt.js\"></SCRIPT>");
	}
}
var brow = 1;
var atc = 1;
var cbc = 1; // is this file loaded?

