var aDOM = 0, ieDOM = 0, nsDOM = 0; var stdDOM = document.getElementById;
if (stdDOM) aDOM = 1; else {ieDOM = document.all; if (ieDOM) aDOM = 1; else {
var nsDOM = ((navigator.appName.indexOf('Netscape') != -1)
&& (parseInt(navigator.appVersion) ==4)); if (nsDOM) aDOM = 1;}}
function xDOM(objectId, wS) {
if (stdDOM) return wS ? document.getElementById(objectId).style:
document.getElementById(objectId);
if (ieDOM) return wS ? document.all[objectId].style: document.all[objectId];
if (nsDOM) return document.layers[objectId];
}
function posLeft() {return typeof window.pageXOffset != 'undefined' ? window.pageXOffset:document.documentElement.scrollLeft? document.documentElement.scrollLeft:document.body.scrollLeft? document.body.scrollLeft:0;}
function posTop() {return typeof window.pageYOffset != 'undefined' ? window.pageYOffset:document.documentElement.scrollTop? document.documentElement.scrollTop: document.body.scrollTop?document.body.scrollTop:0;}
function moveObjTo(objectID,x,y) {var objs = xDOM(objectID,1); objs.right = x; objs.top = y;}

var xxx = 0; var yyy = 100;
var xxx1 = 0; var yyy1 = 0;
var chat_loaded = 0;

function moveit() {
	var x = (posLeft()+xxx) + 'px';
	var y = (posTop()+yyy) + 'px';

//	var divxy = my_getcookie( 'ipb-combochat-div' );
//	yyy1 = int( divxy.substr(divxy.indexOf(',')+1,5));

	var x1 = (posLeft()+xxx1) + 'px';
	var y1 = (posTop()+yyy1) + 'px';

	moveObjTo('chat-bookmark',x,y);
//	moveObjTo('get-chat',x1,y1);
}


//----------------------------------------------------------------------------------
function chat_hide()
{
	timerStop();
	document.getElementById('get-chat').style.display='none';
	document.getElementById('chat-bookmark').style.display='block';
	chat_loaded = 0;
}

function chat_init()
{
	chat_main     = document.getElementById( 'get-chat' );
	chat_drag 	   = document.getElementById( 'chat-drag' );
	chat_bookmark = document.getElementById( 'chat-bookmark' );
	
	
  	chat_main.style.position = 'absolute';
	chat_main.style.display  = 'block';
	chat_main.style.zIndex   = 99;
	chat_bookmark.style.display  = 'none';

	var s = document.getElementById('splitter');
	var l = document.getElementById('leftbar');
	var r = document.getElementById('content');
	hs.init();

	horResize(l,r,s);	

/*	if(window.innerWidth){
	    chat_main.style.position='fixed';
	}	*/

	//----------------------------------
	// Not loaded? INIT
	//----------------------------------
	
	if ( ! chat_loaded )
	{
		
		//----------------------------------
		// Stop IE showing select boxes over
		// floating div [ 2 ]
		//----------------------------------
		
/*		if ( is_ie && document.getElementById('cbc-shim')==null)
		{
			var cbc_content = document.getElementById('bodycontent');
			cbc_content.innerHTML  = "<iframe id='cbc-shim' src='javascript:;' class='ifram3f232' scrolling='no' frameborder='0' style='position:absolute; top:0px; left:0px; display:none;'></iframe>"+cbc_content.innerHTML;

			cbc_shim               = document.getElementById('cbc-shim');
			cbc_shim.style.width   = cbc_content.offsetWidth;
			cbc_shim.style.height  = cbc_content.offsetHeight;
			cbc_shim.style.zIndex  = cbc_content.style.zIndex - 1;
			cbc_shim.style.top     = cbc_content.style.top;
			cbc_shim.style.left    = cbc_content.style.left;
			cbc_shim.style.display = "block";
		}
*/

		//----------------------------------
		// Figure width and height
		//----------------------------------
		
		var my_width  = 0;
		var my_height = 0;
		
		if ( typeof( window.innerWidth ) == 'number' )
		{
			//----------------------------------
			// Non IE
			//----------------------------------
		  
			my_width  = window.innerWidth;
			my_height = window.innerHeight;
		}
		else if ( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) )
		{
			//----------------------------------
			// IE 6+
			//----------------------------------
			
			my_width  = document.documentElement.clientWidth;
			my_height = document.documentElement.clientHeight;
		}
		else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) )
		{
			//----------------------------------
			// Old IE
			//----------------------------------
			
			my_width  = document.body.clientWidth;
			my_height = document.body.clientHeight;
		}
		
		//----------------------------------
		// Get div height && width
		//----------------------------------
		
		var divheight = parseInt( chat_main.style.height );
		var divwidth  = parseInt( chat_main.style.width );

		divheight = divheight ? divheight : 400;
		divwidth  = divwidth  ? divwidth  : 800;
		
		//----------------------------------
		// Got it stored in a cookie?
		//----------------------------------
		
		var divxy = my_getcookie( 'ipb-combochat-div' );
		var co_ords;
		
		if ( divxy && divxy != null )
		{
			co_ords = divxy.split( ',' );
		
			//----------------------------------
			// Got co-ords?
			//----------------------------------
			
			if ( co_ords.length )
			{
				var final_width  = co_ords[0];
				var final_height = co_ords[1];
				
				if ( co_ords[0] > my_width )
				{
					//----------------------------------
					// Keep it on screen
					//----------------------------------
					
					final_width = my_width - divwidth;
				}
				
				if ( co_ords[1] > my_height )
				{
					//----------------------------------
					// Keep it on screen
					//----------------------------------
					
					final_height = my_height - divheight;
				}
				
				chat_main.style.left = final_width  + 'px';
				chat_main.style.top  = final_height + 'px';
			}
		}
		else
		{
			//----------------------------------
			// Reposition DIV roughly centered
			//----------------------------------

			chat_main.style.left = my_width  / 2  - (divwidth / 2)  + 'px';
			chat_main.style.top  = my_height / 2 - (divheight / 2 ) + 'px';
		}
		
		Drag.cookiename = 'ipb-combochat-div';
		Drag.init( chat_drag, chat_main );
		
		setTimeout(chat_hide,autohide*1000);

		chat_loaded = 1;
		doLoad(true);
        timerStart(refresh,true);
//		moveit();

	}
}
