$(function () {
    $('#testimonialslist').cycle({fx: 'scrollUp', delay: 3000});
    $('.pics').cycle({ 
        fx:     'fade', 
        timeout: 2000, 
        pager:  '#image-nav' 
        });
        
    $("#clientarea").hover(function() {
        $(this).css('zIndex', 2);
        $(this).stop().animate({ top: '0px'}, 'slow', 'easeOutQuad');
    }, function() {
        $(this).stop().animate({ top: '-66px'}, 'fast', 'easeOutQuad', function() {
            $(this).css('zIndex', 0);
        });
    });
    $("#clientarea2").hover(function() {
        $(this).stop().animate({ top: '0px'}, 'slow', 'easeOutQuad');
    }, function() {
        $(this).stop().animate({ top: '-66px'}, 'fast', 'easeOutQuad');
    });
    $("ul#pricefaq li.rounded").hover(function() {$(this).animate({ backgroundColor: "#ddd" }, 600);},function() {$(this).animate({ backgroundColor: "#fff" }, 400);});
    $("div#tweet p").hover(function() {$(this).animate({ backgroundColor: "#999" }, 600);},function() {$(this).animate({ backgroundColor: "#474747" }, 400);});
    
    jQuery.fn.isChildOf = function(b){
        return (this.parents(b).length > 0);
    };
    
    $('#dialog_link').click(function() {
        $('#language-currency').toggle();
        var bodyClick = function(e) {
            if (!$(e.target).isChildOf('.languages_box')) {
                $('#language-currency').hide();
                $('body').unbind('click', bodyClick);
            }
        };
        $('body').bind('click', bodyClick);
    }).hover(function() {
        $(this).addClass("ui-state-hover");
    }, function() {
        $(this).removeClass("ui-state-hover");
    }).mousedown(function(){
        $(this).addClass("ui-state-active");
    }).mouseup(function(){
        $(this).removeClass("ui-state-active");
    });
    
    new function($) {
      $.fn.setSelectionRange = function(start, end) {
        if ($(this).get(0).setSelectionRange) {
          $(this).get(0).setSelectionRange(start, end);
        } else if ($(this).get(0).createTextRange) {
          var range = $(this).get(0).createTextRange();
          range.collapse(true);
          range.moveEnd('character', end);
          range.moveStart('character', start);
          range.select();
        }
      }
    }(jQuery);
});
