livehelp js


var WEBPATH = "http://www.grafmarket.pl/CSLHv27/"; //-----------------------------------------------------------------
// File: livehelp.js :
// - This is the client side Javascript file to control the
// image shown on the clients website. It should be called
// on the clients HTML page as a javascript include such as:
// script src="http://yourwebsite.com/livehelp/livehelp_js.php"
// This js file will show the image of online.gif if an operator
// is online otherwise it will show offline.gif . Also a
// second image is placed on the site as a control image
// where the width of the image controls the actions made by
// the operator to the poor little visitor..
//
//-----------------------------------------------------------------

// GLOBALS..
//------------
// This is the control image where the width of it controls the
// actions made by the operator.
cscontrol= new Image;
// this is a flag to control if the image is set on the page
// yet or not..
var csloaded = false;

// just to make sure that people do not just open up the page
// and leave it open the requests timeout after 999 requests.
var csTimeout = 99;

// The id of the page request.
var csID = null;

// if the operator requests a chat we only want to open one window...
var openLiveHelpalready = false;

//-----------------------------------------------------------------
// loop though checking the image for updates from operators.
function csrepeat()
{
// if the request has timed out do not do anything.
if (csTimeout < 0)
return;

csTimeout--;

// update image for requests from operator.
csgetimage();

// check image for updates from operators.
cslookatimage();

// do it again.
setTimeout('csrepeat()', 3000);
}

//-----------------------------------------------------------------
// Update the control image. This is the image that the operators
// use to communitate with the visitor.
function csgetimage()
{
// set a number to identify this page .
if (csID==null) csID=Math.round(Math.random()*9999);

var u = WEBPATH + 'image.php?' +
'cmd=userstat' +
'&page=' + escape(document.location) +
'&title=' + escape(document.title) +
'&referrer=' + escape(document.referrer) +
'&pageid=' + csID +
'&department=' + 1;
cscontrol.src = u;
csloaded = true;
}

// looks at the size of the control image and if the width is 55
// then open the chat.
//-----------------------------------------------------------------
function cslookatimage()
{
if (csloaded) {
var w = cscontrol.width;
if (w == 0)
return;
csloaded = false;
if ((w == 55) && (openLiveHelpalready == false)) {
openWantsToChat();
openLiveHelpalready = true;
}
}
}


//-----------------------------------------------------------------
// opens live help
function openLiveHelp()
{
window.open(WEBPATH + 'livehelp.php?department=1', 'chat54050872', 'width=540,height=390,menubar=no,scrollbars=0,resizable=1');
}

//-----------------------------------------------------------------
// The Operator wants to chat with the visitor about something.
function openWantsToChat()
{
// ok we asked them .. now lets not ask them again for awhile...
var u = WEBPATH + 'image.php?' +
'cmd=browse' +
'&page=' + escape(document.location) +
'&title=' + escape(document.title) +
'&referrer=' + escape(document.referrer) +
'&pageid=' + csID +
'&department=' + 1;
cscontrol.src = u;

// open the window..
window.open(WEBPATH + 'livehelp.php?cmd=chatinsession&department=1', 'chat54050872', 'width=540,height=390,menubar=no,scrollbars=0,resizable=1');
}

//table holding the live help icon...
document.write('');
document.write('');
document.write('');
document.write('');
document.write('');
document.write('');
document.write('');
document.write('');
setTimeout('csrepeat()', 250);


Wyszukiwarka

Podobne podstrony:
Util js
js zegarek na www
Animation js
Format js
Map js
Tile js
PHP JS readme
Style js
b js
Rule js
js 6
help?llon js source
js 4
Format js
js lab2
Jś Wytrębowiczowi
MO JM 02 JS 03

więcej podobnych podstron