/*
dbButtons Object
(
    [id] => 283
    [siteid] => 1
    [nickname] => PWC-CTC Float
    [operator_name] => Jessica
    [online_message] => Hello, please enter your name and phone number and someone will call you back as quickly as possible
    [branding_image] => 
    [rb_pos] => normal
    [rb_type] => call
    [imagefile] => /icons/call-back-butto_1285367258.gif
    [anchor_items] => Array
        (
            [0] => tl
            [1] => tr
            [2] => br
            [3] => bl
        )

    [anchor] => 
    [offsetx] => 
    [offsety] => 
    [pushChatimg] => 
    [pushBox_time] => 0
)

*/
// <Script>

//|
//|  Insert Mootools into the mix
//|


var jsQueue = document.createElement("script");
jsQueue.language = "Javascript";
jsQueue.type = "text/javascript";
jsQueue.src = "http://pwcagent.com/Livechat/js/message_queue.js?v=1";

var jsGeo = document.createElement("script");
jsGeo.language = "Javascript";
jsGeo.type = "text/javascript";
jsGeo.src = "http://j.maxmind.com/app/geoip.js";

var durationCount = 0;
var myWidth = 0, myHeight = 0;
var imgWidth = 130, imgHeight = 60;

setTimeout('appendScript_283(283);', 300);

function appendScript_283(btnID)
{
	var chatID = btnID;
	if (document.getElementsByTagName('body') == null)
	{
		setTimeout('appendScript_283('+chatID+');', 100);
		return;
	}

	document.getElementsByTagName('body')[0].appendChild(jsGeo);		
	document.getElementsByTagName('body')[0].appendChild(jsQueue);	
	
	//|  mootools is now loaded	
	setTimeout('loadChatSystem_283('+chatID+');', 100);
}


function livechat_getsizes_283()
{
	
	if ( typeof( window.innerWidth ) == 'number' ) 
	{
		myWidth = window.innerWidth;
		myHeight = window.innerHeight;
	} else if ( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
		//IE 6+ in 'standards compliant mode'
		myWidth = document.documentElement.clientWidth;
		myHeight = document.documentElement.clientHeight;
	} else if ( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
		//IE 4 compatible
		myWidth = document.body.clientWidth;
		myHeight = document.body.clientHeight;
	}
}

function livechat_getstyle_283()
{
	var style = "position: absolute; position: fixed;"

	var dx, dy;
	var anchor = '';
	var offsetx = '';
	var offsety = '';

	if ((anchor == 'tl') || (anchor == ""))
	{
		dx = 0;
		dy = 0;
		if(offsetx != '' && offsety != '')
		{
			style += "left:" + offsetx + "px; top:" + offsety + "px;";	
		}	
		else
		{
			style += "left:0px; top:0px;";
			return style; 	 
		}	
	} else 
	if (anchor == 'tr')
	{
		dx = myWidth - imgWidth;
		dy = 0;
		
		if(offsetx != '' && offsety != '')
			style += "right:" + offsetx + "px; top:" + offsety + "px;";	
		else
			style += "right:" + imgWidth + "px; top:0px;";
	} else
	if (anchor == 'br')
	{
		dx = myWidth - imgWidth;
		dy = myHeight - imgHeight;
		if(offsetx != '' && offsety != '')
			style += "right:" + offsetx + "px; bottom:" + offsety + "px;";	
		else
			style += "right:" + imgWidth + "px; bottom:" + imgHeight + "px;";
	} else 
	{
		dx = 0;
		dy = myHeight - imgHeight;
		if(offsetx != '' && offsety != '')
			style += "left:" + offsetx + "px; bottom:" + offsety + "px;";	
		else
			style += "bottom:" + imgHeight + "px;";
	}
	return style;
}

function livechat_link_283(refHtml)
{
	var str = "<a href='javascript:void(0);' onClick='livechat_open_window_283();'>";
	str += refHtml;
	str += "</a>";
		return str;
}

function livechat_open_window_283()
{
	window.open("http://pwcagent.com/Livechat/OpenChat.php?buttonid=283", "livechat",
		"status=0,toolbar=0,width=650,height=540,resizable=0,menubar=0,scrollbars=yes");
}

function loadChatSystem_283(chatID)
{	
	
	var divID = chatID;

	if (typeof(mq_init) != "function")
	{
		setTimeout('loadChatSystem_283('+divID+');', 250);		
		return;
	}

	mq_init(1);
		
	mq_register_command("chat", function(data) {
	});
	
	mq_register_command("join", function(data) {		
	});		
	
	mq_register_command("push", function(data) {		
	});

	sendTracingRequest_283();
	setInterval('sendTracingRequest_283();', 10000);
	//setTimeout('showBox_283();', 1000);

		

	
				//|
		//|  Normally positioned button
			
			var jsTracker 	= document.createElement("div");
			jsTracker.id 	= 'livechat_click_'+divID;
			
			jsTracker.innerHTML = livechat_link_283("<img src='http://pwcagent.com/Livechat/icons/call-back-butto_1285367258.gif' border='0' alt='live chat' title='Live Chat' />");
			document.getElementsByTagName('body')[0].appendChild(jsTracker);
			jsTracker.style.cssText = livechat_getstyle_283();	



			//var txt = 'Kilroy was here.';
//			var newT = document.createTextNode(str1);
//			document.getElementsByTagName('body')[0].appendChild(newT);
			
			
			   var cssNode = document.createElement('link');
			   cssNode.rel = 'stylesheet';
			   cssNode.type = 'text/css';
			   cssNode.href = 'http://pwcagent.com/Livechat/css/thickbox.css';
			   cssNode.media = 'screen';
			   document.getElementsByTagName('body')[0].appendChild(cssNode);
			
   		       var script = document.createElement('script');
			   script.id = 'uploadScript';
			   script.type = 'text/javascript';
			   script.src = "http://pwcagent.com/Livechat/js/jquery.js";
			   document.getElementsByTagName('body')[0].appendChild(script);
			  
			   var script1 = document.createElement('script');
			   script1.id = 'uploadScript';
			   script1.type = 'text/javascript';
			   script1.src = "http://pwcagent.com/Livechat/js/thickbox.js";
			   document.getElementsByTagName('body')[0].appendChild(script1);


			//document.getElementsByTagName('body').onload=showBox_283();
		} 


function sendTracingRequest_283()
{
	durationCount += 1;
	message_queue_poll_data = mq_send("join", { nickname: 'PWC-CTC Float', username: 'visitor', url: document.URL, duration: durationCount});	
}

function openPopup_283()
{
		window.open('http://pwcagent.com/Livechat/popUp.php?buttonid=283','name','height=200,width=450,status=yes,resizable=yes');
	}

function showBox_283()
{
	var a = document.getElementById('link');
	var t = a.title || a.name || null;
	var l = a.href || a.alt;
	var g = a.rel || false;
	tb_show(t,l,g);
}
