/**
 * *********************************************
 *  ______      ______                  _       
 * |  ___ \    |  ___ \       _        | |      
 * | | _ | |___| |   | | ____| |_    _ | | ____ 
 * | || || (___) |   | |/ _  )  _)  / || |/ _  )
 * | || || |   | |   | ( (/ /| |__ ( (_| ( (/ / 
 * |_||_||_|   |_|   |_|\____)\___|_)____|\____)
 *                                              
 * 
 * @description		default javascript
 * @author			coma ag | jue
 * @date			2010-07
 * @copyright		2010 coma ag
 * @link			http://www.coma.de
 * *********************************************
 */


$(document).ready(function() {

/* .oOooOooOooOooOooOooOooOooOooOooOooOooOooOooOooOooOooOooOooOooOooOooOo. */

	/**
	 * Javascript-Meldung ausblenden und Glasfaser-DSL-Hinweis neu ausrichten
	 *
	 * @date	2010-11
	 */
	$('#no_js_info').hide();

	/**
	 * Erweiterungsklassen setzen falls CSS-Selektor nicht bekannt (z.B. hover auf blockelemente im IE)
	 *
	 * @date	2010-07
	 */
	// hauptnavigation
	$('#topnav div:first-child').addClass('first-child');
	$('#topnav div:last-child').addClass('last-child');
	$('#topnav div.nav1:last-child').addClass('nav1-last-child');
	$('#topnav div.nav1active:last-child').addClass('nav1active-last-child');
	$('#topnav div.nav1').hover(function(){
		$(this).addClass('hover');
	},
	function(){
		$(this).removeClass('hover');
	});
	$('#topnav div.nav1:last-child').hover(function(){
		$(this).addClass('nav1active-last-child-hover');
	},
	function(){
		$(this).removeClass('nav1active-last-child-hover');
	});
	
	// navigation an der seite
	$('#sidenavContainer div:first-child').addClass('first-child');
	$('#sidenavContainer div:last-child').addClass('last-child');
	if ($('#sidenavContainer div:last-child').hasClass('nav2cur')) $('#sidenavContainer div:last-child').addClass('last-child-on');
	$('#sidenavContainer div.nav2on.last-child').addClass('nav2on-last-child');
	
	// service navigation an der seite
	$('#servicenavContainer span:first-child').addClass('first-child');
	$('#servicenavContainer span:last-child').addClass('last-child');
	$('#servicenavContainer span.sub-sub, #servicenavContainer span.sub-cur').removeClass('last-child');
	if ($('#servicenavContainer span:first-child').hasClass('cur')) $('#servicenavContainer span:first-child').addClass('first-child-cur');
	if ($('#servicenavContainer span:last-child').hasClass('cur')) $('#servicenavContainer span:last-child').addClass('last-child-cur');
	
	// tabnavigation in den produkten
	$('#productdetail-nav div.tabs .tab:first-child').addClass('first-child');
	$('#productdetail-nav div.tabs .tab:last-child').addClass('last-child');
	$('#productdetail-nav div.tabs .tab').hover(function(){
		$(this).addClass('hover');
		if ($(this).hasClass('first-child')) $(this).addClass('first-child-hover');
		if ($(this).hasClass('last-child')) $(this).addClass('last-child-hover');
	},
	function(){
		$(this).removeClass('hover');
		if ($(this).hasClass('first-child')) $(this).removeClass('first-child-hover');
		if ($(this).hasClass('last-child')) $(this).removeClass('last-child-hover');
	});
	
	
	
	/**
	 * Setzt die Hoehe der Zusatzoptionen und kümmert sich um die Layer
	 *
	 * @date	2010-08
	 */
	if ($('div.productbox-addoption').length > 0)
	{
	
		// eindeutige id's vergeben
		var i = 0;
		$('div.productbox-addoption-normal, div.productbox-addoption-large, div.productbox-addoption-placeholder').each(function(){
			i++;
			$(this).attr('id', 'productbox-addoption-' + i);
			$(this).find('.extras a').attr('id', 'open-productbox-addoption-details-' + i);
			price = $(this).find('.content .price div.price_val').html();
			if (price == '' || price == ' ')
			{
				$(this).find('.content .price').hide();
			}
			else
			{
				price_height = $(this).find('div.price').height();
				$(this).css('padding-bottom', (price_height + 10) + 'px');
			}

			if ((i % 2) == 0)
			{
				
				$(this).addClass('productbox-addoption-right');
				
				prev_elem_id = i - 1;
				prev_elem_height = $('#productbox-addoption-' + prev_elem_id).height() - 1;
				self_height = $(this).height() - 1;
				
				if (prev_elem_height > self_height)
				{
					if ($(this).hasClass('productbox-addoption-small') == false) $(this).height(prev_elem_height);
				}
				else if (self_height > prev_elem_height)
				{
					if ($('#productbox-addoption-' + prev_elem_id).hasClass('productbox-addoption-small') == false) $('#productbox-addoption-' + prev_elem_id).height(self_height);
				}
			}
			
		});
	
		// link ausblenden wenn kein inhalt
		if ($('div.productbox-addoption .extras a').text() == '') $('div.productbox-addoption .extras a').hide();
		
		// details einblend
		$('div.productbox-addoption .extras a').click(function(){
			
			var id = $(this).attr('id').replace('open-productbox-addoption-details-', 'check-productbox-addoption-details-');
			if ($('#' + id).length > 0) return false;
			
			parent_id = $(this).attr('id').replace('open-productbox-addoption-details-', 'productbox-addoption-');
			position = $('#' + parent_id).offset();
			
			is_left = (parseInt(parent_id.replace('productbox-addoption-', '')) % 2) == 0 ? true : false;
			if ($('#' + parent_id).hasClass('productbox-addoption-large') && is_left == true)
			{
				prev_elem_id = parseInt(parent_id.replace('productbox-addoption-', '')) - 1;
				prev_position = $('#productbox-addoption-' + prev_elem_id).offset();
				position.left = prev_position.left;
			}
			
			type = ($('#' + parent_id).hasClass('productbox-addoption-large') ? 'productbox-addoption-details-large' : 'productbox-addoption-details-normal' );
			$('body').append('<div style="top:' + (position.top + 6) + 'px;left:' + position.left + 'px;display:none;" id="' + id + '" class="productbox-addoption-details ' + type + '">' + $('#' + parent_id).find('div.extras_template').html() + '</div>');
			//$('body').append('<div style="display:none;" id="productbox-addoption-details-overlay"></div>');
			
			headline 	= $('#' + parent_id).find('h2').html();
			content 	= $('#' + parent_id).find('div.extras_content').html();
			price		= $('#' + parent_id).find('div.price div.price_val').html();
			
			if (price == '') $('#' + id + ' div.extras_price').hide();
			$('#' + id + ' div.extras_headline').html(headline);
			$('#' + id + ' div.extras_content').html(content);
			$('#' + id + ' div.extras_price div.extras_price_val').html(price);
			$('#' + id).append('<div class="extras_close"></div>');
			
			//$('#productbox-addoption-details-overlay').height($(document).height());
			//$('#productbox-addoption-details-overlay').width($(document).width());
			
			$('#' + id).fadeIn('fast');
			//$('#productbox-addoption-details-overlay').fadeTo('slow', 0.75);
			
			$('#' + id + ' .extras_close').click(function(){
				$('#' + id).fadeOut('fast', function(){
					$(this).remove();
					//$('#productbox-addoption-details-overlay').fadeOut('fast', function(){
					//	$(this).remove();
					//});
				});
			});
			
			return false;
		});
	}

	
	
	/**
	 * Extrahiert aus einem Inputfeld den Strassennamen und die Nummer und setzt diese in eigenstaendige Inputfelder
	 *
	 * @date	2010-07
	 */
	if ($('div.teaser-dsl-check form').length > 0)
	{
		
		teaser = $('div.teaser-dsl-check form');
		
		teaser.find('input[name="streetnr"]').keyup(function(){
		
			value= $(this).val();
			nr = value.match(/([0-9]){1,3}/g);
			if (nr != null)
			{
				teaser.find('input=[name="a_nr"]').val(nr);
				street = value.replace(nr, '');
				space = street.substr(street.length-1,1);
				if (space == ' ') street = street.substr(0,street.length-1);
				street = street.replace(',', '');
				teaser.find('input=[name="a_strasse"]').val(street);
			}
			else
			{
				if(value.search(/([0-9])/g) == -1) teaser.find('input=[name="a_strasse"]').val(value);
			}
		
		});
		teaser.find('input[name="zip"]').keyup(function(){teaser.find('input=[name="a_plz"]').val($(this).val())});
		
		teaser.find('input').focus(function(){
			if ($(this).attr('original_value') != '' && $(this).val() == $(this).attr('original_value')) $(this).val('');
		}).blur(function(){
			if ($(this).attr('original_value') != '' && $(this).val() == '') $(this).val($(this).attr('original_value'));
		});

	}
	
	
	/**
	 * Setzt die Values fuer die Inputfelder
	 *
	 * @date	2010-08
	 */
	if ($('#customer_login').length > 0)
	{
		login = $('#customer_login');
		
		// ein und ausblenden
		login.find('.bottom a').click(function(){
			if ($(this).hasClass('bottom-open'))
			{
				$(this).removeClass('bottom-open');
				login.find('.form').slideUp('normal');
			}
			else
			{
				$(this).addClass('bottom-open');
				login.find('.form').slideDown('normal');
			}
			return false;
		});
		
		// input values setzen
		login.find('form input').focus(function(){
			if ($(this).attr('original_value') != '' && $(this).val() == $(this).attr('original_value')) $(this).val('');
		}).blur(function(){
			if ($(this).attr('original_value') != '' && $(this).val() == '') $(this).val($(this).attr('original_value'));
		});

	}
	
	/**
	 * Hoehenfix für Inhalte mit verschienen Hoehen in nebeneinanderliegenden Boxen
	 *
	 * @date	2010-08
	 */
	if ($('div.fix-height').length > 0)
	{
		
		// dreispaltige produktboxen
		var height = 0;
		var i = 1;
		$('div.productboxes-container-3-3 div.fix-height').each(function(){
			$(this).attr('id', 'fix-height-container-3-3-' + i);
			if ($(this).height() > height) height = ($(this).height() + ($(this).find('.productbox-pricebox').length > 0 ? 90 : 0));
			if ((i % 3) == 0)
			{
				height = height + 5;
				
				$(this).height(height);
				//height_content= $('#fix-height-container-3-3-' + (i)).height() + $('#fix-height-container-3-3-' + (i)).next().next().height();
				//$('#fix-height-container-3-3-' + (i - 1)).parent().parent().height(height_content);
				//$('#fix-height-container-3-3-' + (i)).parent().parent().height(height_content);
				
				//$('#fix-height-container-3-3-' + (i - 2)).parent().parent().height(height_content);
				$('#fix-height-container-3-3-' + (i - 1)).height(height);
				$('#fix-height-container-3-3-' + (i - 2)).height(height);
			}
			
			i++;
		});
		
		// dreispaltiges layout
		var height = 0;
		var i = 1;
		$('div.productdetail-rows-3 div.fix-height').each(function(){
			$(this).attr('id', 'fix-height-productdetail-rows-3-' + i);
			if ($(this).height() > height) height = $(this).height();
			if ((i % 3) == 0)
			{
				height = height + 5;
				$(this).height(height);
				$('#fix-height-productdetail-rows-3-' + (i - 1)).height(height);
				$('#fix-height-productdetail-rows-3-' + (i - 2)).height(height);
			}
			
			i++;
		});
		
		// zweispaltige produktboxen
		var height = 0;
		var i = 1;
		$('div.productboxes-container-2-3 div.fix-height').each(function(){
			$(this).attr('id', 'fix-height-productboxes-container-2-3-' + i);
			if ($(this).height() > height) height = $(this).height();
			if ((i % 2) == 0)
			{
				height = height + 5;
				$(this).height(height);
				$('#fix-height-productboxes-container-2-3-' + (i - 1)).height(height);
			}
			
			i++;
		});
		
		// zweispaltiges layout
		var height = 0;
		var i = 1;
		$('div.productdetail-rows-2 div.fix-height').each(function(){
			$(this).attr('id', 'fix-height-productdetail-rows-2-' + i);
			if ($(this).height() > height) height = $(this).height();
			if ((i % 2) == 0)
			{
				height = height + 5;
				$(this).height(height);
				$('#fix-height-productdetail-rows-2-' + (i - 1)).height(height);
			}
			
			i++;
		});
		
	}
	
	/**
	 * Kleine Zusatzoptionen in 3er Spalte auf gleiche Hoehe bringen
	 *
	 * @date	2010-09
	 */
	if ($('div.productdetail-rows-3 .productdetail-row .productbox-addoption-small').length > 0)
	{
		height = 0;
		$('div.productdetail-rows-3 .productdetail-row .productbox-addoption-small').each(function(){
			if ($(this).height() > height) height = $(this).height();
		});
		$('div.productdetail-rows-3 .productdetail-row .productbox-addoption-small').height(height);
	}
	
	/**
	 * Zusatzoptionen in 2er Spalte auf gleiche Hoehe bringen
	 *
	 * @date	2010-09
	 */
	if ($('div.productdetail-rows-2 .productdetail-row .productbox-addoption').length > 0)
	{
		$('div.productdetail-rows-2').each(function(){
			height_left = $(this).find('.productdetail-row-2-left .productbox-addoption').height();
			height_right = $(this).find('.productdetail-row-2-right .productbox-addoption').height();
			if (height_left > height_right)
			{
				$(this).find('.productdetail-row-2-right .productbox-addoption').css('padding-bottom', $(this).find('.productdetail-row-2-left .productbox-addoption').css('padding-bottom'));
				height = height_left;
			}
			else
			{
				$(this).find('.productdetail-row-2-left .productbox-addoption').css('padding-bottom', $(this).find('.productdetail-row-2-right .productbox-addoption').css('padding-bottom'));
				height = height_right;
			}
			$(this).find('.productdetail-row .productbox-addoption').height(height);
		});
		
	}
	
	/**
	 * Jeden zweiten Verlinkungsteaser einruecken
	 *
	 * @date	2010-10
	 */
	if ($('.link-to-box').length > 1)
	{
		$('.link-to-box:odd').addClass('link-to-box-odd');
	}
	
	/**
	 * Verlinkungsteaser in 2er Spalte auf gleiche Hoehe bringen
	 *
	 * @date	2010-10
	 */
	if ($('div.productdetail-rows-2 .productdetail-row .link-to-box').length > 0)
	{
		$('div.productdetail-rows-2').each(function(){
			height_left = $(this).find('.productdetail-row-2-left .link-to-box').height();
			height_right = $(this).find('.productdetail-row-2-right .link-to-box').height();
			if (height_left > height_right)
			{
				height = height_left;
			}
			else
			{
				height = height_right;
			}
			$(this).find('.productdetail-row .link-to-box').height(height);
		});
		
	}
	
	/**
	 * Spalten in den Produktdetails auf gleiche Hoehe bringen
	 *
	 * @date	2010-07
	 */
	if ($('div.productdetail-rows').length > 0)
	{
		$('div.productdetail-rows').each(function(){
			$(this).find('div.productdetail-row').height($(this).height());
		});
	}
	
	/**
	 * Produktboxen auf gleiche Hoehe bringen
	 *
	 * @date	2010-07
	 */
	if ($('div.productboxes-container').length > 0)
	{
		$('div.productboxes-container').each(function(){
			//$(this).find('div.productbox').height($(this).height() - 58);
			//$(this).find('div.productbox').height($(this).height() - 48);
			$(this).find('div.productbox').height((($(this).find('div.productbox-3-3 div.productbox-pricebox').length > 0 && $(this).parent().hasClass('productdetail')) ? ($(this).height() + 42) : ($(this).height() - 48)));
		});
	}
	
	/**
	 * Bilder in Zusatzoptionen auf gleiche Hoehe bringen
	 *
	 * @date	2010-09
	 */
	$('.productbox-addoption').each(function(){
		$(this).find('.content .image').css('height', ($(this).outerHeight()));
	});
	
	/**
	 * Contenttoggle fuer die FAQs
	 *
	 * @date	2010-08
	 */
	$('.faq-item .faq-item-answer').hide();
	$('.faq-item .faq-item-question').click(function(){
		$('.faq-item .faq-item-answer').slideUp('fast');
		$(this).parent().find('.faq-item-answer').slideDown('slow');
		return false;
	});
	
	/**
	 * Contenttoggle fuer die Referenzen
	 *
	 * @date	2010-08
	 */
	$('.feedback-item .feedback-item-text').hide();
	$('.feedback-item .feedback-item-readmore').click(function(){
		$('.feedback-item .feedback-item-text').hide();
		$('.feedback-item .feedback-item-teaser, .feedback-item .feedback-item-readmore').show();
		$(this).parent().find('.feedback-item-teaser').slideUp('fast', function(){
			$(this).parent().find('.feedback-item-readmore').hide();
			$(this).parent().find('.feedback-item-text').slideDown('slow');
		});
		return false;
	});
	
	
	
	/**
	 * Setzt die Hoehe der Zusatzoptionen und kümmert sich um die Layer
	 *
	 * @date	2010-08
	 */
	if ($('div.layer-link').length > 0)
	{
	
		$('.productdetail-row-2-right .layer-link').addClass('layer-link-right');
	
		// ausblenden
		$('div.layer-link .layer-link-content').hide();
	
		// eindeutige id's vergeben
		var i = 0;
		$('div.layer-link').each(function(){
			i++;
			$(this).attr('id', 'layer-link-' + i);
			$(this).find('a').attr('id', 'open-layer-link-' + i);
			
		});
	
		// link ausblenden wenn kein inhalt
		if ($('div.layer-link a').text() == '') $('div.layer-link a').hide();
		
		// details einblend
		$('div.layer-link a').click(function(){
			
			var id = $(this).attr('id').replace('open-layer-link-', 'check-layer-link-');
			if ($('#' + id).length > 0) return false;
			
			self_id = $(this).attr('id');
			position = $('#' + self_id).offset();
			
			type = ($('#' + self_id).parent().hasClass('layer-link-large') ? 'layer-link-content-large' : 'layer-link-content-normal' );
			$('body').append('<div style="top:' + (position.top + 6) + 'px;left:' + ($('#' + self_id).parent().hasClass('layer-link-right') ? 189 : position.left) + 'px;display:none;" id="' + id + '" class="layer-link-content ' + type + '">' + $('#' + self_id).parent().find('div.layer-link-content').html() + '</div>');
			//$('body').append('<div style="display:none;" id="productbox-addoption-details-overlay"></div>');
			
			$('#' + id).append('<div class="close"></div>');
			$('#' + id).fadeIn('fast');

			
			$('#' + id + ' .close').click(function(){
				$('#' + id).fadeOut('fast', function(){
					$(this).remove();
				});
			});
			
			return false;
		});
	}
	
	/**
	 * Postleitzahlensuche 
	 *
	 * @date	2010-08
	 */
	$('#plz-result').parent().css('display','none');
	$('#plz-result').parent().css('padding-top','10px');

	$('#plz-input').focus(function(){
		$(this).val('');
	}).blur(function(){
		if ($(this).val() == '') $(this).val('PLZ');
	});

	$('form.shopsuche-ueber-mnet').submit(function(){
		$('#plz-result').parent().css('display','none');
		$('#plz-result').contents().remove();
		var input = $('#plz-input').val();

		if(input == '' || input.length < 3)
		{
			$('#plz-result').contents().remove();
		}
		else
		{
			var control = 0;
			//$('#plz-result').parent().css('display','block');
			$('#plz-result').parent().fadeIn('fast');

			$.getJSON('/fileadmin/json/plz_search.json', function(data)
			{

				//Augsburg
				if(plzResult(data.Augsburg.PLZ, data.Augsburg.Name , input, data.Augsburg.Id) == 1 ){ control = 1;}
				//Bayreuth
				if(plzResult(data.Bayreuth.PLZ, data.Bayreuth.Name, input, data.Bayreuth.Id) == 1 ){ control = 1;}
				//Ingolstadt
				if(plzResult(data.Ingolstadt.PLZ, data.Ingolstadt.Name, input,  data.Ingolstadt.Id) == 1 ){ control = 1;}
				//Kempten
				if(plzResult(data.Kempten.PLZ, data.Kempten.Name, input, data.Kempten.Id) == 1 ){ control = 1;}
				//Muenchen
				if(plzResult(data.Muenchen.PLZ, data.Muenchen.Name, input, data.Muenchen.Id) == 1 ){ control = 1;}
				//Nuernberg
				if(plzResult(data.Nuernberg.PLZ, data.Nuernberg.Name, input, data.Nuernberg.Id) == 1 ){ control = 1;}
				//Regensburg
				if(plzResult(data.Regensburg.PLZ, data.Regensburg.Name, input, data.Regensburg.Id) == 1 ){ control = 1;}
				//Ulm
				if(plzResult(data.Ulm.PLZ, data.Ulm.Name, input, data.Ulm.Id) == 1 ){ control = 1;}
				//Wuerzburg
				if(plzResult(data.Wuerzburg.PLZ, data.Wuerzburg.Name, input, data.Wuerzburg.Id) == 1 ){ control = 1;}
				
				// Kein Ergebnis
				if(control == 0){
					$('#plz-result').append('<p>Leider konnte keine M-net Niederlassung in Ihrer Region gefunden werden.<br />Welche Regionen zum M-net Netzgebiet geh&ouml;ren, sehen Sie auch auf der Karte des Netzgebietes.</p>');
					return false;
				}
			});
		}
		
		return false;
	});
		
	/**
	 * Sorgt dafuer, dass sich alle PDFs in einem neuen Fenster oeffnen
	 * 
	 * @date 2010-08
	 */
	$('a').each(function(){	
		href = $(this).attr('href');
		if (href != undefined)
		{
			match = href.search(/.pdf/);
			if (match != -1) $(this).attr('target', '_blank');
		}
	});
	
	/**
	 * Sorgt dafuer, dass sich alle extrenen Links in einem Produktbutton in neuem Fenster oeffnen
	 * 
	 * @date 2010-10
	 */
	$('a').each(function(){	
		href = $(this).attr('href');
		base = $('base').attr('href');
		if (href != undefined && href.search(/http:\/\/|https:\/\//) != -1 && href.search(base) == -1) $(this).attr('target', '_blank');
	});
	
	/**
	 * Sorgt für eine einheitliche bild größe in der image-box
	 *
	 * @date 2010-08
	 */
	 $('.image-box img').each(function(){
		 if ($(this).attr("height") > 110)
		 {
			h = $(this).attr("height");
			$(this).attr("height", 110);
			w = $(this).attr("width");
			new_w = w - ((h - 110) / h * w);
			$(this).attr("width", new_w);
		}
	});
	$('.image-box').next().next().css("margin","0");
	
	/**
	 * Positionierung des Plus Symbols
	 *
	 * @date 2010-08
	 */
	if ($('.plus-between').length > 0)
	{
		$('.plus-between').each(function(){
			$(this).css('margin-top', '-' + (($(this).height()/2)+1) + 'px');
		});
		if ($(".csc-textpic-imagewrap img").attr("width") > 588 )
		{
			$(".csc-textpic-imagewrap img").attr("width", 588);
			$(".csc-textpic-imagewrap img").css("margin", "10px 0 0 0");
		}
	}
	
	/**
	 * Breite der Ergebnislabel fuer den Poll festlegen
	 *
	 * @date 2010-08
	 */
	if ($('.tx-rsdynamicpoll-pi1').length > 0)
	{
		fix_poll_answerlabel_width();
		
		question = $('.tx-rsdynamicpoll-pi1 h3.question').html();
		$('.tx-rsdynamicpoll-pi1 h3.question').remove();
		
		$('.teaser-poll .top-content').append('<h3>' + question + '</h3>');
	}
	if ($('.tx-rsdynamicpoll-pi1 .answer_result').length == 0)
	{
		$('.tx-rsdynamicpoll-pi1 .submit_button input').click(function(){
			fix_poll_answerlabel_width_interval = window.setInterval('fix_poll_answerlabel_width()', 100);
		});
	}
	
	$('.productdetail-row-2-left table').each(function(){
		width = ($(this).width() - 10) + 'px';
		$(this).width(width);
	});
	
	/**
	 * Letzter Teaser in der Teaserbar auf der Startseite bekommt kein margin recht
	 *
	 * @date 2010-09
	 */
	if ($('div.index-teaser-bar div.teaser').length > 0)
	{
		$('div.index-teaser-bar div.teaser:last').css('margin-right', 0);
	}
	
	/**
	 * Sitemap erstem li margin geben
	 * Sitemap letzem li border wegnehmen
	 * Sitemap in der Höhe anpassen
	 *
	 * @date 2010-09
	 */
	$('#sitemap ul.csc-sitemap').css({position:'relative',left:'8px'});
	$('#sitemap ul.csc-sitemap-level1 > li:last').css('border-right', 'none');
	if ($('#sitemap').length > 0)
	{
		var sitemap_height = 0;
		$('#sitemap ul.csc-sitemap-level1 > li').each(function(){
		
			if ($(this).height() > sitemap_height) sitemap_height = $(this).height();
		
		});
		$('#sitemap ul.csc-sitemap-level1 > li').height(sitemap_height);
	}
	
	/**
	 * Formularfelder mit Standartwerten versehen und Events binden
	 *
	 * @date 2010-09
	 */
	if ($('form .form-default-autofill').length > 0)
	{
		$('form .form-default-autofill').each(function(){
			if ($(this).val() == '') $(this).val(($(this).attr('rel') != undefined ? $(this).attr('rel') : ''));
			$(this).focus(function(){
				if ($(this).attr('rel') != '' && $(this).val() == $(this).attr('rel')) $(this).val('');
			}).blur(function(){
				if ($(this).attr('rel') != '' && $(this).val() == '') $(this).val($(this).attr('rel'));
			});
		});
	}

/* .oOooOooOooOooOooOooOooOooOooOooOooOooOooOooOooOooOooOooOooOooOooOooOo. */

});

/**
 * Breite der Ergebnislabel fuer den Poll festlegen
 *
 * @date 2010-08
 */
var fix_poll_answerlabel_width_interval = false;
var fix_poll_answerlabel_width_interval_runs = 0;
function fix_poll_answerlabel_width()
{
	fix_poll_answerlabel_width_interval_runs++;
	poll_answerlabel_width = 0;
	if ($('.tx-rsdynamicpoll-pi1 .answer_result').length > 0)
	{
		$('.tx-rsdynamicpoll-pi1 .answer_result .label').each(function(){
			if ($(this).width() > poll_answerlabel_width) poll_answerlabel_width = $(this).width();
		});
		$('.tx-rsdynamicpoll-pi1 .answer_result .label').css('width', poll_answerlabel_width + 'px');
		$('.tx-rsdynamicpoll-pi1 .answer_result .percent_bar').css('margin-left', ((poll_answerlabel_width * 2) - 10 )+ 'px');
		if (fix_poll_answerlabel_width_interval != false) window.clearInterval(fix_poll_answerlabel_width_interval);
	}
	if (fix_poll_answerlabel_width_interval_runs > 99) window.clearInterval(fix_poll_answerlabel_width_interval);
}

function plzResult(data, city, input, id)
{
	var check = 0;
	var result = null;
	var link = null;
	
	for(i = 0; i<data.length; i++){
		plz = data[i].toString();
		if(plz.indexOf(input) == 0)
		{
			check = 1;
			result = city;
			link = id;
		}
	}
	
	//if(check == 1) $('#plz-result').append('Erfahren Sie mehr &uuml;ber die f&uuml;r Ihre Region zust&auml;ndige M-net Niederlassung in <a href="/index.php?id='+link+'">'+result+'</a>.<br />');
	if(check == 1) window.location.replace('/index.php?id='+link);
	
	return check;

}
