function getClientWidth()
{
  return document.compatMode=='CSS1Compat' && !window.opera?document.documentElement.clientWidth:document.body.clientWidth;
}

function getElementComputedStyle(elem, prop)
{
  if (typeof elem!="object") elem = document.getElementById(elem);
  
  // external stylesheet for Mozilla, Opera 7+ and Safari 1.3+
  if (document.defaultView && document.defaultView.getComputedStyle)
  {
    if (prop.match(/[A-Z]/)) prop = prop.replace(/([A-Z])/g, "-$1").toLowerCase();
    return document.defaultView.getComputedStyle(elem, "").getPropertyValue(prop);
  }
  
  // external stylesheet for Explorer and Opera 9
  if (elem.currentStyle)
  {
    var i;
    while ((i=prop.indexOf("-"))!=-1) prop = prop.substr(0, i) + prop.substr(i+1,1).toUpperCase() + prop.substr(i+2);
    return elem.currentStyle[prop];
  }
  
  return "";
}

function show_site(id) {

var i = 0;

while (document.getElementById('a_'+i) != null) {
	
	if (document.getElementById('a_'+i).name != 'selected') {

		document.getElementById('a_'+i).style.display = 'block';
	}
i++;
}

var i = 0;

while (document.getElementById('a_'+i) != null) {

	var a = 'a_'+i;	
	var sait = 'sait_a_'+i;
	var title = 'title_a_'+i;
	
	if (document.getElementById(a).name == 'selected') {

		document.getElementById(a).name = '';
		document.getElementById(a).style.display = 'block';
		document.getElementById(sait).style.display = 'none';
		document.getElementById(title).style.display = 'none';
	}
i++;
}

var sait = 'sait_'+id;
var title = 'title_'+id;

document.getElementById(id).name = 'selected';
document.getElementById(id).style.display = 'none';
document.getElementById(sait).style.display = 'block';
document.getElementById(title).style.display = 'block';

change_width();

}


function change_width() {
		
		var row = 3;
		
		if (getClientWidth() > 1550) row = 4; 
		
		var dx = (getClientWidth()-500)*0.8-220;
		var dy = 168 + (getClientWidth()-1600)*0.1 - 20*(row-3);

		if (dx/(row-1) < 220) dx = 220 *(row-1);
		if (dy < 140) dy = 140;

		var x = 0;
		var y = 0;
		
		var i = 0;

		while (document.getElementById('a_'+i) != null ) {	
		
			for (j=1; (j<=row && document.getElementById('a_'+i) != null); j++) {		
						
				document.getElementById('a_'+i).style.left = x;
				document.getElementById('a_'+i).style.top = y;
				z = y + 180;														// Определяем позицию нижнего блока, обеспечивающего зазор внизу
		
				x = x + (dx/(row-1));

				i++;
			}
			
			x = 0;
			y = y + dy;		
		
		}

		document.getElementById('bottom').style.top = z;
		document.getElementById('eschyo').style.top = y+40;

}