// This version of the script is an older version provided by Groopz tech support
// because the applet images did not appear to be refreshing properly on a dial-up
// connection.

// Follow-up by BB on 3/13/06 - The small/hidden version of the groopz applet (groopz-ug-pbu-sm.js) was conflicting
// with the drop-down DHTML menu system that was being implemented (firefox only).  It worked OK with the visible
// version of the groopz applet.  Consequently in an attempt to resolve the problem, I'm instead using this (the visible)
// version of the groopz applet modified to make it invisible, like the one that was in use previously.  To do so, I'm
// changing the name references to the images that appear and also the height & width attributes.

document.write("<APPLET CODEBASE=http://groopz.pbu.edu/groopz2/");
document.write(" CODE=com.diginet.groopz.suite.ec.applet.GroopzApplet.class ");
document.write(" WIDTH=0 ");
document.write(" HEIGHT=0 ");
document.write(" MAYSCRIPT ");
document.write(" ARCHIVE=GroopzApplet.jar ");
document.write(" name=GroopzApplet> ");

gid = getCookie("GroopzUID");
if(gid == null) {
	gid = Math.random();
	var dat = new Date();
	dat.setTime(dat.getTime() + 365*24*60*60*1000); 
	var expString = "; expires=" + dat.toGMTString();
	document.cookie = "GroopzUID" + "=" + escape(gid) + expString; 
}

//document.write(" <param name = UserName value = 'MyUser'>");
document.write(" <param name = GroopzUID value = "+gid+">");

// The name of the server to connect to.  This must be the same machine
// that the applet is served from.  For http tunneling, this should be
// the full URL to the HttpTunnelingServlet
document.write(" <param name = server value = groopz.pbu.edu>");	

// The name of the site to connect to.  In the absence of this
// paramter, the default is 1000
document.write(" <param name = site value = 1000>");



//custom param fields 
if(customParams.length !=0)
document.write(customParams);

// The protocol to use by default (tcp, http, udp)
document.write(" <param name = network value = tcp>");
//http tunneling is off by default
document.write(" <param name = allowhttp value = yes>");

// The title of the page shown in Groopz Operator.  This value is set to the 
// title of the web page it came from.
document.write(" <param name = title value = '"+document.title+"'>");

// The referrer 
document.write(" <param name = referrer value = '"+document.referrer+"'>");

// E-Mail Stuff
//document.write(" <param name = email = url >");
// If 'email' is set to 'url' define the following variables:
document.write(" <param name = emailURL value = http://www.pbu.edu/admissions/undergrad/inf-request.htm >");
document.write(" <param name = emailTarget value = _top >");
//document.write(" <param name = emailTo value = test@test.com >");
//document.write(" <param name = email_Img value = email.gif >");
//document.write(" <param name = emailBG value = 217,217,217 >");
//document.write(" <param name = emailFG value = 80,80,80 >");

// The URL (relative to the Codebase above) of the image to use as the
// skin of the applet's Chat Dialog
document.write(" <param name = skin_img value = pbu-skin.gif>");

// The URL (relative to the Codebase above) of the image to use as the
// face of the applet when operators are available for calls
document.write(" <param name = active_img value = invisible.gif>");

// The URL (relative to the Codebase above) of the image to use as the
// face of the applet when no operators are available.
document.write(" <param name = away_img value = invisible.gif>");

// The URL (relative to the Codebase above) of the image to use as the
// face of the applet when the user clicks and requests help
document.write(" <param name = paging_img value = invisible.gif>");

// The URL (relative to the Codebase above) of the image to use as the
// send button in the "up" state (not pressed) (this button is on the Chat Dialog)
document.write(" <param name = sendup_img value = send-up.gif>");

// The URL (relative to the Codebase above) of the image to use as the
// send button in the "down" state (pressed) (this button is on the Chat Dialog)
document.write(" <param name = senddown_img value = send-down.gif>");

// The URL (relative to the Codebase above) of the image to use as the
// close button in the "up" state (not pressed) (this button is on the Chat Dialog)
document.write(" <param name = closeup_img value = close-up.gif>");

// The URL (relative to the Codebase above) of the image to use as the
// close button in the "down" state (pressed) (this button is on the Chat Dialog)
document.write(" <param name = closedown_img value = close-down.gif>");

// The location where the Operator's name should appear.
// This position is the top left corner of the name specified in pixels relative to the top left corner of the Chat Window
// The x and y coordinates are separated by a comma, so the point (100, 95) would be written as value = 100,95
document.write(" <param name = name_pos value = 91,31>");

// The location where the Send button should appear.
// This position is the top left corner specified in pixels relative to the top left corner of the Chat Window
// The x and y coordinates are separated by a comma, so the point (100, 95) would be written as value = 100,95
document.write(" <param name = send_pos value = 308,253>");

// The location where the Close button should appear.
// This position is the top left corner specified in pixels relative to the top left corner of the Chat Window
// The x and y coordinates are separated by a comma, so the point (100, 95) would be written as value = 100,95
document.write(" <param name = close_pos value = 308,285>");

// The location where the message input area should appear.
// This position is the top left corner specified in pixels relative to the top left corner of the Chat Window
// followed by the width and height of the input area.
// The values are separated by a comma, so to put the area at the point (10, 15) with a width and height of  200 X 100
// the value should be written as value = 10,15,200,100
document.write(" <param name = input_pos value = 8,253,293,61>");

// The location where the chat messages should appear.
// This position is the top left corner specified in pixels relative to the top left corner of the Chat Window
// followed by the width and height of the input area.
// The values are separated by a comma, so to put the area at the point (10, 15) with a width and height of  200 X 100
// the value should be written as value = 10,15,200,100
document.write(" <param name = chat_pos value = 8,60,381,185>");

document.write(" </APPLET>");
document.write(" <!-- End Applet Code -->");

function getCookie(name) {
	var result = null; 
	var myCookie = " " + document.cookie + ";";
	var searchName = " " + name + "=";
	var startOfCookie = myCookie.indexOf(searchName); 
	var endOfCookie; 
	if (startOfCookie != -1) {
		startOfCookie += searchName.length; 
		endOfCookie = myCookie.indexOf(";", startOfCookie); 
		result = unescape(myCookie.substring(startOfCookie, endOfCookie)); 
	}
	return result; 
}
