
categories = new Array("praxis", "hypnose", "therapie", "heilung", "karten", "kontakt");

visualImage = new Object();

// let's have all categories images filenames as the first entry in the array
for (var i = 0; i < categories.length; ++i) {
	visualImage[categories[i]] = new Array();
	visualImage[categories[i]][0] = categories[i];
	
	// let's include the second image statically for the moment until these have to be defined manually
	visualImage[categories[i]][1] = categories[i] + "02";
}
	
if (typeof(currentcategory) != "undefined") {
	// let's define the randomly chosen image as the default of the object
	rndm = 0 + (visualImage[currentcategory].length-1)*(Math.random());
	rndm = Math.round(rndm);
	
	visualrndmImage = "images/visual-" + visualImage[currentcategory][rndm] + ".jpg";
	
	//console.log(rndm + " - " + visualrndmImage);
}

$(document).ready( function() {
	$('#firstlevelnavigation, #logo').hide();
	
	$('#firstlevelnavigation li > a').each( function() {
		var teaserslink = $(this).attr('href');
		
		$(this).closest('li').addClass('clickable').click( function() {
			window.location.href = teaserslink;
		})
	});
	
	$('#firstlevelnavigation, #logo').fadeIn(2000);
	
	/* getting the form by the 1und1 formmailer */
	$('#kontakt form').after('<div id="contactform"></div>').remove();
	
	var options = {
	    success:    function() { 
	        $('#kontakt #contactform form').after('Vielen Dank für Ihre Nachricht.').remove();
	    } 
	}; 
	$('#kontakt #contactform').load('/tinc?key=W4MgiPGp&formname=kontakt form', function() {
		$('#kontakt #contactform form').ajaxForm(options); 
	});
	
	if ($('body').attr('id') == "home") {
		//console.log("image preloading");
		
		for (var x = 0; x < visualImage.length; ++x) {
			for (var z = 0; z < visualImage[x].length; ++z) {
				var Bild = new Image();
    			Bild.src = "images/visual-" + visualImage[x][z] + ".jpg";
   			}
		}
		
	}
});
