var perl_dir='/cgi-bin/control';


document.write('<style type="text/css">\n');document.write('.lsinvitation{ position:absolute;top:0px;left:0px;width:100%;padding:2px;margin:0px;background:#D4D0C8;font-family:MS Shell Dlg;font-size:7pt;color:#ff0000; }\n');document.write('#ls_on{ display:none;cursor:pointer; }\n');document.write('#ls_off{display:none;}\n');document.write('</style>\n');function visitor_comes(){if(!getCookie_ls('ls_visitor')){setCookie_ls('ls_visitor');}else{ var ls_visitor=document.ls_visitor;ls_visitor.SetVariable("/:visitor_id", getCookie_ls('ls_visitor'));ls_visitor.SetVariable("/:perl_dir", perl_dir);}};function operator_comes(){ if(getCookie_ls('ls_operator')){var ls_operator=document.ls_operator;ls_operator.SetVariable("/:operator_id", getCookie_ls('ls_operator'));}};function op_gets_visitors_id(){  var ls_op_lns=document.ls_op_lines;ls_op_lns.SetVariable("/:visitor_id", visitor); ls_op_lns.SetVariable("/:operator_id", getCookie_ls('ls_operator'));};function visitor_asks_chat(){ var visitor_id=getCookie_ls('ls_visitor'); visitor_id=perl_dir+'/livesupport.pl?action=visitor_chatwindow&visitor='+visitor_id+'&perl_dir='+perl_dir;var visitor_chatwindow = window.open(visitor_id ,"ls_chat","toolbar=0,location=0,menubar=0,scrollbars=0,resizable=1,width=450,height=350" );} ; function visitors_btn(btn){ var buttons = btn.split('|');document.getElementById('visitors_buttons').innerHTML=''; for(i=0;i<buttons.length-1;i++){  var btn_dtl =buttons[i].split('*'); var visitor_name= 'Visitor' +btn_dtl[0].substring(9,btn_dtl[0].length );  if(btn_dtl[2]){visitor_name=btn_dtl[2];} var btn = document.createElement('div'); btn.id='btn'+btn_dtl[0]; btn.innerHTML ='<A HREF=\'javascript:op_opens_chat('+btn_dtl[0]+',"'+visitor_name+'");\' TITLE="'+btn_dtl[3]+'"  >'+visitor_name+'</A> ' ; btn.className='op_vsbtns';if(btn_dtl[1]==1){btn.className='op_vsbtns_open'; } ;if(btn_dtl[4]==1){ btn.className='op_vsbtns_in'; btn.innerHTML='<A HREF="'+btn_dtl[3]+'" TITLE="'+btn_dtl[3]+'" target=_blank >'+visitor_name+'</A> ' ;} document.getElementById('visitors_buttons').appendChild(btn);   }} ; function resore_button(btn,name){ document.getElementById('btn'+btn).style.border='1px outset #fff'; if(btn==777){}else{ document.getElementById('btn'+btn).innerHTML ='<A HREF=\'javascript:op_opens_chat('+btn+',"'+name+'");\'  >'+name+'</A> ' ; }  } ; var old_invitation ; function offer_chat(vs_id){  if(parent.document.getElementById('checkbox'+vs_id).checked==true){ var ls_op_lns=document.ls_op_lines;ls_op_lns.SetVariable("/:chat_invitation",  getCookie_ls('ls_operator')+':'+parent.document.getElementById('invitation_words'+vs_id).value);}else{ var ls_op_lns=document.ls_op_lines;ls_op_lns.SetVariable("/:chat_invitation", '');} } ; function display_chat_invitation(vs_id){ if(document.getElementById('invitation_span'+vs_id).style.display=='none'){document.getElementById('invitation_span'+vs_id).style.display='block'}else{document.getElementById('invitation_span'+vs_id).style.display='none';document.getElementById('checkbox'+vs_id).checked=false;} ; } ; function play_chat_invitation(inv){ if(inv==0){if(document.getElementById('ls_invitation')){removeElement_ls('ls_on', 'ls_invitation');old_invitation='';}}else{if(inv == old_invitation){return ;}; document.getElementById('ls_on').innerHTML='';if(!document.getElementById('ls_invitation')){var invt=document.createElement('div'); invt.id='ls_invitation'; invt.className='lsinvitation';document.getElementById('ls_on').appendChild(invt); } ; old_invitation =inv; write_text(document.getElementById('ls_invitation'),inv,0,'');}};function write_text(ob,txt,cnt,new_txt){  new_txt +=txt.charAt(cnt) ;cnt++; ob.innerHTML =new_txt; if(cnt<txt.length){setTimeout(function() {write_text(ob,txt,cnt,new_txt);}, 100);}};

function op_opens_chat(vs_id,vs_name){ if(!document.getElementById('fldst'+vs_id)){var op_chat = document.createElement('fieldset'); op_chat.id='fldst'+vs_id; op_chat.className='op_chat_fldst';op_chat.style.background='#fff';document.getElementById('op_chatarea').appendChild(op_chat);var op_chat_legend = document.createElement('legend');op_chat_legend.innerHTML='<SPAN id=lgnd'+vs_id+' style=\'font-size:17px;color:#666666;float:left:line-height:20px;\'><B>'+vs_name + '</B></span> <A HREF=\'javascript:removeElement_ls("op_chatarea", "fldst'+vs_id+'");resore_button('+vs_id+',"'+vs_name+'");\' style=\'text-decoration:none;font-size:9px;color:#000;\' >[ Close ]</A> <A HREF=\'?action=chat_history&visitor='+vs_id+'\' target=\'_blank\' style=\'text-decoration:none;font-size:9px;color:#000;\' >[ History ]</A>'; if(vs_id == 777){ op_chat_legend.innerHTML+='<INPUT id=checkbox777 type=checkbox style=\'display:none;\'>'; }else { op_chat_legend.innerHTML+= '[<A HREF=javascript:display_chat_invitation('+vs_id+') style=\'font-size:9px;\' > Offer chat </A>:]<SPAN id=invitation_span'+vs_id+'  style=\'display:none;\'><INPUT id=invitation_words'+vs_id+'   TYPE=text style=\'border:1px solid #666666;width:370px;height:12px;margin:0px;padding:0px;font-size:10px;color:#ff0000;\' Value=\'Write here custom invitation or select PreMade Phrase.Check the box if ready.\'  onfocus="if(this.value.match(\'PreMade Phrase.Check\')){this.value=\'\';}"><INPUT TYPE=checkbox id=checkbox'+vs_id+' style=\'width:15px;height:15px;\'  > </SPAN>';}; document.getElementById('fldst'+vs_id).appendChild(op_chat_legend);var op_chatHTML=document.createElement('div'); op_chatHTML.innerHTML="<IFRAME ID='chat_lines_op"+vs_id+"' src=''  frameborder=0 WIDTH=400 HEIGHT=300 style='min-height:300px;'></IFRAME>";op_chatHTML.innerHTML +="<IFRAME ID='operator_speaks"+vs_id+"' src=''  frameborder=0 scrolling=no WIDTH=400 HEIGHT=70 ></IFRAME>";op_chatHTML.innerHTML +="<DIV  style='cursor:pointer;font-size:9px;font-family:verdana;color:#666666;text-align:center;'  onclick=\"if(document.getElementById('operator_notes"+vs_id+"').style.display=='none'){document.getElementById('operator_notes"+vs_id+"').style.display='block';this.innerHTML='[ Fold ]';}else{document.getElementById('operator_notes"+vs_id+"').style.display='none';this.innerHTML='[ Unfold ]';}\" >[ Unfold ]</DIV>";op_chatHTML.innerHTML +="<IFRAME ID='operator_notes"+vs_id+"' src='?action=operator_notes&visitor="+vs_id+"&operator="+getCookie_ls('ls_operator')+"'  frameborder=0 scrolling=yes WIDTH=400   style='display:none;' ></IFRAME>";document.getElementById('fldst'+vs_id).appendChild(op_chatHTML)   ;





var src1="?action=chat_lines_op&visitor="+vs_id; 
var id1 = 'chat_lines_op'+vs_id;

var src2="?action=operator_speaks&visitor="+vs_id+"&operator="+getCookie_ls('ls_operator'); 
var id2 ='operator_speaks'+vs_id;

document.getElementById(id1).src =src1;  
document.getElementById(id2).src =src2 ;


setTimeout(function() {

document.getElementById(id1).src =src1;  
document.getElementById(id2).src =src2 ;
}, 1000);

}} ; function add_newlines(lines){  var new_lines = lines.split('|'); var style_type ; for(i=0;i<new_lines.length-1;i++){ if(new_lines[i].match('Guest')){ style_type='style_visitor';}else{ style_type='style_operator';} ; var ln = document.createElement('li'); ln.className=style_type; ln.innerHTML =chat_string_create_urls(new_lines[i]) ; document.getElementById('the_chatlines').appendChild(ln); scrollme();  } ; new_lines='';} ;function red_legend(vs_id){top.window.parent.document.getElementById('lgnd'+vs_id ).style.color='red';} ; function setCookie_ls(name){ var today = new Date(); var expiry = new Date(today.getTime() + 365 * 24 * 60 * 60 * 1000); var new_id=today.getTime(); var the_cookie = name+"=" + new_id + ";" ; the_cookie += the_cookie + "expires=" + expiry.toGMTString() + ";" ;the_cookie += the_cookie + "path=/;"; document.cookie = the_cookie; var ls=document.ls_visitor;  ls.SetVariable("/:visitor_id", new_id);     ls.SetVariable("/:perl_dir", perl_dir);} ; function getCookie_ls(name) { var index = window.document.cookie.indexOf(name + "="); if (index == -1){ return null;} ;index = window.document.cookie.indexOf("=", index) + 1;var endstr = window.document.cookie.indexOf(";", index);if (endstr == -1){ endstr = window.document.cookie.length; } ;return unescape(window.document.cookie.substring(index, endstr));} ; function currentpage_ls(){ var ls=document.ls_visitor; ls.SetVariable("/:on_page",escape(parent.window.location)  ); } ; function operators_online(op){ if(!op){document.getElementById('ls_on').style.display='none';document.getElementById('ls_off').style.display='block';}else{   document.getElementById('ls_on').style.display='block';document.getElementById('ls_off').style.display='none';}} ; function scrollme(){dh=document.body.scrollHeight;ch=document.body.clientHeight;if(dh>ch){moveme=dh-ch;window.scrollTo(0,moveme)}} ; function removeElement_ls(parentDiv, childDiv){  if (childDiv == parentDiv) { alert("The parent div cannot be removed.");}else if (document.getElementById(childDiv)) {  var child = document.getElementById(childDiv);var parent = document.getElementById(parentDiv);parent.removeChild(child); }else {alert("Child div has already been removed or does not exist.");return false;}}
function chat_string_create_urls(input)
{
    return input
    .replace(/(ftp|http|https|file):\/\/[\S]+(\b|$)/gim,
'<a href="$&" class="my_link" target="_blank">$&</a>')
    .replace(/([^\/])(www[\S]+(\b|$))/gim,
'$1<a href="http://$2" class="my_link" target="_blank">$2</a>');
} 




