var destination = "typewriter";
var delay = 50;
var currentChar = 1;
var currentText = 0;
var currentDelay = 2000;

var text_arr = new Array ('Компьютерный сервис Эконом&Экономыч поздравляет всех посетителей с наступающим Новым Годом.', 
						  'В канун праздника мы подготовили вам подарок — специльное предложение <a href="ekspluataciya.php">Ввод компьютера в эксплуатацию</a>', 
						  'Этот пакет услуг предназначен для тех, кто купил новый компьютер и хочет как можно скорее использовать его по максимуму');
var text = text_arr[currentText];

function type()
{	
	if (document.getElementById)
	{
		var dest = document.getElementById(destination);
		if (dest)
		{
			dest.innerHTML = text.substr(0, currentChar);
			currentChar++;
			
			if (currentChar > text.length)
			{
				currentChar = 1;
				
				if (currentText >= text_arr.length - 1)
				{
					currentText = 0;
					currentDelay = 10000;
				}
				else {
					currentText++;
					currentDelay = 2000;
				}
				
				text = text_arr[currentText];
				setTimeout("type()", currentDelay);
			}
			else
			{
				setTimeout("type()", delay);
			}
		}
	}
}

function getObj(id) {
	if (document.getElementById) { 
		return document.getElementById(id); 
	}
	else if (document.all) {  
		return document.all[id]; 
	}
	else if (document.layers) { 
		return document.layers[id]; 
	}
}

function placeFooter () {
	var obj = new Array();
	var h = new Array();
	var top;
	
	obj[1] = getObj('leftColumn');
	obj[2] = getObj('centerColumn');
	obj[3] = getObj('rightColumn');
	
	h[1] = obj[1].offsetHeight;
	h[2] = obj[2].offsetHeight;
	h[3] = obj[3].offsetHeight;
	
	top = Math.max(h[1], Math.max(h[2], h[3]));
	
	top += 270;
	
	getObj('footer').style.top = top + 'px';
}

function showPackage (id) {
	if (getObj(id).style.display == 'none') {
		getObj(id).style.display = 'block';
	}
	else getObj(id).style.display = 'none';
	placeFooter ();
}

function showInfo (id) {
	if (getObj(id).style.display == 'none') {
		getObj(id).style.display = 'block';
	}
	else getObj(id).style.display = 'none';
	placeFooter ();
}

function init() {
	placeFooter();
	//type();
}

window.onload = init;