
/* Namespace */

web1on1 = new Object();

web1on1.ChatButton = {
	
	/**
	 * Method which initializes the chat button
	 * 
	 * @param {Object} config
	 * @return void
	 */
	init: function(config)
	{
		var divHolder 											= document.createElement('div');
		divHolder.className									= 'cb_online';
		divHolder.style.display							= 'none';
		divHolder.style.position						= 'fixed';
		divHolder.style.right								= '-2px';
		divHolder.style.top									= config.top;		
		divHolder.style.backgroundRepeat 		= 'no-repeat';
		divHolder.style.backgroundColor 		= config.backgroundColor;
		divHolder.style.backgroundImage 		= "url('" + config.backgroundImageUrl + "')";
		divHolder.style.backgroundPosition 	= 'center center';
		divHolder.style.cursor							= 'pointer';
		divHolder.style.width 							= '38px';
		divHolder.style.height 							= '102px';
		
		var div 														= document.createElement('div');
		div.className												= 'cb_chatbutton';
		div.style.margin										= '2px';
		div.style.width 										= '100%';
		div.style.height 										= '96px';
		div.style.border										= '1px solid ' + config.borderColor;		
		divHolder.appendChild(div);
		
		divHolder.onmouseover = function()
		{
			divHolder.style.right = '0';
		};
		
		divHolder.onmouseout = function()
		{
			divHolder.style.right = '-2px';
		};
		
		divHolder.onclick = function()
		{
			
		};
		
		document.body.appendChild(divHolder);
	}
		
};

//
//addLoadEvent()
//Adds event to window.onload without overwriting currently assigned onload functions.
//Function found at Simon Willison's weblog - http://simon.incutio.com/
//
web1on1.AddLoadEvent = function(func)
{	
	var oldonload = window.onload;
	
	if (typeof window.onload != 'function') {
		window.onload = func;
	} else {		
		window.onload = function() 
		{
			oldonload();
			func();
		}
	}
};
	
web1on1.AddLoadEvent(function()
{		
  var chatButton = new web1on1.ChatButton.init(web1on1Config);
});
