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 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 set_XY(id)
{	 var 	X = getClientWidth()/2 + getBodyScrollLeft() - 300;
	 if(X<0) { X = 0; };
	 var  Y = getBodyScrollTop();
	 if(Y<250) { Y = 250; };

	 document.getElementById(id).style.position = 'absolute';
 	 document.getElementById(id).style.zIndex = 10000;

	 document.getElementById(id).style.top = Y;
	 document.getElementById(id).style.left = X;

	 return;
}

function Start_img(id)
{//	setInterval("changeThisImage("+id+")", 7000);	setInterval("changeThisImage1("+id+")", 7000);
//	setTimeout("changeThisImage1("+id+")", 7000);
}


function changeThisImage(id)
{//	document.getElementById('load_div_'+id).innerHTML = '<img style="margin-left:13px; margin-top: 0px; width:240px;" src="/templates/skin1/images/loading1.gif#'+id+'" />';

 	setTimeout("start_load("+id+")",1000);
 	setTimeout("clear_load("+id+")",3100);
	return;}

function changeThisImage1(id)
{
 	start_load1(id);
 	setTimeout("hide_div("+id+",100)",3100);

	return;
}

function hide_div(id, op)
{
	if(op>0)
	{		document.getElementById('load_top_'+id).style.opacity = op/100;
	    document.getElementById('load_top_'+id).style.filter  = 'progid:DXImageTransform.Microsoft.Alpha(opacity='+op+')';
		op = op-5;
		setTimeout("hide_div("+id+","+op+")", 50);
	}
	else{		document.getElementById('load_top_'+id).innerHTML = document.getElementById('load_back_'+id).innerHTML;
		document.getElementById('load_top_'+id).style.opacity =	1;
	    document.getElementById('load_top_'+id).style.filter  = 'progid:DXImageTransform.Microsoft.Alpha(opacity=100)';
		 return;
	};

	return;
}

function start_load(id)
{	document.getElementById('blok_'+id+'_a').style.display = 'none';
	document.getElementById('blok_'+id+'_a').style.visibility = 'hidden';
	loadDataInd(id,'top_img');
	return;}

function start_load1(id)
{	old_img = document.getElementById('pred_img['+id+']').value;
	loadDataId( id, 'top_img', old_img);
	return;
}

function clear_load(id)
{	document.getElementById('load_div_'+id).innerHTML = '';
	return;}

	Sur_cat_item = 0;

function show_kat_sub(id)
{
	if(Sur_cat_item && Sur_cat_item!=id) {		Surdiv = api.getElementById('kat_items_'+Sur_cat_item);
		Surdiv.className = 'hide_kat_subitems';
	}
	Subdiv = api.getElementById('kat_items_'+id);

	if(Subdiv.className == 'hide_kat_subitems')
	{		Subdiv.className = 'show_kat_subitems';
	}
	else
	{		Subdiv.className = 'hide_kat_subitems';	};

	Sur_cat_item = id;
	return false;}

