var ToolTipYpos = 110;
var portOverStat = false;
(function($){
var PROP_NAME = 'NoticeMsg';
$.fn.noticeMsg = function(message, options) {
var op = $.extend({}, {
message: 'Notification',
addClass: '',
dur: 3000,
fade: 300, 
klassenName: 'notice-message'
}, options),
m = message || op.message;

return this.each(function(){
var e = this == window || this == document ? document.body : this;
var $el = $(e).children('.'+op.klassenName).length ? $(e).children('.'+op.klassenName) : $('<div class="'+op.klassenName+' ' + op.addClass + '" />').appendTo(e);

$el.html(m)
.click(remove)
.css({
display: 'none',
top: ($(this).height() - $el.innerHeight())/2,
left: ($(this).width() - $el.innerWidth())/2
})
.fadeIn(op.fade);

clearTimeout($.data(e, PROP_NAME));
op.dur && $.data(e, PROP_NAME, setTimeout(remove, op.dur));

function remove() {
$.removeData(e, PROP_NAME);
$el.fadeOut(op.fade, function(){
$el.remove();
});
}
});
};
$.noticeMsg = function(message, options) {
$(document.body).noticeMsg(message, options);
}
})(jQuery);

/*
*************************************************
*    Javascript Copyright www.Muntumedia.de     *
*					Dörte Stein       			*
*
*
*
*
*
*
*************************************************
*/
//Auf Leerstring überprüfen
function checkEmpty(str)
{
	if(str.replace(/ /gi,"") != "")
	{
		return(true);
	}
	else
	{
		return(false);
	}
}




//Kontaktformular Überprüfen und absenden
function sendeKontakt(formular)
{
	var alertBox = document.getElementById('alertBox');
	alertBox.innerHTML = "";
	var kontaktformular = document.getElementById(formular);
	var allElem = Array();
	var sendready = true;
	var errText = "";
	var elements;
  	if(kontaktformular.all)
	{
		elements=kontaktformular.all;
	}
  	else if(kontaktformular.getElementsByTagName && !kontaktformular.all)
	{
		elements=kontaktformular.getElementsByTagName("*");
	}
	for(i=0;i<elements.length;i++)
  	{
		if(checkEmpty(elements[i].className))
		{
			if(elements[i].className.search(/(essential)/) != -1)
			{
				allElem.push( elements[i]);
			}
		}
  	}
	var e = 0;
	for(i=0;i<allElem.length;i++)
  	{
		var wert = checkEmpty(allElem[i].value);
		var tf_name = allElem[i].title;
		if(wert == false)
		{
			var kom = (e > 0)? "," : "";
			errText += kom + tf_name;
			sendready = false;
			e++;
		}
	}
	if(sendready == true)
	{
		kontaktformular.submit();
	}
	else
	{
		$('#kontaktform').noticeMsg("Die Eingabefelder: &quot;<span>"+errText+"&quot;</span> dürfen nicht leer sein!");
		//alert("Die Eingabefelder "+errText+" dürfen nicht leer sein!");
	}
}




//Activelink setzen

function activeLink(linkAdd,pram)
{
	var params=document.URL;
	return(params);
	
}

function alertSizeContent() {
  var conHeightElem = document.getElementById('ContentBox');
  var conHeight = conHeightElem.height;
  return conHeight;
}

function alertSize() {
  var myWidth = 0, myHeight = 0;
  if( typeof( window.innerWidth ) == 'number' ) {
    //Non-IE
    myWidth = window.innerWidth;
    myHeight = window.innerHeight;
  } else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
    //IE 6+ in 'standards compliant mode'
    myWidth = document.documentElement.clientWidth;
    myHeight = document.documentElement.clientHeight;
  } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
    //IE 4 compatible
    myWidth = document.body.clientWidth;
    myHeight = document.body.clientHeight;
  }
  return [ myWidth, myHeight ];
}

function getScrollXY() {
  var scrOfX = 0, scrOfY = 0;
  if( typeof( window.pageYOffset ) == 'number' ) {
    //Netscape compliant
    scrOfY = window.pageYOffset;
    scrOfX = window.pageXOffset;
  } else if( document.body && ( document.body.scrollLeft || document.body.scrollTop ) ) {
    //DOM compliant
    scrOfY = document.body.scrollTop;
    scrOfX = document.body.scrollLeft;
  } else if( document.documentElement && ( document.documentElement.scrollLeft || document.documentElement.scrollTop ) ) {
    //IE6 standards compliant mode
    scrOfY = document.documentElement.scrollTop;
    scrOfX = document.documentElement.scrollLeft;
  }
  return [ scrOfX, scrOfY ];
}


function checkLogoPos()
{
	var infoBox = document.getElementById('infoBox');
	var Fensterhoehe =  alertSize();
	var ScrollOffset = getScrollXY();
	var Contenthoehe = document.getElementById("ContentBox").offsetHeight;
	var Contentbreite = document.getElementById("ContentBox").offsetWidth;
	var muntulogo = document.getElementById("muntulogo");
	var adress = document.getElementById("footerAdress");
	var tooltip = document.getElementById("MuntuTooltip");
	var xSpace = (Fensterhoehe[0] - (Contentbreite + 25)) - 400;
	var ySpace = (Fensterhoehe[1] - (Contenthoehe + 293)) - 80;
	var rePOS = false;
	/*infoBox.innerHTML = "Fensterhöhe: " + Fensterhoehe[1] + ", ScrollOffset: " + ScrollOffset[1] + ", Content Höhe: " + Contenthoehe + "<br />Fensterbreite: " + Fensterhoehe[0] + ", Contentbreite: " + Contentbreite + ", Xspace: " + xSpace + ", ySpace: " + ySpace;
	infoBox.style.top = ScrollOffset[1] + "px";*/
	if(xSpace < 0)
	{
		if(ySpace < 0)
		{
			/*infoBox.innerHTML += "<br /><br />LOGO REPOSITIONIERUNG";*/
			rePOS = true;
			muntulogo.style.bottom = ySpace + "px";
			adress.style.bottom = ySpace + "px";
			tooltip.style.bottom = (ySpace+110) + "px";
			ToolTipYpos = ySpace + 110;
			
		}
		else
		{
			muntulogo.style.bottom = "0px";
			adress.style.bottom = "0px";
			tooltip.style.bottom = "110px";
			ToolTipYpos = 110;
			rePOS = false;
		}
	}
	else
	{
		muntulogo.style.bottom = "0px";
		adress.style.bottom = "0px";
		tooltip.style.bottom = "110px";
		ToolTipYpos = 110;
		rePOS = false;
	}
	
	if(rePOS == false)
	{
		if(Fensterhoehe[1] < 376)
		{
			muntulogo.style.bottom = (Fensterhoehe[1] - 376)-ScrollOffset[1] + "px";
			adress.style.bottom = (Fensterhoehe[1] - 376)-ScrollOffset[1] + "px";
			tooltip.style.bottom = (ySpace+110) + "px";
			ToolTipYpos = ySpace + 110;
			
		}
		else
		{
			muntulogo.style.bottom = (0-ScrollOffset[1]) + "px";
			adress.style.bottom = (0-ScrollOffset[1]) + "px";
			tooltip.style.bottom = "110px";
			ToolTipYpos = 110;
		}
	}
	
	if(Fensterhoehe[0] < 560)
	{
		setActiveStyleSheet("smart");
	}
	else
	{
		setActiveStyleSheet("standard");
	}
	
}


$(document).ready(function() {
			checkLogoPos();
			$("#imprintlink").fancybox({
				'width'				: 550,
				'height'			: 450,
				'autoScale'			: false,
				'transitionIn'		: 'fade',
				'transitionOut'		: 'fade',
				'speedIn'			: 300,
				'speedOut'			: 500,
				'easingIn'			: 'linear',
				'type'				: 'iframe',
				'overlayOpacity'	: 0.7,
				'overlayColor'		: '#333'
			});
			
			$(".videolink").fancybox({
				'width'				: 400,
				'height'			: 335,
				'autoScale'			: false,
				'transitionIn'		: 'fade',
				'transitionOut'		: 'fade',
				'speedIn'			: 300,
				'speedOut'			: 500,
				'easingIn'			: 'linear',
				'type'				: 'iframe',
				'overlayOpacity'	: 0.7,
				'overlayColor'		: '#333'
			});
			
		    var box = document.getElementById('MuntuTooltip');
			$("#muntulogo").hover(function() 
			{
				$(box).stop(true, true).animate({opacity: "show", bottom: ToolTipYpos, right: "260"}, "slow");
			}, function() 
			{
				$(box).animate({opacity: "hide", bottom: ToolTipYpos, right: "260"}, "fast");
			});

			jQuery('#parallax_kommunikation').jparallax({triggerExposesEdges: true}, {}, {xtravel:0.3}, {xtravel:0.2, ytravel:-0.8});

			jQuery('#parallax_ausstrahlung').jparallax({triggerExposesEdges: true}, {}, {xtravel:1, ytravel:0}, {xtravel:0.3});
			
			jQuery('#parallax_angebot').jparallax({triggerExposesEdges: true}, {}, {xtravel:0.3, ytravel:0}, {xtravel:0.3});
			
			jQuery('#parallax_portrait').jparallax({triggerExposesEdges: true}, {}, {xtravel:-0.2}, {xtravel:0.3});
			
			jQuery('#parallax_kunden').jparallax({triggerExposesEdges: true}, {}, {xtravel:0.2}, {xtravel:0.8, ytravel:0});

		});


$(window).resize(function() {
		checkLogoPos();
		});
$(window).scroll(function() {
		checkLogoPos()
		});


function setActiveStyleSheet(title) 
{
	var i, a, main;
	for(i=0; (a = document.getElementsByTagName("link")[i]); i++)
   	{
		if(a.getAttribute("rel").indexOf("style") != -1 && a.getAttribute("title")) 
		{
       		a.disabled = true;
       		if(a.getAttribute("title") == title)
	   		{
		   		a.disabled = false;
	   		}
     	}
   }
}


function switchClass(elem, stat)
{
	var tabImage = document.getElementById('portImage').offsetWidth;
	var infoBox = document.getElementById('infoBox');
	var Fensterhoehe =  alertSize();
	var overFlow = (Fensterhoehe[0]-58) - tabImage;
	/*infoBox.innerHTML = "Tabel Width = "+(Fensterhoehe[0]-58)+", ImageWidth = " + tabImage + "Overflow= " + overFlow;*/
	if(stat =="over" && overFlow < 0)
	{
		if(portOverStat == false)
		{
			portOverStat = true;
			jQuery(elem).jparallax({xparallax:true}, {xtravel:overFlow + 'px', ytravel:'0px'});
		}
	}
}
