jQuery.noConflict();

var submenues = new Array();

function setAutoHeight(container, element) {
	    var elements = jQuery(container).find(element);
	    if (elements.length > 0) {
	        elements.css('height', 'auto');
	        var maxHeight = 0;
	        elements.each(function(e) {
	            h = jQuery(this).height();
	            if (h > maxHeight) {
	                maxHeight = h;
	            }
	        });
	        if (maxHeight > 0) {
	            elements.css('height', (maxHeight+16)+'px');
	        }
	    }
} 


jQuery(document).ready(function() {

	

	setAutoHeight('.row', '.content_box_middle');

	jQuery("#navigation ul ul").each(initSubmenu);
	jQuery("#navigation > ul > li > a").click(toggleMenu);
	jQuery('.window_open').click(function() {
		window.open(this.href,'window_open', 'width=640,height=445,location=yes, menubar=yes, resizeable=yes, scrollbars=yes, status=yes');
		return false;
	})

	jQuery('.provisionen-mobile-pk').click(function(){
		jQuery('.content-provisionen-mobile-gk').css('display', 'none');
		jQuery('.provisionen-mobile-gk').parent().parent('li').removeClass('current');
		jQuery('.provisionen-mobile-pk').parent().parent('li').addClass('current');
		jQuery('.content-provisionen-mobile-pk').css('display', 'block');
		jQuery('html,body').animate({scrollTop: 0});
	});
	jQuery('.provisionen-mobile-gk').click(function(){
		jQuery('.content-provisionen-mobile-pk').css('display', 'none');
		jQuery('.provisionen-mobile-pk').parent().parent('li').removeClass('current');
		jQuery('.provisionen-mobile-gk').parent().parent('li').addClass('current');
		jQuery('.content-provisionen-mobile-gk').css('display', 'block');
		jQuery('html,body').animate({scrollTop: 0});
	});
	
	//	Falls die Seite inkl. Anchor, z.B. #cascomfortsofortpaket aufgerufen wird, setzen wir anchor:
	var anchor = document.location.hash.split('?')[0];
	var locationHash = anchor.split('#')[1];
	if(locationHash) {
		if(locationHash=='geschaeftskundentarife') {
			jQuery('.content-provisionen-mobile-pk').css('display', 'none');
			jQuery('.provisionen-mobile-pk').parent().parent('li').removeClass('current');
			jQuery('.provisionen-mobile-gk').parent().parent('li').addClass('current');
			jQuery('.content-provisionen-mobile-gk').css('display', 'block');
			jQuery('html,body').animate({scrollTop: 0});
		}
	}
	
});

function initSubmenu()
{
	if ( jQuery(this).parent().hasClass("activated") == false && jQuery("li", jQuery(this).parent()).hasClass("activated") == false ) {
		jQuery(this).slideUp(0);
	}
}

function toggleMenu()
{
	if ( jQuery("ul", jQuery(this).parent()).length > 0 ) {
		jQuery("ul", jQuery(this).parent()).slideToggle(200);
	}
}

function jumpToFaq()
{
	window.location.hash = "faq_" + jQuery("#select_faq").val();
}

