
function user_xmlhttp_handler(){}
var is_ended=null;var is_send_message_delied=null;function onclose(){if(!is_ended){is_ended=1;var xmlhttp=CreateXmlHttpReq(user_xmlhttp_handler);XmlHttpGET(xmlhttp,"./?action=exit");alert('You have cancelled this chat request.');}
}
function onclosechat(safe){if(!is_ended){is_ended=safe?2:1;if(frames[0]){if(frames[0].message_timeout){clearTimeout(frames[0].message_timeout);frames[0].usermessage();}
}
if(safe){alert('Your chat session has ended.');}
}
}
function ending_chat(){if(is_ended)window.close();else onclosechat();}
function rate(){if(mark_selected!=0){ipopup('rate',mark_selected,'516','220');}else{alert('Please submit a rating');}
}
function transcript(){ipopup('transcript','','516','220');}
function sendmessage(){if(is_send_message_delied)return;var it=document.getElementById('m');var it_value=it.value;if(it_value){is_typing=0;var id_last_message=document.getElementById('id_last_message').value;if(id_last_message=='-1'){id_last_message=0;document.getElementById('id_last_message').value='0';}
var user_name=document.getElementById('user_name').value;var tm=new Date;var message_date=''
if(tm.getHours()>9)message_date+=tm.getHours();else message_date+='0'+tm.getHours();if(tm.getMinutes()>9)message_date+=':'+tm.getMinutes();else message_date+=':0'+tm.getMinutes();if(tm.getSeconds()>9)message_date+=':'+tm.getSeconds();else message_date+=':0'+tm.getSeconds();if(!(frames['messages']&&frames['messages'].document&&frames['messages'].document.getElementById(id_last_message)))return;frames['messages'].document.getElementById(id_last_message).innerHTML+=
'\    <table cellpadding=0 cellspacing=0>\       <tr valign=top>\          <td>\            <font color=#999999>'+message_date+
'</font>&nbsp;\          </td>\          <td>\            <font color=#FF0000><b>'+user_name+':</b> '+nl2br(htmlspecialchars(it_value))+
'</font>\          </td>\       </tr>\    </table>\r\n';frames['messages'].scrollTo(0,1000000);var xmlhttp=CreateXmlHttpReq(user_xmlhttp_handler);XmlHttpPOST(xmlhttp,"?","action=message_add&content="+encodeURIComponent(it_value));}
it.focus();it.value='';}
var xmlhttp_typing=null;var busy_typing=0;var is_typing=0;var typing_off_timer=setTimeout('no_typing()',5000);function typing(){clearTimeout(typing_off_timer);typing_off_timer=setTimeout('no_typing()',5000);if(is_typing==0)set_typing_status(1);}
function no_typing(){if(is_typing==1)set_typing_status(0);typing_off_timer=setTimeout('no_typing()',5000);}
function set_typing_status(value){if(busy_typing)return;busy_typing=1;xmlhttp_typing=CreateXmlHttpReq(typing_xmlhttp_handler);XmlHttpGET(xmlhttp_typing,"?action=typing&id="+value);}
function typing_xmlhttp_handler(){if(xmlhttp_typing.readyState!=4)return;if(xmlhttp_typing.status==200){var responseHeader=xmlhttp_typing.getAllResponseHeaders();is_typing=parseInt(parseResponseHeader("Occ-Is-Typing",responseHeader));}
busy_typing=0;}
var xmlhttp_check=null;var request_timeout=null;function CheckAvailXmlHttpHandler(){if(request_timeout)clearTimeout(request_timeout);request_timeout=setTimeout('request()',2000);if(xmlhttp_check.readyState!=4||xmlhttp_check.status!=200){return;}
if(counter>0)eval(xmlhttp_check.responseText);}
function request(){if(!is_ended){xmlhttp_check=CreateXmlHttpReq(CheckAvailXmlHttpHandler);XmlHttpGET(xmlhttp_check,'?action=check');}
}
var el_width;var el_height;var el_width_start=0;var el_height_start=0;function occ_el_move(){var ydiff=el_height_start-document.body.scrollTop;var xdiff=el_width_start-document.body.scrollLeft;if(ydiff!=0){movey=Math.round(ydiff/10);el_height_start-=movey}
if(xdiff!=0){movex=Math.round(xdiff/10);el_width_start-=movex}
if(document.getElementById('occ_elemen')){document.getElementById('occ_elemen').style.top=el_height_start+el_height;document.getElementById('occ_elemen').style.left=el_width_start+el_width;}
}
function occ_flowinit(){el_width=Math.round(document.body.clientWidth/2)-200;el_height=Math.round(document.body.clientHeight/2)-100;setInterval('occ_el_move()',20);}
function push_url(str){close_win();var rnd=Math.round((Math.random()*10000000));window.open(str,'pushurl'+rnd,'');}
function close_win(){document.getElementById('occ_elemen').innerHTML='';}
var img;img=new Image();img.src='images/star_1.gif';var mark_selected=0;function mark_show(num){for(var i=1;i<=5;i++){var tmp=document.getElementById('star_'+i);tmp.src='images/star_0.gif';}
if(!num){num=mark_selected;}
for(var i=1;i <=num;i++){tmp=document.getElementById('star_'+i);tmp.src='images/star_1.gif';}
}
function mark_apply(num){mark_selected=num;document.getElementById('rate_text').innerHTML=num+' out of 5 stars';}
