jQuery.noConflict();
(function($){
    var lastActiveIndexSlider = 0;
    var activeIndex = 0;
    
    //Tabs ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
    jQuery.wp_setTabs = function(el, panes, eventHandler){
        var paneCont;
        if (panes != 'undefined' && panes != null && panes != '') {
            paneCont = panes;
        }
        else {
            paneCont = "div.wp_panes > div";
        }
        $(el).tabs(paneCont, {
            effect: 'fade',
            event: eventHandler
        });
    }
    
    //Accordian ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
    jQuery.tools.tabs.addEffect("slide", function(i, done){
        this.getPanes().slideUp().css({});//backgroundColor: "#FF6600"
        this.getPanes().eq(i).slideDown(function(){
            $(this).css({
                backgroundColor: 'transparent'
            });
            done.call();
        });
    });
    
    jQuery.wp_accordian = function(accordianId, startIndex, eventHandler){
    
        var accordianIdSet;
        if (accordianId != 'undefined' && accordianId != null && accordianId != '') {
            accordianIdSet = accordianId;
        }
        else {
            accordianIdSet = ".wp_accordion";
        }
        
        $(accordianIdSet).tabs(accordianIdSet + " div.wp_pane", {
            tabs: 'h2',
            effect: 'slide',
            initialIndex: startIndex,
            event: eventHandler
        });
    }
    
    // Scrollable Vertical ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
    jQuery.easing.flubberVert = function(x, t, b, c, d){
        var s = 1.70158;
        if ((t /= d / 2) < 1) 
            return c / 2 * (t * t * (((s *= (1.525)) + 1) * t - s)) + b;
        return c / 2 * ((t -= 2) * t * (((s *= (1.525)) + 1) * t + s) + 2) + b;
    }
    
    jQuery.wp_scrollableVert = function(el, circ){
        var elSet;
        if (el != 'undefined' && el != null && el != '') {
            elSet = el;
        }
        else {
            elSet = ".wp_vert_scrollable";
        }
        $(elSet).scrollable({
            vertical: true,
            mousewheel: false,
            next: '.wp_vert_next',
            prev: '.wp_vert_prev',
            disabledClass: 'wp_vert_disabled',
            circular: circ
        });
    }
    
    // Scrollable Horizontal ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
    jQuery.easing.flubberHor = function(x, t, b, c, d){
        var s = 1.70158;
        if ((t /= d / 2) < 1) 
            return c / 2 * (t * t * (((s *= (1.525)) + 1) * t - s)) + b;
        return c / 2 * ((t -= 2) * t * (((s *= (1.525)) + 1) * t + s) + 2) + b;
    }
    
    jQuery.wp_scrollableHor = function(el, circ){
        var elSet;
        if (el != 'undefined' && el != null && el != '') {
            elSet = el;
        }
        else {
            elSet = ".wp_hor_scrollable";
        }
        $(elSet).scrollable({
            vertical: false,
            mousewheel: false,
            next: '.wp_hor_next',
            prev: '.wp_hor_prev',
            disabledClass: 'wp_hor_disabled',
            circular: circ
        });
    }
    
    jQuery.wp_lightboxStd = function(el){
        /*
         settings = jQuery.extend({
         // Configuration related to overlay
         overlayBgColor: 		'#000',		// (string) Background color to overlay; inform a hexadecimal value like: #RRGGBB. Where RR, GG, and BB are the hexadecimal values for the red, green, and blue values of the color.
         overlayOpacity:			0.8,		// (integer) Opacity value to overlay; inform: 0.X. Where X are number from 0 to 9
         // Configuration related to navigation
         fixedNavigation:		false,		// (boolean) Boolean that informs if the navigation (next and prev button) will be fixed or not in the interface.
         // Configuration related to images
         imageLoading:			'img/lightbox/lightbox-ico-loading.gif',		// (string) Path and the name of the loading icon
         imageBtnPrev:			'img/lightbox/lightbox-btn-prev.gif',			// (string) Path and the name of the prev button image
         imageBtnNext:			'img/lightbox/lightbox-btn-next.gif',			// (string) Path and the name of the next button image
         imageBtnClose:			'img/lightbox/lightbox-btn-close.gif',		// (string) Path and the name of the close btn
         imageBlank:				'img/lightbox/lightbox-blank.gif',			// (string) Path and the name of a blank image (one pixel)
         // Configuration related to container image box
         containerBorderSize:	10,			// (integer) If you adjust the padding in the CSS for the container, #lightbox-container-image-box, you will need to update this value
         containerResizeSpeed:	400,		// (integer) Specify the resize duration of container image. These number are miliseconds. 400 is default.
         // Configuration related to texts in caption. For example: Image 2 of 8. You can alter either "Image" and "of" texts.
         txtImage:				'Image',	// (string) Specify text "Image"
         txtOf:					'of',		// (string) Specify text "of"
         // Configuration related to keyboard navigation
         keyToClose:				'c',		// (string) (c = close) Letter to close the jQuery lightBox interface. Beyond this letter, the letter X and the SCAPE key is used to.
         keyToPrev:				'p',		// (string) (p = previous) Letter to show the previous image
         keyToNext:				'n',		// (string) (n = next) Letter to show the next image.
         // Don�t alter these variables in any way
         imageArray:				[],
         activeImage:			0
         },settings);
         */
        jQuery(el).lightBox({
            imageLoading: 'css/img/lightbox/lightbox-ico-loading.gif',
            imageBtnPrev: 'css/img/lightbox/lightbox-btn-prev.gif',
            imageBtnNext: 'css/img/lightbox/lightbox-btn-next.gif',
            imageBtnClose: 'css/img/lightbox/lightbox-btn-close.gif',
            imageBlank: 'css/img/lightbox/lightbox-blank.gif'
        });
    }
    
    // Lightbox ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
    jQuery.wp_lightbox = function(classNames, animate, autoPlay, startZoom, enableSlideshow, loop, overlayOpacity){
        /*
         * animate:true,
         * autoPlay:true,
         * borderSize:39,
         * containerID:document,
         * enableSlideshow:true,
         * googleAnalytics:false,
         * imageDataLocation:"south",
         * closeLocation:"",
         * initImage:"",
         * loop:true,
         * overlayDuration:0.2,
         * overlayOpacity:0.7,
         * prefix:"",
         * classNames:"wp_vlightbox",
         * resizeSpeed:7,
         * showGroupName:false,
         * slideTime:4,
         * strings:{closeLink:"", loadingMsg:"lade ...", nextLink:"vor", prevLink:"", startSlideshow:"", stopSlideshow:"", numDisplayPrefix:"", numDisplaySeparator:"/"}
         */
        if (classNames == "" || classNames == null || classNames == 'undefined') {
            classNames = 'wp_vlightbox';
        }
        else {
            classNames = classNames;
        }
        
        if (overlayOpacity == "" || overlayOpacity == null || overlayOpacity == 'undefined') {
            overlayOpacity = 0.7;
        }
        else {
            overlayOpacity = overlayOpacity;
        }
        
        var wp_boxParams = {
            classNames: classNames,
            animate: animate,
            autoPlay: autoPlay,
            startZoom: startZoom,
            enableSlideshow: enableSlideshow,
            loop: loop,
            overlayOpacity: overlayOpacity,
            imageDataLocation: ''
        };
        (new jQuery).visualLightbox(wp_boxParams);
    }
    
    // Slide Panel ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
    jQuery.wp_slidePanel = function(buttonName, panelName, toggleClass){
        if (buttonName == "" || buttonName == null || buttonName == 'undefined') {
            buttonName = '.wp_btn-slide';
        }
        else {
            buttonName = buttonName;
        }
        
        if (panelName == "" || panelName == null || panelName == 'undefined') {
            panelName = '#wp_slider_panel';
        }
        else {
            panelName = panelName;
        }
        
        if (toggleClass == "" || toggleClass == null || toggleClass == 'undefined') {
            toggleClass = 'wp_slider_active';
        }
        else {
            toggleClass = toggleClass;
        }
        
        $(buttonName).click(function(){
            $(panelName).slideToggle("slow");
            $(this).toggleClass(toggleClass);
            return false;
        });
    }
    
    // Tab Over ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
    jQuery.wp_tabOver = function(tabBox, descBoxes, event){
        if (tabBox == "" || tabBox == null || tabBox == 'undefined') {
            tabBox = '#wp_products';
        }
        else {
            tabBox = tabBox;
        }
        
        if (descBoxes == "" || descBoxes == null || descBoxes == 'undefined') {
            descBoxes = 'div.wp_description';
        }
        else {
            descBoxes = descBoxes;
        }
        
        if (event == "" || event == null || event == 'undefined') {
            event = 'mouseover';
        }
        else {
            event = event;
        }
        
        $(tabBox).tabs(descBoxes, {
            event: event
        });
    }
    
    // Accordian Horizontal ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
    jQuery.wp_accordianHor = function(accordBox, eventer, tabs){
        if (accordBox == "" || accordBox == null || accordBox == 'undefined') {
            accordBox = '.wp_hor_accordion';
        }
        else {
            accordBox = accordBox;
        }
        
        if (eventer == "" || eventer == null || eventer == 'undefined') {
            eventer = 'mouseover';
        }
        else {
            eventer = eventer;
        }
        
        if (tabs == "" || tabs == null || tabs == 'undefined') {
            tabs = 'img';
        }
        else {
            tabs = tabs;
        }
        
        $(accordBox).tabs(accordBox + ' div', {
            tabs: tabs,
            effect: 'horizontal',
            event: eventer
        });
    }
    // Accordian Horizontal Webstyle ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
    jQuery.wp_accordianHor_webStyle = function(elScroll, elAcc, maxSizeField, spacing){
    
        if (elScroll == "" || elScroll == null || elScroll == 'undefined') {
            elScroll = '.wp_webstyle_scroll';
        }
        else {
            elScroll = elScroll;
        }
        
        if (elAcc == "" || elAcc == null || elAcc == 'undefined') {
            elAcc = '.wp_acc_hor';
        }
        else {
            elAcc = elAcc;
        }
        
        if (maxSizeField == "" || maxSizeField == null || maxSizeField == 'undefined') {
            maxSizeField = 450;
        }
        else {
            maxSizeField = maxSizeField;
        }
        
        if (spacing == "" || spacing == null || spacing == 'undefined') {
            spacing = 15;
        }
        else {
            spacing = spacing;
        }
        
        $(elScroll).scrollable({
            circular: true
        }).click(function(){
            $(this).data("scrollable").next();
        });
        
        $(elAcc).kwicks({
            max: maxSizeField,
            spacing: spacing,
            duration: 500
        });
    }
    
    //Effekt
    $.easing.bouncy = function(x, t, b, c, d){
        var s = 1.70158;
        if ((t /= d / 2) < 1) 
            return c / 2 * (t * t * (((s *= (1.525)) + 1) * t - s)) + b;
        return c / 2 * ((t -= 2) * t * (((s *= (1.525)) + 1) * t + s) + 2) + b;
    }
    
    
    // Tooltip ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
    jQuery.wp_tooltip = function(toolTipBox, tipClass, effect, position){
        $.tools.tooltip.addEffect("bouncy", function(done){
            this.getTip().animate({
                top: '+=15'
            }, 500, 'bouncy', done).show();
        }, function(done){
            this.getTip().animate({
                top: '-=15'
            }, 500, 'bouncy', function(){
                $(this).hide();
                done.call();
            });
        });
        
        if (toolTipBox == "" || toolTipBox == null || toolTipBox == 'undefined') {
            toolTipBox = '#wp_tooltipbox img[title]';
        }
        else {
            toolTipBox = toolTipBox;
        }
        
        if (tipClass == "" || tipClass == null || tipClass == 'undefined') {
            tipClass = 'wp_tooltip';
        }
        else {
            tipClass = tipClass;
        }
        
        if (effect == "" || effect == null || effect == 'undefined') {
            effect = 'slide';
        }
        else {
            effect = effect;
        }
        
        if (position == "" || position == null || position == 'undefined') {
            position = 'top center';
        }
        else {
            position = position;
        }
        
        $(toolTipBox).tooltip({
            tipClass: tipClass,
            effect: effect,
            position: position
        });
    }
    
    // Box Slider ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
    jQuery.referenzen_boxslider = function(el, circ, navi, autoScroll, speed, interval, startIndex, navigatorClass, descriptionDiv){
    
        var elSet;
        
        if (startIndex != 'undefined' && startIndex != null && startIndex != '') {
            startIndex = startIndex;
        }
        else {
            startIndex = 0;
        }
        
        if (interval != 'undefined' && interval != null && interval != '') {
            interval = interval;
        }
        else {
            interval = 1000;
        }
        
        if (speed != 'undefined' && speed != null && speed != '') {
            speed = speed;
        }
        else {
            speed = 500;
        }
        
        if (el != 'undefined' && el != null && el != '') {
            elSet = el;
        }
        else {
            elSet = ".referenzen_boxslider";
        }
        
        if (navi != 'undefined' && navi != null && navi != '') {
            navi = navi;
        }
        else {
            navi = ".wp_box_navigation";
        }
        
        if (autoScroll != 'undefined' && autoScroll != null && autoScroll != '') {
            autoScroll = autoScroll;
        }
        else {
            autoScroll = false;
        }
        
        if (navigatorClass) {
            navigatorClass = navigatorClass;
        }
        else {
            navigatorClass = 'referenzen_boxslider_current';
        }
        var t = null;
        
        if ($(elSet).length > 0) {
            t = $(elSet).scrollable({
                vertical: false,
                speed: speed,
                mousewheel: false,
                next: '.referenzen_boxslider_next',
                prev: '.referenzen_boxslider_prev',
                disabledClass: 'referenzen_boxslider_disabled',
                circular: circ,
                onSeek: function(){
                    activeIndex = this.getIndex() + 1;
                    $.startSlider_referenzen(elSet);
                },
                onBeforeSeek: function(){
                    activeIndex = this.getIndex() + 2 > 6 ? 6 : this.getIndex() + 2;
                    $.startSlider_referenzenBefore(elSet);
                }
            }).navigator({
                navi: navi,
                naviItem: 'a',
                activeClass: navigatorClass,
                history: false,
                autopause: true
            }).autoscroll({
                autoplay: autoScroll,
                interval: interval,
                autopause: true
            });
            
            var api = $(t).data("scrollable");
            api.seekTo(startIndex);
            lastActiveIndexSlider = startIndex;
                             
						// aktueller Index
						api.onSeek( function()  
												{  
							          	/*if(this.getIndex() > 0)
							          		$('#ref-content' + String(this.getIndex()-1)).hide();
							          	*/
							          	
													for (i=0;i<=7;i++)
													{
														$('#ref-content' + String(i)).hide();
													}							          	
													
            							$('#ref-content' + String(this.getIndex())).show();
 							
										      //alert(this.getIndex()); 
										    }) ;

            // nächster Index
						api.onBeforeSeek( function()  {  
										      //alert(this.getIndex()+1); 
										    }) ;
        }
    }
    
    jQuery.wp_menu = function(el, menuType){
        /*
         {
         hoverClass:    'sfHover',
         pathClass:     'overideThisToUse',
         pathLevels:    1,
         delay:         800,
         animation:     {opacity:'show'}, |  animation:   {opacity:'show',height:'show'}
         speed:         'normal',
         autoArrows:    true,
         dropShadows:   true,
         disableHI:     false,
         onInit:        function(){},
         onBeforeShow:  function(){},
         onShow:        function(){},
         onHide:        function(){}
         }
         */
        if (el != 'undefined' && el != null && el != '') {
            elSet = el;
        }
        else {
            elSet = 'ul.sf-menu';
        }
        
        if (menuType != 'undefined' && menuType != null && menuType != '') {
            menuType = 'sf-' + menuType;
        }
        else {
            menuType = '';
        }
        
        $(elSet).addClass(menuType);
        
        $(elSet).superfish({
            animation: {
                height: 'show',
                opacity: 'show'
            },
            delay: 1200
        });
    }
    
    jQuery.wp_apple_overlay = function(el){
        if (el != 'undefined' && el != null && el != '') {
            elSet = el;
        }
        else {
            elSet = '#wp_apple_overlay_triggers img[rel]';
        }
        $(elSet).overlay({
            effect: 'apple'
        });
    }
    
    jQuery.wp_zoom = function(el, sW, sH, lW, lH, frameColor, frameWidth){
        if (el != 'undefined' && el != null && el != '') {
            elSet = el;
        }
        else {
            elSet = '#wp_apple_overlay_triggers img[rel]';
        }
        
        $(elSet).listZoom({
            sW: sW,
            sH: sH,
            lW: lW,
            lH: lH,
            frameColor: frameColor,
            frameWidth: frameWidth,
            loaderContent: 'Bild wird geladen...'
        });
    }
    
    jQuery.wp_accordion_kwick = function(el, maxSizeField, spacing){
    
        if (el != 'undefined' && el != null && el != '') {
            el = el;
        }
        else {
            el = '.wp_accordion_kwick';
        }
        
        if (maxSizeField != 'undefined' && maxSizeField != null && maxSizeField != '') {
            maxSizeField = maxSizeField;
        }
        else {
            maxSizeField = 205;
        }
        
        if (spacing != 'undefined' && spacing != null && spacing != '') {
            spacing = spacing;
        }
        else {
            spacing = 3;
        }
        
        $(el).kwicks({
            max: maxSizeField,
            spacing: spacing,
            isVertical: true
        });
    }
    
    //Slider Special
    var newStart = 0;
    jQuery(document).ready(function(){
		$("#sliderTexte div").hide();
    });
    jQuery.startSlider_referenzenBefore = function(el){
        if ($(el).attr("id") == 'startSlider_referenzen' && newStart >= 2) {
            $("#sliderTexte div").fadeOut("slow");
        }
    }
    
    jQuery.startSlider_referenzen = function(el){
        if ($(el).attr("id") == 'startSlider_referenzen') {
            $("#startbeschreib_" + activeIndex).fadeIn("slow");
        }
        newStart++;
    }
    
})(jQuery);



