function initStart()
{	
	var panel = new YAHOO.widget.Panel("menuStart",
		{
		fixedcenter: true, 
		constraintoviewport: true, 
		visible:false,
		modal: false, 
		width:"760px", 
		height:"660px",
		draggable:true } );
		
		overlayManager.register(panel);
		panel.render();
		menuPanel[0] = panel;
		
		waitDialog = new YAHOO.widget.Panel("wait",  { width: "240px", 
	                                                      fixedcenter: true, 
	                                                      close: false, 
	                                                      draggable: false, 
	                                                      zindex:4,
	                                                      modal: true,
	                                                      visible: false
	                                                    } 
	                                                );
													
	    overlayManager.register(waitDialog);
		
        waitDialog.setHeader("Bitte warten...");
        waitDialog.setBody("<img src='img/rel_interstitial_loading.gif'/>");
        waitDialog.render(document.body);
		

}

function showMenu(id)
{
	if(menuPanel[id])
	{
		menuPanel[id].show();
	}
	else
	{
		var post = "id=" + id;
		var callback =
		{
			success: function(o)
			{
				var id = o.argument[0];
				
				var panelDiv = document.createElement("div");
				panelDiv.id = "menuPanel"+id
				document.body.appendChild(panelDiv);
				panelDiv.innerHTML = o.responseText;
						
				var panel = new YAHOO.widget.Panel(panelDiv,
					{ fixedcenter: true, 
					constraintoviewport: true, 
					visible:false,
					modal: false, 
					width:"700px", 
					height:"640px",
					draggable:true } );
					
				overlayManager.register(panel);
				
				panel.render();
				panel.show();
				
				menuPanel[id] = panel;			
			},
			failure: function(o)
			{
				alert("Error in showMenu()");
			},
			argument: [id]
		}
		YAHOO.util.Connect.asyncRequest('POST', "mod/header/xhrGetMenu.php", callback, post); 		
	}
}

function sendContactMail()
{
	var form = document.getElementById("sendContactMailForm");
	var error = new Array();
	
	if(isEmpty(trim(form.name.value)))
	{
		error.push("Bitte gib deinen Namen ein!");
	}
	if(isEmpty(trim(form.email.value)))
	{
		error.push("Bitte gib deine E-Mail Adresse ein!");
	}
	if(isEmpty(trim(form.message.value)))
	{
		error.push("Bitte gib eine Nachricht ein!");
	}
	if(isEmpty(error))
	{
		YAHOO.util.Connect.setForm(form);
		
		var callback =
		{
			success: callbackSendContactMail,
			failure: function(o)
			{
				alert("Error in sendContactMail()");
			}
		};
		
		YAHOO.util.Connect.asyncRequest('POST', "mod/header/xhrSendContactMail.php", callback); 
	}
	else
	{
		$("sendContactMailError").innerHTML = error.join("<br>");
		$("sendContactMailError").style.display = "";
	}		
}

function callbackSendContactMail(o)
{
	if(o.responseText != "1")
	{
		alert(o.responseText);
	}
	else
	{
		var form = document.getElementById("sendContactMailForm");
		form.name.value="";
		form.email.value="";
		form.message.value="";
		$("sendContactMailError").innerHTML = "Deine Nachricht wurde abgeschickt!";
		$("sendContactMailError").style.display = "";
	}
}

function faqToggle(id)
{
	var question = $("faqQuestion"+id);
	var answer = $("faqAnswer"+id);
	
	if(question.className == "open")
	{
		question.className = "closed";
		answer.style.display = "none";
	}
	else
	{
		question.className = "open";
		answer.style.display = "";		
	}
}
