var cs_finish_A = 0;
function chatAvailable(){
    var img = $('<img>').attr('src', '/sf/v3/images/chatslider/available.gif');
    var div = $('<div>').css('cursor', 'pointer').click(function() {
        var href = 'https://chat2.livechatinc.com/licence/1082504/open_chat.cgi?lang=es&amp;groups=0';
        var caracteristicas = "height=520,width=530,scrollTo,resizable=0,scrollbars=1,location=0";  
        window.open(href, 'Chat', caracteristicas);  
    });
    div.append(img);
    $('#chatslider-smartbutton').append(div);
    $('#callslider').click(function() {
        var href = 'call.jsp';
        var caracteristicas = "width=236,height=220,resizable=no,toolbar=no,menubar=no,location=no,status=no";
        window.open(href, 'Llamada a Soluci\u00f3n Factible', caracteristicas);
    })
    return true;
}
function slider() {
    var cs_animation=1;
    var cs_move=$('#chatslider-smartbutton').width();
    if($('div').hasClass('slider')){
        var cs_start=$('.slider').css("marginLeft").replace('px','');
        var cs_finish=cs_start+cs_move;
    }
    $('.slider').mouseenter(function(){
        if($(this).css("marginLeft").replace('px','')==cs_start){
            $(this).animate({
                marginLeft:"+="+cs_move
            },cs_animation*1000,function(){
                cs_finish_A=$(this).css("marginLeft").replace('px','')
            });
            $(this).resume("mouseover_timer");
        }
    });
    $('.slider').click(function(){
        if($(this).css("marginLeft").replace('px','')==cs_finish_A){
            $(this).animate({
                marginLeft:"-="+cs_move
            },cs_animation*1000,function(){
                cs_start=$(this).css("marginLeft").replace('px','')
            });
            $(this).resume("mouseover_timer");
            $(this).resume("mouseleave_timer");
        }
    });
    $('.slider').mouseleave(function(){
        if($(this).css("marginLeft").replace('px','')==cs_finish_A){
            $(this).suspend(2000,"mouseleave_timer").click();
        }
    });
}
(function(){function h(c){if(c.suspended_originalMethod)return h(c.suspended_originalMethod);return c}var d={};$.suspend=$.fn.suspend=function(c,a){var b=this,e;if(!b.suspended_timers)b.suspended_timers=[];for(e in b)typeof b[e]==="function"&&e!=="suspend"&&e!=="resume"&&function(f){var g=b[f];b[f]=function(){var i=arguments;b.suspended_timers[b.suspended_timers.length]=setTimeout(function(){g.apply(b,i);g=undefined},c);if(a){d[a]=d[a]||[];d[a][d[a].length]=b.suspended_timers[b.suspended_timers.length-1]}return b};b[f].suspended_originalMethod=g}(e);setTimeout(function(){b.resume()},0);return b};$.resume=$.fn.resume=function(c){var a;if(typeof c==="string"&&d[c]&&d[c].length){for(a in d[c])clearTimeout(d[c][a]);d[c]=[];return this}for(a in this)if(typeof this[a]==="function")if(this[a].suspended_originalMethod)this[a]=h(this[a]);if(c&&this.suspended_timers&&this.suspended_timers instanceof Array){for(a in this.suspended_timers)clearTimeout(this.suspended_timers[a]);this.suspended_timers=[]}return this}})();
$(function() {
    chatAvailable();
    slider();
});

