    function scrollToElement(theElement) {
    if (typeof theElement != "string")
        theElement = document.getElementById(theElement);

    var selectedPosX = 0;
    var selectedPosY = 0;

    while (theElement != null) {
        selectedPosX += theElement.offsetLeft;
        selectedPosY += theElement.offsetTop;
        theElement = theElement.offsetParent;
    }

    window.scrollTo(selectedPosX, selectedPosY);
}/*
anchorScroller=function (id,sec) {

          var j = jQuery.noConflict();
                        j.(id).animate({
                                scrollTop: 0
                        }, sec);
                        return false;
                };*/

function exitakk() {

          var j = jQuery.noConflict();
if(confirm("Выйти в свой класс?")!=false){
	j.ajax ({
					url: "restoreclass.php",
					type: "GET",
					data: {} ,
					success: function () {
			window.location.href ='/';
			}
					});
}
}
	function refrClock()
						{
							var d=new Date();
							var c=d.toLocaleString();
					//	document.getElementById("clock").innerHTML=c;
       						document.getElementById("clock2").innerHTML=c;
							setTimeout("refrClock()",1000);
						}
 $(document).ready(function(){
          var j = jQuery.noConflict();
var toggle = function(direction, display) {
    return function() {
      var self = this;
      var ul = j("ul", this);
      if( ul.css("display") == display && !self["block" + direction] ) {
        self["block" + direction] = true;
        ul["slide" + direction]("slow", function() {
          self["block" + direction] = false;
        });
      }
    };
  }
  j("li.menu").hover(toggle("Down", "none"), toggle("Up", "block"));
  j("li.menu ul").hide();
       // Скрываем все спойлеры
        j('.sp-body').hide()

        // по клику отключаем класс folded, включаем unfolded, затем для следующего
        // элемента после блока .spoiler-head (т.е. .spoiler-body) показываем текст спойлера
        j('.sp-head').click(function(){
   //      j(this).next().toggle("slow");
            j(this).toggleClass("folded").toggleClass("unfolded").next().toggle()
        })

       });
 function add_favorite(a) {
  title=document.title;
  url=document.location;
  try {
    // Internet Explorer
    window.external.AddFavorite(url, title);
  }
  catch (e) {
    try {
      // Mozilla
      window.sidebar.addPanel(title, url, "");
    }
    catch (e) {
      // Opera
      if (typeof(opera)=="object") {
        a.rel="sidebar";
        a.title=title;
        a.url=url;
        return true;
      } /*
	  else if (window.chrome)  {
	   chrome.bookmarks.create({'parentId':sider1, 'title': title ,'url': url });     }  */
      else {
        // Unknown
        alert('Нажмите Ctrl-D чтобы добавить страницу в закладки');
      }
    }
  }
  return false;
}
