/**
 * Creating Cookimanager Object
 */
var manager = new CookieManager();

function showTeaser(id,switchImgId,mode){
	switchImg = document.getElementById(switchImgId);
	if(switchImg){
		switchImg.src = 'fileadmin/images/list_minus.png';
		switchImg.onclick = function(){hideTeaser(id,switchImgId);};
		if(mode=='cookie')
		{
			document.getElementById(id).style.display = 'block';
		}else{
			Effect.Appear(id,{duration: 0.4});
		}
		manager.setCookie(id,'block');
	}
}
function hideTeaser(id,switchImgId,mode){
	switchImg = document.getElementById(switchImgId);
	if(switchImg){
		switchImg.src = 'fileadmin/images/list_plus.png';
		switchImg.onclick = function(){showTeaser(id,switchImgId);};	
		if(mode=='cookie')
		{
			document.getElementById(id).style.display = 'none';
		}else{
			Effect.Fade(id,{duration: 0.4});		
		}
		manager.setCookie(id,'none');
	}
}	

function expand(id) {
		if (expanded[name] == false) {
			Effect.toggle(document.getElementById(id), 
                          'blind', 
                          { duration: 0.4, 
                            afterFinish: function(effect) { effect.element.style.height = ''; } } );
			expanded[name] = true;
            update_checkboxes();
		}
	}

	function deflate(id) {
		if (expanded[name] == true) {
			Effect.toggle(document.getElementById(id), 
                          'blind', 
                          { duration: 0.4, 
                            afterFinish: function(effect) { effect.element.style.height = ''; } } );
		}
	}

function init_TeaserLayer(){
	
	var rightarea = document.getElementById("content-right");
	var rightarea_divs = rightarea.getElementsByTagName("div");
	var rightarea_divs_length = rightarea_divs.length;
			
	for (var i=0;i<rightarea_divs_length;i++){
		if(isIE) current_id = rightarea_divs[i].id;
		if(!isIE) current_id = rightarea_divs[i].getAttribute("id");
		if(current_id != null){
			if(current_id.match(/teaser-[0-9]*/) != null){
				aCookieName = current_id.match(/teaser-[0-9]*/);
	    		result = manager.getCookie(aCookieName);
	    		if(result == 'none'){
						hideTeaser(current_id,'switchImg-'+current_id,'cookie');
				}
				if(result == 'block') {
						showTeaser(current_id,'switchImg-'+current_id,'cookie');
				}
				if(result == null){
					hideTeaser(current_id,'switchImg-'+current_id);			
				}
				
			}
	
		}
	}
}