/*-CUSTOM JQUERY----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------*/
/*-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------*/
/*-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------*/


/*-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------*/
/*-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------*/
/*-CAROUSEL LITE----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------*/


(function(jQuery) {                                          // Compliant with jquery.noConflict()
jQuery.fn.jCarouselLite = function(o) {
    o = jQuery.extend({
        btnPrev: null,
        btnNext: null,
        btnGo: null,
        mouseWheel: false,
        auto: null,
        hoverPause: false,

        speed: 200,
        easing: null,

        vertical: false,
        circular: true,
        visible: 3,
        start: 0,
        scroll: 1,

        beforeStart: null,
        afterEnd: null
    }, o || {});

    return this.each(function() {                           // Returns the element collection. Chainable.

        var running = false, animCss=o.vertical?"top":"left", sizeCss=o.vertical?"height":"width";
        var div = jQuery(this), ul = jQuery("ul", div), tLi = jQuery("li", ul), tl = tLi.size(), v = o.visible;

        if(o.circular) {
            ul.prepend(tLi.slice(tl-v+1).clone()) // add last visible part, to the begin of the ul
              .append(tLi.slice(0,o.scroll).clone());  // add first visble part, to the end of the ul
            o.start += v-1; //the script added an item at the front, move the start position with one part
        }

        var li = jQuery("li", ul), itemLength = li.size(), curr = o.start;
        div.css("visibility", "visible");

        li.css({overflow: "hidden", float: o.vertical ? "none" : "left"});
        ul.css({margin: "0", padding: "0", position: "relative", "list-style-type": "none", "z-index": "1"});
        div.css({overflow: "hidden", position: "relative", "z-index": "2", left: "0px"});

        var liSize = o.vertical ? height(li) : width(li);   // Full li size(incl margin)-Used for animation
        var ulSize = liSize * itemLength;                   // size of full ul(total length, not just for the visible items)
        var divSize = liSize * v;                           // size of entire div(total length for just the visible items)

        li.css({width: li.width(), height: li.height()});
        ul.css(sizeCss, ulSize+"px").css(animCss, -(curr*liSize));

        div.css(sizeCss, divSize+"px");                     // Width of the DIV. length of visible images

        if(o.btnPrev) {
            jQuery(o.btnPrev).click(function() {
                return go(curr-o.scroll);
            });
            //not needed (scriptbreaker)
            /*
            if(o.hoverPause) {
                jQuery(o.btnPrev).hover(function(){stopAuto();}, function(){startAuto();});
            }
            */
        }


        if(o.btnNext) {
            jQuery(o.btnNext).click(function() {
                return go(curr+o.scroll);
            });
            //not needed (scriptbreaker)
            /*
            if(o.hoverPause) {
                jQuery(o.btnNext).hover(function(){stopAuto();}, function(){startAuto();});
            }
            */
        }

        if(o.btnGo)
            jQuery.each(o.btnGo, function(i, val) {
                jQuery(val).click(function() {
                	//added by the scriptbreaker extension
                	return go(o.circular ? (o.visible+i-1) : i);

                	//why is that?
                	//return go(o.circular ? o.visible+i : i);
                });
            });

        if(o.mouseWheel && div.mousewheel)
            div.mousewheel(function(e, d) {
                return d>0 ? go(curr-o.scroll) : go(curr+o.scroll);
            });

        var autoInterval;

        function startAuto() {
          stopAuto();
          autoInterval = setInterval(function() {
                  go(curr+o.scroll);
              }, o.auto+o.speed);
        };

        function stopAuto() {
            clearInterval(autoInterval);
        };

        if(o.auto) {
            if(o.hoverPause) {
            	//scriptbreaker extention add the hover pause to the children instead of the element itself
                div.children().hover(function(){stopAuto();}, function(){startAuto();});
            }
            startAuto();
        };

        function vis() {
            return li.slice(curr).slice(0,v);
        };

        function go(to) {
            if(!running) {

                if(o.beforeStart)
                    o.beforeStart.call(this, vis());

                if(o.circular) {            // If circular we are in first or last, then goto the other end
                    if(to<0) {           // If before range, then go around
                        ul.css(animCss, -( (curr + tl) * liSize)+"px");
                        curr = to + tl;
                    } else if(to>itemLength-v) { // If beyond range, then come around
                        ul.css(animCss, -( (curr - tl) * liSize ) + "px" );
                        curr = to - tl;
                    } else curr = to;
                } else {                    // If non-circular and to points to first or last, we just return.
                    if(to<0 || to>itemLength-v) return;
                    else curr = to;
                }                           // If neither overrides it, the curr will still be "to" and we can proceed.

                running = true;

                ul.animate(
                    animCss == "left" ? { left: -(curr*liSize) } : { top: -(curr*liSize) } , o.speed, o.easing,
                    function() {
                        if(o.afterEnd)
                            o.afterEnd.call(this, vis(), curr, o.btnGo);
                        running = false;
                    }
                );
                // Disable buttons when the carousel reaches the last/first, and enable when not
                if(!o.circular) {
                    jQuery(o.btnPrev + "," + o.btnNext).removeClass("disabled");
                    jQuery( (curr-o.scroll<0 && o.btnPrev)
                        ||
                       (curr+o.scroll > itemLength-v && o.btnNext)
                        ||
                       []
                     ).addClass("disabled");
                }

            }
            return false;
        };
    });
};

function css(el, prop) {
    return parseInt(jQuery.css(el[0], prop)) || 0;
};
function width(el) {
    return  el[0].offsetWidth + css(el, 'marginLeft') + css(el, 'marginRight');
};
function height(el) {
    return el[0].offsetHeight + css(el, 'marginTop') + css(el, 'marginBottom');
};

})(jQuery);


/*-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------*/
/*-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------*/
/*-SCROLL TOP----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------*/


	function scrollToTop(){jQuery(document).everyTime(5, "scroller-top", function(){
			if(window.pageYOffset)
			var speed = -1*(2 + window.pageYOffset / 30);
		else
			var speed = -1*(2 + document.documentElement.scrollTop / 30);
			window.scrollBy(0,speed);
			if(window.pageYOffset){
			   if(window.pageYOffset<=3) {
				window.scrollTo(0,0);
				jQuery(document).stopTime("scroller-top");
			}
			} else

			   if(document.documentElement.scrollTop<=3) {
				window.scrollTo(0,0);
				jQuery(document).stopTime("scroller-top");
			}
		});
		return false;
	}

	jQuery(document).ready(function(){
		jQuery('a.scroll-top').click(function(){
            scrollToTop();
        });
	});



/*-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------*/
/*-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------*/
/*-Table Search----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------*/



(function($, window, document, undefined) {
    $.fn.quicksearch = function (target, opt) {

        var timeout, cache, rowcache, jq_results, val = '', e = this, options = $.extend({
            delay: 100,
            selector: null,
            stripeRows: null,
            loader: null,
            noResults: '',
            bind: 'keyup',
            onBefore: function () {
                return;
            },
            onAfter: function (_query) {
                var specTableHeader = jQuery('table.spec-table thead.table-header').first(); 
                if(specTableHeader.length){
                    var headers = specTableHeader.nextAll('thead');
                    var _q = _query.join(' ');
                    headers.each(function(){
                        var thisheader = jQuery(this);
                        var thisheadertxt = thisheader.find('td').first().html();
                        var thisbody = thisheader.next();
                        var rows = thisbody.children();
                        var rowscnt = rows.length;
                        var cnt = 0;
                        
                        var queryOK = false;
                        if(thisheadertxt.toLowerCase().indexOf(_q) != -1) queryOK = true;
                        if(_q.length < 1) queryOK = false;
                        
                        if(queryOK == false) {
                            rows.each(function(){
                                if(jQuery(this).css('display') == 'none')
                                    cnt++;
                            });
                            if(cnt == rowscnt) {
                                jQuery(this).css('display','none');
                            } else {
                                jQuery(this).css('display','');
                            }
                        } else {
                            thisheader.css('display','');
                            _rows = jQuery(this).next().children();
                            _rows.each(function(){
                                if(jQuery(this).css('display') == 'none') jQuery(this).css('display', '');
                            });
                        }
                            
                        
                       
                            
                    });
                }
                return;
            },
            show: function () {
                this.style.display = "";
            },
            hide: function () {
                this.style.display = "none";
            },
            prepareQuery: function (val) {
                return val.toLowerCase().split(' ');
            },
            testQuery: function (query, txt, _row) {
                for (var i = 0; i < query.length; i += 1) {
                    if (txt.indexOf(query[i]) === -1) {
                        return false;
                    }
                }
                return true;
            }
        }, opt);

        this.go = function () {

            var i = 0,
            noresults = true,
            query = options.prepareQuery(val),
            val_empty = (val.replace(' ', '').length === 0);

            for (var i = 0, len = rowcache.length; i < len; i++) {
                if (val_empty || options.testQuery(query, cache[i], rowcache[i])) {
                    options.show.apply(rowcache[i]);
                    noresults = false;
                } else {
                    options.hide.apply(rowcache[i]);
                }
            }

            if (noresults) {
                this.results(false);
            } else {
                this.results(true);
                this.stripe();
            }

            this.loader(false);
            options.onAfter(query);

            return this;
        };

        this.stripe = function () {

            if (typeof options.stripeRows === "object" && options.stripeRows !== null)
            {
                var joined = options.stripeRows.join(' ');
                var stripeRows_length = options.stripeRows.length;

                jq_results.not(':hidden').each(function (i) {
                    $(this).removeClass(joined).addClass(options.stripeRows[i % stripeRows_length]);
                });
            }

            return this;
        };

        this.strip_html = function (input) {
            var output = input.replace(new RegExp('<[^<]+\>', 'g'), "");
            output = $.trim(output.toLowerCase());
            return output;
        };

        this.results = function (bool) {
            if (typeof options.noResults === "string" && options.noResults !== "") {
                if (bool) {
                    $(options.noResults).hide();
                } else {
                    $(options.noResults).show();
                }
            }
            return this;
        };

        this.loader = function (bool) {
            if (typeof options.loader === "string" && options.loader !== "") {
                (bool) ? $(options.loader).show() : $(options.loader).hide();
            }
            return this;
        };

        this.cache = function () {

            jq_results = $(target);

            if (typeof options.noResults === "string" && options.noResults !== "") {
                jq_results = jq_results.not(options.noResults);
            }

            var t = (typeof options.selector === "string") ? jq_results.find(options.selector) : $(target).not(options.noResults);
            cache = t.map(function () {
                return e.strip_html(this.innerHTML);
            });

            rowcache = jq_results.map(function () {
                return this;
            });

            return this.go();
        };

        this.trigger = function () {
            this.loader(true);
            options.onBefore();

            window.clearTimeout(timeout);
            timeout = window.setTimeout(function () {
                e.go();
            }, options.delay);

            return this;
        };

        this.cache();
        this.results(true);
        this.stripe();
        this.loader(false);

        return this.each(function () {
            $(this).bind(options.bind, function () {
                val = $(this).val();
                e.trigger();
            });
        });

    };

}(jQuery, this, document));
/*-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------*/
/*-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------*/
/*-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------*/



/*-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------*/
/*-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------*/
/*-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------*/

