
//total number of imgages to be changed 
var mood_image_length = 0;
//actual showed mood image
var actual_mood_image = 0;
//old showed mood image
var old_mood_image = 0;
// duration of Loop
var duration_of_loop = 8500;
// duraation of fade_in when a click is done
var fadein_duration_click = 500;
//Period which it takes to slide in new Image
var fadein_duration = 2000;
//true if change should be performed 
var do_moodarea_image_change = true;

$(document).ready(function() {
	var div_counter = 0;
	$('div.centerCol').children('div').each(function(){
	      	if(div_counter > 0){	
            		$(this).css('margin-bottom','60px');
           	}
           	if($(this).hasClass('csc-default')){
        		div_counter ++;
        	}
               
    	});
    		
	// function for changing moodimages
	init_change_moodarea_image();
	
	setInterval( "change_moodarea_image()", duration_of_loop );
	
});
/*
* Function to delete the default search item
*
**/
function delete_default_searchItem(input){
	if(input.value == 'Suchbegriff'){
		input.value = '';
	}
}

/*
*Function to check the input in the searchbox
*
*return true or false
**/
function CheckInput(){
	var return_value = true;
	if(document.getElementById('tx-indexedsearch-searchbox-sword').value == ''){
		return_value = false;
	}
	//alert(document.getElementById('tx-indexedsearch-searchbox-sword').value);
	return return_value;
}
/*
 * MOODAREA
 * 
 * Image Change effect
 * 
 */

/* Init-function
 * called when page is loaded
 */
function init_change_moodarea_image()
{
	// set total number of images to be slided
	mood_image_length =  ($("#container_moodarea_image div.moodimage").length);
	//alert(mood_image_length+' lang');
	if (mood_image_length > 1)
	{
		// set actual img to front 
		$("#container_moodarea_image div.moodimage").css({"z-index": "30"});
		$("#container_moodarea_image div.moodimage:first").css({"z-index": "32"});
		$("#container_moodarea_image div.moodimage:last").css({"z-index": "31"});
		
	}
	else
	{
		do_moodarea_image_change = false;
	}

}



function change_moodarea_image()
{	
	if (do_moodarea_image_change)
	{
	
		// set the old images of last loop (pre pre images to back)
		$("#container_moodarea_image div.moodimage").each(function(){
			
			if ($(this).css("z-index") == "31")
			{
				$(this).css({"z-index" : "30", "opacity" : "1.0"});
			}
			else if ($(this).css("z-index") == "32")
			{
				$(this).css({"z-index" : "31", "opacity" : "1.0"});
			}
		});
		
		// checks which images is next
		//if it is last image set it to first, otherwise set it plus one (++)
		if (actual_mood_image == mood_image_length-1)
		{
			actual_mood_image = 0;
		}
		else 
		{
			actual_mood_image++;
		}

		// set image to faded in to front an set opacity to 0.0
		// fade in actual image in front 
		$("#container_moodarea_image div.moodimage:eq(" + actual_mood_image + ")").css({"display": "none", "z-index": "32"}).fadeIn(fadein_duration);
		
	}	
}


