function check_search_term(){
	if(jQuery(".searching").val()!="")
		return true;
	else
		return false;	
}

function manageParagraphBoxes() {
	
	var isIE = false;
	if (navigator.appVersion.indexOf('MSIE 6') != -1 || navigator.appVersion.indexOf('MSIE 7') != -1) isIE = true;

	jQuery('.paragraph-cols .completeview').hide();
	if (!isIE) jQuery('.paragraph-cols .completeview .text').hide();
	jQuery('.paragraph-cols .shortview').show();
	
	
	jQuery('.paragraph-cols').each(function() {
		if (jQuery('.closer', this).size() > 0) {
			jQuery('.titles', this).css({cursor:'pointer'});
		} else {
			jQuery('.titles', this).css({cursor:'text'});
		}
	});
	

	jQuery('.paragraph-cols .shortview').css({cursor:'pointer'});
	
	
	jQuery('.paragraph-cols').each(function() {
		var me = this;
		
		var jTitle = jQuery('.titles', me);
		var jShortV = jQuery('.shortview', me);
		var jCompleteV = jQuery('.completeview', me);
		var jCompleteVO = jQuery('.completeview-only', me);
		var jCloser = jQuery( '.closer', me);
		var jText = jQuery('.completeview .text', me);

		var jShortImg = jQuery('.image', jShortV);
		var jCompleteImg = jQuery('.image', jCompleteV);



		if (jShortImg.size() > 0) {
			var jImg = jQuery( 'img', jShortImg);
			if (jImg.height() < jShortImg.height()) {
				jShortImg.height(jImg.height());
				jCompleteImg.height(jImg.height());
			}
		} else if (jCompleteVO.size() > 0) {
			var jCompleteImg = jQuery('.image', jCompleteVO);
			
			var jImg = jQuery( 'img', jCompleteImg);
			if (jImg.height() < jCompleteImg.height()) {
				jCompleteImg.height(jImg.height());
			}
		}
		
		
		var shortviewH = jShortV.height();
		if (!isIE) jText.show();
		var completeviewH = jCompleteV.height();
		if (!isIE) jText.hide();

		
		jCompleteV.css({
			height:shortviewH
		});

		jShortV.click(function() {
			if (jCompleteV.css('display') == 'none') {
				jShortV.hide();
				jCompleteV.show();
				if (!isIE) jText.fadeIn(250);
				jCompleteV.animate( {
					height:completeviewH
				}, 500);
			}
		});

		jCloser.click(function() {
			if (jShortV.css('display') == 'none') {
			
				if (!isIE) jText.fadeOut(125);
				jCompleteV.animate( {
					height:shortviewH
				}, 250, function() {
					jCompleteV.hide();
					jShortV.show();
				});
			}
		});

		jTitle.click(function() {
			if (jShortV.css('display') == 'none') {
				jCloser.click();
			} else {
				jShortV.click();
			}
		});
		
	});
	
}


function manageNewsBoxes() {
	
	var isIE = false;
	if (navigator.appVersion.indexOf('MSIE 6') != -1 || navigator.appVersion.indexOf('MSIE 7') != -1) isIE = true;

	jQuery('.news .completeview').hide();
	if (!isIE) jQuery('.news .completeview .text').hide();
	jQuery('.news .shortview').show();
	jQuery('.news h3').css({cursor:'pointer'});
	jQuery('.news .shortview').css({cursor:'pointer'});
	
	jQuery('.news').each(function() {
		var me = this;
		
		var jTitle = jQuery('h3', me);
		var jShortV = jQuery('.shortview', me);
		var jCompleteV = jQuery('.completeview', me);
		var jCloser = jQuery( '.closer', me);
		var jText = jQuery('.completeview .text', me);

		var jShortImg = jQuery('.image-left', jShortV);
		var jCompleteImg = jQuery('.image-left', jCompleteV);


		if (jShortImg.size() > 0) {
			var jImg = jQuery( 'img', jShortImg);
			if (jImg.height() < jShortImg.height()) {
				jShortImg.height(jImg.height());
				jCompleteImg.height(jImg.height());
			}
		}
		
		
		var shortviewH = jShortV.height();
		if (!isIE) jText.show();
		var completeviewH = jCompleteV.height();
		if (!isIE) jText.hide();

		
		jCompleteV.css({
			height:shortviewH
		});

		jShortV.click(function() {
			if (jCompleteV.css('display') == 'none') {
				jShortV.hide();
				jCompleteV.show();
				if (!isIE) jText.fadeIn(250);
				jCompleteV.animate( {
					height:completeviewH
				}, 500);
			}
		});

		jCloser.click(function() {
			if (jShortV.css('display') == 'none') {
			
				if (!isIE) jText.fadeOut(125);
				jCompleteV.animate( {
					height:shortviewH
				}, 250, function() {
					jCompleteV.hide();
					jShortV.show();
				});
			}
		});

		jTitle.click(function() {
			if (jShortV.css('display') == 'none') {
				jCloser.click();
			} else {
				jShortV.click();
			}
		});

		if (jShortV.hasClass('toopen')) {
			window.setTimeout( function() {jShortV.click();}, 500);
		}
		
	});
}



function jump2(url){
	if(url!='' && url != 'expertlogin') {
		window.open(url, "neuesfenster");
	} else if (url == 'expertlogin') {
		//alert('Fachlogin notwendig! TODO');
	}
		//location.href = url;
}

function galerieChangeBigImage(linkElement, selectorFullsizeImage, selectorThumbbar, id){
	//jQuery(selectorThumbbar).children(".a_thumb").click(function(){
		id = id || "";
		var bigsrc = jQuery(linkElement).attr("rel");
		
		//alert(jQuery(this)[0]);
		var newElement = document.createElement("div");
		jQuery(newElement).html("&nbsp;");
		jQuery(newElement).attr("class","div_gallery_image");
		jQuery(newElement).css({
			"background":"url("+bigsrc+") no-repeat center"
		});
		
		if(jQuery(linkElement).children(".span_tooltip").html()!=null)
			var picture_description = jQuery(linkElement).children(".span_tooltip").html();
		
		jQuery(selectorFullsizeImage).prepend(newElement);
		if(jQuery(linkElement).children(".span_tooltip").html()!=null)
			jQuery(newElement).append("<div class='div_picture_description'>"+picture_description+"</div>");
		
		
		if(id!="" && galleryContents[id]){
			jQuery(".div_gallery_image", selectorFullsizeImage).html(galleryContents[id]);
		}

		var parent = jQuery(selectorFullsizeImage, ".div_gallery_container");
		var childs = parent[0].childNodes;
		
		jQuery(newElement).fadeIn("slow", function(){
			jQuery(childs[1]).fadeOut("slow", function(){
				jQuery(childs[1]).remove();
			});
		});
		jQuery(newElement).attr("src");
		jQuery(newElement).css("background");
		jQuery(".a_thumb_active", selectorThumbbar).removeClass("a_thumb_active");
		jQuery(linkElement).addClass("a_thumb_active");
	//});
}

// Spezial Galerien - siehe Therapiegebiete Indikationsseite
function galerieChangeBigImageSpezial(linkObj, id, elementId){
		var bigsrc = jQuery(linkObj).attr("rel");
		
		jQuery(".thumbspezial_overlay").css("display","none");
		jQuery('.div_gallery_thumbbar'+id+" a .span_hidden").each(function(){
			var restoreThumb = jQuery(this).html();
			jQuery(this).prev().attr("src",restoreThumb);
		});
		if(galleryActiveThumbs[elementId])
			jQuery(linkObj).children("img").attr("src",galleryActiveThumbs[elementId]);
		
		var newElement = document.createElement("div");
		jQuery(newElement).html("&nbsp;");
		jQuery(newElement).attr("class","div_gallery_image_spezial");
		jQuery(newElement).css({
			"background":"url("+bigsrc+") no-repeat center"
		});
		
		if(jQuery(linkObj).children(".span_tooltip").html()!=null)
			var picture_description = jQuery(linkObj).children(".span_tooltip").html();
		
		jQuery(".div_gallery_image_container"+id).prepend(newElement);
		if(jQuery(linkObj).children(".span_tooltip").html()!=null)
			jQuery(newElement).append("<div class='div_picture_description'>"+picture_description+"</div>");
		
		
		if(elementId!="" && galleryContents[elementId]){
			jQuery(".div_gallery_image_spezial", ".div_gallery_image_container"+id).html(galleryContents[elementId]);
		}

		var parent = jQuery(".div_gallery_image_container"+id, ".div_gallery_container");
		var childs = parent[0].childNodes;
		
		jQuery(newElement).fadeIn("fast", function(){
			jQuery(childs[1]).fadeOut("fast", function(){
				jQuery(childs[1]).remove();
			});
		});
		jQuery(newElement).css("background");
		jQuery(".a_thumb_active", ".div_gallery_thumbbar"+id).removeClass("a_thumb_active");
		jQuery(linkObj).addClass("a_thumb_active");
		jQuery(".thumbspezial_overlay",linkObj).css("display","block");
}

//Bildergalerien - Cycle
function initGalleryCycle(selectorThumbbar,selectorPrev,selectorNext){
	var galleryThumbCount = jQuery(selectorThumbbar).children().length;
	
	jQuery(selectorThumbbar).cycle({ 
	    fx:     'fade',
	    speed:  'slow',
	    timeout: 0, 
	    prev: selectorPrev,
	    next: selectorNext,
	    nowrap:true,
	    prevNextClick: function(isNext, zeroBasedSlideIndex, slideElement){
			if (!isNext && zeroBasedSlideIndex==0) {
				jQuery(".gallery_prev_arrow", jQuery(selectorPrev)).attr("src", "/ccds_tpl_img/pbde/gallery-arrow-left-hell.jpg");
			}
	    	if (isNext && zeroBasedSlideIndex>0) {
	    		jQuery(".gallery_prev_arrow", jQuery(selectorPrev)).attr("src", "/ccds_tpl_img/pbde/gallery-arrow-left.jpg");
			}
	    	
	    	if (isNext && zeroBasedSlideIndex==(galleryThumbCount-1)) {
	    		jQuery(".gallery_next_arrow", jQuery(selectorNext)).attr("src", "/ccds_tpl_img/pbde/gallery-arrow-right-hell.jpg");
	    	}
	    	
	    	if (!isNext && zeroBasedSlideIndex<(galleryThumbCount-1)) {
	    		jQuery(".gallery_next_arrow", jQuery(selectorNext)).attr("src", "/ccds_tpl_img/pbde/gallery-arrow-right-hell.jpg");
	    	}

			if (!isNext && (zeroBasedSlideIndex==0 || zeroBasedSlideIndex<(galleryThumbCount-1))) {
				jQuery(".gallery_next_arrow", jQuery(selectorNext)).attr("src", "/ccds_tpl_img/pbde/gallery-arrow-right.jpg");
			}

	    }
	});
}

function openerCloserStellenangebote(element){
	var opener = jQuery(".opener", element).css("display");
	if(opener=="none")
		jQuery(".opener", element).fadeIn();
	else if(opener=="block" || "inline")
		jQuery(".opener",element).hide();
}

function start_selectbox(){
	if(jQuery("#div_produktauswahl_content").css("display")=="block"){
		jQuery("#div_produktauswahl_content").hide();
	}
	else if(jQuery("#div_produktauswahl_content").css("display")=="none"){
		jQuery("#div_produktauswahl_content").show();
		stat_selectbox_global();
	}
}

function stat_selectbox_global(){
	jQuery("#content, #submenu h2, #submenu_spacer_left, #footer, #stage_start, #header").click(function(){
		jQuery("#div_produktauswahl_content").hide();
	});
}

jQuery(document).ready(function() {
	//jQuery('#textcontainer').pngFix();
	
/*	if (window.navigator.userAgent.indexOf("MSIE ") > -1 &&
			parseFloat(navigator.appVersion) >= 4)*/	
	
	
	jQuery('.languageselector .ls-layer').mouseover(function() {
		jQuery(this).addClass('visible');
		jQuery(this).removeClass('default');
	});
	
	jQuery('.languageselector .ls-layer').mouseout(function() {
		jQuery(this).removeClass('visible');
		jQuery(this).addClass('default');
	});
	
	
	jQuery("a[rel^='prettyPhoto']").prettyPhoto({theme:'facebook', overlay_gallery:false, showTitle:false});

	jQuery('#imagecontainer').cycle({ 
	    fx:     'fade', 
	    speed:  2000,
	    timeout: 7000
	});
	jQuery('#textcontainer').cycle({ 
	    fx:     'scrollUp', 
	    speed:  2000,
	    timeout: 7000,
	    cleartypeNoBg: true
	});

	manageNewsBoxes();
	
	manageParagraphBoxes();
	
/*	

	jQuery('.absatz-aufklappbar').each(function() {
		var me = this;
		jQuery('.additionalcontent', me).hide();
		jQuery('.readmore', me).click(function() {
			jQuery('.additionalcontent', me).slideDown('normal', function() {jQuery('.readmore', me).slideUp();});
			return false;
		});
		jQuery('.readless', me).click(function() {
			jQuery('.additionalcontent', me).slideUp('normal', function() {jQuery('.readmore', me).slideDown();});
			return false;
		});
	});

	jQuery('.absatz-fliesstext').each(function() {
		
		var me = this;
//		if (!jQuery(this).parent().hasClass('orig')) jQuery('.additionalcontent', me).hide();
		
		var h = jQuery(me).height()+25;
		var oh = jQuery(me).prev().height();
		
		var isIE = false;
		if (navigator.appVersion.indexOf('MSIE 6') != -1 || navigator.appVersion.indexOf('MSIE 7') != -1) isIE = true;
		
//		jQuery(me).width(680);
//		jQuery(me).css({ width:680, margin:0});
		if (jQuery(me).parent().hasClass('orig')) {
//			jQuery(me).parent().width(680);
//			jQuery(me).parent().css({ width:680, margin:0});
		}
		
		jQuery('.readmore', me).click(function() {
//			jQuery('.additionalcontent', me).slideDown('normal', function() {});
			//jQuery('.additionalcontent', me).slideDown(1000, function() {});
			//jQuery('.readmore', me).parent().hide();
			
			
			jQuery(me).hide();
			
			if (!isIE)
				jQuery('.additionalcontent', jQuery(me).prev()).css( 'opacity', 0);
			jQuery(me).prev().show();
			jQuery(me).prev().height(h);
			//jQuery(me).prev().width(680);
			jQuery(me).prev().animate( {
				height:oh
			}, 1000);
			if (!isIE)
				jQuery('.additionalcontent', jQuery(me).prev()).animate( {'opacity': 1},500);
			jQuery(me).prev().attr( 'relH', h);
			//jQuery(me).prev().slideDown(1000, function() {});
			
			
			//jQuery(me).prev().slideDown(1000, function() {});
//			jQuery('.readmore', me).slideUp();
			return false;
		});
		jQuery('.readless', me).click(function() {
			//jQuery('.additionalcontent', me).slideUp(1000, function() {});
//			jQuery('.additionalcontent', me).slideUp('normal', function() {});
			//jQuery('.readmore', me).parent().show();
			//jQuery(me).parent().slideUp(1000, function() {});
//			jQuery('.readmore', me).slideDown();
			
			
			var h = jQuery(me).parent().attr('relH');
			//alert(h);
			jQuery(me).parent().animate( {
				height:h
			}, 250, function() {
				jQuery(this).hide();
				jQuery(this).next().show();
			});
			if (!isIE)
				jQuery('.additionalcontent', jQuery(me).parent()).animate( {'opacity': 0},250);
			//jQuery(me).parent().next().slideDown();
			return false;
		});
		
		jQuery('.toggle_readmore_img', me).click(function(){
			if(jQuery(me).prev().css("display")=="none"){
				//jQuery('.additionalcontent', me).slideDown(1000, function() {});
				
				//jQuery('.readmore', me).parent().hide();
				jQuery('.readmore', me).click();
				
			} else if(jQuery(me).parent().css("display")=="block") {

				jQuery('.readless', me).click();
				//jQuery('.additionalcontent', me).slideUp(1000, function() {});
				//jQuery('.readmore', me).parent().show();
				//jQuery('.readmore', me).click();
			}
			return false;
		});
	});
	
*/	
	// Sitemap öffner
	jQuery(".a_sitemap_toggler").click(function(){
		if(jQuery("#div_sitemap_container").css("display")=="none")
			jQuery('#div_sitemap_container').fadeIn(1000);
		else if(jQuery("#div_sitemap_container").css("display")=="block")
			jQuery('#div_sitemap_container').slideUp(1000);
		
		jQuery("#pos_sitemap").scrollTop();
	});
	
	// Pflichttexte
	jQuery('.pflichttexte').hide();

	
	
	jQuery('.pblogin .mainbtn').click(function() {
		jQuery('.form', jQuery(this).parent()).slideToggle();
		jQuery('.vform', jQuery(this).parent()).slideToggle();
	});
	
	
	jQuery('a.email').each(function(){
		e = this.rel.replace('/','@');
		this.href = 'mailto:' + e;
		jQuery(this).text(e);
	});
	
	jQuery("#div_produktauswahl_opener").bind("click", start_selectbox);
	jQuery("#div_produktauswahl_content").bind("mouseover", function(){
		jQuery("#div_produktauswahl_content").bind("mouseleave", function(){
			window.setTimeout(jQuery("#content").click(), 800);
			//jQuery("#content").click();
			jQuery("#div_produktauswahl_content").unbind("mouseleave");
		});
	});
	
	
	jQuery('.popupproductinfo').each(function() {
		var popup = jQuery(this);
		jQuery('img.close', this).click(function() {
			popup.fadeOut();
		});
	});
	
	/* Job & Karriere - Akkordion */
	jQuery('h2.akkordion').click(function(){
		if(jQuery(this).next('.jobakkordion').hasClass('hidden')){
			jQuery(this).addClass('active');
			jQuery(this).next('.jobakkordion').slideDown();
			jQuery(this).next('.jobakkordion').removeClass('hidden');
			var oldImage = jQuery(this).children('img').attr('src');
			jQuery(this).children('img').attr('src', jQuery('.hidden img', this).attr('src'));
			jQuery('.hidden img', this).attr('src', oldImage);
		} else {
			jQuery(this).next('.jobakkordion').slideUp();
			jQuery(this).next('.jobakkordion').addClass('hidden');
			jQuery(this).removeClass('active');
			var oldImage = jQuery(this).children('img').attr('src');
			jQuery(this).children('img').attr('src', jQuery('.hidden img', this).attr('src'));
			jQuery('.hidden img', this).attr('src', oldImage);
		}
	});
	
	jQuery('.readmorejob').click(function(){
		if(jQuery(this).parent().prev('.jobdetails').hasClass('hidden')){
			jQuery(this).parent('.weiterlesen_small').addClass('weiterlesen_big');
			jQuery(this).parent('.weiterlesen_small').removeClass('weiterlesen_small');
			jQuery(this).parent().prev('.jobdetails').slideDown();
			jQuery(this).parent().prev('.jobdetails').removeClass('hidden');
			var content = jQuery(this).html();
			jQuery(this).html(jQuery(this).attr('rel'));
			jQuery(this).attr('rel', content);
		} else {
			jQuery(this).parent('.weiterlesen_big').addClass('weiterlesen_small');
			jQuery(this).parent('.weiterlesen_big').removeClass('weiterlesen_big');
			jQuery(this).parent().prev('.jobdetails').slideUp();
			jQuery(this).parent().prev('.jobdetails').addClass('hidden');
			var content = jQuery(this).html();
			jQuery(this).html(jQuery(this).attr('rel'));
			jQuery(this).attr('rel', content);
		}
	});
	
	jQuery('.formularjob').click(function(){
		var selectValue = jQuery(this).attr('rel');
		
		jQuery('.jobformakk .jobselect option').each(function(){
			if(selectValue==jQuery(this).val()){
				jQuery('.jobformakk .jobselect option[value='+selectValue+']').attr('selected', 'selected');
			}
		});
		
		var formOffset = jQuery('.jobformakk').offset();
		jQuery(document).scrollTop(formOffset.top);
		
		if(jQuery('.jobformakk').hasClass('hidden'))
			jQuery('.jobformakk').prev().click();
	});
	
	jQuery('.jobfiles').click(function(){
		var countFiles = 0;
		jQuery('.bewerbungfiles input').each(function(){
			countFiles++;
		});
		
		if(countFiles<10)
			jQuery('.bewerbungfiles').append('<input name="bewerbungdatei[]" type="file" />');
	});
});


function showLogin( id, caller) {
	
	jQuery('.popuplogin').hide();
	jQuery(id).css('top', jQuery(caller).offset().top+'px');
	jQuery(id).fadeIn();

}


function hideLogin( id) {
	jQuery(id).fadeOut();
}



function showProductinfo( id, caller) {
	
	jQuery('.popupproductinfo').hide();
	jQuery(id).css('top', jQuery(caller).offset().top+'px');
	jQuery(id).fadeIn();

}


function hideProductinfo( id) {
	jQuery(id).fadeOut();
}





function popupwindow (Adresse,breite,hoehe,parameter) {
  MeinFenster = window.open(Adresse, "popupfenster", "width="+breite+",height="+hoehe+","+parameter+"");
  MeinFenster.focus();
}
