sfHover = function()
{
	var sfEls = document.getElementById("calend").getElementsByTagName("li");
	for (var i=0; i<sfEls.length; i++)
	{
		sfEls[i].onmouseover = function()
			{
				this.className+=" sfhover";
			}
		sfEls[i].onmouseout=function()
			{
				this.className=this.className.replace(new RegExp(" sfhover\\b"), "");
			}
	}
}
if (window.attachEvent) window.attachEvent("onload", sfHover);

function openWindow(filename, w, h, winname)
{
    var nWidth;
        var nHeigth;
				if(filename.match(/\?/)){
					         filename += '&'+Math.random();
				}else{
					         filename += '?'+Math.random();
				}
        if (h) nHeigth = h; else nHeigth = 500;
        if (w) nWidth = w; else nWidth = 700;
        if (!winname) winname = "_blank";
		//		alert([filename," w ", w," h ",  h," winname ",  winname," nWidth ", nWidth," nHeigth ", nHeigth]);
        var desktop = window.open(filename, winname, "width="+nWidth+",height="+nHeigth+",toolbar=no,location=no,status=no,menubar=no,scrollbars=yes,resizable=yes");
};

function get_radio_value(f)
{
	for (var i=0; i < f.length; i++)
	{
		if (f[i].checked)
		{
			var value = f[i].value;
		}
	}
	return value;
}

function addBookmark(url, title)
{
  if (!url) url = location.href;
  if (!title) title = document.title;
  //Gecko
  if ((typeof window.sidebar == "object") && (typeof window.sidebar.addPanel == "function"))
  	{window.sidebar.addPanel (title, url, "");}
  //IE4+
  else if (typeof window.external == "object")
  	{window.external.AddFavorite(url, title);}
  //Opera7+
  else if (window.opera && document.createElement)
  {
    var a = document.createElement('A');
    if (!a) return false; //IF Opera 6
    a.setAttribute('rel','sidebar');
    a.setAttribute('href',url);
    a.setAttribute('title',title);
    a.click();
  }
  else {return false;}
  return true;
}

function urlEncode (str)
           {
               if (!str || typeof(str) == "undefined") return;
               var utf8Array = {};
               var i = j = j2 = 0;
               for (i = 0; i <= 255; i++)
               {
                   j = parseInt(i/16); var j2 = parseInt(i%16);
                   utf8Array[String.fromCharCode(i)] = ('%' + j.toString(16) + j2.toString(16)).toUpperCase();
               }

               var rusAdditional =
               {
                  '_' : '%5F', 'À' : '%C0', 'Á' : '%C1', 'Â' : '%C2', 'Ã' : '%C3', 'Ä' : '%C4', 'Å' : '%C5',
                  'Æ' : '%C6', 'Ç' : '%C7', 'È' : '%C8', 'É' : '%C9', 'Ê' : '%CA', 'Ë' : '%CB', 'Ì' : '%CC',
                  'Í' : '%CD', 'Î' : '%CE', 'Ï' : '%CF', 'Ð' : '%D0', 'Ñ' : '%D1', 'Ò' : '%D2', 'Ó' : '%D3',
                  'Ô' : '%D4', 'Õ' : '%D5', 'Ö' : '%D6', '×' : '%D7', 'Ø' : '%D8', 'Ù' : '%D9', 'Ú' : '%DA',
                  'Û' : '%DB', 'Ü' : '%DC', 'Ý' : '%DD', 'Þ' : '%DE', 'ß' : '%DF', 'à' : '%E0', 'á' : '%E1',
                  'â' : '%E2', 'ã' : '%E3', 'ä' : '%E4', 'å' : '%E5', 'æ' : '%E6', 'ç' : '%E7', 'è' : '%E8',
                  'é' : '%E9', 'ê' : '%EA', 'ë' : '%EB', 'ì' : '%EC', 'í' : '%ED', 'î' : '%EE', 'ï' : '%EF',
                  'ð' : '%F0', 'ñ' : '%F1', 'ò' : '%F2', 'ó' : '%F3', 'ô' : '%F4', 'õ' : '%F5', 'ö' : '%F6',
                  '÷' : '%F7', 'ø' : '%F8', 'ù' : '%F9', 'ú' : '%FA', 'û' : '%FB', 'ü' : '%FC', 'ý' : '%FD',
                  'þ' : '%FE', 'ÿ' : '%FF', '¸' : '%B8', '¨' : '%A8'
               }
               for (i in rusAdditional) utf8Array[i] = rusAdditional[i];

               var res = "";
               for(i = 0; i < str.length; i++)
               {
                  var simbol = str.substr(i,1);
                  res += typeof utf8Array[simbol] != "undefined" ? utf8Array[simbol] : simbol;
               }

               res = res.replace(/\s/g, "+");
               return res;
           }


// function mousePageXY(e)
// {
    // if (!e) e = window.event;
    // if (e.pageX || e.pageY)
    // {
      // mouse_x = e.pageX;
      // mouse_y = e.pageY;
    // }
    // else if (e.clientX || e.clientY)
    // {
      // mouse_x = e.clientX + (document.documentElement.scrollLeft || document.body.scrollLeft) - document.documentElement.clientLeft;
      // mouse_y = e.clientY + (document.documentElement.scrollTop || document.body.scrollTop) - document.documentElement.clientTop;
    // }
// window.status = mouse_x + " " + mouse_y; 
// }
// document.onmousemove = function(e){var mCur =mousePageXY(e);}

// function ccc(el, form)
// {
	// var r = getAbsolutePosition(el);
	// alert(r.x + " " + r.y + " " + form);

	// var parrent=document.getElementById('poisk');
	// var ch_div=document.createElement('div');
	
	// ch_div.style.position='absolute';
	// ch_div.style.top=  r.y + 'px';
	// ch_div.style.left= r.x + 'px';
	// ch_div.id = 'rrr';
	// ch_div.style.zIndex = 200;
	// parrent.appendChild(ch_div);
	// var body = "<p onClick=\"var parrent=document.getElementById('poisk') ;parrent.removeChild(document.getElementById('rrr')); \" >safasdfas</p>dfasdfasdf<br>safasdfasdfasdfasdf<br>safasdfasdfasdfasdf<br>safasdfasdfasdfasdf<br>";
	// ch_div.innerHTML=body
// }

// function getAbsolutePosition(el) {
	// var r = { x: el.offsetLeft, y: el.offsetTop };
	// if (el.offsetParent) {
		// var tmp = getAbsolutePosition(el.offsetParent);
		// r.x += tmp.x;
		// r.y += tmp.y;
	// }
	// return r;
// }
