
var currentFeature = 1;
var maxFeaturesCount = 5;
var loopIntro = new Array(2);
loopIntro[0] = "intro1"; 
loopIntro[1] = "intro2"; 
loopIntro[2] = "intro3"; 

var currentIntro = 0;

toggles = function toggles() {
	document.getElementById('lang').onclick = function() {
		if(document.getElementById('langs').style.display == 'block') {
			document.getElementById('langs').style.display = 'none'; 
		} else {
			document.getElementById('langs').style.display = 'block';
		}
	}

	for (i=0; i < maxFeaturesCount; i++) {			
			var elemId = 'feature'+(i+1);
			var elem = document.getElementById(elemId);
			if (elem)
			{
				elem.n = i+1;
				document.getElementById(elemId).onclick = function() {
					// scroll through all features and remove class
					selectFeature(this.n);
				}
			}
		}

	$(loopIntro[0]).shake( { delay: 3.0, distance: 1, duration: 0.5 });
	$(loopIntro[0]).shake( { delay: 4.5, distance: 1, duration: 0.6 });
	$(loopIntro[0]).shake( { delay: 5.5, distance: 1, duration: 0.5 });
		
	setTimeout('morphIntro()', 10000);
		
}


function morphIntro() {

	$(loopIntro[currentIntro]).fade();		
	$('pic_' + loopIntro[currentIntro]).fade();		

	currentIntro++;
	if (currentIntro >= loopIntro.length) currentIntro = 0;

	$(loopIntro[currentIntro]).appear({ delay: 1 });
	$('pic_' + loopIntro[currentIntro]).appear({ delay: 1.3 });
	
	setTimeout('morphIntro()', 11000);
}

function nextFeature() {
	currentFeature++;
	if (currentFeature > maxFeaturesCount)
		currentFeature = 1;

	selectFeature(currentFeature);
}

function prevFeature() {
	currentFeature--;
	if (currentFeature <= 0)
		currentFeature = 5;
		
	selectFeature(currentFeature);
}

function selectFeature(n) {
	
	currentFeature = n;
	for (i2=0; i2 < maxFeaturesCount; i2++)
	{			
		document.getElementById('feature'+(i2+1)).className = 'feature';		
		document.getElementById('featureimg'+(i2+1)).className = 'hidden'; 
	}
	//this.className = 'feature active';
	document.getElementById('feature'+(n)).className = 'feature active'; 
	document.getElementById('featureimg'+(n)).className = ''; 
}

window.onload = toggles;

