document.write(''); function setCookie(name, value, days) { if (!days) days = 1; // default to 1 day if empty var expdate = new Date(); expdate.setTime(expdate.getTime() + days*24*60*60*1000); dc = name + "=" + escape(value) +"; expires=" + expdate.toGMTString(); document.cookie = dc; } setCookie('ChatSys','1','1'); function readCookie(cookiename) { var cookiestring=""+document.cookie; var index1=cookiestring.indexOf(cookiename); if (index1==-1 || cookiename=="") return ""; var index2=cookiestring.indexOf(';',index1); if (index2==-1) index2=cookiestring.length; return unescape(cookiestring.substring(index1+cookiename.length+1,index2)); } function open_chat(depart,ref,click){ var Times = readCookie('Times'); // alert(readCookie('Opened')); var Online = 0; // the following can be optimized but since it works we'll leave it like this for now if (readCookie('Opened') != 1){ if ((click == 0) && ((Times >= 0) || (Online == 0) )) var to_open = 0; else var to_open = 1; } else var to_open = 0; // alert(to_open); if (to_open == 1){ if (Times == 'NaN') Times = 1; Times = parseFloat(Times) + 1; setCookie('Times',Times,1); window.open("http://chat.aplus.net/freeman/chatwindow.cgi?department=" + depart + "&site=msg3&REFERER=" + ref,"AplusChat","height=350,width=500,status=no,toolbar=no,menubar=no,location=no"); } } function open_onload(){ setTimeout("open_chat('sales','Aplus',0);",240000); } function set_opened(){ setCookie('Opened','1','1'); } function remove_opened(){ setCookie('Opened','notopened','1'); } open_onload();