//**********************
//Must include this on each storefront page using
//<script language="JavaScript" src="header.js"></script>
//To Do:	
//	1) Modify my_track and create an entry on the Franchise Control Panel for each franchise site;
//	2) Modify my_initial if the storefront pages reside on a different domain or folder.
//**********************

var my_track = "self";
var my_initial = "include/initial.asp";
var my_detail = "detail.htm";

InitialHeader(false);
function InitialHeader(bRefresh)
{
var i, sStr, page, curPage = "" + window.location;
	curPage = curPage.toLowerCase();
	if (curPage.indexOf('.asp') && window.goback != null) 
	{
		sStr = curPage;
		i = sStr.lastIndexOf("/");
		if (i > 0) sStr = sStr.substring(0, i+1);
		curPage = goback.toLowerCase();
		if (curPage.indexOf(sStr) == 0)	curPage = "";
	}
	i = curPage.lastIndexOf("?");
	if (i > 0) curPage = curPage.substring(0, i+1);
	i = curPage.lastIndexOf("/");
	if (i > 7) 
		curPage = curPage.substring(0, i+1);
	else if (curPage.length && i < 0) 
		curPage += '/';
		
	page = my_initial + "?track=" + my_track + "+" + escape(curPage);
	if (window.sessionid)
	page += "&id=" + sessionid;
	
	if (bRefresh)
		page += '&rnd=' + Math.round(Math.random()*100000); 
	
	document.write('<' + 'script language="JavaScript" src="' +
		page + '"></' + 'script>\r\n');
}

var myStyle = 
	'&linecolor=' + escape('#0080FF') + 
	'&menu=category' + 
	'&body=bodyblue' + 
	'&bold=bodyheading' + 
	'&hlcolor=' + escape('#88C4FF') + 
	'&bgcolor=' + escape('#E0FFE0') + 
	'&hdcolor=' + escape('#3399FF') + 
	'&header=bodywhite' + 
	'&rowcolor=' + escape('#E0FFE0') + 
	'&row=bodyblack' + 
	'&label=bodyblue' + 
	'&heading=heading' + 
	'&detail=' + escape(my_detail) + 
	'&popup=yes';

var myStyle0 = '?' + myStyle.substring(1, myStyle.length);
function setStyle(sField, sValue)
{
var thisStyle = myStyle;
var i, j, sStr;
	i = thisStyle.indexOf('&' + sField + '=');
	if (i >= 0)
	{
		j = thisStyle.indexOf('&', i + 1);
		if (j == 0) j = thisStyle.length;
		sStr = thisStyle.substring(i, j);
		thisStyle = thisStyle.replace(sStr, '&' + sField + '=' + escape(sValue));		
	}
	else
		thisStyle += '&' + sField + '=' + escape(sValue);
	return thisStyle;
}	

