
function doWidth() {
  if(document.body.scrollWidth>=1260){
	document.getElementById("widescreen").style.display = "block";
	} else {
	document.getElementById("widescreen").style.display = "none";
	}
}

window.onresize = function() {
                   doWidth();
                }

function setMMWidth()
	{
	lb = document.getElementById("leftBlocks");
	nb = document.getElementById("newsBlock");
	fb = document.getElementById("flashBlock");
	rb = document.getElementById("rightBlocks");
	rbp = document.getElementById("rightBlocksPages");



	if(lb)
		{
		lb.style.width = "36%";
		if(lb.offsetWidth < 516) lb.style.width = "516px";
		}
	if(nb)
		{
		nb.style.width = "36%";
		if(nb.offsetWidth < 514) nb.style.width = "514px";
		}
	if(fb)
		{
		fb.style.width = "36%";
		if(fb.offsetWidth < 514) fb.style.width = "514px";
		}
	if(rb)
		{
		rb.style.width = "26.4%";
		if(rb.offsetWidth < 285) rb.style.width = "284px";
		}
	if(rbp)
		{
		rbp.style.width = "50%";
		if(rbp.offsetWidth < 532)
			{
			rbp.style.width = "528px";
			}
		else
			{
			if(rbp.offsetWidth < 680) rbp.style.width = "50%";
			if(rbp.offsetWidth > 680) rbp.style.width = "680px";
			}
		}
	if(document.getElementById("leftBlocksPages"))
		{
		if(document.getElementById("leftBlocksPages").offsetHeight > (document.getElementById("contentBlocksPages").offsetHeight-100))
			{
			document.getElementById("contentBlocksPages").style.height = document.getElementById("leftBlocksPages").offsetHeight+100+"px";
			}
		}
	}
function HHBlocks()
	{
	if(document.getElementById("leftBlocksPages"))
		{
		if(document.getElementById("leftBlocksPages").offsetHeight > (document.getElementById("contentBlocksPages").offsetHeight-100))
			{
			document.getElementById("contentBlocksPages").style.height = document.getElementById("leftBlocksPages").offsetHeight+100+"px";
			}
		}
		if(document.body.scrollWidth>=1260){
			document.getElementById("widescreen").style.visibility = "visible";
		} else {
			document.getElementById("widescreen").style.display = "none";
		};




		//Clocks();
	}
function getBlocks(p,t,c) // Получаем блоки по классу без jQuery
	{
	var blocks = p.getElementsByTagName(t);
	returnArray = new Array;
	for(i=0;i<blocks.length;i++)
		{
		if(blocks[i].className == c)
			{
			returnArray[returnArray.length] = blocks[i];
			}
		}
	return returnArray;
	}

function scrollLeft(b,m,w,s,nb,p) // едем влево
	{
	cm = -1 * m;
	if(cm < w)
		{
		document.getElementById(b).style.marginLeft = m + "px";
		newM = m - 5;
		setTimeout("scrollLeft('"+b+"',"+newM+","+w+",'"+s+"','"+nb+"','"+p+"')",10);
		}
	else
		{
		// возвращаем стили для тянучки
		document.getElementById(b).style.display = "none";
		document.getElementById(s).style.width = "auto";
		document.getElementById(p).style.width = "auto";
		document.getElementById(b).style.width = "auto";
		document.getElementById(nb).style.width = "auto";
		isWorking = false;
		}
	}

function scrollRight(b,m,w,s,nb,p) // едем вправо
	{
	if(m < 0)
		{
		document.getElementById(b).style.marginLeft = m + "px";
		newM = m + 5;
		setTimeout("scrollRight('"+b+"',"+newM+","+w+",'"+s+"','"+nb+"','"+p+"')",10);
		}
	else
		{
		// возвращаем стили для тянучки
		document.getElementById(nb).style.display = "none";
		document.getElementById(s).style.width = "auto";
		document.getElementById(p).style.width = "auto";
		document.getElementById(b).style.width = "auto";
		document.getElementById(b).style.marginLeft = "0px";
		document.getElementById(nb).style.width = "auto";
		isWorking = false;
		}
	}

var sCount = 0; // счетчик скроллинга больших (первых) блоков
var isWorking = false; // флаг активности, т.е. true-едем, false-стоим (лечим double click)

function goLeft(s) // запускаем скроллинг
	{
	if(isWorking == false)
		{
		scroller = document.getElementById(s);
		var blocksArray = getBlocks(scroller,"div","block");
		curWidth = scroller.offsetWidth;
		if(sCount < blocksArray.length-1)
			{
			document.getElementById("innerScroll").style.width = document.getElementById("innerScroll").offsetWidth + "px";
			isWorking = true;
			scrollerW = curWidth * 2;
			blockW = curWidth;
			
			scroller.style.width = scrollerW + "px";
			
			blocksArray[sCount].style.width = blockW + "px";
			blocksArray[sCount+1].style.width = blockW + "px";
			blocksArray[sCount+1].style.display = "block";
			scrollLeft(blocksArray[sCount].id,0,curWidth,s,blocksArray[sCount+1].id,"innerScroll");
			sCount++;
	
			document.getElementById("leftButton").src = "/i/leftButtonAct.gif";
			document.getElementById("rightButton").src = "/i/rightButtonAct.gif";
			
			if(sCount == blocksArray.length-1)
				{
				document.getElementById("leftButton").src = "/i/leftButtonAct.gif";
				document.getElementById("rightButton").src = "/i/rightButtonPas.gif";
				}
			}
		}
	}


function goRight(s) // запускаем скроллинг
	{
	if(isWorking == false)
		{
		scroller = document.getElementById(s);
		var blocksArray = getBlocks(scroller,"div","block");
		curWidth = scroller.offsetWidth;
		if(sCount > 0)
			{
			document.getElementById("innerScroll").style.width = document.getElementById("innerScroll").offsetWidth + "px";
			isWorking = true;
			scrollerW = curWidth * 2;
			blockW = curWidth;
			
			m = -1 * curWidth;
			
			scroller.style.width = scrollerW + "px";
			
			blocksArray[sCount].style.width = blockW + "px";
			blocksArray[sCount-1].style.width = blockW + "px";
			blocksArray[sCount-1].style.marginLeft = m + "px";
			blocksArray[sCount-1].style.display = "block";
			scrollRight(blocksArray[sCount-1].id,m,curWidth,s,blocksArray[sCount].id,"innerScroll");
			sCount--;
	
			document.getElementById("leftButton").src = "/i/leftButtonAct.gif";
			document.getElementById("rightButton").src = "/i/rightButtonAct.gif";
			
			if(sCount == 0)
				{
				document.getElementById("leftButton").src = "/i/leftButtonPas.gif";
				document.getElementById("rightButton").src = "/i/rightButtonAct.gif";
				
				}
			}
		}
	}

var sCountDec = 0; // счетчик скроллинга маленьких (вторых) блоков

function goLeftDec(s) // заускаем скроллинг
	{
	if(isWorking == false)
		{
		scroller = document.getElementById(s);
		var blocksArray = getBlocks(scroller,"div","block");
		curWidth = scroller.offsetWidth;
		if(sCountDec < blocksArray.length-1)
			{
			document.getElementById("innerScrollDec").style.width = document.getElementById("innerScrollDec").offsetWidth + "px";
			isWorking = true;
			scrollerW = curWidth * 2;
			blockW = curWidth;
			
			scroller.style.width = scrollerW + "px";
			
			blocksArray[sCountDec].style.width = blockW + "px";
			blocksArray[sCountDec+1].style.width = blockW + "px";
			blocksArray[sCountDec+1].style.display = "block";
			scrollLeft(blocksArray[sCountDec].id,0,curWidth,s,blocksArray[sCountDec+1].id,"innerScrollDec");
			sCountDec++;
	
			document.getElementById("leftButtonDec").src = "/i/leftButtonDecAct.gif";
			document.getElementById("rightButtonDec").src = "/i/rightButtonDecAct.gif";
			
			if(sCountDec == blocksArray.length-1)
				{
				document.getElementById("leftButtonDec").src = "/i/leftButtonDecAct.gif";
				document.getElementById("rightButtonDec").src = "/i/rightButtonDecPas.gif";
				}
			}
		}
	}


function goRightDec(s) // запускаем скроллинг
	{
	if(isWorking == false)
		{
		scroller = document.getElementById(s);
		var blocksArray = getBlocks(scroller,"div","block");
		curWidth = scroller.offsetWidth;
		if(sCountDec > 0)
			{
			document.getElementById("innerScrollDec").style.width = document.getElementById("innerScrollDec").offsetWidth + "px";
			isWorking = true;
			scrollerW = curWidth * 2;
			blockW = curWidth;
			
			m = -1 * curWidth;
			
			scroller.style.width = scrollerW + "px";
			
			blocksArray[sCountDec].style.width = blockW + "px";
			blocksArray[sCountDec-1].style.width = blockW + "px";
			blocksArray[sCountDec-1].style.marginLeft = m + "px";
			blocksArray[sCountDec-1].style.display = "block";
			scrollRight(blocksArray[sCountDec-1].id,m,curWidth,s,blocksArray[sCountDec].id,"innerScrollDec");
			sCountDec--;
	
			document.getElementById("leftButtonDec").src = "/i/leftButtonDecAct.gif";
			document.getElementById("rightButtonDec").src = "/i/rightButtonDecAct.gif";
	
			if(sCountDec == 0)
				{
				document.getElementById("leftButtonDec").src = "/i/leftButtonDecPas.gif";
				document.getElementById("rightButtonDec").src = "/i/rightButtonDecAct.gif";
				}
			}
		}
	}
	
function showAnimationImg(obj)
{ 
	imgSrc = new String(obj.src);
	imgSrcArray = imgSrc.split("/");
	img = imgSrcArray.pop();
	if(img == 'rightButtonAct.gif')
		obj.src = '/i/rightButtonAct_over.gif';
	else if(img == 'leftButtonAct.gif')
		obj.src = '/i/leftButtonAct_over.gif';
	else if(img == 'rightButtonDecAct.gif')
		obj.src = '/i/rightButtonDecAct_over.gif';
	else if(img == 'leftButtonDecAct.gif')
		obj.src = '/i/leftButtonDecAct_over.gif';
}

function showStaticImg(obj)
{
	imgSrc = new String(obj.src);
	imgSrcArray = imgSrc.split("/");
	img = imgSrcArray.pop();
	if(img == 'rightButtonAct_over.gif')
		obj.src = '/i/rightButtonAct.gif';
	else if(img == 'leftButtonAct_over.gif')
		obj.src = '/i/leftButtonAct.gif';
	else if(img == 'rightButtonDecAct_over.gif')
		obj.src = '/i/rightButtonDecAct.gif';
	else if(img == 'leftButtonDecAct_over.gif')
		obj.src = '/i/leftButtonDecAct.gif';
}

function showMenuPanel(nom) // показываем навигационную панель
	{
	menuLink = document.getElementById("menuLink_"+nom);
	menuPanel = document.getElementById("menuPanel_"+nom);
	
	if(menuLink.className == "select" || menuLink.className == "act select")
			menuLink.className = "act select";
	else
		menuLink.className = "act";
	
	if(menuPanel)
		{
		lp = menuLink.offsetLeft;
		menuPanel.style.display = "inline";
		menuPanel.style.left = lp + "px";
		}
	}
function hideMenuPanel(nom) // убираем навигационную панель
	{
	menuLink = document.getElementById("menuLink_"+nom);
	menuPanel = document.getElementById("menuPanel_"+nom);
	
	if(menuPanel)
		{
		lp = menuLink.offsetLeft;
		menuPanel.style.display = "none";
		menuPanel.style.left = "0px";
		} 
		if(menuLink.className == "select" || menuLink.className == "act select")
			menuLink.className = "select";
		else
			menuLink.className = "";
	}

ddaccordion.init({ //top level headers initialization
	headerclass: "expandable", //Shared CSS class name of headers group that are expandable
	contentclass: "categoryitems", //Shared CSS class name of contents group
	revealtype: "click", //Reveal content when user clicks or onmouseover the header? Valid value: "click", "clickgo", or "mouseover"
	mouseoverdelay: 200, //if revealtype="mouseover", set delay in milliseconds before header expands onMouseover
	collapseprev: true, //Collapse previous content (so only one open at any time)? true/false 
	defaultexpanded: [], //index of content(s) open by default [index1, index2, etc]. [] denotes no content
	onemustopen: false, //Specify whether at least one header should be open always (so never all headers closed)
	animatedefault: false, //Should contents open by default be animated into view?
	persiststate: false, //persist state of opened contents within browser session?
	toggleclass: ["closemenu", "openmenu"], //Two CSS classes to be applied to the header when it's collapsed and expanded, respectively ["class1", "class2"]
	togglehtml: ["prefix", "", ""], //Additional HTML added to the header when it's collapsed and expanded, respectively  ["position", "html1", "html2"] (see docs)
	animatespeed: "slow", //speed of animation: integer in milliseconds (ie: 200), or keywords "fast", "normal", or "slow"
	oninit:function(headers, expandedindices){ //custom code to run when headers have initalized
		//do nothing 
	},
	onopenclose:function(header, index, state, isuseractivated){ //custom code to run whenever a header is opened or closed
		//do nothing
	}
})
