/* cas pre skryvanie/odkryvanie */
var timeout = 1500;
/* pocet kontaktov */
var contactmax = 3;
/* cas ktory bude zobrazeny dany kontakt*/
var disptime = 5000;
/* zaciatocky kontakt */
var id = 1; 

function opacity(opacStart, opacEnd) {
	
	millisec = timeout;
	aid = 'contact'+id;
    var speed = Math.round(millisec / 100);
    var timer = 0;

    //determine the direction for the blending, if start and end are the same nothing happens
    if(opacStart > opacEnd) {
        for(i = opacStart; i >= opacEnd; i--) {
            setTimeout("changeOpac(" + i + ",'" + aid + "')",(timer * speed));
            timer++;
        }
    } else if(opacStart < opacEnd) {
        for(i = opacStart; i <= opacEnd; i++)
            {
            setTimeout("changeOpac(" + i + ",'" + aid + "')",(timer * speed));
            timer++;
        }
    }
}

//change the opacity for different browsers
function changeOpac(opacity, id) {
    var object = document.getElementById(id).style;
    object.opacity = (opacity / 100);
    object.MozOpacity = (opacity / 100);
    object.KhtmlOpacity = (opacity / 100);
    object.filter = "alpha(opacity=" + opacity + ")";
} 

function display(elem) {
	document.getElementById(elem).style.display = 'block';
}

function hide(elem) {
	document.getElementById(elem).style.display = 'none';
}

function dipsplayAfter(elem, time) {
	setTimeout("display('"+elem+"')", time);
}

function hideAfter(elem, time) {
	setTimeout("hide('"+elem+"')", time);
}

function start() {
	
	opacity(100, 0);
	hideAfter('contact'+id, timeout);
	
	id++;
	if (id == contactmax+1) { id = 1; }
	var temp = 'contact'+id;
	
	setTimeout("changeOpac(0, '"+temp +"')", timeout);
	setTimeout("dipsplayAfter('"+temp+"', '"+timeout+"')", timeout);
	setTimeout("opacity(0, 100)", 2*timeout);
	setTimeout("start()", 3*timeout+disptime);
}

