function doResize() 
{
	iWindowHeight = parseInt($(window).height());
	iPadding = parseInt($('#wrapper').css('padding-bottom'));
	iDocumentHeight = parseInt($('body').height())-iPadding;

	if (iWindowHeight > iDocumentHeight)
	{
		$('#wrapper').css('padding-bottom', (iWindowHeight - iDocumentHeight + 30)+'px');
	} else {
		$('#wrapper').css('padding-bottom', '30px');
	}

};


var resizeTimer = null;



$(document).ready(function() {

	/* focusEmpty Elemente
	-  bei focus Feld leeren, sofern noch der Standardwert enthalten ist
	--------------------------------------------------------------------- */
	aFocusEmpty = Array();

	$('input.focusEmpty').each(function() {
		aFocusEmpty[$(this).attr('name')] = $(this).val();
	});


	$('input.focusEmpty').focus(function()
	{
		if ($(this).val() == aFocusEmpty[$(this).attr('name')]) {
			$(this).val('');
		}
	}).blur(function()
	{
		if ($(this).val() == '') {
			$(this).val(aFocusEmpty[$(this).attr('name')]);
		}
	});

	/* textInput Felder
	-------------------------------------------------------------- */
	$('form input.textInput').focus(function()
	{
		$(this).addClass('textOver');
	}).blur(function() {
		$(this).removeClass('textOver');
	});


	/* resize
	-------------------------------------------------------------- */
	$(window).bind('resize', function()
	{
		if (resizeTimer) clearTimeout(resizeTimer);
		resizeTimer = setTimeout(doResize, 100);
	});

	$(window).bind('load', function()
	{
		if (resizeTimer) clearTimeout(resizeTimer);
		doResize();
		resizeTimer = setTimeout(doResize, 100);
	});


	/* Hover-Elemente
	-------------------------------------------------------------- */
	$('.hoverItem').hover(
		function()
		{
			$(this).addClass("hoverItemCurrent");
		},
		function()
		{
			$(this).removeClass("hoverItemCurrent");
		}
	);


	/* Product Slider
	-------------------------------------------------------------- */
	$('#productNavigation div#navRight').click(
		function()
		{
			$('#productNavigation #items ul li:first').remove().appendTo('#productNavigation #items ul');
		}
	);

	$('#productNavigation div#navLeft').click(
		function()
		{
			$('#productNavigation #items ul li:last').remove().prependTo('#productNavigation #items ul');
		}
	);

	/* FlashingBox
	------------------------------------------------------------- */
	$('.flashingBox').effect('bounce',{},500);


	/* Newsletterbox
	------------------------------------------------------------- */
	$('div#newsletterBox form').submit(function() {
		var oNow = new Date();

		sAddress = $('div#newsletterBox form #newsletterBoxEMail').val();

		$.ajax({
			type: "POST",
			url: "/system/ajax/newsletter_add_email.php",
			data: "email="+sAddress+"&t="+oNow.getTime(),
			async: false,
			success: function(msg){
				sReturn = msg;
				if (sReturn == 'success') {
					$('div#newsletterBox form').hide();
					$('div#newsletterBox').removeClass('hoverItem hoverItemCurrent').addClass('stateCurrent').unbind("mouseover").unbind("mouseout").effect('bounce',{},500);
				}
				if (sReturn == 'error_invalid_email') {
					alert('Bitte geben Sie eine gültige E-Mail Adresse ein.');
				}

				if (sReturn == 'error_double_email') {
					alert('Ihre E-Mail Adresse konnte nicht eingetragen werden, da Sie bereits in unsere Datenbank vorhanden ist.');
				}
			}
		});

		return false;
	});


	/* Tooltip
	------------------------------------------------------------- */
	$('a.tooltip-local').cluetip({attribute: 'alt', titleAttribute: 'dummy', local:true, cursor: 'pointer',cluetipClass: 'rounded', dropShadow: false, sticky: false, ajaxCache: false, arrows: false, cluezIndex: 800});

});



Shadowbox.init({
    language: 'de-DE',
    players:    ['img','iframe','html']
});


