/*
 * chatwindow.js
 * A little chat box slidy kind of thing, the less-annoying version.
 *
 * There is server-side code that works with this to prevent displaying this box on every page.
 *
 * Written by Jeff Parker - jeffreyp(at)codero.com
 *
 * Props to the jQuery community for guidance and support
 *
 * $Id: chatwindow.js 3925 2010-09-10 21:15:29Z tonys $
 */

    function wait4it()
    {
         J('#chat-pop').animate({
                bottom: 0
            }, 2500,function(){
                _gaq.push(['_trackEvent', 'Live Chat', 'Popup Window', 'Displayed',pageviewNum]);
            });
	return false;
    }

    //customer doesn't want to talk - leave the screen quickly!
    function getOuttaHere()
    {
        J('#chat-pop').animate({
                bottom: '-313px'
            }, 500,function(){
                J('#chat-pop').hide();
            });
    }

    //customer ignored this box - leave slowly, as if sulking, and go to the land of abandoned chat-boxes (offscreen)
    function getOuttaHereKindaSlow()
    {
        J('#chat-pop').animate({
                bottom: '-313px'
            }, 3000,function(){
                _gaq.push(['_trackEvent', 'Live Chat', 'Popup Window', 'Auto Hide Event',pageviewNum]);
                J('#chat-pop').hide();
            });
    }
    
J(document).ready(function()
    {
        //play initial animation
        setTimeout("wait4it()",5000);

        //give peeps 30 seconds to respond or go away
        setTimeout("getOuttaHereKindaSlow()",30000);

        //nobody wants to chat :(
        J('.bye').click(function()
	{
            if(J(this).hasClass('chat-close')){
                _gaq.push(['_trackEvent', 'Live Chat', 'Popup Window', 'Close X Button',pageviewNum]);
            }else{
            _gaq.push(['_trackEvent', 'Live Chat', 'Popup Window', 'No Thanks Button',pageviewNum]);
            }

            getOuttaHere();
	    return false;
	});

         //a great success. someone wants to talk to us :)
        J('.hi').click(function()
	{
            popitup2('http://pgdigital.com.br/praiaecia/chat.php');
            _gaq.push(['_trackEvent', 'Live Chat', 'Popup Window', 'Chat Now Button',pageviewNum]);
            getOuttaHere();
	    return false;
	});
	return false;
    });

