function jsiNavigation (pObjVariableName, pNavigationId)
{
	
   //
   // attributes
   //
   this.Id = pNavigationId;
   this.Name = pObjVariableName; 
   this.Element = document.getElementById (pNavigationId);
   this.Count = 0;
   this.CurrentItem = 0;
   this.PreviousItem = 0;
   this.Button = new Array();
   this.Parent;
   this.HScrollbar;

   //
   // functions
   //
   this.ItemAdd       = jsiNavigation_ItemAdd;
   this.ItemSet       = jsiNavigation_ItemSet;
   this.ItemUnSet     = jsiNavigation_ItemUnSet;
   //this.ItemClick     = jsiNavigation_ItemClick;
   this.HScrollbarAdd = jsiNavigation_HScrollbarAdd;	
   this.Resize        = jsiNavigation_Resize;

   //
   // constructor
   //
   if (jsiById(this.Id + "_ul") != null) jsiRemoveElement (this.Id + "_ul");
   this.ElementUL = jsiCreateElement ("ul", this.Id + "_ul", "", this.Element);
   this.Element.style.overflow = "hidden";

}

function jsinavigation_Button (pId, pItemNo, pOnClickObject) {

   this.Id = pId;
   this.Element = jsiCreateElement ("li", this.Id, "", null);
   this.Element.innerHTML = "<a href='#" + pItemNo + "'>" + (pItemNo) + "</a>";
   jsiAddEvent (this.Element, "click", function () { jsinavigation_GotoPage (pOnClickObject, pItemNo); } );

}

function jsinavigation_GotoPage (pOnClickObject, pItemNo) {
eval (pOnClickObject + ".Show(" + pItemNo + ");");
}

function jsiNavigation_ItemAdd () {

   // eleman sayısını bir arttır
   this.Count = this.Count + 1;
   this.Button[this.Count] = new jsinavigation_Button(this.Id + "_item" + this.Count, this.Count, this.Parent.Object);
   this.ElementUL.appendChild (this.Button[this.Count].Element);

   this.Button[this.Count].Element.setAttribute("jsiTooltip", "Position:TopLeft;text:click to go the page " + this.Count);
   jsiAddTooltip (this.Button[this.Count].Id);

   // yeni yaratılan elemanla birlikte UL elmanının genişliğini ayarla,
   // örnek genişlik olarak 1.elemanın genişliğini kullan
	this.ElementUL.style.width = jsiTotalWidth (this.Id + "_item1") * this.Count + "px";
}

function jsiNavigation_ItemUnSet (pItemInd){

   if (pItemInd > 0) this.Button[pItemInd].Element.className = "";

}

function jsiNavigation_ItemSet (pItemInd) {
var buttonOffsetLeft,
    buttonClientWidth,
    divScrollLeft,
    divClientWidth;

	  // if page is not in the client area, scroll the scrollbar
	  buttonOffsetLeft  = this.Button[pItemInd].Element.offsetLeft;
	  buttonClientWidth = this.Button[pItemInd].Element.clientWidth;
	  divScrollLeft     = this.Element.scrollLeft;
	  divClientWidth    = this.Element.clientWidth;

  	// eğer butonun tamamı güzkmüyor ise ve gösterilen alanın sağında kalıyor ise sağa kaydır.
	  while (buttonOffsetLeft + buttonClientWidth > divScrollLeft + divClientWidth) {
			   	  this.Element.scrollLeft += buttonClientWidth;
				     if (this.HScrollbar != undefined) {
					   	   this.HScrollbar.ButtonPosition ();
			      }
      	  buttonOffsetLeft  = this.Button[pItemInd].Element.offsetLeft;
	        buttonClientWidth = this.Button[pItemInd].Element.clientWidth;
	        divScrollLeft     = this.Element.scrollLeft;
	        divClientWidth    = this.Element.clientWidth;
	  }

  	// if button is in the right side of the hidden area, scroll the numbers right
  	if (buttonOffsetLeft < divScrollLeft) {
				  this.Element.scrollLeft = buttonOffsetLeft;
				  if (this.HScrollbar != undefined) {
						   this.HScrollbar.ButtonPosition ();
			   }
	  }

  	// set current page button class as current
	  this.Button[pItemInd].Element.className = "current";

}

// !!! Kullanılmıyor sanırsam..... sorun çıkmadı ise sonradan bunları sillllll ............
//function jsiNavigation_ItemClick (pItemInd) {
//
//   this.Parent.Show (PitemInd);
//
//}

function jsiNavigation_HScrollbarAdd (pScrollbarId, pContentId, pAutoSize) {
var objVariableName;

   this.HScrollbar = new jsiHScrollbar (this.Name + ".HScrollbar", pScrollbarId, pContentId, pAutoSize);

}

function jsiNavigation_Resize () {

   if (this.HScrollbar != undefined) {
						this.HScrollbar.Resize();
			}
  
}

