function getUrlVars()
{
    var vars = [], hash;
    var hashes = window.location.href.slice(window.location.href.indexOf('?') + 1).split('&');
    for(var i = 0; i < hashes.length; i++)
    {
        hash = hashes[i].split('=');
        vars.push(hash[0]);
        vars[hash[0]] = hash[1];
    }
    return vars;
}

$.each(jQuery.browser, function(i, val) {
     if ( $.browser.msie ) {
     } else {
         $('*[title]').niceTitles();
     }
});

var $pathname = window.location.pathname;
    /* mobile detection */
    if( navigator.userAgent.match(/Android/i) ||
         navigator.userAgent.match(/webOS/i) ||
         navigator.userAgent.match(/iPhone/i) ||
         navigator.userAgent.match(/iPad/i) ||
         navigator.userAgent.match(/BlackBerry/)
       ){
       if(getUrlVars()["v"]!='Desktop' && $pathname == '/'){
           window.location = 'indexMobile.php';
        }
    }
/* */
function thanksforcontact(oid, city, duration, user, distance, summe) 
{ 
    try
    {           
        var pageTracker = _gat._getTracker('UA-220894-38'); 
        pageTracker._initData(); 
        pageTracker._trackPageview(); 
        pageTracker._addTrans(oid, '0', summe, distance, city, 'DE'); 
        pageTracker._addItem(oid, city, duration, user, summe, '1'); 
        pageTracker._trackTrans(); 
    }  
    catch(err)  
    { 
        var debug = 'debug'; 
    } 
    $('.hideAfterSuccess').hide(); 
} 

function doOutfitToggle()
{
    $('.jqTransformChecked').each(function()
    {
        if ($(this).parent('span').find('input').attr("id")=='ask_outfit_Ja')
        {
            $('.toggle').show();
        }
        if ($(this).parent('span').find('input').attr("id")=='ask_outfit_Nein')
        {
            $('.toggle').hide();
        }
    });
}
function initOverlay(overlayId)
{
    var pathname     = window.location.pathname;
    var checkBackend = pathname.indexOf('backend');
    if(checkBackend == -1 )
    {
        $(overlayId).overlay(
        {
            oneInstance:false,
            expose:{
                color:'#000',
                loadSpeed:200,
                opacity:0.2
            },
            closeOnClick: false,
            onBeforeLoad: function()
            {
                var wrap = this.getOverlay().find(".contentWrap");
                wrap.load(this.getTrigger().attr("href"));
            }
        }
        );
    }
}
function gup(elemId, name, value)
{
    url    = $(elemId).attr('href');
    modact = url.split('?');
    fullUrl= modact[0]+'?';
    params = modact[1];
    params = params.split('&');

    for(var i = 0; i < params.length; i++)
    {
        keyval = params[i].split('=');
        if (keyval[0]==name)
        {
            keyval[1] = encodeURI(value);
        }
        if (i>0)
        {
            fullUrl = fullUrl+'&';
        }
        fullUrl = fullUrl+keyval[0]+'='+keyval[1];
    }
    $(elemId).attr('href', fullUrl);
}

function mbFilterToggle()
{
    $('.cityLableFilterToggle').toggle
    (
        function(){$('#cityFilter').fadeIn();},
        function(){$('#cityFilter').fadeOut();}
    );

    $('.stateLabelFilterToggle').toggle(
        function(){$('#statesFilter').fadeIn();},
        function(){$('#statesFilter').fadeOut();}
    );
}



$(document).ready(function(){
    
function getUrlVars()
{
    var vars = [], hash;
    var hashes = window.location.href.slice(window.location.href.indexOf('?') + 1).split('&');
    for(var i = 0; i < hashes.length; i++)
    {
        hash = hashes[i].split('=');
        vars.push(hash[0]);
        vars[hash[0]] = hash[1];
    }
    return vars;
}


$('.rightColumn>.Escortlist ul').columnize({ columns: 2 });

$.each(jQuery.browser, function(i, val) {
     if ( $.browser.msie ) {
     } else {
         $('*[title]').niceTitles();
     }
});

var $pathname = window.location.pathname;
    /* mobile detection */
    if( navigator.userAgent.match(/Android/i) ||
         navigator.userAgent.match(/webOS/i) ||
         navigator.userAgent.match(/iPhone/i) ||
         navigator.userAgent.match(/iPad/i) ||
         navigator.userAgent.match(/BlackBerry/)
       ){
       if(getUrlVars()["v"]!='Desktop' && $pathname == '/'){
           window.location = 'indexMobile.php/start/241';
        }
    }


var $checkEscort = $pathname.indexOf('195');
var $checkProfil = $pathname.indexOf('profil');

var $teaserImg = $('.HeadlineTeaser .image img').attr('src')

if(!$teaserImg) {
    if($checkEscort < 0 & $checkProfil <0 ) {
        $('#contentHome .blockTop').height(100);
    }
}

    if($checkEscort > 0){
       $('#overlayask').addClass('smallLayer');
    };


    /* citylayer show city */
    $('.Article table#honorarTable').hide();

    /* Honorartabelle */
    
    $('.Article table#honorarTable caption .close').click( function() {
    $('.Article table#honorarTable').hide();
    });

    $('#calculatorContent .bgCity .showTable').click( function() {
    $('.Article table#honorarTable').fadeIn();
    });



    /*Right Click (context menu)*/
    $(document).bind("contextmenu",function(e){
          return false;
     });
 

    /* footer always to the bottom */
    $(function(){
        positionFooter();
        function positionFooter(){
            var padding_top = $("#footer").css("padding-top").replace("px", "");
            var page_height = $(document.body).height() - padding_top;
            var window_height = $(window).height();
            var difference = window_height - page_height;
            if (difference < 0)
                difference = 0;
 
            $("#footer").css({
                padding: difference + "px 0 0 0"
            })
        }
 
        $(window)
        .resize(positionFooter)
    });
	
    /* link Navi */
    $('.linkNavi').insertBefore('.Article');
	
    /* incontent Navi */
    $('.incontentNavi').insertBefore('.contBottom');
	
    $('img.gaeste').click(function(){
        $('.Article .gaeste').fadeIn();
        $('.Article .gaeste').parent('.Article').fadeIn();
		
        $('.Article .philosophie').hide();
        $('.Article .philosophie').parent('.Article').hide();
        $('.Article .MBLadys').hide();
        $('.Article .MBLadys').parent('.Article').hide();
    });
	
    $('img.philosophie').click(function(){
        $('.Article .philosophie').fadeIn();
        $('.Article .philosophie').parent('.Article').fadeIn();
		
        $('.Article .gaeste').hide();
        $('.Article .gaeste').parent('.Article').hide();
        $('.Article .MBLadys').hide();
        $('.Article .MBLadys').parent('.Article').hide();
    });
	
    $('img.mbladies').click(function(){
        $('.Article .MBLadys').fadeIn();
        $('.Article .MBLadys').parent('.Article').fadeIn();
		
        $('.Article .philosophie').hide();
        $('.Article .philosophie').parent('.Article').hide();
        $('.Article .gaeste').hide();
        $('.Article .gaeste').parent('.Article').hide();
    });
	
	
    /* duo profile switch */
    $('.userName2').click(function(){
        $('.user2').addClass('active');
        $('.user1').removeClass('active');
		
        $('.userProfile1').hide();
        $('.userProfile2').fadeIn();
        $('.userName1').addClass('deactive');
        $('.userName2').removeClass('deactive');
		
    });
    $('.userName1').click(function(){
        $('.user1').addClass('active');
        $('.user2').removeClass('active');
		
        $('.userProfile2').hide();
        $('.userProfile1').fadeIn();
        $('.userName2').addClass('deactive');
        $('.userName1').removeClass('deactive');
		
    });
	
    try
    {
        $('.i42BMSpage').css('height',$(window).height() - 70 + 'px');
        setTimeout( "$('form.formbuilder').jqTransform()", 500);
	    
        if($('#Kontaktformular_nationalitaet').html()!='' && $('#Kontaktformular_nationalitaet').html()!=null)
        {
            setTimeout( "changeValOfNationalitaet()", 200 );
        }
        var pathname = window.location.pathname;
        var checkBackend = pathname.indexOf('backend');
		
        if(checkBackend == -1 ){
            $('a img[rel]').overlay({
                oneInstance:false,
                expose:{
                    color:'#000',
                    loadSpeed:200,
                    opacity:0.2
                },
                closeOnClick: false
            });
            $('#form1 .captcha input.captcha').val('');
        }
	
        if($('#form1 .messages').html()!='' && $('#form1 .messages').html()!=null) {
            var messages = $('#form1 .messages').html();
		
            $('#form1 #kontaktform').before('<div class="messages before clearfix">'+messages+'</div>');
		    
            $('#form1 .messages').each(function() {
                if($(this).hasClass('before')) {
                } else {
                    $(this).remove();
                }
            })
        }
        $('#slideshow div.next').animate({
            opacity: 0
        }, 0);
        setInterval( "slideSwitch()", 5000 );
        footerbottom();

        $(window).resize( function() {
            footerbottom();
        })
    }
    catch (e)
    {}
	
	
    /*Scrollable girlfriends*/
    $("#browsable").scrollable({
        history: true,
        circular: true,
        size:5
    }).navigator({history: true});

    // initialize scrollable
    $("#exklusiv").scrollable(
    {
        history: true,
        circular: true,
        size:5
    }
    ).navigator().autoscroll({
        interval: 3000,
        history: true
				
    });
    
    $('#slider').nivoSlider({
        controlNavThumbs:true,
        controlNavThumbsFromRel:true,
		pauseTime: 3000,
		effect: 'fold',
		startSlide:0, //Set starting Slide (0 index)
		slideshowEnd: function(){$('#slider').data('nivo:vars').stop = true},
		directionNav: true
    });
	
	//	Scrolled by user interaction
	$('#thumbsScroll').carouFredSel({
		prev: '#prevThumbs',
		next: '#nextThumbs',
		pagination: "#pager2",
		auto: false
	});
	
	$('#sliderHolder').mouseenter(function() {
		$('#slider .thumbScrollBG').stop(true, true).fadeIn();
		$('.nivo-controlNav').css('visibility','visible');
		$('.nivo-controlNav').css('display','none');
		$('.nivo-controlNav').stop(true, true).fadeIn();
	});
		
	$('#sliderHolder').mouseleave(function() {
		$('#slider .thumbScrollBG').stop(true, true).fadeOut();
		$('.nivo-controlNav').stop(true, true).fadeOut();
    });
	
	$('.nivo-directionNav a').mouseenter(function() {
		$('#slider .thumbScrollBG').stop(true, true).fadeOut();
		$('.nivo-controlNav').stop(true, true).fadeOut();
	});
	$('.nivo-directionNav a').mouseleave(function() {
		$('#slider .thumbScrollBG').stop(true, true).fadeIn();
		$('.nivo-controlNav').stop(true, true).fadeIn();
	});
	
    /*UserProfilShow*/
    $('.UserProfile li a').click(function(){
        if(!$('.UserProfile .contHolder').hasClass('contSetted'))
        {
            $('.UserProfile .contHolder').addClass('contSetted');
            $('.UserProfile .contHolder').css('height', $('.UserProfile .contHolder').attr('clientHeight'));
            $('.UserProfile .contHolder .box_upCont').css('position', 'absolute');
        }
        var butVal = $(this).attr('rel');
    	
        $('.UserProfile .contHolder .box_upCont').animate({
            opacity: 'hide'
        }, 200);
        $('.UserProfile .contHolder .box_' + butVal).animate({
            opacity: 'show'
        }, 200);
        $('.UserProfile li').show();
        $('.UserProfile .but_' + butVal).hide();
    });

    /* Article Comment */
$('.Component.ArticleComment').hide();
$('#commentForm').hide();
    $('.ArticleFeedback li a').click(function(){
        if(!$('.ArticleComment').hasClass('active')){
        $('.Article.Component p, .Article.Component h3:first, .Article.Component table').hide();
        $('.ArticleComment, .ArticleCommentViewer p').show();
        $('.ArticleComment').addClass('active');
        $('.ArticleFeedback li a').text('zurück');
        $('.ArticleFeedback li a').addClass('noBG');
        } else {
        $('.Article.Component p, .Article.Component h3:first').show();
        $('.ArticleComment').hide();
        $('.ArticleComment').removeClass('active');
        $('.ArticleFeedback li a').text('Feedback');
        $('.ArticleFeedback li a').removeClass('noBG');
        }
    });
    $('.newComment').click(function(){
        $('#commentForm').toggle();
    });

    $('.ArticleCommentViewer').prepend($('.ArticleCommentEditor'));

});

/* scrollable fix */
function changeValOfNationalitaet() {
    document.getElementById('Kontaktformular_nationalitaet').selectedIndex = 44;
}
/*slideshow*/
function slideSwitch() {
    var $active = $('#slideshow div.active');

    var $next =  $active.next().length ? $active.next()
    : $('#slideshow div.first');

    $active.animate({
        opacity: 0
    }, 1000, function() {
        $active.removeClass('active');
    });

    $next.animate({
        opacity: 1
    }, 1000, function() {
        $next.addClass('active');
    });
}

function footerbottom() {
    if($('#cmsEditor').length == 0)
    {
        var heightPage = $('#page').attr('clientHeight');
        var heightContent = $('#content').attr('clientHeight');
        var heightHtml = $('html').attr('clientHeight');
        if ( heightPage < heightHtml) {
            $('#content').attr('style','min-height:'+(heightHtml-(heightPage-heightContent+1))+'px');
        }
        else {
            $('#content').removeAttr('style');
            var heightPage = $('#page').attr('clientHeight');
            var heightContent = $('#content').attr('clientHeight');
            var heightHtml = $('html').attr('clientHeight');
            if ( heightPage < heightHtml) {
                $('#content').attr('style','min-height:'+(heightHtml-(heightPage-heightContent+1))+'px');
            }
        }
    }
    else
    {
        var heightPage = $('#page').attr('clientHeight');
        var heightContent = $('#content').attr('clientHeight');
        var heightHtml = ($('html').attr('clientHeight')-70);
        if ( heightPage < heightHtml) {
            $('#content').attr('style','min-height:'+(heightHtml-(heightPage-heightContent+1))+'px');
        }
        else {
            $('#content').removeAttr('style');
            var heightPage = $('#page').attr('clientHeight');
            var heightContent = $('#content').attr('clientHeight');
            var heightHtml = ($('html').attr('clientHeight')-70);
            if ( heightPage < heightHtml) {
                $('#content').attr('style','min-height:'+(heightHtml-(heightPage-heightContent+1))+'px');
            }
        }
    }
}
/****browse button style****/
(function($) {
    
    $.fn.filestyle = function(options) {
                
        /* TODO: This should not override CSS. */
        var settings = {
            width : 250
        };
                
        if(options) {
            $.extend(settings, options);
        };
                        
        return this.each(function() {
            
            var self = this;
            var wrapper = $("<div>")
            .css({
                "width": settings.imagewidth + "px",
                "height": settings.imageheight + "px",
                "background": "url(" + settings.image + ") 0 0 no-repeat",
                "background-position": "right",
                "display": "inline",
                "position": "absolute",
                "overflow": "hidden"
            });
                            
            var filename = $('<input class="file">')
            .addClass($(self).attr("class"))
            .css({
                "display": "inline",
                "width": settings.width + "px"
            });

            $(self).before(filename);
            $(self).wrap(wrapper);

            $(self).css({
                "position": "relative",
                "height": settings.imageheight + "px",
                "width": settings.width + "px",
                "display": "inline",
                "cursor": "pointer",
                "opacity": "0.0"
            });

            if ($.browser.mozilla) {
                if (/Win/.test(navigator.platform)) {
                    $(self).css("margin-left", "-142px");                    
                } else {
                    $(self).css("margin-left", "-168px");                    
                };
            } else {
                $(self).css("margin-left", settings.imagewidth - settings.width + "px");                
            };

            $(self).bind("change", function() {
                filename.val($(self).val());
            });
        });
    };
    
})(jQuery);

// STYLING FILE INPUTS 1.0 | Shaun Inman <http://www.shauninman.com/> | 2007-09-07
if (!window.SI) {
    var SI = {};
};
SI.Files =
{
    htmlClass : 'SI-FILES-STYLIZED',
    fileClass : 'inputUpload',
    wrapClass : 'upload',
    
    fini : false,
    able : false,
    init : function()
    {
        this.fini = true;
        
        var ie = 0 //@cc_on + @_jscript_version
        if (window.opera || (ie && ie < 5.5) || !document.getElementsByTagName) {
            return;
        } // no support for opacity or the DOM
        this.able = true;
        
        var html = document.getElementsByTagName('html')[0];
        html.className += (html.className != '' ? ' ' : '') + this.htmlClass;
    },
    
    stylize : function(elem)
    {
        if (!this.fini) {
            this.init();
        }
        if (!this.able) {
            return;
        }
        
        elem.parentNode.file = elem;
        elem.parentNode.onmousemove = function(e)
        {
            e = e || window.event;
            if (typeof e.pageY == 'undefined' &&  typeof e.clientX == 'number' && document.documentElement)
            {
                e.pageX = e.clientX + document.documentElement.scrollLeft;
                e.pageY = e.clientY + document.documentElement.scrollTop;
            }

            var ox = oy = 0;
            var elem = this;
            if (elem.offsetParent)
            {
                ox = elem.offsetLeft;
                oy = elem.offsetTop;
                while (elem = elem.offsetParent)
                {
                    ox += elem.offsetLeft;
                    oy += elem.offsetTop;
                }
            }

            var x = e.pageX - ox;
            var y = e.pageY - oy;
            var w = this.file.offsetWidth;
            var h = this.file.offsetHeight;

            this.file.style.top     = y - (h / 2)  + 'px';
            this.file.style.left    = x - (w - 30) + 'px';
        };
    },
    
    stylizeById : function(id)
    {
        this.stylize(document.getElementById(id));
    },
    
    stylizeAll : function()
    {
        if (!this.fini) {
            this.init();
        }
        if (!this.able) {
            return;
        }
        
        var inputs = document.getElementsByTagName('input');
        for (var i = 0; i < inputs.length; i++)
        {
            var input = inputs[i];
            if (input.type == 'file' && input.className.indexOf(this.fileClass) != -1 && input.parentNode.className.indexOf(this.wrapClass) != -1)
            {
                this.stylize(input);
            }
        }
    }
};

/* jQuery Tools 1.2.3 Scrollable - New wave UI design
Modified by PawPrint.net to add itemCount, fix circular scrolling, and repair initialIndex in scroller */

(function($) {

    // static constructs
    $.tools = $.tools || {
        version: '1.2.3a'
    };

    $.tools.scrollable = {

        conf: {
            circular: false,
            clonedClass: 'cloned',
            disabledClass: 'disabled',
            easing: 'swing',
            initialIndex: 0,
            item: null,
            items: '.items',
            keyboard: true,
            mousewheel: false,
            next: '.next',
            prev: '.prev',
            speed: 400,
            vertical: false,
            wheelSpeed: 0,
            itemCount: 4
        }
    };

    // get hidden element's width or height even though it's hidden
    function dim(el, key) {
        var v = parseInt(el.css(key), 10);
        if (v) {
            return v;
        }
        var s = el[0].currentStyle;
        return s && s.width && parseInt(s.width, 10);
    }

    function find(root, query) {
        var el = $(query);
        return el.length < 2 ? el : root.parent().find(query);
    }

    var current;

    // constructor
    function Scrollable(root, conf) {

        // current instance
        var self = this,
        fire = root.add(self),
        itemWrap = root.children(),
        index = 0,
        vertical = conf.vertical;

        if (!current) {
            current = self;
        }
        if (itemWrap.length > 1) {
            itemWrap = $(conf.items, root);
        }//WHY WHY WHY???

        // methods
        $.extend(self, {

            getConf: function() {
                return conf;
            },

            getIndex: function() {
                return index;
            },

            getSize: function() {
                return self.getItems().size();
            },

            getNaviButtons: function() {
                return prev.add(next);
            },

            getRoot: function() {
                return root;
            },

            getItemWrap: function() {
                return itemWrap;
            },

            getItems: function() {
                return itemWrap.children(conf.item).not("." + conf.clonedClass);
            },

            move: function(offset, time) {
                if(conf.circular || (index+offset >= 0) && (index+offset <= self.getSize() - conf.itemCount)){
                    return self.seekTo(index + offset, time);
                }else{
                    return self;
                }
            },

            next: function(time) {
                return self.move(1, time);
            },

            prev: function(time) {
                return self.move(-1, time);
            },

            begin: function(time) {
                return self.seekTo(0, time);
            },

            end: function(time) {
                return self.seekTo(self.getSize() - conf.itemCount +1, time);
            },

            focus: function() {
                current = self;
                return self;
            },

            addItem: function(item) {
                item = $(item);

                if (!conf.circular)  {
                    itemWrap.append(item);
                } else {
                    $(".cloned:last").before(item);
                    $(".cloned:first").replaceWith(item.clone().addClass(conf.clonedClass));
                }

                fire.trigger("onAddItem", [item]);
                return self;
            },


            /* all seeking functions depend on this */
            seekTo: function(i, time, fn) {

                // avoid seeking from end clone to the beginning
                if (conf.circular && i === 0 && index == -1 && time !== 0) {
                    return self;
                }

                // check that index is sane
                if (!conf.circular && i < 0 || i > self.getSize() || i < -1) {
                    return self;
                }

                var item = i;

                if (i.jquery) {
                    i = self.getItems().index(i);
                } else {
                    item = self.getItems().eq(i);
                }

                // onBeforeSeek
                var e = $.Event("onBeforeSeek");
                if (!fn) {
                    fire.trigger(e, [i, time]);
                    if (e.isDefaultPrevented() || !item.length) {
                        return self;
                    }
                }

                var props = vertical ? {
                    top: -item.position().top
                } : {
                    left: -item.position().left
                };

                index = i;
                current = self;
                if (time === undefined) {
                    time = conf.speed;
                }

                itemWrap.animate(props, time, conf.easing, fn || function() {
                    fire.trigger("onSeek", [i]);
                });

                return self;
            }

        });

        // callbacks
        $.each(['onBeforeSeek', 'onSeek', 'onAddItem'], function(i, name) {

            // configuration
            if ($.isFunction(conf[name])) {
                $(self).bind(name, conf[name]);
            }

            self[name] = function(fn) {
                $(self).bind(name, fn);
                return self;
            };
        });

        // circular loop
        if (conf.circular) {
            var cloned1 = null,
            cloned2 = null;

            cloned2 = self.getItems().slice(0,(conf.itemCount)).clone().addClass(conf.clonedClass).appendTo(itemWrap);//first [4] at the end
            cloned1 = self.getItems().slice(-1).clone().addClass(conf.clonedClass).prependTo(itemWrap);//last [4] at the start

            self.onBeforeSeek(function(e, i, time) {

                if (e.isDefaultPrevented()) {
                    return;
                }

                /*
					1. animate to the clone without event triggering
					2. seek to correct position with 0 speed
				*/
                if (i == -1) {
                    self.seekTo(cloned1.eq(-1), time, function()  {
                        self.seekTo(self.getSize()-1,0,function(){});
                    });
                    return e.preventDefault();

                } else if (i == self.getSize()) {
                    self.seekTo(cloned2.eq(0), time, function()  {
                        self.begin(0);
                    });
                }

            });

            // seek over the cloned item(s)
            self.seekTo(0, 0);
        }

        // next/prev buttons
        var prev = find(root, conf.prev).click(function() {
            self.prev();
        }),
        next = find(root, conf.next).click(function() {
            self.next();
        });

        if (!conf.circular && self.getSize() > 1) {

            self.onBeforeSeek(function(e, i) {
                window.setTimeout(function() {
                    if (!e.isDefaultPrevented()) {
                        if(self.getSize() <= conf.itemCount){
                            prev.addClass(conf.disabledClass);
                            next.addClass(conf.disabledClass);
                        }else if(!conf.circular){
                            prev.toggleClass(conf.disabledClass, i <= 0);
                            next.toggleClass(conf.disabledClass, i >= self.getSize() - conf.itemCount);
                        }
                    }
                }, 1);
            });
        }

        // mousewheel support
        if (conf.mousewheel && $.fn.mousewheel) {
            root.mousewheel(function(e, delta)  {
                if (conf.mousewheel) {
                    self.move(delta < 0 ? 1 : -1, conf.wheelSpeed || 50);
                    return false;
                }
            });
        }

        if (conf.keyboard)  {
            $(document).bind("keydown.scrollable", function(evt) {
                // skip certain conditions
                if (!conf.keyboard || evt.altKey || evt.ctrlKey || $(evt.target).is(":input")) {
                    return;
                }
                // does this instance have focus?
                if (conf.keyboard != 'static' && current != self) {
                    return;
                }

                var key = evt.keyCode;
                if (vertical && (key == 38 || key == 40)) {
                    self.move(key == 38 ? -1 : 1);
                    return evt.preventDefault();
                }

                if (!vertical && (key == 37 || key == 39)) {
                    self.move(key == 37 ? -1 : 1);
                    return evt.preventDefault();
                }
            });
        }

        // initial index
        setTimeout( function(){
            var vSeekIdx = Math.min(conf.initialIndex, Math.max(0,(self.getSize() - conf.itemCount)));
            self.seekTo(vSeekIdx);
        },conf.speed);
    }

    // jQuery plugin implementation
    $.fn.scrollable = function(conf) {

        // already constructed --> return API
        var el = this.data("scrollable");
        if (el) {
            return el;
        }

        conf = $.extend({}, $.tools.scrollable.conf, conf);

        this.each(function() {
            el = new Scrollable($(this), conf);
            $(this).data("scrollable", el);
        });

        return conf.api ? el: this;

    };
})(jQuery);

