
//********Global Configuration*************
var server = "www.planetrealestate.com";			//Groopz Server Addres
var siteid = "1";											//Groopz Site ID
var away_img = "pre-header-homechat-away.gif";					//Applet Button when Operators are "away"
var active_img = "pre-header-homechat-active.gif";			//Applet Button when Operators are logged in
var paging_img = "pre-header-homechat-paging.gif";			//Applet Button when after visitor has paged Operator
/*
var away_img = "groopz-away.gif";		
var active_img = "groopz-active.gif";
var paging_img = "groopz-paging.gif";
*/
var button_width = "10";									//Width in pixels of the above three images
var button_height = "10";									//Height in pixels of the above three images
if ( groopzPopup )
{
  button_width = "129";
  button_height = "32";
  away_img   = "groopz-popup-away.gif";					//Applet Button when Operators are "away"
  active_img = "groopz-popup-active.gif";			//Applet Button when Operators are logged in
  paging_img = "groopz-popup-paging.gif";			//Applet Button when after visitor has paged Operator
}
var persist = "true"; 										//Set to true to enable applet persistance
var tunneling = "false"; 									//Set to true to enable HTTP Tunneling
var group = "";														//Enter "Group" value here
//Email Stuff
var email = "builtin";										// Set 'email' to 'builtin', 'url', or 'disable'
// If 'email' is set to 'builtin' define the following variables:
var emailTo = "operator@planetrealestate.com";			//Email address that emails should be sent to
var email_img = "pre-logo-email.jpg";							//Image used in email pop-up window
var emailBG = "249,241,218";							//Background color of email pop-up window
var emailFG = "0,0,0";										//Text color of email pop-up window
// If 'email' is set to 'url' define the following variables:
var emailURL = "http://www.yourserver.com/email";	//URL of Email page
var emailTarget = "_new";									//"_new" for new window, "_self" for same window
//********Global Configuration*************

isMac = (navigator.appVersion.indexOf("Mac")!=-1) ? true : false;
IEmac = ((document.all)&&(isMac)) ? true : false;
IEwin = ((document.all)&&(navigator.appVersion.indexOf("MSIE")!=-1) && !isMac) ? true : false;
NS = (navigator.appName.indexOf("Netscape")!=-1) ? true : false;
Mozilla = (navigator.userAgent.indexOf("Mozilla")!=-1) ? true : false;

if(isMac==true) {
	var tunneling = "false";
}

NS6_7 = Mozilla && !IEwin

var useJS = isMac==false;
var useJS = NS6_7==false;
useJS = true;

Imagenames = new Array(3);
Imagenames[0] = "http://" + server + "/groopz/groopz2/Resources/" + siteid +"/" + away_img;
Imagenames[1] = "http://" + server + "/groopz/groopz2/Resources/" + siteid +"/" + active_img;
Imagenames[2] = "http://" + server + "/groopz/groopz2/Resources/" + siteid +"/" + paging_img;
for(i=0; i<Imagenames.length; i++) {
	var pl = new Image();
	pl.src = Imagenames[i];
}

if (useJS==true) {
	/* document.write('<A HREF ="" onClick="_GroopzButton_click(); return false;" ');
	document.write('onMouseOver=\'status = \"Click Here for Live Assistance\"; return true\' onMouseOut=\'status = defaultStatus\' >');
	document.write('<IMG name = "_GroopzIm" border=0 SRC="' + Imagenames[0] +'">');
	document.write('</A>') */
	setTimeout ("_GroopzCheck ()", 1000)
}

document.write("<APPLET ID=\"idGROOPZ\" NAME=\"groopz\" CODEBASE=http://" + server + "/groopz/groopz2/");
document.write(" CODE=com.diginet.groopz.suite.ec.applet.GroopzApplet.class ");
document.write(" WIDTH=");
document.write((useJS == false) ? button_width + " " :"0 ");
document.write(" HEIGHT=");
document.write((useJS == false) ? button_height + " " :"0 ");
document.write(" MAYSCRIPT ");
document.write(" ARCHIVE=GroopzApplet.jar>");

var user_id = getCookie("USER_ID");
var firstName = '';
if ( user_id )
{
  gid=user_id;
  firstName = getCookie("FIRST_NAME");
}
else
{
  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; 
}

if ( firstName && (String(firstName) != String("")) )
{
  document.write(" <param name = UserName value = '"+firstName+"'>");
}
else
{
  document.write(" <param name = UserName value = 'Visitor "+String(gid)+"'>");
}
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 = " + server + ">");	

// The name of the site to connect to.  In the absence of this
// paramter, the default is 1000
document.write(" <param name = site value = " + siteid +">");

// 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 = " + tunneling + ">");

document.write(" <param name = persist value = " + persist + ">");

if(group.length != 0)
	document.write(" <param name = Groups value = " + group + ">");

// 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

if(email=="builtin") {
	document.write(" <param name = emailTo value = " + emailTo + " >");
	document.write(" <param name = email_Img value = " + email_img + "  >");
	document.write(" <param name = emailBG value = " + emailBG + " >");
	document.write(" <param name = emailFG value = " + emailFG + " >");
}

if(email=="url") {
	document.write(" <param name = emailURL value = " + emailURL + " >");
	document.write(" <param name = emailTarget value = " + emailTarget + "  >");
}

// 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 = groopz-skin.gif>");
document.write(" <param name = skin_img value = groopz-skin-pre.jpg>");

// 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 = " + active_img + ">");

// 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 = " + away_img + ">");

// 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 = " + paging_img + ">");

// 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(" <param name = avatar_pos value = 13,15>");

if ( customParams ){
  document.write( customParams );
}

if (!groopzPopup ){

/* support section */
document.write(' <param name="customParam2" value ="Support-Browser-Advanced">');
document.write(' <param name="customValue2" value ="'+
  navigator.appName+' '+
  navigator.appVersion+' ( '+
  navigator.platform+' / '+
  navigator.cpuClass+' )">');

if (window.ScriptEngine){
  tempstring = 
    ScriptEngine()+' '+
    ScriptEngineMajorVersion()+'.'+
    ScriptEngineMinorVersion()+ ' Build '+
    ScriptEngineBuildVersion();
}else{
  tempstring='Yes';
}

document.write(' <param name="customParam3" value ="Support-JavaScript">');
document.write(' <param name="customValue3" value ="'+tempstring+'">');

var strFlash = new String();

if (flashinstalled == 0){
  strFlash += 'Unknown';
}
  if (flashinstalled == 1){
    strFlash += 'No';
  }
if (flashinstalled == 2){
  strFlash += 'Yes';
}

if (flashversion){
  strFlash += ' ( v'+flashversion+' )';
}

document.write(' <param name="customParam4" value ="Support-Flash">');
document.write(' <param name="customValue4" value ="'+strFlash+'">');

/******************************************
      Browser sniffer script - EVIL!!
  Written by Mark Wilton-Jones, 30/8/2002
*******************************************

Before you use this, I want you to read this. It is important.

You should NEVER use this method to determine browser support.
You should ALWAYS check if the browser supports what you are
trying to do. It is arrogant to assume that you know exactly
how all browsers behave. This technique should only be used if
you know that a specific browser has a specific bug that you
need to avoid. Then and ONLY then should you detect that browser
and write a browser specific script for it.

This script can be used to detect all 4th+ generation browsers
that I know of, even if they attempt to masq their identity
(unlike most 'browser sniffer' scripts). This algorithm will
fail if a browser that I do not know about is being used. That
is highly possible. I'm sure that there are others that I do
not know about. I am sure that there are some that this script
can detect that YOU did not know about. This script will also
fail if future versions of these browsers are released that
behave differently to their ancestors. Every type of 'browser
sniffer' will fail if that happens. That means that every time
a new browser is released, you will have to rewrite every
browser sniffer you use and update it for the new browser.

To save yourself the waste of time, and to save your viewers
the frustration of having to contend with such a bad programming
style, ALWAYS detect a browser's capabilities, not its make or
version number.

if( window.focus ) { window.focus(); }

if( document.all ) { myElement = document.all['myElementID']; }

if( window.screen ) { myHeight = window.screen.height; }
_____________________________________________________________________________________________________

I DO NOT authorise this script's use for determining script support.
It is only to be used according to the guidelines given above.
_____________________________________________________________________________________________________

To use, simply put the line:
<script type="text/javascript" language="javascript1.2" src="PATH TO SCRIPT/sniffer.js"></script>
inbetween the <head> tags of your document, before ANY OTHER scripts.

Four variables will be created:
yourBro[0] = browser code, yourBro[1] = browser name, yourBro[2] = operating system code, yourBro[3] = operating system name

Possible results:

Browser code | Browser name
-------------|----------------------------
    ice      | ICEbrowser
    op7      | Opera 7+
    opr      | Opera 6-
    ipn      | iPanel MicroBrowser
    icb      | iCab
    hjv      | HotJava
    kde      | Konqueror / Safari
    wtv      | WebTV
    nbx      | Netgem NetBox
    otv      | OpenTV
    omn      | Omniweb
    esc      | Escape (or iBrow - I think)
    ns4      | Netscape 4
    gek      | Gecko engine (Mozilla, Netscape 6+ etc.)
    clu      | Clue browser
    ie4      | Internet Explorer 4
    ie5      | Internet Explorer 5+
    oth      | an unknown browser

Operating system code | Operating system name
----------------------|----------------------------
         lin          | Linux
         unx          | Unix
         mac          | MacOS
         win          | Windows
         wtv          | WebTV Platform
         ngm          | Netgem
         otv          | OpenTV Platform
         oth          | an unknown operating system
___________________________________________________________________________________________________*/

var yourBro = [];

//perform checks for different browsers
if( navigator.vendor == 'KDE' ) { yourBro[0] = 'kde'; yourBro[1] = 'Konqueror / Safari'; }
else if( navigator.__ice_version ) { yourBro[0] = 'ice'; yourBro[1] = 'ICEbrowser'; }
else if( window.ScriptEngine && ScriptEngine().indexOf( 'InScript' ) + 1 ) { yourBro[0] = 'icb'; yourBro[1] = 'iCab'; }
else if( navigator.userAgent.toLowerCase().indexOf( 'hotjava' ) + 1 && typeof( navigator.mimeTypes ) == 'function' ) { yourBro[0] = 'hjv'; yourBro[1] = 'HotJava'; }
else if( document.layers && !document.classes ) { yourBro[0] = 'omn'; yourBro[1] = 'Omniweb'; }
else if( document.layers && !navigator.mimeTypes['*'] ) { yourBro[0] = 'esc'; yourBro[1] = 'Escape or iBrow'; }
else if( document.layers ) { yourBro[0] = 'ns4'; yourBro[1] = 'Netscape 4'; }
else if( window.opera && document.childNodes ) { yourBro[0] = 'op7'; yourBro[1] = 'Opera 7+'; }
else if( navigator.userAgent.toLowerCase().indexOf( 'opera' ) + 1 ) { yourBro[0] = 'opr'; yourBro[1] = 'Opera 6-'; }
else if( navigator.appName.indexOf( 'WebTV' ) + 1 ) { yourBro[0] = 'wtv'; yourBro[1] = 'WebTV'; }
else if( navigator.userAgent.toLowerCase().indexOf( 'netgem' ) + 1 ) { yourBro[0] = 'nbx'; yourBro[1] = 'Netgem NetBox'; }
else if( navigator.userAgent.toLowerCase().indexOf( 'opentv' ) + 1 ) { yourBro[0] = 'otv'; yourBro[1] = 'OpenTV'; }
else if( navigator.userAgent.toLowerCase().indexOf( 'ipanel' ) + 1 ) { yourBro[0] = 'ipn'; yourBro[1] = 'iPanel MicroBrowser'; }
else if( document.getElementById && !document.childNodes ) { yourBro[0] = 'clu'; yourBro[1] = 'Clue browser'; }
else if( document.childNodes && !document.all && !navigator.taintEnabled ) { yourBro[0] = 'kde'; yourBro[1] = 'Konqueror / Safari'; }
else if( navigator.product == 'Gecko' ) { yourBro[0] = 'gek'; yourBro[1] = 'Gecko engine (Mozilla, Netscape 6+ etc.)'; }
else if( document.getElementById ) { yourBro[0] = 'ie5'; yourBro[1] = 'Internet Explorer 5+'; }
else if( document.all ) { yourBro[0] = 'ie4'; yourBro[1] = 'Internet Explorer 4'; }
else { yourBro[0] = 'oth'; yourBro[1] = 'an unknown browser'; }

//perform checks for different operating systems
if( navigator.userAgent.toLowerCase().indexOf( 'linux' ) + 1 ) { yourBro[2] = 'lin'; yourBro[3] = 'Linux'; }
else if( navigator.userAgent.toLowerCase().indexOf( 'x11' ) + 1 ) { yourBro[2] = 'unx'; yourBro[3] = 'Unix'; }
else if( navigator.userAgent.toLowerCase().indexOf( 'mac' ) + 1 ) { yourBro[2] = 'mac'; yourBro[3] = 'MacOS'; }
else if( navigator.userAgent.toLowerCase().indexOf( 'win' ) + 1 ) { yourBro[2] = 'win'; yourBro[3] = 'Windows'; }
else if( navigator.userAgent.toLowerCase().indexOf( 'webtv' ) + 1 ) { yourBro[2] = 'wtv'; yourBro[3] = 'WebTV Platform'; }
else if( navigator.userAgent.toLowerCase().indexOf( 'netgem' ) + 1 ) { yourBro[2] = 'ngm'; yourBro[3] = 'Netgem'; }
else if( navigator.userAgent.toLowerCase().indexOf( 'opentv' ) + 1 ) { yourBro[2] = 'otv'; yourBro[3] = 'OpenTV Platform'; }
else { yourBro[2] = 'oth'; yourBro[3] = 'an unknown operating system'; }

document.write(' <param name="customParam5" value ="Support-Browser-Simple">');
document.write(' <param name="customValue5" value ="'+yourBro[1]+' :: '+yourBro[3]+'">');

document.write(' <param name="customParam6" value ="Support-URL">');
document.write(' <param name="customValue6" value ="'+window.location.href+'">');


var dateNow = new Date();
document.write(' <param name="customParam7" value ="Support-Browser-Time">');
document.write(' <param name="customValue7" value ="'+dateNow.toGMTString()+'">');

document.write(' <param name="customParam8" value ="Support-Cookies-Has">');
document.write(' <param name="customValue8" value ="'+document.cookie+'">');

document.write(' <param name="customParam9" value ="Support-Server-Time">');
document.write(' <param name="customValue9" value ="'+serverTime+'">');

if ( navigator.plugins )
{
  var pluginString = new String();
  var i;

  for ( i=0; i<navigator.plugins.length; i++ )
  {
    if ( i != 0 )
    {
      pluginString += ' :: ';
    }
    pluginString += navigator.plugins[i].name;
  }

  //pluginString += new String(':: Java '+version);

  document.write(' <param name="customParam10" value ="Support-Browser-Plugins">');
  document.write(' <param name="customValue10" value ="'+pluginString+'">');
}
else
{
  document.write(' <param name="customParam10" value ="Support-Browser-Plugins">');
  document.write(' <param name="customValue10" value ="Unknown">');
}
}

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; 
}

var checkCounter = 0;
var paging = false;
var loaded = false;
window.onerror = trapError;

function trapError(sMsg, sUrl, sLine) {
	if (sMsg=="Object doesn't support this property or method") {
		return true;
	}
	else return false;
}

function _GroopzCheck(status)
{
	if (loaded == false) {		
		checkCounter++
		if (checkCounter<10) 
			setTimeout ("_GroopzCheck ()", 1000)		
	}
	if (document.applets.groopz.isConnected()) {		
		if (paging == true) paging = document.applets.groopz.isPaging();
		if (document.applets.groopz.isOperatorAvailable()) {
			if (paging == true) _GroopzButton_swap(2)
			else _GroopzButton_swap(1)
		} else _GroopzButton_swap(0)
		if (loaded == true) setTimeout ("_GroopzCheck ()", 5000)
		loaded = true;
		
	}	
}	

function _GroopzButton_click()
{
	if (document.applets.groopz.isOperatorAvailable() && paging == false)
	{
		_GroopzButton_swap(2)
		paging = true;
		document.applets.groopz.helpRequest()
	} else if (document.applets.groopz.isOperatorAvailable() == false) {
		if (email=="builtin" && document.applets.groopz.isConnected()) {		
			document.applets.groopz.sendEmail()
		} 
		else if (email=="builtin" && !document.applets.groopz.isConnected()) {
			window.open("mailto:"+emailTo);
		}
		else if (email=="url") {
			window.open(emailURL, emailTarget);
		} 
	}
}

function _GroopzButton_swap(index)
{	
  GroopzIm = document.getElementById( 'idGROOPZ_HEADER' );
  if ( GroopzIm )
  {
    if (document.layers)
      GroopzIm.src = Imagenames[index]
    else if (document.images)
      GroopzIm.src = Imagenames[index]		
  }
}
