// JS Magic! //

$(document).ready(function () {
  // Set up the live person listener
   inviteTimer = setInterval ( "checkInvite()", 5000 );

  // Cufon the Type
  Cufon.set('fontFamily', 'ITC Kabel');
  Cufon.replace('h1', {
    textShadow: '#333 1px 1px'
  });
  Cufon.replace('h2,h3,.button,.read_more_header');
  //launch modal popup window based on the href
  $('a[rel=photo_modal]').click(function () {
    new Boxy("<img src='" + $(this).attr("href") + "' width='640px' height ='480px'/>", {
      modal: true
    });
    return false;
  });
  // IF JS is Enabled (most cases) Initiate the Read More
  $("#read_more_text").hide();
  $(".read_more_header").css("cursor", "pointer");
  // Toggle Function for the Read More
  $(".read_more_header").toggle(

  function () {
    $("#read_more_text").slideDown("fast");
  }, function () {
    $("#read_more_text").slideUp("fast");
  });
  
  // hide the live chat of a button
  $('#live_chat_close').live('click', function() {
  hideChatAlert();
});

  $('#live_chat_accept').live('click', function() {
  hideChatAlert();
eval(lpAccept);
});
});

var lpAccept;
var lpReject;

function showChatAlert() {
  // show live chat
  $('body').prepend("<div id='live_chat'><div id='live_chat_container'><h1>Instant Help</h1><p>Chat live with one of our Poker representatives and we'll be happy to help you.</p><a href='#' id='live_chat_accept''>Chat Now</a></div><div id='live_chat_close'>close</div></div>");

 lpAccept = $('.chatInvite').attr('ia');
 lpReject = $('.chatInvite').attr('ir');

lpAccept=lpAccept.replace(' return false;','');

	//$('#live_chat_accept').attr('onClick', lpAccept);
	//$('#live_chat_close').attr('onClick', lpReject);

$('#live_chat').slideDown();

}

function hideChatAlert() {
  // hide live chat
  $('#live_chat').slideUp(function () {
    $(this).remove();
  });

}

function checkInvite ( )
{
	//alert('checking');
  if ($('.chatInvite').length)
  	{
           showChatAlert();
	  clearInterval(inviteTimer);
    }
    else
    {
     // alert('not found');
	}
}

