chat_post=''; play_vdo=0;  chat_count=0; chat_lid=-1; chat_onl=0; d_opa=0; d_obj=false; lockscr=0; msie=0;

if(typeof window.external=='object' && typeof document.all=='object'){
msie=1; iev=navigator.userAgent;iev=iev.split('MSIE');iev=parseInt(iev[1]);if(iev<7){
document.write('<link rel="stylesheet" type="text/css" href="'+skin_dir+'/msie.css" />');}}


function opa_go(a){
d_obj.style.filter='alpha(opacity='+d_opa+')';
j=d_opa/100;d_obj.style.opacity=j;
if(a>0){d_opa+=5;
if(d_opa>100){clearInterval(d_int);d_opa=100}}
else{d_opa-=5;
if(d_opa<1){clearInterval(d_int);d_obj.style.display='none';d_opa=0}
}}


function opa_st(a,b){
if((d_opa==100 || d_opa==0) && veffects==1){
d_obj=a; if(b>0){
a.style.opacity=0;
a.style.filter='alpha(opacity=0)';
a.style.display='block';
d_opa=0;d_int=setInterval('opa_go(1)',10);}
else{d_opa=100;d_int=setInterval('opa_go(0)',10);}
}else{
if(b>0){a.style.display='block';}else{a.style.display='none';}
}}


function set_ie6size(){
z=document.body.clientHeight
if(msie>0 && iev<7){
h=z-msie_factor;document.getElementById('mda').style.height=h+'px'}}


function http_obj(){
if(msie>0){
r=new ActiveXObject("Microsoft.XMLHTTP")}
else{r=new XMLHttpRequest()}return r}


function onlist_recev(){
chat_count+=1;
htto=http_obj();s='ajx_sett='+ajx_sett+'&l='+chat_lid+'&c='+chat_count+'&o='+chat_onl;
if(chat_post.length>0){
amp=/&/g;chat_post=chat_post.replace(amp,'%26');
pl=/\+/g;chat_post=chat_post.replace(pl,'%2B');
s=s+'&p='+chat_post;chat_post='';}
htto.open('post','ucp_aj.php');
htto.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
htto.onreadystatechange=onlist_print;htto.send(s);}


function onlist_print(){
if(htto.readyState==4){
document.getElementById('mda').style.backgroundImage='none';
response=htto.responseText.toString();
response=response.split('|:|');
if(response.length>4){
response[1]=parseInt(response[1]);
response[2]=parseInt(response[2]);
response[3]=parseInt(response[3]);
if(document.getElementById('chats')){
rch=parseInt(document.getElementById('chats').innerHTML);
document.getElementById('chats').innerHTML=response[1];
if(response[1]>rch){document.getElementById('chats').style.color=ch_color;
document.getElementById('fpls').innerHTML=flsh_cht;}}
if(tbl_print==1 &&  tbl_add==0){document.getElementById('onltable').innerHTML=response[0];}
if(tbl_print==1 &&  tbl_add==1){
if(response[3]==chat_count){
chat_onl=response[4];
if(response[2]>0){chat_lid=response[2]}
if(response[0].length>5){
document.getElementById('mda').innerHTML+=response[0];
if(lockscr==0){lockscr=1;
document.getElementById('mda').scrollTop=9999999;
document.getElementById('mda').scrollTop=9999999; setTimeout('lockscr=0',200);}
document.getElementById('fpls').innerHTML=flsh_msg;
}}}}}}


function chat_recev(){
chat_count+=1;
htto=http_obj();s='u='+u+'&l='+chat_lid+'&c='+chat_count;
if(chat_post.length>0){
amp=/&/g;chat_post=chat_post.replace(amp,'%26');
pl=/\+/g;chat_post=chat_post.replace(pl,'%2B');
s=s+'&p='+chat_post;chat_post='';}
htto.open('post','chat_aj.php');
htto.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
htto.onreadystatechange=chat_print;htto.send(s);}


function chat_print(){
if(htto.readyState==4){
if(chat_count>0){document.getElementById('mda').style.backgroundImage='none';}
response=htto.responseText.toString();
response=response.split('|:|');
response[1]=parseInt(response[1]);
response[2]=parseInt(response[2]);
if(response.length>3){
if(response[2]==chat_count){
if(response[1]>0){chat_lid=response[1];}
if(response[3].length>5){
document.getElementById('mda').innerHTML+=response[3];
if(lockscr==0){lockscr=1;
document.getElementById('mda').scrollTop=9999999;
document.getElementById('mda').scrollTop=9999999; setTimeout('lockscr=0',200);}
}}
cs=chat_status(response[0],response[3].length);
if(cs && response[2]==chat_count){document.getElementById('rec_onl').innerHTML+=flsh_cht;}
}}}


function force_cr(){
if(chat_post.length>0){
document.getElementById('ln').disabled=true;
clearInterval(brc);chat_recev();
brc=setInterval('chat_recev()',chat_updt*1000);
setTimeout('txt_esc()',chat_intv);}}


function force_dr(){
if(chat_post.length>0){
document.getElementById('ln').disabled=true;
clearInterval(brc);onlist_recev();
brc=setInterval('onlist_recev()',chat_updt*1000);
setTimeout('txt_esc()',chat_intv);}}


function txt_esc(){
a=document.getElementById('ln');
a.disabled=false; a.value=' '; a.blur(); a.value=''; a.focus();}


function chat_status(a,b){
tmp=curr_status; dta=''; if(a!='00'){
if(a!=lang_user){lang_user=a;chat_started=1}
document.title=lang_user+' '+' ('+lang_chatsess+')';
document.getElementById('rec_onl').innerHTML='<img src="'+img_onl+'" alt="" />&nbsp;'+lang_chatsess+': <b><a href="info.php?wsssp=link" onclick="close_boxes();show_usr(u,0,0,2,\'\');return false">'+lang_user+'</a></b>';
curr_status=1} else{
if(chat_started<1){chatnor=lang_chatnor1;chatreq='';}
else{chatnor=lang_chatnor2;chatreq=' (<a href="info.php?wsssp=link" onclick="window.location=\'ch_rd.php?r=1&u=\'+u+\'&z=\'+lang_user;return false">'+lang_chatreq+'</a>)';}
document.title=lang_user+' '+chatnor;
document.getElementById('rec_onl').innerHTML='<img src="'+img_off+'" alt="" />&nbsp;'+lang_user+' '+chatnor+chatreq;
curr_status=0}
if(b>5){dta='(abc) ';}if(tmp!=curr_status){dta='(***) ';}
document.title=dta+document.title;
if(dta!=''){return true}else{return false}}


function set_status(q){
r=window.location.toString();
window.location='status.php?q='+q+'&r='+r;}


function show_usr(u,r,p,b,c){
m=document.getElementById('s_usr');
m.innerHTML='';opa_st(m,1);
if(msie>0){m.style.position='absolute'}
httu=http_obj();s='q='+u+'&r='+r+'&p='+p+'&b='+b+'&c='+c;
httu.open('post','user_aj.php');
httu.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
httu.onreadystatechange=disp_usr;httu.send(s);}


function disp_usr(){
if(httu.readyState==4){
response=httu.responseText.toString();
document.getElementById('s_usr').innerHTML=response;}}


function process_chat(x,r,z){
if(r<4){
if(navigator.userAgent.indexOf('Gecko/')!=-1){loc=',location=1';}else{loc='';}
ss=window.open('ch_rd.php?u='+x+'&r='+r+'&z='+z,'blabimchat'+x,'width=550,height=380,resizable=1'+loc);
ss.focus();setTimeout('ucp_close(0)',200);} else{window.location='ch_rd.php?u='+x+'&r='+r}}


function add_buddy(x,y){
window.location='ucp_buddies.php?add='+x+'&bname='+y}


function ucp_close(x){
if(close_ucp>0 || x==1){
if(parent.document.getElementById('blabimbar')){
parent.document.getElementById('blabimbar').style.width='auto';
parent.document.getElementById('blabimbar').style.height='auto';
parent.oncnt_recev(); parent.oncnt_intv();}
else{self.close();}
}}


function set_snd(x){
flsh='<object data="'+x+'" type="application/x-shockwave-flash" width="1" height="1" style="position:absolute;left:0px;top:0px;visibility:hidden"><param name="movie" value="'+x+'" /><param name="menu" value="false" /><param name="quality" value="high" /></object>';
return flsh;}


function remv_astr(){
str=document.title;
str=str.replace('(***) ','')
str=str.replace('(abc) ','')
document.title=str;}


function smilie_box(){
for(i=0;i<smiles.length;i++){
document.writeln(' <a href="info.php?wsssp=link" onclick="add_smilie(\''+smiles[i]+'\');return false"><img class="box_simg" src="'+skin_dir+'/smilies/'+sfiles[i]+'" alt="'+smiles[i]+'" title="'+smiles[i]+'" /></a> ')}}


function add_smilie(x){
a=document.getElementById('ln');
if(a.disabled==false){
a.value=a.value+ ' '+x+' ';
a.focus();}}


function close_boxes(){
document.getElementById('s_fle').style.display='none';
document.getElementById('s_emo').style.display='none';
document.getElementById('s_usr').style.display='none';
document.getElementById('s_vdo').innerHTML=''; play_vdo=0;
document.getElementById('s_vdo').style.display='none';
}


function fll(x,y){
y=parseInt(y);
switch(y){
case 1: z='[img]'+x+'[/img]';break;
case 2: z='[dnd]'+x+'[/dnd]';break;
case 3: z='[video]'+x+'[/video]';break;
default:  z=x;break;}
a=document.getElementById('ln');
if(a.disabled==false){
a.value=a.value+ ' '+z+' ';
a.focus();}}


function seed_rand(x){
y=Math.floor(Math.random()*x+1186812);
return y;}


function count_txt(a,b){
c=a.value.length; if(c>b){a.value=a.value.substr(0,b)}}


function cop_link(m){
if(typeof window.clipboardData=='object'){
window.clipboardData.setData('text',m)
alert('Clipboard: '+m)}else{prompt('',m)}}


function show_img(m){ims=window.open(m,'img_sch');if(typeof ims=='object'){ims.focus()}}


function goto_dnd(m){window.open('download.php?q='+m)}


function show_vdo(m){
if(typeof document.getElementById('s_vdo')=='object' && typeof play_vdo=='number'){
svdo=document.getElementById('s_vdo');
if(svdo.style.display!='block'){close_boxes();opa_st(svdo,1);}
vsrc=skin_dir+'/novid.swf';sX=230;sY=180

if(m.indexOf('youtube.com/watch?v=')!=-1){vsrc=m.split('youtube.com/watch?v=');vsrc='http://youtube.com/v/'+vsrc[1]}
if(m.indexOf('metacafe.com/watch/')!=-1){vsrc=m.split('metacafe.com/watch/');vsrc='http://www.metacafe.com/fplayer/'+vsrc[1];vsrc=vsrc.substr(0,vsrc.length-1)+'.swf'}

if(vsrc.indexOf(skin_dir)==-1){sX=250;sY=250;}
vsrc='<object style="width:'+sX+'px;height:'+sY+'px" type="application/x-shockwave-flash" data="'+vsrc+'"><param name="movie" value="'+vsrc+'" /></object>';
svdo.style.width=sX+'px';svdo.style.height=sY+'px';
svdo.innerHTML=vsrc;setTimeout('play_vdo=1',2000)}else{window.open(m);}}
