// JavaScript Document
try
{
	Shadowbox.init
	(
		{
			language: 'de-DE',
			players:  ['img', 'html', 'iframe', 'qt', 'wmp', 'swf', 'flv'],
			autoplayMovies: true,
			overlayColor: '#000',
			viewportPadding:100
		}
	);
}catch(e){}
function pageStart()
{
	try
	{
		get_new_dimension();
		window.onresize = get_new_dimension;
		ContentObj = new Content('ContentObj');
	}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_send'), 'click', send_contact);
//	}catch(e){}
}
hurra_registerOnLoad(pageStart);

//--
// Resize BG Images
//--
var bodyHeight;
var bodyWidth;
var imgOriginalWidth = 1920;
var imgOriginalHeight = 1200;

function set_body_height()
{
	bodyHeight = document.body.offsetHeight;
}
function set_body_width()
{
	bodyWidth = document.body.offsetWidth;
}
function loader_image_omload(img)
{
	img.style.display = 'block';	
}
function image_omload(img)
{
	img.style.display = 'block';
	//img.parentNode.firstChild.style.display = 'none';
}
function get_new_dimension()
{
	set_body_height();
	set_body_width();
	
	var ImgContainerList = hurra_getElementsByTagAndClassName('background_container', 'div');
	
	var newHeight;
	var newWidth;
	
	var diffHeight = imgOriginalHeight - bodyHeight;
	var diffHeightPerCent = diffHeight / (imgOriginalHeight/100);
	
	var diffWidth = imgOriginalWidth - bodyWidth;
	var diffWidthPerCent = diffWidth / (imgOriginalWidth/100);
	
	//Wenn das Bild schmäler aber Höher als die Seite ist
	if(diffWidthPerCent < 0 && diffHeightPerCent >= 0)
	{
		newWidth = bodyWidth;
		newHeight = Math.ceil
		(
			(imgOriginalHeight / 100)
			*
			(100 + (diffWidthPerCent*-1))
		);
	}
	//Wenn das Bild niedriger aber Breiter als die Seite ist
	else if(diffHeightPerCent < 0 && diffWidthPerCent >= 0)
	{
		newHeight = bodyHeight;
		newWidth = Math.ceil
		(
			(imgOriginalWidth / 100)
			*
			(100 + (diffHeightPerCent*-1))
		);
	}
	//Wenn das Bild schmäler und niedriger als die Seite ist
	else if(diffWidthPerCent < 0 && diffHeightPerCent < 0)
	{
		if(diffWidthPerCent < diffHeightPerCent)
		{
			newWidth = bodyWidth;
			newHeight = Math.ceil
			(
				(imgOriginalHeight / 100)
				*
				(100 + (diffWidthPerCent*-1))
			);
		}
		else
		{
			newHeight = bodyHeight;
			newWidth = Math.ceil
			(
				(imgOriginalWidth / 100)
				*
				(100 + (diffHeightPerCent*-1))
			);
		}
	}
	//Wenn das Bild Höher und Breiter als die Seite ist
	else if(diffWidthPerCent > 0 && diffHeightPerCent > 0)
	{
		if(diffWidthPerCent < diffHeightPerCent)
		{
			newWidth = bodyWidth;
			newHeight = Math.ceil
			(
				(imgOriginalHeight / 100)
				*
				(100 - (diffWidthPerCent))
			);
		}
		else
		{
			newHeight = bodyHeight;
			newWidth = Math.ceil
			(
				(imgOriginalWidth / 100)
				*
				(100 - (diffHeightPerCent))
			);
		}
	}
	for(var i = 0; i < ImgContainerList.length; i++)
	{
		ImgContainerList[i].childNodes[1].style.height = newHeight+'px';
		ImgContainerList[i].childNodes[1].style.marginTop = '-'+Math.ceil(newHeight/2)+'px';
		ImgContainerList[i].childNodes[1].style.width = newWidth+'px';
		ImgContainerList[i].childNodes[1].style.marginLeft = '-'+Math.ceil(newWidth/2)+'px';
	}
}

//--
// Move Content
//--
var ContentObj;
function showHide_content()
{
	ContentObj.showHide_content();
}
function shadowbox_open()
{
	ContentObj.hide_content_adOnce();
}
function shadowbox_close()
{
	ContentObj.showHide_content();
}
function show_bgImage_previous()
{
	ContentObj.show_bgImage_previous();
}
function show_bgImage_next()
{
	ContentObj.show_bgImage_next();
}

function Content(objName)
{
	this.objName = objName;
	
	this.contentHtmlObj = document.getElementById('page_container');
	this.imgBgOterContainer = document.getElementById('background_outer_container');
	this.contentHtmlObjBg = document.getElementById('bg_page_container');
	this.extraLink = document.getElementById('extra_link_container');
	
	this.bttnShowHide = document.getElementById('bttn_move_content');
	this.bttnShowHideOpenSrc = 'pix/bttn_hide_content.gif';	
	this.bttnShowHideCloseSrc = 'pix/bttn_show_content.gif';
	this.contentIsMoving = false;

	this.bgImgList = bgImgList;
	this.activeBgIndex = 0;
	this.activeBgLeft = 0;
	this.nextBgIndex = false;
	this.nextbgLeft = 0;
	this.bgIsMoving = false;
	this.bgMoveInterval = false;
	this.bgIntervalSpeed = 10;
	this.bgMoveWidth = 10;
	this.bgImgList[0][1] = document.getElementById('bg_1');
	this.activeBgContainer = this.bgImgList[0][1];
	this.nextBgContainer;
	
	this.bttnBgImageNext = document.getElementById('img-nav-next');
	hurra_addEvent(this.bttnBgImageNext, 'click', show_bgImage_next);
	this.bttnBgImagePrevious = document.getElementById('img-nav-previous');
	hurra_addEvent(this.bttnBgImagePrevious, 'click', show_bgImage_previous);
	
	this.interval = false;
	this.contentCurrentLeft = 0;
	this.contentWidth = 550;
	this.intervalSpeed = 10;
	this.moveWidth = 50;
	
	hurra_addEvent(this.bttnShowHide, 'click', showHide_content);
	
	this.showHide_content = function()
	{
		if(this.contentIsMoving === false)
		{
			this.bttnShowHide.style.display = 'none';
			if(this.bttnShowHide.src.indexOf(this.bttnShowHideOpenSrc) == -1)
			{
				this.start_show_content();
			}
			else
			{
				this.start_hide_content();
			}
		}
	}
	this.start_show_content = function()
	{
		this.interval = window.setInterval(this.objName+'.move_content_open()' ,this.intervalSpeed);
		this.contentIsMoving = true;
		this.hide_buttons_move_bg();
	}
	this.move_content_open = function()
	{
		if(this.contentCurrentLeft+this.moveWidth < 0)
		{
			this.contentCurrentLeft += this.moveWidth;
			this.contentHtmlObj.style.left = this.contentCurrentLeft+'px';
			this.contentHtmlObjBg.style.left = this.contentCurrentLeft+'px';
		}
		else
		{
			window.clearInterval(this.interval);
			this.interval = false;
			
			this.contentCurrentLeft = 0;
			this.contentHtmlObj.style.left = this.contentCurrentLeft+'px';
			this.contentHtmlObjBg.style.left = this.contentCurrentLeft+'px';
			
			this.contentIsMoving = false;
			this.bttnShowHide.src = this.bttnShowHideOpenSrc;
			this.bttnShowHide.style.left = this.contentWidth+'px';
			this.bttnShowHide.style.display = 'block';
			
			document.getElementById('scroll_container').style.overflow = 'auto';
			this.extraLink.style.display = 'block';
		}
	}
	this.start_hide_content = function()
	{
		this.interval = window.setInterval(this.objName+'.move_content_close()' ,this.intervalSpeed);
		this.contentIsMoving = true;
		this.extraLink.style.display = 'none';
	}
	this.move_content_close = function()
	{
		if(this.contentCurrentLeft-this.moveWidth > this.contentWidth*-1)
		{
			this.contentCurrentLeft -= this.moveWidth;
			this.contentHtmlObj.style.left = this.contentCurrentLeft+'px';
			this.contentHtmlObjBg.style.left = this.contentCurrentLeft+'px';
		}
		else
		{
			window.clearInterval(this.interval);
			this.interval = false;
			this.contentCurrentLeft = this.contentWidth*-1;
			this.contentHtmlObj.style.left = this.contentCurrentLeft+'px';
			this.contentHtmlObjBg.style.left = this.contentCurrentLeft+'px';
			
			this.contentIsMoving = false;
			this.bttnShowHide.src = this.bttnShowHideCloseSrc;
			this.bttnShowHide.style.left = '0px';
			this.bttnShowHide.style.display = 'block';
			
			document.getElementById('scroll_container').style.overflow = 'hidden';
			this.show_buttons_move_bg();
		}
	}
	this.hide_content_adOnce = function()
	{
		this.contentCurrentLeft = this.contentWidth*-1;
		this.contentHtmlObj.style.left = this.contentCurrentLeft+'px';
		this.contentHtmlObjBg.style.left = this.contentCurrentLeft+'px';
		
		this.contentIsMoving = false;
		this.bttnShowHide.src = this.bttnShowHideCloseSrc;
		this.bttnShowHide.style.left = '0px';
		this.bttnShowHide.style.display = 'none';
		
		document.getElementById('scroll_container').style.overflow = 'hidden';
		this.extraLink.style.display = 'none';
	}
	
	//Hintergrunbilder verschieben
	this.show_bgImage_previous = function()
	{
		if(this.bgIsMoving === false)
		{
			this.hide_buttons_move_bg();
			this.bgIsMoving = true;
			if(this.activeBgIndex > 0)
			{
				this.nextBgIndex = this.activeBgIndex-1;
			}
			else
			{
				this.nextBgIndex = this.bgImgList.length-1;
			}
			this.nextbgLeft = 100;
			this.activeBgLeft = 0;
			this.activate_next_bgImage();
			this.bgMoveInterval = window.setInterval(this.objName+'.move_bg_left()' ,this.bgIntervalSpeed);
		}
	}
	this.move_bg_left = function()
	{
		if(this.nextbgLeft - this.bgMoveWidth > 0)
		{
			this.nextbgLeft -= this.bgMoveWidth;
			this.activeBgLeft -= this.bgMoveWidth;
			this.nextBgContainer.style.left = this.nextbgLeft+'%';
			this.activeBgContainer.style.left = this.activeBgLeft+'%';
		}
		else
		{
			window.clearInterval(this.bgMoveInterval);
			this.bgMoveInterval = false;
			
			this.nextbgLeft = 0;
			this.activeBgLeft = -100;
			this.nextBgContainer.style.left = this.nextbgLeft+'%';
			this.activeBgContainer.style.left = this.activeBgLeft+'%';
			
			this.activeBgContainer.style.display = 'none';
			this.activeBgContainer = this.nextBgContainer;
			this.activeBgIndex  = this.nextBgIndex;
			this.bgIsMoving = false;
			if(this.contentIsMoving === false && this.bttnShowHide.src.indexOf(this.bttnShowHideOpenSrc) == -1)
			{
				this.show_buttons_move_bg();
			}
		}
	}
	this.show_bgImage_next = function()
	{
		if(this.bgIsMoving === false)
		{
			this.hide_buttons_move_bg();
			if(this.activeBgIndex < this.bgImgList.length-1)
			{
				this.nextBgIndex = this.activeBgIndex+1;
			}
			else
			{
				this.nextBgIndex = 0;
			}
			this.nextbgLeft = -100;
			this.activeBgLeft = 0;
			this.activate_next_bgImage()
			this.bgMoveInterval = window.setInterval(this.objName+'.move_bg_right()' ,this.bgIntervalSpeed);
		}
	}
	this.move_bg_right = function()
	{
		if(this.nextbgLeft + this.bgMoveWidth < 0)
		{
			this.nextbgLeft += this.bgMoveWidth;
			this.activeBgLeft += this.bgMoveWidth;
			this.nextBgContainer.style.left = this.nextbgLeft+'%';
			this.activeBgContainer.style.left = this.activeBgLeft+'%';
		}
		else
		{
			window.clearInterval(this.bgMoveInterval);
			this.bgMoveInterval = false;
			
			this.nextbgLeft = 0;
			this.activeBgLeft = 100;
			this.nextBgContainer.style.left = this.nextbgLeft+'%';
			this.activeBgContainer.style.left = this.activeBgLeft+'%';
			
			this.activeBgContainer.style.display = 'none';
			this.activeBgContainer = this.nextBgContainer;
			this.activeBgIndex  = this.nextBgIndex;
			this.bgIsMoving = false;
			if(this.contentIsMoving === false && this.bttnShowHide.src.indexOf(this.bttnShowHideOpenSrc) == -1)
			{
				this.show_buttons_move_bg();
			}
		}
	}
	this.activate_next_bgImage = function()
	{
		//Wenn Bg image noch nicht im Cache ist
		if(this.bgImgList[this.nextBgIndex].length == 1)
		{
			this.bgImgList[this.nextBgIndex][1] = document.createElement('div');
			this.bgImgList[this.nextBgIndex][1].className = "background_container";
			this.imgBgOterContainer.appendChild(this.bgImgList[this.nextBgIndex][1]);
			this.bgImgList[this.nextBgIndex][1].innerHTML = '<img class="bg_image_loader" src="pix/background/loader.gif" /><img onload="image_omload(this)" class="bg_image" src="'+this.bgImgList[this.nextBgIndex][0]+'" />';
		}
		
		this.nextBgContainer = this.bgImgList[this.nextBgIndex][1];
		this.nextBgContainer.style.left = this.nextbgLeft+'%';
		get_new_dimension();
		this.nextBgContainer.style.display = 'block';
	}
	this.show_buttons_move_bg = function()
	{
		this.bttnBgImageNext.style.display = 'block';
		this.bttnBgImagePrevious.style.display = 'block';
	}
	this.hide_buttons_move_bg = function()
	{
		this.bttnBgImageNext.style.display = 'none';
		this.bttnBgImagePrevious.style.display = 'none';
	}
}








function input_focus()
{
	if(this.name == this.value)
	{
		this.value = "";
	}
}
function input_blur()
{
	if(this.value == "")
	{
		this.value = this.name;
	}
}


function send_contact()
{
	var errorReport = '';
	
	var salutation = document.getElementsByName('contact_salutation');
	var foundSalutation = false;
	for(var i=0; i< salutation.length; i++)
	{
		if(salutation[i].checked)
		{
			salutation = salutation[i];
			foundSalutation = true;
			break;
		}
	}
	if(foundSalutation == false)
	{
		errorReport += "Bitte wählen Sie Ihre Anrede aus!<br />";
	}

	var name = document.getElementById('contact_name');
	if(!hurra_check_length(name.value, 2))
	{
		errorReport += "Bitte füllen Sie das Feld Name aus!<br />";
	}
	
	var firstname = document.getElementById('contact_firstname');
	if(!hurra_check_length(firstname.value, 2))
	{
		errorReport += "Bitte füllen Sie das Feld Vorame aus!<br />";
	}

	var lastname = document.getElementById('contact_lastname');
	if(!hurra_check_length(lastname.value, 2))
	{
		errorReport += "Bitte füllen Sie das Feld Nachname aus!<br />";
	}

	var company = document.getElementById('contact_company');
	if(!hurra_check_length(company.value, 2))
	{
		errorReport += "Bitte füllen Sie das Feld Firma aus!<br />";
	}

	var email = document.getElementById('contact_email');
	if(!hurra_check_length(email.value, 2))
	{
		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 phone = document.getElementById('contact_phone');
	if(!hurra_check_length(phone.value, 2))
	{
		errorReport += "Bitte füllen Sie das Feld Telefon aus!<br />";
	}
	
	var street = document.getElementById('contact_street');
	if(!hurra_check_length(street.value, 2))
	{
		errorReport += "Bitte füllen Sie das Feld Straße aus!<br />";
	}

	var zip = document.getElementById('contact_zip');
	if(!hurra_check_length(zip.value, 2))
	{
		errorReport += "Bitte füllen Sie das Feld Postleitzahl aus!<br />";
	}

	var city = document.getElementById('contact_city');
	if(!hurra_check_length(city.value, 2))
	{
		errorReport += "Bitte füllen Sie das Feld Ort aus!<br />";
	}

	var country = document.getElementById('contact_country');
	if(!hurra_check_length(country.value, 2))
	{
		errorReport += "Bitte füllen Sie das Feld Land aus!<br />";
	}

	var message = document.getElementById('contact_message');
	if(!hurra_check_length(message.value, 2))
	{
		errorReport += "Bitte füllen Sie das Feld Nachricht aus!<br />";
	}

	if(errorReport.length > 0)
	{
		hurra_alert("Achtung", errorReport, "");
		return false;	
	}
	postVars = "pass=ju236ju&Name="+name.value+"&Email="+email.value+"&Telefon="+phone.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_firstname').value = '';
				document.getElementById('contact_lastname').value = '';
				document.getElementById('contact_company').value = '';
				document.getElementById('contact_email').value = '';
				document.getElementById('contact_phone').value = '';
				document.getElementById('contact_street').value = '';
				document.getElementById('contact_zip').value = '';
				document.getElementById('contact_city').value = '';
				document.getElementById('contact_country').value = '';
				document.getElementById('contact_message').value = '';
				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);
}
