jQuery.noConflict();
jQuery(document).ready(function(){
	initSubMenu();
	hoverLightbox();
	clearInputs();
	initLabels();
});
/*--- hide submenus --- */
function initSubMenu() {
	jQuery('#menu li:not(.active) div > ul').hide();
}
/*--- clear inputs function ---*/
function clearInputs(){
	jQuery('input:text').each(function(){
		if(this.value == '')
			return;
		this._val = this.value;
		this.onfocus = function(){
			if(this.value == this._val) this.value = '';
		}
		this.onblur = function(){
			if(this.value == '') this.value = this._val;
		}
	});
	jQuery('input:password').each(function(){
		if(this.value == '')
			return;
		this._val = this.value;
		this.onfocus = function(){
			if(this.value == this._val) this.value = '';
		}
		this.onblur = function(){
			if(this.value == '') this.value = this._val;
		}
	});
	jQuery('textarea').each(function(){
		if(this.value == '')
			return;
		this._val = this.value;
		this.onfocus = function(){
			if(this.value == this._val) this.value = '';
		}
		this.onblur = function(){
			if(this.value == '') this.value = this._val;
		}
	});
}
/*--- Zaehlerstand visualisieren ---*/
function changeLocation(selectBox) {

	if(selectBox.selectedIndex > 0) {
		jQuery('#more').animate({height: '330px'}, 1000);
		jQuery('#more2').animate({height: '420px'}, 1000);
	}

	var labelizeElements = [];
	if(selectBox.selectedIndex == 1) {
		jQuery('#visual_counter').show().animate({height: '290px'}, 1000);
		jQuery('#wasser').fadeIn();
		jQuery('#gas').fadeOut();
		jQuery('#strom').fadeOut();
		jQuery.merge(labelizeElements, [jQuery('#visual_counter'), jQuery('#wasser')]);
	} else if(selectBox.selectedIndex == 2) {
		jQuery('#visual_counter').show().animate({height: '290px'}, 1000);
		jQuery('#gas').fadeIn();
		jQuery('#wasser').fadeOut();
		jQuery('#strom').fadeOut();
		jQuery.merge(labelizeElements, [jQuery('#visual_counter'), jQuery('#gas')]);
	} else if(selectBox.selectedIndex == 3) {
		jQuery('#visual_counter').show().animate({height: '290px'}, 1000);
		jQuery('#gas').fadeIn();
		jQuery('#wasser').fadeIn();
		jQuery('#strom').fadeOut();
		jQuery.merge(labelizeElements, [jQuery('#visual_counter'), jQuery('#wasser'), jQuery('#gas')]);
	} else if(selectBox.selectedIndex == 4) {
		jQuery('#visual_counter').show().animate({height: '290px'}, 1000);
		jQuery('#wasser').fadeIn();
		jQuery('#gas').fadeOut();
		jQuery('#strom').fadeOut();
		jQuery.merge(labelizeElements, [jQuery('#visual_counter'), jQuery('#wasser')]);
	} else if(selectBox.selectedIndex == 5) {
		jQuery('#visual_counter').show().animate({height: '290px'}, 1000);
		jQuery('#strom').fadeIn();
		jQuery('#gas').fadeIn();
		jQuery('#wasser').fadeIn();
		jQuery.merge(labelizeElements, [jQuery('#visual_counter'), jQuery('#wasser'), jQuery('#gas'), jQuery('#strom')]);
	} else if(selectBox.selectedIndex == 6) {
		jQuery('#visual_counter').show().animate({height: '290px'}, 1000);
		jQuery('#wasser').fadeIn();
		jQuery('#gas').fadeOut();
		jQuery('#strom').fadeOut();
		jQuery.merge(labelizeElements, [jQuery('#visual_counter'), jQuery('#wasser')]);
	} else if(selectBox.selectedIndex == 7) {
		jQuery('#visual_counter').show().animate({height: '290px'}, 1000);
		jQuery('#wasser').fadeIn();
		jQuery('#gas').fadeOut();
		jQuery('#strom').fadeOut();
		jQuery.merge(labelizeElements, [jQuery('#visual_counter'), jQuery('#wasser')]);
	} else if(selectBox.selectedIndex == 8) {
		jQuery('#visual_counter').show().animate({height: '290px'}, 1000);
		jQuery('#wasser').fadeIn();
		jQuery('#gas').fadeOut();
		jQuery('#strom').fadeOut();
		jQuery.merge(labelizeElements, [jQuery('#visual_counter'), jQuery('#wasser')]);
	}
	/*if(typeof jQuery.fn.labelize == 'function'){
		jQuery(labelizeElements).queue('fx', function(){
			jQuery(this).find('input:text').labelize();
		});
	}*/
}

/*--- Shows images on mouseover particular links ---*/
function hoverLightbox() {
	jQuery('.hoverLightbox').hover(
		function(event) {
			var leftPos = event.pageX + 10;
			var TopPos = event.pageY + 10;
			jQuery('body').append('<img src="'+this.href+'" alt="'+this.title+'" class="hoverLightboxElement" />');
			jQuery('img:last').css({position:'absolute', left:leftPos+'px', top:TopPos+'px'});
		},
		function() {
			jQuery('img.hoverLightboxElement:last').remove();
		}
	).click(
		function() {
			return false;
		}
	);
}

/*--- Send Newsletter subscription form ---*/
function newsletter(formid) {
	jQuery("#"+ formid +" :text").css({color: '#fff'});
	var oldval = jQuery("#"+ formid +" :text").eq(0).val();
	var anrede = "";
	if(jQuery("#"+ formid +" :checked").val() == 1)
		anrede = "Herr ";
	else if(jQuery("#"+ formid +" :checked").val() == 2)
		anrede = "Frau ";
	jQuery("#"+ formid +" :text").eq(0).val(anrede + oldval);
	jQuery("#"+ formid).submit();
}

/*--- equal iframe height ---*/
function equalheight(iframe) {
	var hash = '';
	if(hash = window.location.hash.substr(1, 999)) {
		hash = Number(hash) + 10;
		if(document.getElementById(iframe))
			document.getElementById(iframe).height = hash + "px";
		return;
	}
	window.setTimeout("equalheight("+ iframe +");", 200);
}
/*--- slide labels ---*/
function initLabels(){
	if(typeof jQuery.fn.labelize != 'function')
		return false;

	jQuery('input:text', jQuery('#content').find('form')).labelize();
}
