function select_skin( url )
{	location.href( url + '&skin=' + api.getElementById("select_skin").value );}


function getClientWidth()
{
  return document.compatMode=='CSS1Compat' && !window.opera?document.documentElement.clientWidth:document.body.clientWidth;
}

function getClientHeight()
{
  return document.compatMode=='CSS1Compat' && !window.opera?document.documentElement.clientHeight:document.body.clientHeight;
}

function getBodyScrollTop()
{
  return self.pageYOffset || (document.documentElement && document.documentElement.scrollTop) || (document.body && document.body.scrollTop);
}

function getBodyScrollLeft()
{
  return self.pageXOffset || (document.documentElement && document.documentElement.scrollLeft) || (document.body && document.body.scrollLeft);
}

function getDocumentHeight()
{
	return (document.body.scrollHeight > document.body.offsetHeight)?document.body.scrollHeight:document.body.offsetHeight;
}

function getDocumentWidth()
{
	return (document.body.scrollWidth > document.body.offsetWidth)?document.body.scrollWidth:document.body.offsetWidth;
}

function getClientCenterX()
{
	return parseInt(getClientWidth()/2)+getBodyScrollLeft();
}

function getClientCenterY()
{
	return parseInt(getClientHeight()/2)+getBodyScrollTop();
}


function bookmark(title, url) {
 // если название страницы не было чётко указано, возьмём заголовок текущей страницы
 if (title == undefined)
  title = document.title;

 // то же самое и с URL-ом
 if (url == undefined)
  url = top.location.href;

 if (window.sidebar) {
  // Firefox
  window.sidebar.addPanel(title, url, '');
 } else if (window.opera && window.print) {
  // Opera
  var t = document.createElement('a');
  t.setAttribute('rel', 'sidebar');
  t.setAttribute('href', url);
  t.setAttribute('title', title);
  t.click();
 } else {
  // IE
  window.external.AddFavorite(url, title);
 }
 return false;
}



function sethomepage(myLink)
{
        if(navigator.appName.indexOf('Microsoft')!=-1)
        {
               // IE
               myLink.style.behavior='url(#default#homepage)';
               myLink.setHomePage(location.href);
               //myLink.setHomePage('www.2voprosa.ru');
        }
        else if(navigator.appName.indexOf('Netscape')!=-1)
        {
               // Netscape / firefox browsers
               var msg = "Перетащите эту ссылку на кнопку 'Домой' чтобы сделать ее стартовой страницей.";
               alert(msg);
        }
        else if(navigator.appName.indexOf('Opera')!=-1)
        {
               // Opera
               var msg = "Откройте меню 'Инструменты/Настройки' и нажмите кнопку 'Использовать текущую страницу в качестве стартовой'.";
               alert(msg);

        }
}

function showMilitaryTime() {
	if (document.form.showMilitary[0].checked) {
	return true;
	}
	return false;
}

function showTheHours(theHour) {
	if (theHour > 0 && theHour < 13) {
	return (theHour);
	}
	if (theHour == 0) {
	//return (12);
	return (theHour);
	}
	//return (theHour-12);
	return (theHour);
}



function showZeroFilled(inValue) {
	if (inValue > 9) {
	return '' + inValue;
	}
	return '0' + inValue;
}


function showAmPm() {
	if (showMilitaryTime()) {
	return ('');
	}
	if (now.getHours() < 12) {
	return (' AM');
	}
	return (' PM');
}

function showTheTime() {
	now = new Date;
	//document.form.showTime.value = showTheHours(now.getHours()) + ':' + showZeroFilled(now.getMinutes()) + ':' + showZeroFilled(now.getSeconds());
	var ttt = showTheHours(now.getHours()) + ':' + showZeroFilled(now.getMinutes()) + ':' + showZeroFilled(now.getSeconds());


	current_date = new Date()
	var mon=current_date.getMonth()+1
	tec=current_date.getDate()+ "." + mon + "." + current_date.getYear()
	//dateblock.innerHTML='<font color=#255B78><b>'+tec+'</b></font>';

	clock.innerHTML='<font color=#255B78><b>'+tec+'&nbsp;г.&nbsp;&nbsp;</b></font><font color=#255B78><b>'+ttt+'</b></font>';


	setTimeout('showTheTime()',1000);
}
function date() {
	current_date = new Date()
	var mon=current_date.getMonth()+1
	tec=current_date.getDate()+ "." + mon + "." + current_date.getYear()
	dateblock.innerHTML='<font color=#255B78><b>'+tec+'</b></font>';
}

function getRelLeft(which) {
	//var elem = document.getElementById(which);
	var elem = document.all[which];

	var pos = elem.offsetLeft;
	//alert(pos);
	while (elem.offsetParent != null) {
		elem = elem.offsetParent;
		pos += elem.offsetLeft;
		if (elem.tagName == 'BODY') break;
	}
	sl=document.body.scrollLeft;
	//pos=pos+sl;
	return pos;
}

function getRelTop(which) {
	var elem = document.all[which];
	var pos = elem.offsetTop;
	while (elem.offsetParent != null) {
		elem = elem.offsetParent;
		pos += elem.offsetTop;
		if (elem.tagName == 'BODY') break;
	}
	st=document.body.scrollTop;
	//pos=pos-st;
	//alert(pos);
	return pos;
}


function show_drop(what, ttop) {
	hide_all_drop();
	var top=ttop;
	//alert(top);
	var elid='drop'+what;
	var id=document.getElementById(elid);
	id.style.display='block';
	//id.style.visibility='visible';
	id.style.left=getRelLeft('td'+what)-7;
	id.style.top=getRelTop('td'+what)-top-7;
}


function hide_all_drop1() {
	NodeList = document.getElementsByTagName("div");
	for (i=0; i < NodeList.length; ++i)
	{
		if(NodeList[i].name){
			//alert (NodeList(i).name);
			var subname = NodeList[i].name;
			subname = subname.substring(0,8);
			//alert (subname);
			if(subname=='pathpart')
			{
					//NodeList(i).style.visibility='hidden';
					//alert (NodeList[i].name);
					NodeList[i].style.display='none';
			}
		}
	}
}

function hide_all_drop() {
	var g = document.getElementById('pathblock').childNodes;
	for(var i=0;i<g.length;i++) {
		//alert(g[i].nodeName );
	   if(g[i].nodeName == 'DIV') {
		   g[i].style.display='none';
	   }
	}
}



//-----------------------------------------------------------------------------
  function doOnMouseOver(what) {
         if(what == "1") {
              CloseBox("2");
              CloseBox("3");
         }
         if(what == "2") {
              CloseBox("1");
              CloseBox("3");
         }
         if(what == "3") {
              CloseBox("1");
              CloseBox("2");
         }
//         else {
//              CloseBox("1");
//         }
         eval("links" + what).style.left = getRelLeft("menu" + what)-6; // сдвиг по горизонтали
         eval("links" + what).style.top = getRelTop("menu" +what)+17;    // Отступ по вертикали
         eval("links" + what).is_open = true;
         eval("links" + what).style.display = "block";
  }
//-----------------------------------------------------------------------------
  function doOnMouseOut(what) {
           eval("links" + what).is_open = false;
           setTimeout("CloseBox("+ what +")",400);
  }
//-----------------------------------------------------------------------------
  function CloseBox(what) {
           if(!eval("links" + what).is_open) {
                eval("links" + what).style.display = "none";
           }
  }
//-----------------------------------------------------------------------------

function del_partner(){
	if(confirm("Вы действительно хотите удалить свой аккаунт?")){
			return true;
		}
	else return false;
}


function s_type_switch(obj, id)
{	document.getElementById(id).action = s_type_list[obj.value];}

function ya_inp_focus(e)
{	if(e.value == document.getElementById('ya_full_text').value)
	{		 e.value = '';
		 e.className = 'stext_in_sel';	};}

function ya_inp_blur(e)
{
	if(e.value == '')
	{
		 e.value = document.getElementById('ya_full_text').value;
		 e.className = 'stext_in';
	};

}


comment_status = 0;

function great_comment_form(id)
{
	if(comment_status == 1)
	{
		document.getElementById(id).style.visibility = 'hidden';
		document.getElementById(id).style.display = 'none';
		comment_status = 0;
	}
	else
	{
		document.getElementById(id).style.visibility = 'visible';
		document.getElementById(id).style.display = 'inline';
		comment_status = 1;
	};
}

function add_buy(id)
{
	val = prompt('Введите колличество для заказа:', 1);

	if(val)
	{		document.location.href = '/'+val+'/buy/'+id+'/Tovari/';
	};

	return false;
}

