
var bclength=3;//Set the length of the breadcrumbs here
locate = document.location.href.replace(/,/g,"~");
//locate=locate.replace("’","%u2019");
//alert (locate);

////////////////////////////////////////////////////////////////////////////////////Please do not edit anything beyond this.

var q = 0;
var noplease = 0;
var proceed=1;
document.cookie="temporary =";
var trycheck = getCookie("temporary");
function special()
{
//alert(tryArr);
    if (tryArr)
	{
	document.cookie = "temporary ="+tryArr+";"+"path=/;";
	}
}
if (trycheck)
{
//alert ("Cookie is present for the BC, but I have written code to properly handle the function")


//tryActual is the variable which stores the actual content in the existing cookie /////////////////////////////
tryActual = trycheck.split(",");//alert(trycheck);
cooklenby2 = tryActual.length/2;
	if (cooklenby2<bclength)//Cookie value is not yet filled upto 5 values
	{	
	var tryArr = new Array(cooklenby2+1);//creating array cooklenby2 plus 1 for current page
		for (i=0;i<tryArr.length;i++)
		{
		tryArr[i]=new Array(2);
		}
		for (i=0;i<tryActual.length;i=i+2)
		{
			j = i/2;
			k=i+1
			
			tryArr[j][0] = escape(tryActual[i]);//storing cookie value into new array
			tryArr[j][1] = escape(tryActual[k]);//storing cookie value into new array
		}

		//Check whether, the Title is already present or not.
		for (i=0;i<tryActual.length;i=i+2)
		{
		//alert(title);
			if (title==tryActual[i])//if this page's title and any value in the cookie is same
			{
				by2=i/2;
					if (by2==0)//Special because you cannot use a loop for this
					{
					tryArr  = new Array(0);
					tryArr[0] = new Array(2);
					
					tryArr[0][0] = escape(title);//escape(tryActual[0]);
					tryArr[0][1] = escape(locate.replace(",","~"));
					break;
					}
					else  //greater than 0
					{
					noplease=1;
					l = by2+1;
					tryArr = new Array(l)//creating a new Array by the same name of the reqd index
					for (n=0;n<tryArr.length;n++)
						{
						tryArr[n]=new Array(2);//double dimensional array
						}
						p=0;
						for (p=0;p<by2+1;p++)
						{
						k=p*2;
						z=k+1;
						c=p+1;
						//Handling the breadcrumb value in case of page refresh.
							//alert (tryArr[c+1]+"//"+c)
							if (tryArr[c])//the next value is availabe so proceed
							{
							tryArr[p][0]=escape(tryActual[k]);
							tryArr[p][1]=escape(tryActual[z].replace(",","~"));
							}
							else//this is the last value!! It should contain this page's details
							{
							//alert ("else part"+p);
							tryArr[p][0]=escape(title);
							tryArr[p][1]=escape(locate.replace(",","~"));
							}
							
						}
					}
			}
		}
		j= j+1;
		//this is for the last value to be the link of this page's title and link
		if(tryArr[j])
		{
			tryArr[j][0] = escape(title);
			tryArr[j][1] = escape(locate.replace(",","~"));
		}
	}
	else//cookie is already filled upto 5 values
	{
	//creating an array to first store the available cookie value till required
		var tryArr = new Array(bclength);//creating array of the specified bclength
		for (i=0;i<tryArr.length;i++)
		{
		tryArr[i]=new Array(2);//double dimensional arrays for storing title and link
		}
		//i=0;
		
//SPECIALLY HANDLING ONE CASE WHERE THE FIRST VALUE MATCHES THE CURRENT TITLE
		if (title==tryActual[0])
		{
			tryArr  = new Array(0);
			tryArr[0] = new Array(2);
			tryArr[0][0] = escape(title);//tryActual[0];
			tryArr[0][1] = escape(locate.replace(",","~"));
			proceed=0;
		}
		if(proceed==1)//Major if Condition~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
		{
			for (i=2,j=0;i<tryActual.length;i=i+2,j++)
			{
	////////////////////////Here another checking whether the cookie value is same as current title
				if (title==tryActual[i])//if this page's title and any value in the cookie is same
				{
					by2=i/2;
						if (by2==0)//Special because you cannot use a loop for this
						{
						tryArr  = new Array(0);
						tryArr[0] = new Array(2);
						//tryArr[1] = new Array(2);
						
						tryArr[0][0] = escape(title);
						tryArr[0][1] = escape(locate.replace(",","~"));
						break;
						}
						else//greater than 0
						{
						noplease=1;
						l=0;
						l = by2+1;
						tryArr = new Array(l)//creating a new Array by the same name of the reqd index
							for (n=0;n<tryArr.length;n++)
							{
							tryArr[n]=new Array(2);//double dimensional array
							}
							p=0;
							z=0;
							k=0;
							temp = by2+1;
							temp2 = by2+2;
							for (p=0;p<temp;p++)
							{
											
							k=p*2;
							z=k+1;
							c=p+1;
								if (tryArr[c])//the next value is availabe so proceed
								{
								tryArr[p][0]=escape(tryActual[k]);
								tryArr[p][1]=escape(tryActual[z].replace(",","~"));
								}
								else//this is the last value!! It should contain this page's details
								{
								//alert ("inside else");
								tryArr[p][0]=escape(title);
								tryArr[p][1]=escape(locate.replace(",","~"));
								break;
								}
							}
							//break;
						}
						//break;
				}
				//break;
	////////////////////////Ends here
				else
				{
				//j = i/2;
					if (noplease==0)
					{
					k=i+1;//alert(tryActual);alert(k);alert(tryActual[k]);
					//alert ("It should not come here 2! Val of k is "+k);
					tryArr[j][0] = escape(tryActual[i]);//storing cookie value into new array
					tryArr[j][1] = escape(tryActual[k].replace(",","~"));//storing cookie value into new array
					}
				}
				
			}
			if(tryArr[j])
			{
				tryArr[j][0] = escape(title);
				tryArr[j][1] = escape(locate.replace(",","~"));
			}
		}//Major If condition~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
		/*for (i=0;i<tryActual.length-2;i=i+2)
		{
			j = i/2;
			k=i+1
				
			tryArr[j][0] = escape(tryActual[i]);
			tryArr[j][1] = escape(tryActual[k].replace(",","~"));
		}*/
	}
}
else
{
//new cookie should be created here, entering just the current page's title and link
var tryArr = new Array(0)
tryArr[0] = new Array(2)
	tryArr[0][0]=escape(title);
	tryArr[0][1]=escape(locate.replace(",","~"));
}
	document.cookie = "temporary ="+tryArr+";"+"path=/;";

var tryObjBC;
var add;
tryObjBC="<div style='padding-left:35px'>";
tryObjBC += "<b> <a href="+laddress+" class=bc>Home</a></b> |";
//tryObjBC = "<b> <a href='http://www.tajhotels.com' class=bc>Home</a></b> |";

for (i=0;i<tryArr.length;i++)
{
	j=i+1;
	if (tryArr[j])//check whether there is a value after this
	{
	add = unescape(tryArr[i][1]).replace(/~/g,",");//this is working great in IE and NS 6+ and NS 4+
	tryObjBC += "&nbsp;<a class=bc href=";
	tryObjBC += add;//tryArr[i][1];
	tryObjBC += ">";
	tryObjBC += unescape(tryArr[i][0]);
	tryObjBC += "</a>&nbsp;";
	tryObjBC += "|";
	}
	else
	{
	//if(i){//this condition is checked to prevent the display of breadcrumbs at the first level
		tryObjBC += "&nbsp;<span class=bc>"+unescape(tryArr[i][0])+"</span>";
		//}
	}
}
if(br=='N' && document.layers){}
else{
	tryObjBC += "<span style='line-height:1px;'><br><br>&nbsp;<br></span>";
	}//alert(tryObjBC);
	tryObjBC+="</div>"
document.write (tryObjBC.replace("*",","));
document.onfocus=special();


//This was tentatively completed but was fully completed when Ashok was right here and wanted to see this code work in a full flow. Gosh! It was made to work by me at the last minute with absolutely no support from TajSupport.
