// JavaScript Document
function pageStart()
{
	try
	{
		var flashDescPicContainer = document.getElementById('el_pic_container');
		flashDescPicContainer.style.visibility = "visible";
		Set_AC_FL_RunContent_GET(flashDescPicContainer.innerHTML);
		flashDescPicContainer.innerHTML = AC_FL_RunContent( "codebase","http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0","width","230","height","140","src","flash/desc_gal","quality","high","pluginspage","http://www.macromedia.com/go/getflashplayer","movie","flash/desc_gal", "wmode", "transparent" );
		Set_AC_FL_RunContent_GET('');
	}catch(e){}
	/* Randompicheader */
	if(document.getElementById('head_container_bg_1') !== null)
	{
		try
		{
			var pageArray = new Array
			(
				document.getElementById('head_container_bg_1'),
				document.getElementById('head_container_bg_2'),
				document.getElementById('head_container_bg_3')
			);
		}catch(e){}
	}
	else
	{
		try
		{
			var pageArray = new Array
			(
				document.getElementById('head_start_container_bg_1'),
				document.getElementById('head_start_container_bg_2'),
				document.getElementById('head_start_container_bg_3')
			);
		}catch(e){}
	}
	try
	{
		var menupointArray = new Array
		(
			document.getElementById('button_bg_1'),
			document.getElementById('button_bg_2'),
			document.getElementById('button_bg_3')
		);
		AjaxStartmenu = new fusi_Ajax_Startmenu(pageArray, menupointArray, activeIndex = 0);
		AjaxStartmenu.construct();
		hurra_addEvent(document.getElementById('button_bg_1'), 'mouseover', fusi_Ajax_Startmenu_activatePage);
		hurra_addEvent(document.getElementById('button_bg_2'), 'mouseover', fusi_Ajax_Startmenu_activatePage);
		hurra_addEvent(document.getElementById('button_bg_3'), 'mouseover', fusi_Ajax_Startmenu_activatePage);
		AjaxStartmenu.start_timer();
	}catch(e){}
	try
	{
		hurra_addEvent(document.getElementById('contact_name'), 'focus', input_focus);
		hurra_addEvent(document.getElementById('contact_phone'), 'focus', input_focus);
		hurra_addEvent(document.getElementById('contact_email'), 'focus', input_focus);
		hurra_addEvent(document.getElementById('contact_message'), 'focus', input_focus);
		hurra_addEvent(document.getElementById('contact_subject'), 'focus', input_focus);
		hurra_addEvent(document.getElementById('contact_contactperson'), 'focus', input_focus);
		
		hurra_addEvent(document.getElementById('contact_name'), 'blur', input_blur);
		hurra_addEvent(document.getElementById('contact_phone'), 'blur', input_blur);
		hurra_addEvent(document.getElementById('contact_email'), 'blur', input_blur);
		hurra_addEvent(document.getElementById('contact_message'), 'blur', input_blur);
		hurra_addEvent(document.getElementById('contact_subject'), 'blur', input_blur);
		hurra_addEvent(document.getElementById('contact_contactperson'), 'blur', input_blur);
	}catch(e){}

//	try
//	{
//		Set_AC_FL_RunContent_GET('');
//		document.getElementById('head_flash_container').innerHTML = AC_FL_RunContent( "codebase","http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0","width","870","height","351","src","flash/header","quality","high","pluginspage","http://www.macromedia.com/go/getflashplayer","movie","flash/header", "wmode", "transparent" );
//		Set_AC_FL_RunContent_GET('');
//	}catch(e){}
	try
	{
		hurra_addEvent(document.getElementById('contact_submit'), 'click', send_contact);
	}catch(e){}
}
hurra_registerOnLoad(pageStart);

function input_focus()
{
	if(this.name == this.value)
	{
		this.value = "";
	}
}
function input_blur()
{
	if(this.value == "")
	{
		this.value = this.name;
	}
}

/* Ajax Bildwechsler */
var AjaxStartmenu;
function fusi_Ajax_Startmenu(pageArray, menupointArray, activeIndex)
{
	this.timer = false;
	
	this.PageArray = pageArray;
	this.MenupointArray = menupointArray;
	
	this.intervals = new Array();
	this.alphas = new Array();
	
	this.activeIndex = activeIndex;
	
	this.construct = function()
	{
		for(var i = 0; i < this.PageArray.length; i++)
		{
			this.MenupointArray[i].href = "javascript:void(hurra_empty)";
			this.intervals[i] = false;
			if(this.activeIndex != i)
			{
				try{this.PageArray[i].style.filter = "alpha(opacity=0)";}catch(e){}
				try{this.PageArray[i].style.opacity = 0;}catch(e){}
				this.PageArray[i].style.display = "none";
				this.alphas[i] = 0;
				this.MenupointArray[i].className = "";
			}
			else
			{
				try{this.PageArray[i].style.filter = "alpha(opacity=100)";}catch(e){}
				try{this.PageArray[i].style.opacity = 1;}catch(e){}
				this.PageArray[i].style.display = "block";
				this.alphas[i] = 100;
				this.MenupointArray[i].className = "active";
			}
		}
	}
	
	this.start_timer = function()
	{
		this.timer = window.setTimeout('AjaxStartmenu.start_timer_fade()',10000);
	}
	this.start_timer_fade = function()
	{
		window.clearTimeout(AjaxStartmenu.timer);
		this.timer = false;
		
		var maxIndex = this.MenupointArray.length -1;
		if(this.activeIndex+1 > maxIndex)
		{
			this.setFade(this.MenupointArray[0]);
		}
		else
		{
			this.setFade(this.MenupointArray[this.activeIndex+1]);
		}
	}
	
	this.returnIndex_by_menupoint = function(menupoint)
	{
		for(var i = 0; i < this.MenupointArray.length ;i++)
		{
			if(this.MenupointArray[i].id == menupoint.id)
			{
				return i;
			}
		}
	}
	this.setFade = function(menupoint)
	{
		var index = this.returnIndex_by_menupoint(menupoint);
		if(index != this.activeIndex)
		{
			this.activeIndex = index;
			for(var i = 0; i < this.MenupointArray.length; i++)
			{
				if(i == this.activeIndex)
				{
					this.PageArray[i].style.display = "block";
					if(this.intervals[i] !== false)
					{
						window.clearInterval(this.intervals[i]);
						this.intervals[i] = false;
					}
					this.intervals[i] = window.setInterval("AjaxStartmenu.fadeIn("+i+")",50);
					this.MenupointArray[i].className = "active";
				}
				else
				{
					this.MenupointArray[i].className = "";
					if(this.alphas[i] != 0)
					{
						this.PageArray[i].style.display = "block";
						if(this.intervals[i] !== false)
						{
							window.clearInterval(this.intervals[i]);
							this.intervals[i] = false;
						}
						this.intervals[i] = window.setInterval("AjaxStartmenu.fadeOut("+i+")",50);
					}
				}
			}
		}
	}
	this.fadeOut = function(i)
	{
		var growth = -10;
		if(this.alphas[i] + growth > 0)
		{
			this.alphas[i] += growth;
			try{this.PageArray[i].style.filter = "alpha(opacity="+this.alphas[i]+")";}catch(e){}
			try{this.PageArray[i].style.opacity = this.alphas[i]/100;}catch(e){}
		}
		else
		{
			this.PageArray[i].style.display = "none";
			this.alphas[i] = 0;
			try{this.PageArray[i].style.filter = "alpha(opacity=0)";}catch(e){}
			try{this.PageArray[i].style.opacity = 0;}catch(e){}
			window.clearInterval(this.intervals[i]);
			this.intervals[i] = false;
			this.start_timer();
		}
	}
	this.fadeIn = function(i)
	{
		var growth = 10;
		if(this.alphas[i] + growth < 100)
		{
			this.alphas[i] += growth;
			try{this.PageArray[i].style.filter = "alpha(opacity="+this.alphas[i]+")";}catch(e){}
			try{this.PageArray[i].style.opacity = this.alphas[i]/100;}catch(e){}
		}
		else
		{
			this.alphas[i] = 100;
			try{this.PageArray[i].style.filter = "alpha(opacity=100)";}catch(e){}
			try{this.PageArray[i].style.opacity = 1;}catch(e){}
			window.clearInterval(this.intervals[i]);
			this.intervals[i] = false;
		}
	}
}
function fusi_Ajax_Startmenu_activatePage()
{
	
	window.clearTimeout(AjaxStartmenu.timer);
	AjaxStartmenu.timer = false;
	AjaxStartmenu.setFade(this);
	
}


function send_contact()
{
	var errorReport = '';
	
	var name = document.getElementById('contact_name');
	if(!hurra_check_length(name.value, 2) || name.value == name.name)
	{
		errorReport += "Bitte füllen Sie das Feld Name aus!<br />";
	}

	var phone = document.getElementById('contact_phone');
	if(!hurra_check_length(phone.value, 2) || phone.value == phone.name)
	{
		errorReport += "Bitte füllen Sie das Feld Telefon aus!<br />";
	}
	
	var email = document.getElementById('contact_email');
	if(!hurra_check_length(email.value, 2) || email.value == email.name)
	{
		errorReport += "Bitte füllen Sie das Feld Email aus!<br />";
	}
	else if(!hurra_check_mail(email.value))
	{
		errorReport += "Bitte füllen Sie das Feld Email korrekt aus!<br />";
	}
	
	var contactperson = document.getElementById('contact_contactperson');
	
	var subject = document.getElementById('contact_subject');
	if(!hurra_check_length(subject.value, 2) ||subject.value == subject.name)
	{
		errorReport += "Bitte füllen Sie das Feld Betreff aus!<br />";
	}

	var message = document.getElementById('contact_message');
	if(!hurra_check_length(message.value, 2) || message.value == message.name)
	{
		errorReport += "Bitte füllen Sie das Feld Nachricht aus!<br />";
	}

	if(errorReport.length > 0)
	{
		hurra_alert("Achtung", errorReport, "");
		return false;	
	}
	postVars = "pass=meddent&Name="+name.value+"&Email="+email.value+"&Telefon="+phone.value+"&Betreff="+subject.value+"&Depot - Kundenbetreuer="+contactperson.value+"&Nachricht="+message.value;
	request = new Http(
		"send_mail.php",
		null,
		'POST',
		postVars,
		['Content-Type', 'application/x-www-form-urlencoded']
	);
	request.onreadyst = function()
	{
		if (requestQue.List[0].req.readyState == 4)
		{
			if (requestQue.List[0].req.status == 200)
			{
				document.getElementById('contact_name').value = document.getElementById('contact_name').name;
				document.getElementById('contact_email').value = document.getElementById('contact_email').name;
				document.getElementById('contact_phone').value = document.getElementById('contact_phone').name;
				document.getElementById('contact_subject').value = document.getElementById('contact_subject').name;
				document.getElementById('contact_contactperson').value = document.getElementById('contact_contactperson').name;
				document.getElementById('contact_message').value = document.getElementById('contact_message').name;
				hurra_alert("Vielen Dank für Ihre Anfrage!", "Wir werden uns umgehend um Ihr Anliegen kümmern.", "");
				requestQue.requExecuted();
			}
			else
			{
				requestQue.requExecuted();
			}
		}
	}
	requestQue.add(request);
}
