// Array containing 5 elements
var page_title = new Array(10);

var titleSearchName = "theTitle=";
var urlSearchName = "theURL=";

// Add data into the next index in the array
function updateArray(newtitle,newloc)
{
bubble();
page_title[0]=titleSearchName +newtitle;
page_title[5]=urlSearchName +newloc; 
}

// Move the array elements along in the array queue
function bubble()
{
  for (var i = 3; i>-1; i--)
    {      
	if(page_title[i]==null) page_title[i]=" ";

	page_title[i+1]=page_title[i];
    }
  for (var i = 8; i>4; i--)
    {      
	if(page_title[i]==null) page_title[i]=" ";

	page_title[i+1]=page_title[i];
    }
page_title[0]=null;
page_title[5]=null;
}


// Use this function to retrieve the contents of a cookie.
function getCookie(name) 
{
  var dcookie = document.cookie; // cookie contents
  var cname = name + "=";        // cookie name
  var clen = dcookie.length;     // cookie length
  var cbegin = 0;                // cookie start point

  while (cbegin < clen)
    {      var vbegin = cbegin + cname.length;
          if (dcookie.substring(cbegin, vbegin) == cname) 
	{ 
	  var vend = dcookie.indexOf (";", vbegin);
	  if (vend == -1) vend = clen;
	  return unescape(dcookie.substring(vbegin, vend));
	}
          cbegin = dcookie.indexOf(" ", cbegin) + 1;
            if (cbegin == 0) break;
    }
  return null;
}


// Use this function to save a cookie. Value = contents of the arrays.
// Value1= title; value2 = url
function setPageCookie(name, value, expires) 
{
  document.cookie = name + "=" + unescape(value) +"; path=/" + ((expires == null) ? "" : "; expires=" + expires.toGMTString());
}


// Function to make sure that the cookie exists; Returns true if it exists, false otherwise
function checkForCookie()
{
  if (document.cookie.indexOf("fsvsmart" != -1))
    {
      return true;
    }
  else {
    return false;
  }
}


// This function will attempt to split the cookie at the ',' and set the array with it's contents.
function setArray()
{
var startOfCookie = document.cookie.indexOf(titleSearchName);
var endOfCookie = document.cookie.indexOf(";", startOfCookie);

if(endOfCookie == -1) endOfCookie = document.cookie.length;

var cookieString = document.cookie.substring(startOfCookie, endOfCookie+1);

for(var i=0;i<10;i++)
    {
      page_title[i]=cookieString.split(",")[i];
    }
if(page_title[0] == "fsvsmart")
	{		
	page_title[0] = " ";
	}
}


// Use this function to delete a cookie.
function delCookie(name) 
{
  document.cookie = name + "=; expires=Thu, 01-Jan-70 00:00:01 GMT" +  "; path=/";
}


// Test function displays the contents of the cookie
function showCookie()
{
  alert("Cookie:"+document.cookie);
}
	

// Display the stored elements of the array
function display_titles() 	
{

if(page_title[1]!=null)
{
var tmp_array = new Array(10);
	for(var j=0;j<10;j++)
   {
     tmp_array[j]=page_title[j].split("=")[1];
   }
	
//	for (var i = 0; i < page_title.length; i++ )
	for (var i = 0; i < 3; i++ )
    {
  		if (tmp_array[i] == null)
			{
				tmp_array[i] = " ";
			}
document.write("<span class=prodcrumb> >> "+"<a href="+tmp_array[i+5]+">"+tmp_array[i]+"</a></span>");
	//document.write("<span class=prodcrumb> >>"+"<a href="+tmp_array[i+5]+"> "+tmp_array[i]+"</a>"
    }
}
}


// test function to show the contents of the array in an alert box
function showIt()
{
  var g="";
  for(var i=0;i<10;i++)
    {
      g+="page_title["+i+"]="+page_title[i]+"\n";
}

  alert(g);
}
