/*=============================================================================================
--       SITE/SYSTEM : Brand Platform v2
--       DESCRIPTION : Dosctor Discussion Guide Page Creation JavaScript File
--  REVISION HISTORY : Date      Version   Name             Description
		       11/17/08	 1.0.0.0   Richard Yale	    Initial version
=============================================================================================*/

/*=======================
Reading the cookie for creating the list
=======================*/

function readCookie(name) {
  var nameEQ = name + "=";
  var ca = document.cookie.split(';');
  for(var i=0;i < ca.length;i++) {
    var c = ca[i];
    while (c.charAt(0)==' ') c = c.substring(1,c.length);
    if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
  }
  return null;
}

/*============================
Creating the list alternating the elements
============================*/

function createGuide()
{
	var checklist = readCookie("Checklist");
	if(checklist != null)
	{
		var list = checklist.split("/");
		var x = 1;
		for(var i = 0; i < list.length; i++)
		{
			if (list[i] != "")
			{
				addElementGuide(list[i], x);
				if(x == 1)
				{
					x++;
				}
				else
				{
					x--;
				}
			}
		}	
	}
}


/*======================
Adding divs with the topics in them
======================*/

function addElementGuide(name, divNum) {
        var lastDiv = "lastDiv" + divNum.toString();
        var divName = "content" + divNum.toString();
	var n = document.getElementById(divName);
  	var ni = document.getElementById(lastDiv);
  	var newdiv = document.createElement('div');
  	var divIdName = name;
  	newdiv.setAttribute('id',divIdName);
  	newdiv.innerHTML = name;
  	n.insertBefore(newdiv, ni);
}