function loadurl(dest,param,type){
	inprogress=true;
	try{
		eval('xmlhttp'+type+' = window.XMLHttpRequest?new XMLHttpRequest(): new ActiveXObject("Microsoft.XMLHTTP");');
		//xmlhttp = window.XMLHttpRequest?new XMLHttpRequest(): new ActiveXObject("Microsoft.XMLHTTP");
	}
	catch(e){
		// browser doesn't support ajax. handle however you want
	}
	switch(type){
		case 'infoFloat':
			eval('xmlhttp'+type+'.onreadystatechange=handleInfoFloat;');
		break;
		case 'chatList':
			eval('xmlhttp'+type+'.onreadystatechange=handleChatList;');
		break;
		case 'fubar':
			eval('xmlhttp'+type+'.onreadystatechange=handleFubar;');
		break;
		case 'keepAlive':
			eval('xmlhttp'+type+'.onreadystatechange=handleKeepalive;');
		break;
	}	
	eval('xmlhttp'+type+'.open("POST",dest,true);');
	eval('xmlhttp'+type+'.setRequestHeader("Content-type", "application/x-www-form-urlencoded")');
	eval('xmlhttp'+type+'.send(param)');
}
function handleChatList(){
	if((xmlhttpchatList.readyState==4)&&(xmlhttpchatList.status==200||xmlhttpchatList.status==304)){
		response=xmlhttpchatList.responseText;
		document.getElementById('chatList').innerHTML=response;
	}
}
function handleInfoFloat(){
	setTimeout('',500);
	if((xmlhttpinfoFloat.readyState==4)&&(xmlhttpinfoFloat.status==200||xmlhttpinfoFloat.status==304)){
		response=xmlhttpinfoFloat.responseText;
		document.getElementById('infoFloat').innerHTML=response;
	}
}
function handleFubar(){
	if((xmlhttpfubar.readyState==4)&&(xmlhttpfubar.status==200||xmlhttpfubar.status==304)){
		response=xmlhttpfubar.responseText;
		document.getElementById('fubarcontainer').innerHTML=response;
		document.getElementById('fubar').style.left='0px';
		document.getElementById('fubar').innerHTML=document.getElementById('fubar').innerHTML+document.getElementById('fubar').innerHTML;
	}
}
function handleKeepalive(){
	if((xmlhttpkeepAlive.readyState==4)&&(xmlhttpkeepAlive.status==200||xmlhttpkeepAlive.status==304)){
		response=xmlhttpkeepAlive.responseText;
		if(response.indexOf("logout")!=-1){
			window.location.href='http://www.nicheflixxx.com/login.php';
		}
		if(response.indexOf("chatrequest")!=-1){
			setSizes();
			chatPopup();
		}
	}
}
function windowSize(){
	if(parseInt(navigator.appVersion)>3){
		if(navigator.appName=="Netscape"||navigator.userAgent.indexOf("opera")==-1){
			winW=window.innerWidth;
			winH=window.innerHeight;
		}
		if(navigator.appName.indexOf("Microsoft")!=-1){
			winW=document.body.offsetWidth;
			winH=document.body.offsetHeight;
		}
	}
	var data=[winW, winH];
	return data;
}
function initPos(){
	if(window.event){
		document.captureEvents(Event.MOUSEMOVE);
	}
	document.onmousemove=getXY;	
}
function getXY(e){
	var is_chrome = navigator.userAgent.toLowerCase().indexOf('chrome') > -1;
	if(!window.event||is_chrome){
		var de = document.documentElement;
		var b = document.body;
		pos[0]=e.clientX+(de.scrollLeft||b.scrollLeft)-(de.clientLeft||0);
		pos[1]=e.clientY+(de.scrollTop||b.scrollTop)-(de.clientTop||0);
	} 
	else{
		if (document.documentElement && !document.documentElement.scrollTop){
			st=0;
			sl=0;
		}
		else if (document.documentElement && document.documentElement.scrollTop){
			st=document.documentElement.scrollTop;
			sl=document.documentElement.scrollLeft;
		}
		else if (document.body && document.body.scrollTop){
			st=document.body.scrollTop;
			sl=document.body.scrollLeft;
		}
		pos[0]=event.clientX+sl;
		pos[1]=event.clientY+st;	
	}
}
var scrollJump=2;
function scrollFubar(){
	if(document.getElementById('fubar')!=null){
		if(fubarstatus=='scroll'){
			var currentpos=(document.getElementById('fubar').style.left==''?'0px':document.getElementById('fubar').style.left);
			var newpos=currentpos.replace('px','')-scrollJump;
			if(newpos==-1520||newpos<-1520)
				newpos=0;
			else if(newpos>0)
				newpos=0;
			document.getElementById('fubar').style.left=newpos+'px';
		}
	}
}
function scrollDir(direction){
	if(direction=='right'){
		scrollJump=-2;
	}
}
function fubarTab(tab){
	for(i=0;i<=5;i++){
		document.getElementById('fubarBtn'+i).className='fubarButtonInactive';
	}
	document.getElementById('fubarBtn'+tab).className='fubarButtonActive';
	loadurl('/fubar.php','type='+tab,'fubar');
}
function actionInfoFloat(action,pid,showimg){
	var infoFloat=document.getElementById('infoFloat');
	switch(action){
		case 'start':
			floatInited='yes';
			posInfoFloat();
			infoFloat.innerHTML='Loading...';
			loadurl('/infoFloat.php','user_id='+pid+(showimg!=false?'&showimg=true':''),'infoFloat');
			infoFloat.style.display='block';
		break;
		case 'stop':
			floatInited='no';
			posInfoFloat();
			infoFloat.style.display='none';
		break;
	}
}
function posInfoFloat(){
	if(floatInited=='yes'){
		size=windowSize();
		if((size[0]-pos[0])<345)
			offset=-325;
		else
			offset=0;
		var infoFloat=document.getElementById('infoFloat');
		infoFloat.style.top=pos[1]+'px';
		infoFloat.style.left=(pos[0]+15+offset)+'px';
	}
}
function cursor(type){
	this.style.cursor=type;
}
function viewProfile(pid){
	window.open='viewProfile.php?user='+pid;
}
function fubarDelete(pid){
	loadurl('/iframeCMD.php','action=fubardelete&id='+pid,false);
	for(i=0;i<=5;i++){
		if(document.getElementById('fubarBtn'+i).className=='fubarButtonActive')
			active=i;
	}
	fubarTab(active);
}