/*-----------------------------------------
 
 copyright 2009 by mmc
 
 Version: 1.0
 
 Author: Georg Paul
 
 Author URI: http://www.mmc-agentur.at
 
 -------------------------------------------*/



$(document).ready(function(){

	if ($('.csc-sitemap').attr('class')){
		jquerySitemap('.csc-sitemap ul', 'closed', 'vertical');
	}
	
	$('#lang_nav_label').append('<div id="active-flag"></div>');
	
	$('#lang_nav_label').bind('click', function(event){
		event.preventDefault();
		
		$('#languages ul').slideToggle('fast');
	})
	
	$('.portalseite .column1 .teaser:last').css('border-bottom', 'none');


if (errorDIV=document.getElementById('form_error')) {
   
   /* ALLE LABELS AUSLESEN */
   var label=document.getElementsByTagName('label');
   var labelAssoc=new Array(label.length);
   for (var i=0; i<label.length;i++) {
    labelAssoc[label[i].htmlFor]=label[i].innerHTML;
   }
   
   var li=errorDIV.getElementsByTagName('li');
   for (var i=0; i<li.length; i++) {
    var inputValue=li[i].innerHTML;
    inputValue=inputValue.toLowerCase();
    li[i].innerHTML=labelAssoc[inputValue];
   }
}
	
});


function jquerySitemap(rootElement, presentation, type ) {

	if(rootElement){
				
		// assign the layout depending on the given parameter 'type'
		// by default 'vertical' is assigned
			var type = (type == null) ? "vertical" : type;
			$(rootElement).addClass(type);
		
		
		// hide/show sublevels depending on the parameter 'presentation'			
			var presentation = (presentation == null) ? "open" : presentation;
		
			if (presentation == 'closed') {
				$(rootElement + ' ul').hide();
				spanClass = 'collapsed';
			}
			else {
				spanClass = 'expanded';
			}
		
		
		// append the navigation for toggling
			$(rootElement + ' li').find('ul').each(function(){
				$(this).after('<span class="'+ spanClass +'" />');
			})
		
			
		
		// Toggle the Icons onclick
			$('.expanded').live('click', function(){
				$(this).prevAll('ul').slideToggle();
				$(this).attr('class', 'collapsed');
			})
			$('.collapsed').live('click', function(){
				$(this).prevAll('ul').slideToggle();
				$(this).attr('class', 'expanded');
			})	
			
			$('.expanded, .collapsed').hover(function(){
				$(this).css('cursor', 'pointer');
			})			
	};
	

};




