/*
	filename:	base.js
	version:	1.0 - 2010-02-10 - fz	 
	author:		frontend (at) gpm (dot) de 
	depends on:	jquery-1.4.min.js
*/



/* Var holding total with of inner Elements to be slided
 * is important for slide to the right 
 * is used to align last Element to be slided with 
 * right borader of inner window 
 */ 
var sliding_div_width = new Array();
sliding_div_width[0] = new Object();
var val_actual_id = 0;
var val_old_id = 0;
var val_right_button_id = 0;
var val_right_button_width = 0;
var val_right_button_height = 0;
var val_left_button_id = 0;
var val_left_button_width = 0;
var val_left_button_height = 0;

var mouseX = 0;
var mouseY = 0;
var randLinks = 0;

$(document).ready(function() {	
	$(".slider_container").each(function(){
		var width = 0 ;
		var slider_id = "#" + this.id  ;
		$(slider_id + " .sliding_img").each(function(){ 
			width += parseInt ($(slider_id + " .sliding_img").css("width") ) + 58 ;
		});
		//console.log(width);
		sliding_div_width[0][this.id] = width;
		/* initialises the use of right and left navigation button
		 * if total with of DIV to be slided ist less than inner 
		 * window width, no button are displayed
		 */ 
		if (sliding_div_width[0][this.id] > 460) {
			$(slider_id + " .slider_right_active").css({"display":"block"} ) ;
		}		
	});
	
	$(".imgLayer .imgDiv img").mouseover( function() { 
		$(this).css("border-color","#000099");
	} ).mouseout( function() { 
		$(this).css("border-color","#ccc");
	} );

	// Search suggest
	jQuery('input#inputSucheCS').attr('autocomplete','off');
	jQuery('#formSearch').keyup(function() {
		var searchText = encodeURIComponent(jQuery('input#inputSucheCS').attr('value'));
		if( searchText.length > 2 ) {
			jQuery.get('/metadata/suche/searchsuggestsajax.jsp', { q: searchText, js: 1 }, function(data) {
				jQuery('#searchSuggest').html(data);
			});
			if(jQuery('#searchSuggest').css('display') == 'none') {
				jQuery('#searchSuggest').css('display', 'block');
			}
		}
	});

	jQuery('body').click(function() {
		if(jQuery('#searchSuggest').css('display') == 'block') {
			jQuery('#searchSuggest').css('display', 'none');
		}
	});

	// runde Ecken:
	// jQuery('#extendedSeachPopup').corner();

	// Erweiterte Suche - Popup Layer
	jQuery("#extendedSearchLink").click(function(event){
		event.preventDefault();
		jQuery("#extendedSeachPopup").toggle();
		jQuery("#extendedSearchLink").toggleClass("open");
		var inputSearchQ = jQuery("#inputSucheCS").val();
		if ( inputSearchQ != "Ihr Suchbegriff" )
			jQuery("#inputExtSearch").val(inputSearchQ);
	});
	jQuery("#extendedSeachPopup").blur(function(event){
		jQuery(this).hide(); 
	});
	jQuery("body").mousemove(function(e) {
			mouseX = e.pageX;
			mouseY = e.pageY;
			randLinks = parseInt(document.getElementById("stage").offsetLeft)
		});
		
	jQuery(".mnLi").mouseover(function(e) {
			ulChild = $(this).children("ul");
			ulChild.removeClass("navDropDownHidden");
			ulChild.addClass("navDropDownShow");			
		}).mouseleave(function() {
			ulChild = $(this).children("ul");	
			ulChild.removeClass("navDropDownShow");
			ulChild.addClass("navDropDownHidden");
 			
		});
	if(jQuery(".moodBildLayer")) {
		bildwechselMoodbilderStart();
	}
		
});

var anzahlMoodbilder;
var moodbilderArray ;
var moodbildNumber;

function bildwechselMoodbilderStart() {
	anzahlMoodbilder = jQuery(".moodBildLayer").children("div.moodbild").length;
	moodbilderArray = jQuery(".moodBildLayer").children("div.moodbild");
	window.setTimeout("bildwechselMoodbilder(1)", 7000);
}

function bildwechselMoodbilder(moodbildNumber) {
	if(moodbildNumber+1 > anzahlMoodbilder) {
		newMoodbildNumber = 1;
	}
	else {
		newMoodbildNumber = moodbildNumber+1;
	}
	jQuery(".moodBildLayer").children("div#moodBild"+(moodbildNumber)).fadeOut("slow");
	jQuery(".moodBildLayer").children("div#moodBild"+(newMoodbildNumber)).fadeIn("slow");
	//console.log("test = "+newMoodbildNumber);
	timer = window.setTimeout("bildwechselMoodbilder("+newMoodbildNumber+")", 7000);
}

// Funktion um auf der Jobb�rse (ext. SAP-Anwendung) direkt auf Unterseiten verlinken zu k�nnen
function getIFrameLink () {
	var theUrl = 'http://bewerbung.merz.de/';
	var theSearch = window.location.search;
	if(theSearch) {
		theSearch = decodeURIComponent(theSearch.substring(1));
		var theList = theSearch.split('&');
		if(theList.length > 0) {
			if(theList[0].indexOf('list=') == 0) {
				   theUrl = theUrl + '?list=' + theList[0].split('=')[1];
			}
			else if (theList[0].indexOf('initiativ=') == 0) {
				   theUrl = theUrl + '?initiativ=' + theList[0].split('=')[1];
			}
			else if (theList[0].indexOf('offid=') == 0) {
				   theUrl = theUrl + '?offid=' + theList[0].split('=')[1];
			}
			else if (theList[0].indexOf('apply=') == 0) {
				   theUrl = theUrl + '?apply=' + theList[0].split('=')[1];
			}
		}
	}
	$('#iFrameJobboerse').html('<iframe frameborder="0" src="' + theUrl + '" width="860" height="980" scrolling="no">Hier content</iframe>');
}

function toggleNavi(objekt) {
	arrowImage = $(objekt).children("img");
	ulChild = $(objekt).parent("div").parent("li").children("ul");
	ulParent = $(objekt).parent("div").parent("li").parent("ul");
	if(! ulParent.hasClass("noexpand")) {
		ulChild.slideToggle("slow",function(){ 
  			ulParent.addClass("noexpand");
			arrowImage.attr( {src: "/media/layout_1/img/arrow_expand_blank~1.gif"} );
		});		
	}
	else {
		ulChild.slideToggle("slow");
		ulParent.removeClass("noexpand");
		arrowImage.attr( {src: "/media/layout_1/img/arrow_expand_blank.gif"} );	
	}
}

function toggleLayer(objekt) {
	divToggleLayer = $(objekt).parent("h2").parent("div").parent("div");
	divChild = $(objekt).parent("h2").parent("div").parent("div").children("div.toggleBody");
	if(! divToggleLayer.hasClass("noexpand")) {
		divChild.slideToggle("slow",function(){
			divToggleLayer.addClass("noexpand");
			if(divToggleLayer.parent("div").attr("id") == "contentMain" ) {
				divToggleLayer.animate({marginBottom:10},"fast");
			}
		});		
	}
	else {
		if(divToggleLayer.parent("div").attr("id") == "contentMain" ) {
			divToggleLayer.animate({marginBottom:0},"fast");
		}
		divChild.slideToggle("slow",function(){
			divToggleLayer.removeClass("noexpand");
		});
	}	
}

var objektID = "";
var gesperrt = false;

function showMainNavi(objekt,action) {
	ulChild = $(objekt).children("ul");
	if(action == "show" &&  !gesperrt ) {
		ulChild.removeClass("navDropDownHidden");
		ulChild.addClass("navDropDownShow");
		objektID = $(objekt).attr("id");
		gesperrt = true;
	}
	else if(action == "hide" && !objektID.indexOf($(objekt).attr("id")) ) {
		ulChild.removeClass("navDropDownShow");
		ulChild.addClass("navDropDownHidden");
		objektID = "";
		gesperrt = false;
	}
}

function layer(aktivLayer,absatzID,anzahlLayer) {
	layerDavor = (aktivLayer-1);
	layerDanach = (aktivLayer+1);
	if( (layerDavor) == 0 ) {
		layerDavor = anzahlLayer;
	}
	if( (layerDanach) > anzahlLayer) {
		layerDanach = 1;
	}
	document.getElementById("text"+absatzID+layerDavor).style.display = "none";
	document.getElementById("text"+absatzID+aktivLayer).style.display = "block";
	document.getElementById("text"+absatzID+(layerDanach)).style.display = "none";
}

function gotoProductpage(){
	top.location.href = document.getElementById("selectProductlist").options[document.getElementById("selectProductlist").selectedIndex].value;
	//alert(document.getElementById("productlistselect").options[document.getElementById("productlistselect").selectedIndex].value)
} 

function showFormLayer(action,layer) {
	if (action == 1) {
		showOverlayLayer(action);
		$(".popup_overlay").fadeIn(300, function(){
			showLayer(action,layer);
		});
	}
	if (action == 0) {
		showLayer(action,layer);
		showOverlayLayer(action);
	}
}

function showLayer(action,layer) {
	if (action == 1) {
		document.getElementById(layer).style.display = "block";
		document.getElementById(layer).style.visibility = "visible";
	}
	if (action == 0) {
		document.getElementById(layer).style.display = "none";
		document.getElementById(layer).style.visibility = "hidden";	
	}
}

function showOverlayLayer(action) {
    arrayPageDimesion = getPageSize();
	arrayScrollDimesion = getPageScroll();
	if (action == 1) {
		$("body").prepend("<div class=\"popup_overlay\" id=\"layerPopBG\"></div>");
		$(".popup_overlay").css({
			height	: 	arrayPageDimesion[1],
			opacity	:	0.7
		});
		bodyHasOverlay = true;
	}
	if (action == 0) {
		$(".popup_overlay").fadeOut("slow", function(){
	        $(this).remove();    
	    });
	}		
}

var timer;
var infoLayer;
var infoLayerMoved = false;
var divLayer;
var meinObjekt;

function info(objekt,job) {
	if(!infoLayerMoved) {
		infoLayer = jQuery(objekt).parent("div").children("span.bildTitel");
		meinObjekt = objekt;	
		divLayer = jQuery(objekt).parent("div");
	}
	if(job == 1) {
		if(!infoLayerMoved) {
			infoLayer.prependTo("#contentMain");
			infoLayerMoved = true;
		}
		infoLayer.css("display","block");
		infoLayer.css("top",(mouseY-10)+"px");
		infoLayer.css("left",(mouseX-randLinks+20)+"px");
		timer = window.setTimeout("info(meinObjekt,"+job+")", 100);
	}
	if(job == 0) {
		window.clearTimeout(timer);
		infoLayer.prependTo(divLayer);
		infoLayer.css("display","none");
		infoLayerMoved = false;
	}
}

/**
 * getPageSize() by quirksmode.com
 *
 * @return Array Return an array with page width, height and window width, height
 */
function getPageSize() {
	var xScroll, yScroll;
	if (window.innerHeight && window.scrollMaxY) {	
		xScroll = window.innerWidth + window.scrollMaxX;
		yScroll = window.innerHeight + window.scrollMaxY;
	} else if (document.body.scrollHeight > document.body.offsetHeight){ // all but Explorer Mac
		xScroll = document.body.scrollWidth;
		yScroll = document.body.scrollHeight;
	} else { // Explorer Mac...would also work in Explorer 6 Strict, Mozilla and Safari
		xScroll = document.body.offsetWidth;
		yScroll = document.body.offsetHeight;
	}
	var windowWidth, windowHeight;
	if (self.innerHeight) {	// all except Explorer
		if(document.documentElement.clientWidth){
			windowWidth = document.documentElement.clientWidth; 
		} else {
			windowWidth = self.innerWidth;
		}
		windowHeight = self.innerHeight;
	} else if (document.documentElement && document.documentElement.clientHeight) { // Explorer 6 Strict Mode
		windowWidth = document.documentElement.clientWidth;
		windowHeight = document.documentElement.clientHeight;
	} else if (document.body) { // other Explorers
		windowWidth = document.body.clientWidth;
		windowHeight = document.body.clientHeight;
	}	
	// for small pages with total height less then height of the viewport
	if(yScroll < windowHeight){
		pageHeight = windowHeight;
	} else { 
		pageHeight = yScroll;
	}
	// for small pages with total width less then width of the viewport
	if(xScroll < windowWidth){	
		pageWidth = xScroll;		
	} else {
		pageWidth = windowWidth;
	}
	
	// pageWidth = document.body.clientWidth;
	// pageHeight = document.body.clientHeight;

	arrayPageSize = new Array(pageWidth,pageHeight,windowWidth,windowHeight);
	return arrayPageSize;
}

/**
 * getPageScroll() by quirksmode.com
 *
 * @return Array Return an array with x,y page scroll values.
 */
function getPageScroll() {
	var xScroll, yScroll;
	if (self.pageYOffset) {
		yScroll = self.pageYOffset;
		xScroll = self.pageXOffset;
	} else if (document.documentElement && document.documentElement.scrollTop) {	 // Explorer 6 Strict
		yScroll = document.documentElement.scrollTop;
		xScroll = document.documentElement.scrollLeft;
	} else if (document.body) {// all other Explorers
		yScroll = document.body.scrollTop;
		xScroll = document.body.scrollLeft;	
	}
	arrayPageScroll = new Array(xScroll,yScroll);
	return arrayPageScroll;
}

/*  
	|---------------------------------------|
	| functions for Slider / Lightboxeffect |
	|---------------------------------------|
*/

function slide_right(slider_id) {
	var total_width = parseInt(sliding_div_width[0][slider_id]);
	$("#" + slider_id + " .sliding_div:animated").stop();
	if ( parseInt ($("#" + slider_id + " .sliding_div").css("left") ) < -400 ) {
		// sliding		
        $("#" + slider_id + " .sliding_div").animate({ "left": "+=400" }, "slow");
		if (total_width > 460) {
			$("#" + slider_id + " .slider_right_active").css({"display":"block"} ) ;
		}
	}
	/* if remaining width to the right of DIV to be slided is more than 863px
	 * inner Div is slided to the left by 400px
	 */
	else {
		$("#" + slider_id + " .slider_left_active").css({"display":"none"} ) ;
		//sliding
		$("#" + slider_id + " .sliding_div").animate({ "left": 0 + "px"  }, "slow");
		
		if (total_width > 460) {
			$("#" + slider_id + " .slider_right_active").css({"display":"block"} ) ;
		}
	}	
}

function slide_left(slider_id) {
	var total_width = parseInt(sliding_div_width[0][slider_id]);
	$("#" + slider_id + " .sliding_div:animated").stop();
	/* if remaining width to the right of DIV to be slided is less than
	 * width of the inner window (463px) + value the DIV ist slided (400px)
	 * inner DIV will be slided to the left and aligned right with the inner window
	 */ 
	if ( parseInt ($("#" + slider_id + " .sliding_div").css("left") ) + total_width  > 859 ) {
		// sliding
		$("#" + slider_id + " .sliding_div").animate({ "left": "-=400" }, "slow")
	}
	/* if remaining width to the right of DIV to be slided is more than 863px
	 * inner Div is slided to the left by 400px
	 */
	else {
		//sliding
		$("#" + slider_id + " .sliding_div").animate({ "left": - total_width + 459  }, "slow")
		$("#" + slider_id + " .slider_right_active").css({"display":"none"} ) ;
	}
	$("#" + slider_id + " .slider_left_active").css({"display":"block"} ) ;
}

/* Handler for click on cross top left on popupbox
 * click fades #popup_overlay and 
 * div.popup_container_all out
 */
function fade_out_popup() {
	bodyHasOverlay = false;
	popup_container_all_width = 0;
	absatzID = 0;
	$(".popup_container_all").css({"display":"none"});
	showOverlayLayer(0);
}

function openPopup(linkPopup,widthPU,heightPU,hasScrollbars,isResizeable,windowName) {
	var winparams = "width="+widthPU+",height="+heightPU+",scrollbars="+hasScrollbars+",resizeable="+isResizeable+",toolbar=no,menubar=no,location=no";
	var winname = windowName;
	window.open(linkPopup, winname, winparams);
}

/*  
	|---------------------------------------|
	| functions for Popup                   |
	|---------------------------------------|
 
 * mainfunction controlling action of Popup
 * 
 * Is called by click on img in slider
 * Is call by click on nav-buttons in Popup
 * 
 */
 
var bodyHasOverlay = false;
var popup_container_all_width = 0;
var absatzID = 0;
 
function fade_in_popup(slider_id, id_selected, image_width, image_height, absatz_id ) {
    fadein_duration = 400;
    arrayPageDimesion = getPageSize();
	arrayScrollDimesion = getPageScroll();
	absatzID = absatz_id;
	

	if(!bodyHasOverlay) {
		showOverlayLayer(1);
		init_popup(slider_id);
	}

    $("#"+slider_id).prependTo("body");

    $("div#" + slider_id + ":animated").stop();
    
    $("div#" + slider_id + " .popup_navibutton_left").css({"display" : "none"});
    $("div#" + slider_id + " .popup_navibutton_right").css({"display" : "none"});

    // set the old images of last loop (pre pre images to back)
    $("div#" + slider_id + " #popup_headline_" + val_old_id).css({"display" : "none", "z-index": "11"});
    $("div#" + slider_id + " #popup_bottomline_" + val_old_id).css({"display" : "none", "z-index": "11"});
    $("div#" + slider_id + " #popup_pic_slider_" + val_old_id).css({"display" : "none", "z-index": "11"});
    $("div#" + slider_id + " #popup_rightcontent_" + val_old_id).css({"display" : "none", "z-index": "11"});
	
	val_old_id = val_actual_id;	
	// set actual images tu pre image and set it in position to be fades out
	// $("div#" + slider_id + " #popup_headline_" + val_actual_id).animate({opacity: 0.0}, fadein_duration);
	$("div#" + slider_id + " #popup_headline_" + val_actual_id).fadeOut(fadein_duration);	
	$("div#" + slider_id + " #popup_headline_" + val_actual_id).css({"z-index": "12"});
	
	$("div#" + slider_id + " #popup_bottomline_" + val_actual_id).fadeOut(fadein_duration);
	$("div#" + slider_id + " #popup_bottomline_" + val_actual_id).css({"z-index": "12"});	
	
	$("div#" + slider_id + " #popup_pic_slider_" + val_actual_id).fadeOut(fadein_duration);
	$("div#" + slider_id + " #popup_pic_slider_" + val_actual_id).css({"z-index": "12"});	
	
	$("div#" + slider_id + " #popup_rightcontent_" + val_actual_id).fadeOut(fadein_duration);
	$("div#" + slider_id + " #popup_rightcontent_" + val_actual_id).css({"z-index": "12"});	
    
    val_actual_id = id_selected
    if ($.trim($("div#" + slider_id + " #popup_rightcontent_" + id_selected).html())  == "" ) {
        var right_content_width = 0;
    }
    else {
        var right_content_width = 230;
    } 
    
    var div_width = parseInt(image_width) + 40;
    
    
    
    // set image to faded in to front an set opacity to 0.0
	$("div#" + slider_id + " #popup_headline_" + id_selected).css({"display" : "none", "z-index": "13"});
	$("div#" + slider_id + " #popup_headline_" + id_selected).fadeIn(fadein_duration).animate({"width": image_width + "px"}, fadein_duration); 
 																
	$("div#" + slider_id + " #popup_bottomline_" + id_selected).css({"display" : "none", "z-index": "13"});
	$("div#" + slider_id + " #popup_bottomline_" + id_selected).animate({"width": image_width + "px"}, fadein_duration);
    $("div#" + slider_id + " #popup_bottomline_" + id_selected).fadeIn(fadein_duration);
	
	$("div#" + slider_id + " #popup_pic_slider_" + id_selected).css({"display" : "none", "z-index": "13"});
	$("div#" + slider_id + " .popup_div_center_middle").animate({"width": div_width + "px", "height": image_height + "px"}, fadein_duration);	
	$("div#" + slider_id + " #popup_pic_slider_" + id_selected).fadeIn(fadein_duration).animate({"width": image_width + "px", "height": image_height + "px"}, fadein_duration, function() {
        $("div#" + slider_id + " #popup_pic_slider_" + val_old_id).css({"display" : "none"});
    });
	
	$("div#" + slider_id + " #popup_rightcontent_" + val_old_id).css({"display":"none" });
    $("div#" + slider_id + " #popup_rightcontent_" + id_selected).css({"display" : "none", "z-index": "13"});
	//$("div#" + slider_id + " .popup_container_right_content").animate({"width": right_content_width + "px", "height": image_height + "px"}, fadein_duration);
	if(right_content_width > 0) {
		$("div#" + slider_id + " .popup_container_right_content").animate({"width": right_content_width + "px", "height": image_height + "px"}, fadein_duration);
		$("div#" + slider_id + " .popup_container_right_content").css({"display" : "block"});
	}
	if(right_content_width == 0) {
		$("div#" + slider_id + " .popup_container_right_content").css({"display" : "none"});
	}
	$("div#" + slider_id + " #popup_rightcontent_" + id_selected).fadeIn(fadein_duration);
	$("div#" + slider_id + " #popup_bottomline_" + val_old_id).css({"display":"none" });
    $("div#" + slider_id + " #popup_div_right_bottom" + id_selected).css({"display" : "none", "z-index": "13", "position":"absolute", "top": "0px"});
	$("div#" + slider_id + " .popup_div_right_bottom").css( {"width": (parseInt(image_width)+6) + "px"});	
    $("div#" + slider_id + " #popup_div_right_bottom" + id_selected).fadeIn(fadein_duration);      
    
    
	$("div#" + slider_id + " .popup_container_all").css( {"width": (parseInt(image_width + right_content_width) + 100) + "px"});

	$("div#" + slider_id + " .popup_div_right_content_middle").animate({"height": (parseInt(image_height)-5) + "px"}, fadein_duration);
	$("div#" + slider_id + " .popup_div_left_middle").animate({"height": (parseInt(image_height)+20) + "px"}, fadein_duration);
	$("div#" + slider_id + " .popup_div_right_middle").animate({"height": (parseInt(image_height)+25) + "px"}, fadein_duration);    
    
    popup_container_all_width = parseInt(right_content_width) + parseInt(image_width);    
    //$("div#" + slider_id + " .popup_closebutton").animate({"left": (parseInt(popup_container_all_width)+5) + "px"}, fadein_duration);    

    // set position (center) of the popup	
	leftPos = parseInt((arrayPageDimesion[2] - popup_container_all_width) / 2) ;
	$(".popup_container_all").animate({ 
  		"left": leftPos + "px"
	}, "fast");	
	//$(".popup_container_all").css( {"left": leftPos + "px"});
	$(".popup_container_all").css( {"top": (80+arrayScrollDimesion[1]) + "px"});
	$(".popup_container_right_content").css( {"top": (120+arrayScrollDimesion[1]) + "px"});
	$(" .popup_overlay").fadeIn(300, function(){
		$("div#" + slider_id).fadeIn(200, function (){
			set_navi_buttons(slider_id, id_selected, image_width, image_height);
		});	
	});
}

function set_navi_buttons(slider_id, id_selected, image_width, image_height) {
	var popup_left_nav = false;
	var popup_right_nav = false;
	var count = 1;
	
	// if only 1 pic = no navigation button
	if ($("div#" + slider_id + " .popup_pic_slider").length > 1) {
		//setting couter to get active element 
		var count = 1;
		
		//start loop for each pic
		$("div#" + slider_id + " .popup_pic_slider").each( function () {
				//if ("popup_pic_slider_" + absatz_id+ "_" + id_selected ==  this.id){
				if ("popup_pic_slider_" + id_selected ==  this.id){
					//alert("popup_pic_slider_" + absatz_id+ "_" + id_selected +" | "+ this.id);			
					//if active pic is not first pic, left navbutton is set
					if (count > 1) {
						popup_left_nav = true;
					}
					//if active pic is not last pic, right navbutton is set
					if (count < $("div#" + slider_id + " .popup_pic_slider").length) {
						popup_right_nav = true;
					}
					//breaking loop
					return false;						
				}
				count++;					
		});		
	}
	//setting left navbutton
	var navtop = 60  //parseInt((image_height-15)/2)+75;
	var navwidth = parseInt((image_width/2)-5);
	var navheight = parseInt(image_height);
	if (popup_left_nav) {
	    $("div#" + slider_id + " .popup_navibutton_left").css({"display" : "block"});
		$(".naviButtonPic").css({"width" : navwidth + "px", "height" : navheight + "px"});	
		$("div#" + slider_id + " .popup_navibutton_left").css({"width" : navwidth + "px", "height" : image_height + "px", "top" : navtop + "px"});			
		val_left_button_id =  ($("div#" + slider_id + " .popup_pic_slider:eq(" + (count-2) + ")").attr("id").slice( 17, 60)) ;	        
		val_left_button_width = parseInt($("div#" + slider_id + " .popup_pic_slider:eq(" + (count-2) + ")").width()) ;
		val_left_button_height = parseInt($("div#" + slider_id + " .popup_pic_slider:eq(" + (count-2) + ")").height()) ;
	}
	else {
		$("div#" + slider_id + " .popup_navibutton_left").css({"display" : "none"});	
	}
	//setting right button
	if (popup_right_nav) {
		$("div#" + slider_id + " .popup_navibutton_right").css({"left" : (parseInt(image_width) - parseInt(navwidth) + 20) + "px", "display" : "block"});
        $(".naviButtonPic").css({"width" : navwidth + "px", "height" : navheight + "px"});	
		$("div#" + slider_id + " .popup_navibutton_right").css({"width" : navwidth + "px", "height" : image_height + "px", "top" : navtop + "px"});
		val_right_button_id = ($("div#" + slider_id + " .popup_pic_slider:eq(" + (count) + ")").attr("id").slice( 17, 60)) ;
		val_right_button_width = parseInt($("div#" + slider_id + " .popup_pic_slider:eq(" + (count) + ")").width()) ;
        val_right_button_height = parseInt($("div#" + slider_id + " .popup_pic_slider:eq(" + (count) + ")").height()) ;
	}
	else {
		$("div#" + slider_id + " .popup_navibutton_right").css({"display" : "none"});	
	}
}

function fade_inout_navibutton(objekt,job) {
	if(job == "out") {
		$(objekt).addClass("noBackground");
	}
	else {
		$(objekt).removeClass("noBackground");
	}
}

function init_popup(slider_id) {
    
    val_actual_id = 0;
    val_old_id = 0;

    //set display of all right Contents to none
	$("div#" + slider_id + " .popup_headline").each( function () {
		$(this).css({"display" : "none", "z-index": "11"});
	});	
	//set display of all right Contents to none
	$("div#" + slider_id + " .popup_bottomline").each( function () {
		$(this).css({"display" : "none", "z-index": "11"});
	});	
	//set display of all right Contents to none
	$("div#" + slider_id + " .popup_pic_slider").each( function () {
		$(this).css({"display" : "none", "z-index": "11"});
	});	
	//set display of all right Contents to none	
	$("div#" + slider_id + " .popup_rightcontent").each( function () {
		$(this).css({"display" : "none", "z-index": "11"});
	});	
	return true;
}
