 /**
  * JavaScript for Akkordion-Navigation on www.carpe-diem-events.com
  *
  * @author Steffen Friedrich (steffen.friedrich@pingping.ag, www.pingping.ag)
  ***/
function Navi()
{	var e=document.getElementsByTagName('body');
	if(e[0].className.indexOf('layout-0')==-1) // different layout
		return;
	else if(e[0].className.indexOf('bild-none')>-1) // start-page
	{	e=get('main-navigation');
		e=e.firstChild;

		var a=new Array(),act=0,closeWidth,openWidth,c=0;

		while(e)
		{	if(e.className && e.tagName=='LI')
			{	if(c && c<4)
				{	a.push(e);

					e.style.width=(e.offsetWidth-1)+'px';
					e.style.overflow='hidden';

					if(c==1) 
					{	openWidth=e.offsetWidth-1;
					}else
					{	closeWidth=e.offsetWidth-1;
					}
				}	
				c++;
			}
			
			e=e.nextSibling;
		}

		new Akkordion(
			{'type': 'horizontal',
			'action': 'mouseover',
			'inputs': a,
			'panels': a,
			'active': 0,
			'openWidth': openWidth,
			'closeWidth': closeWidth,
			'steps': 15,
			'time': 400,
			}
		);
		
	} else // default accordion
	{	e=get('main-navigation');
		e=e.firstChild;
		while(e)
			if(e.className && e.className.indexOf('open')>-1) // the main navi pt
				break;
			else e=e.nextSibling;
	
		e=e.firstChild;
		while(e)
			if(e.tagName=='UL') break; // the list inside the pt
			else e=e.nextSibling;
		
		e=e.firstChild;
		var a=new Array(),a3=new Array(),act,closeWidth,openWidth,c;
		while(e)
		{	if(e.tagName=='LI')
			{	a.push(e); // add li to arr
				e.style.width=(e.offsetWidth-1)+'px'; // change display stuff/prepare ani
				e.style.overflow='hidden';
				if(e.className.indexOf('open')==-1)
				{ e.className+=' open';
					closeWidth=e.offsetWidth-1;
	
					c = e.firstChild; // setting the 1st 3rd level open
					while(c && c.tagName!='UL')
						c=c.nextSibling;
					a3.push(c);
	
					// glueing the lis together
					var b=1,co, c2 = document.createElement('DIV');
					c2.style.float='right';
					c2.style.width=c.offsetWidth+'px';
	
					c.appendChild(c2);
					c=c.firstChild;
	
					do
					{	co=c.nextSibling;
						if(c2!=c)
							c2.appendChild(c);
						 if(b && c.tagName=='LI')
						 {	c.className+=' open';
						 		b=false;
						 }
							
						c = co;
					} while(c);
	
	
				} else 
				{ act=a.length-1;
					openWidth=e.offsetWidth-1;
	
					c = e.firstChild; // getting the 1st 3rd level ul
					while(c && c.tagName!='UL')
						c=c.nextSibling;
					a3.push(c);
					
					// glueing the lis together
					var co, c2 = document.createElement('DIV');
					c2.style.float='right';
					c2.style.width=c.offsetWidth+'px';
	
					c.appendChild(c2);
					c=c.firstChild;
	
					do
					{	co=c.nextSibling;
						if(c2!=c)
							c2.appendChild(c);
						c = co;
					} while(c);
	
				}
			}
			e=e.nextSibling;
		}
		
		var a2=new Array(), s;
		for(s=0;s<a.length;s++)
		{	e=a[s].firstChild;
			while(e)
				if(e.tagName=='A')break;
					else e=e.nextSibling;
	
			if(act!=a2.length)
			{	if(e.href.indexOf('.0.')>-1)
					e.ajaxHref=e.href.replace(/\.0\./,'.1.');
				else	e.ajaxHref=add2url(e.href,'type=1');
				e.href='#';
			}
			a2.push(e);
		}
	
		new Akkordion(
			{'type': 'horizontal',
			'action': 'click',
			'inputs': a2,
			'panels': a,
			'additionals': a3,
			'active': act,
			'openWidth': openWidth,
			'closeWidth': closeWidth,
			'content': get('content'),
			'ajax': new AJAX(),
			'steps': 15,
			'time': 400,
			'initialContent': '<div class="ajax-waiter"><img src="fileadmin/img/logo-carpediem-event-manufaktur.png" title="Lade Inhalte, bitte warten..." /><br /><br /><img src="fileadmin/img/loading-carpe-diem.gif" alt="Lade Inhalt..." /></div>'
		}
		);
	}


}
		

