//     http://www.php-development.ru/javascripts/tab-view.php

function tabview_aux(TabViewId, CurrentId, className)
{
  var TabView = document.getElementById(TabViewId);
  // ***** Tabs *****

  var Tabs = TabView.firstChild;
  while (Tabs.className != className) Tabs = Tabs.nextSibling;
  var Tab  = Tabs.firstChild;
  var i    = 0;

  do
  {
    if (Tab.tagName == "A")
    {
      i++;
      Tab.href         = "javascript:tabview_switch('"+TabViewId+"', "+i+", '"+className+"');";
      Tab.className    = (i == CurrentId) ? "Current" : "";
      Tab.blur();
    }
  }
  while (Tab = Tab.nextSibling);

  // ***** Pages *****

  var Pages = TabView.firstChild;
  while (Pages.className != 'Pages') Pages = Pages.nextSibling;
  var Page  = Pages  .firstChild;
  var i     = 0;

  do
  {
    if (Page.className == 'Page')
    {
      i++;
      if (Pages.offsetHeight) Page.style.height = (Pages.offsetHeight-2)+"px";
      Page.style.display  = (i == CurrentId) ? 'block' : 'none';
    }
  }
  while (Page = Page.nextSibling);
}

function getCookie(c_name)
{
if (document.cookie.length>0)
  {
  c_start=document.cookie.indexOf(c_name + "=");
  if (c_start!=-1)
    { 
    c_start=c_start + c_name.length+1 ;
    c_end=document.cookie.indexOf(";",c_start);
    if (c_end==-1) c_end=document.cookie.length
    return unescape(document.cookie.substring(c_start,c_end));
    } 
  }
return ""
}

function setCookie(c_name,value,expiredays)
{
var exdate=new Date();
exdate.setDate(exdate.getDate()+expiredays);
document.cookie=c_name+ "=" +escape(value)+((expiredays==null) ? "" : "; expires="+exdate.toGMTString());
}

function checkCookie()
{
username=getCookie('tabIndex');
if (username!=null && username!="")
  {
  tabview_switch('TabView',username,'Tabs');
  //alert(username);
  }
}
// ***** Tab View **************************************************************

function tabview_switch(TabViewId, id, className) { tabview_aux(TabViewId, id, className);/* if(TabViewId=='TabView') setCookie('tabIndex',id,1)*/ }
function tabview_initialize(TabViewId,className) { tabview_aux(TabViewId, 1, className); /*checkCookie();*/ }

//username=getCookie('tabIndex');
//alert(username);
