function invite() {
    $('#chatInvite').slideDown(250, function(){
        $('#questionCloud').animate({
            top: '-54px'
        }, 250)
    })
}

function scrollTo(elem) {
    target = $(elem);
    $('html,body').animate({
        scrollTop: target.offset().top
    }, 800);
}

var decline_cookie = function(c_name, c_value, d_expire) {
    var exdate=new Date();
    exdate.setDate(exdate.getDate() + d_expire);
    document.cookie = c_name+ "=" + escape(c_value) +
    ((d_expire == null) ? "" : ";expires="+exdate.toGMTString()) +
    ';path = /';

}

$(function(){
    
		
    if ($.browser.msie && $.browser.version.substr(0,1)<7) {
        DD_belatedPNG.fix('.png');
    }
		
		
    $('#liveChat_btn, .link_liveChat, .liveChat_link').click(function(){
        window.open('/inc/common/liveChat_tracker.php?referrer='+escape(document.location), 'chat69971338', 'width=472, height=320, resizable=yes, scrollbar=yes');
        cmCreatePageviewTag("Live Chat Initiated", "Live Chat", null, null);
        return false;
    });

    $('#liveCall_btn, .link_liveCall, .liveCall_link').click(function(){
        window.open('/inc/common/liveCall_tracker.php?referrer='+escape(document.location), 'chat69971338', 'width=472, height=320, resizable=yes, scrollbar=yes');
        cmCreatePageviewTag("Live Call Initiated", "Live Call", null, null);
        return false;
    });

    // Overlays
		$('.overlay').fancybox({
				transitionIn:'none',
				transitionOut: 'none',
				overlayOpacity: '.7',
				overlayColor: '#000',
				enableEscapeButton: true,
				padding: 20
		});
			
    // Smooth Scrolling to Anchors
    $('.scrollMe').bind('click', function() {
        scrollTo($(this).attr('href'));
        return false;
    });

    // hide google conversion frame
    $('iframe[name="google_conversion_frame"]').css('display', 'none');

    // custom chat slider

    setTimeout("invite()", 5000);
    $('#inviteClose').bind('click', function(){
        $('#chatInvite').slideUp(500, function(){
            var cookieName = 'chatDecline';
            var cookieOptions = {
                path: '/',
                expires: null
            }
            new decline_cookie(cookieName,'declined', cookieOptions);
        });
    });

});





