var playsound=1;

function start_chat(params){
	if (typeof _ajb != 'undefined') 
		_ajb.addTarget('gameforum_message','gameforum','updateMessages',params,0);
}
function stop_chat(){
	if (typeof _ajb != 'undefined')
	    delete (_ajb.requestMap)['gameforum_message'];
}

function inviteChat(from,game,to){
    subj="Come chat with "+from;
    body=from+" asked you to come to the game <b>"+game+"</b> to chat";
    v=escape("alert('your invitation was sent')");
    doAjax2('POST','./index.php?d=gameforum&e=sendInvite',"subj="+subj+"&body="+body+"&email="+to,'','','',v);
    
}

function openchat(el,c,params){
    if(el.style.display=='none'){
        doAjax2('POST','./index.php?d=gameforum&e=changeState',"state=inline",'','','');
        el.style.display='inline';
        if(params!=",")
            start_chat(params);
        $('onlinelist_link').innerHTML='Hide Chatroom';
    }
    else{
        doAjax2('POST','./index.php?d=gameforum&e=changeState',"state=none",'','','');
        el.style.display='none';
        if(params!=",")
            stop_chat();
        $('onlinelist_link').innerHTML='View Chatroom';
    }
};

function showMsg(){
    if($('topmsg').innerHTML!=""){
        $('topmsg').style.display='inline';
        EvalSound('sound1');
    }
    setTimeout('removeMsg()',2000);
};

function removeMsg(){
    $('topmsg').style.display='none';
    //myRequest('POST','./include/ajax_actions.php','method=update_newmsg','','','');
};

function gameforum_update(type,param,t,t2){
		
    EvalSound('sound1');
    var newdata="<span style='color:red'><b>"+$('username').innerHTML+"<span style='font-size:x-small'> sending... .</span> : </span></b>"+$('txtarea').value+"<br>";
    $('gameforum_message').innerHTML=newdata+$('gameforum_message').innerHTML;
    myRequest(type,param,t,t2);
    $('txtarea').value='';
    $('txtarea').focus();
    
    return false;
}

function togglemute(){
    if(playsound==1){
        playsound=0;
        $('mutelink').innerHTML='unmute';
    }
    else{
        playsound=1;
        $('mutelink').innerHTML='mute';
    }
    
    doAjax2('POST','./index.php?d=gameforum&e=changeMute',"mute="+playsound,'','','');

}

function EvalSound(soundobj) {

    if(playsound==1){
            var thissound= eval("document."+soundobj);
            thissound.Play();
    }
};

