//Globális változók
var currentContact = 0;
var switchingContact = 0;

function SetContact(index) {
	if (index>=ContactsCount) index=0;
	if (index<0) index=ContactsCount-1;
	var leiras = document.getElementById('q3_board');
	if (leiras == null) return;
	var kep = document.getElementById('q3_portre_kep');
	if (kep == null) return;
	
	leiras.innerHTML = '<div id="q3_leiras_spacer">'+Contacts[index].text+'</div>';
	kep.src = Contacts[index].image;
	currentContact = index;
}

function ContactOut(offset,dir) {
	var leiras = document.getElementById('q3_leiras_spacer');
	var inc = offset / 8;
	offset += inc;
	leiras.style.marginLeft = parseInt(offset) + "px";
	if (offset < 240) 
		setTimeout('ContactOut('+offset+','+dir+')',10);
	else {
		SetContact(currentContact+dir);	
		ContactIn(offset);
	}
}

function ContactIn(offset) {
	var leiras = document.getElementById('q3_leiras_spacer');
	var dec = offset / 8;
	offset -= dec;
	leiras.style.marginLeft = parseInt(offset) + "px";
	if (offset > 1) 
		setTimeout('ContactIn('+offset+')',10);
	else 
		switchingContact = 0;
}

function NextContact() {
	if (switchingContact == 0) {
		switchingContact = 1;
		ContactOut(1,1);
	}
}

function PrevContact() {
	if (switchingContact == 0) {
		switchingContact = 1;
		ContactOut(1,-1);
	}	
}