//===============================
// Kayako LiveResponse
// Copyright (c) 2001-2010
// http://www.kayako.com
// License: http://www.kayako.com/license.txt
//===============================

var sessionid_95d4135e = "ead4c710162396cb8d3c1cc8c92c45e0";
var country_95d4135e = "United States";
var countrycode_95d4135e = "us";
var hasnotes_95d4135e = "0";
var campaignid_95d4135e = "";
var campaigntitle_95d4135e = "";
var isfirsttime_95d4135e = 1;
var timer_95d4135e = 0;
var imagefetch_95d4135e = 19;
var updateurl_95d4135e = "";
var screenHeight = window.screen.availHeight;
var screenWidth = window.screen.availWidth;
var colorDepth = window.screen.colorDepth;
var timeNow = new Date();
var referrer = escape(document.referrer);
var windows, mac, linux;
var ie, op, moz, misc, browsercode, browsername, browserversion, operatingsys;
var dom, ienew, ie4, ie5, ie6, moz_rv, moz_rv_sub, ie5mac, ie5xwin, opnu, op4, op5, op6, op7, saf, konq;
var appName, appVersion, userAgent;
var appname = navigator.appName;
var appVersion = navigator.appVersion;
var userAgent = navigator.userAgent;
var dombrowser = "default";
var isChatRunning_95d4135e = 0;
var title = document.title;
var proactiveImageUse_95d4135e = new Image();
windows = (appVersion.indexOf('Win') != -1);
mac = (appVersion.indexOf('Mac') != -1);
linux = (appVersion.indexOf('Linux') != -1);
if (!document.layers) {
	dom = (document.getElementById ) ? document.getElementById : false;
} else {
	dom = false;
}
  var myWidth = 0, myHeight = 0;
  if( typeof( window.innerWidth ) == 'number' ) {
    //Non-IE
    myWidth = window.innerWidth;
    myHeight = window.innerHeight;
  } else if( document.documentElement &&
      ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
    //IE 6+ in 'standards compliant mode'
    myWidth = document.documentElement.clientWidth;
    myHeight = document.documentElement.clientHeight;
  } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
    //IE 4 compatible
    myWidth = document.body.clientWidth;
    myHeight = document.body.clientHeight;
  }
winH = myHeight;
winW = myWidth;
misc=(appVersion.substring(0,1) < 4);
op=(userAgent.indexOf('Opera') != -1);
moz=(userAgent.indexOf('Gecko') != -1);
ie=(document.all && !op);
saf=(userAgent.indexOf('Safari') != -1);
konq=(userAgent.indexOf('Konqueror') != -1);

if (op) {
	op_pos = userAgent.indexOf('Opera');
	opnu = userAgent.substr((op_pos+6),4);
	op5 = (opnu.substring(0,1) == 5);
	op6 = (opnu.substring(0,1) == 6);
	op7 = (opnu.substring(0,1) == 7);
} else if (moz){
	rv_pos = userAgent.indexOf('rv');
	moz_rv = userAgent.substr((rv_pos+3),3);
	moz_rv_sub = userAgent.substr((rv_pos+7),1);
	if (moz_rv_sub == ' ' || isNaN(moz_rv_sub)) {
		moz_rv_sub='';
	}
	moz_rv = moz_rv + moz_rv_sub;
} else if (ie){
	ie_pos = userAgent.indexOf('MSIE');
	ienu = userAgent.substr((ie_pos+5),3);
	ie4 = (!dom);
	ie5 = (ienu.substring(0,1) == 5);
	ie6 = (ienu.substring(0,1) == 6);
}

if (konq) {
	browsercode = "KO";
	browserversion = appVersion;
	browsername = "Konqueror";
} else if (saf) {
	browsercode = "SF";
	browserversion = appVersion;
	browsername = "Safari";
} else if (op) {
	browsercode = "OP";
	if (op5) {
		browserversion = "5";
	} else if (op6) {
		browserversion = "6";
	} else if (op7) {
		browserversion = "7";
	} else {
		browserversion = appVersion;
	}
	browsername = "Opera";
} else if (moz) {
	browsercode = "MO";
	browserversion = appVersion;
	browsername = "Mozilla";
} else if (ie) {
	browsercode = "IE";
	if (ie4) {
		browserversion = "4";
	} else if (ie5) {
		browserversion = "5";
	} else if (ie6) {
		browserversion = "6";
	} else {
		browserversion = appVersion;
	}
	browsername = "Internet Explorer";
}

if (windows) {
	operatingsys = "Windows";
} else if (linux) {
	operatingsys = "Linux";
} else if (mac) {
	operatingsys = "Mac";
} else {
	operatingsys = "Unkown";
}

if (document.getElementById)
{
	dombrowser = "default";
} else if (document.layers) {
	dombrowser = "NS4";
} else if (document.all) {
	dombrowser = "IE4";
}

function browserObject_95d4135e(objid)
{
	if (dombrowser == "default")
	{
		return document.getElementById(objid);
	} else if (dombrowser == "NS4") {
		return document.layers[objid];
	} else if (dombrowser == "IE4") {
		return document.all[objid];
	}
}

function doRand_95d4135e()
{
	var num;
	now=new Date();
	num=(now.getSeconds());
	num=num+1;
	return num;
}

function getCookie_95d4135e(name) {
	var crumb = document.cookie;
	var index = crumb.indexOf(name + "=");
	if (index == -1) return null;
	index = crumb.indexOf("=", index) + 1;
	var endstr = crumb.indexOf(";", index);
	if (endstr == -1) endstr = crumb.length;
	return unescape(crumb.substring(index, endstr));
}

function deleteCookie_95d4135e(name) {
	var expiry = new Date();
	document.cookie = name + "=" + "; expires=Thu, 01-Jan-70 00:00:01 GMT" +  "; path=/";
}

function elapsedTime_95d4135e()
{
	if (timer_95d4135e < 3600)
	{
		timer_95d4135e++;
		imagefetch_95d4135e++;

		if (imagefetch_95d4135e > 20) {
			imagefetch_95d4135e = 0;
			doStatusLoop_95d4135e();
		}

		setTimeout("elapsedTime_95d4135e();", 1000);
	}
}

function doStatusLoop_95d4135e() {
	date1 = new Date();
	updateurl_95d4135e = "http://memberservices.learningbygrace.org/visitor/index.php?_m=livesupport&_a=updatefootprint&time="+date1.getTime()+"&rand="+doRand_95d4135e()+"&url="+encodeURIComponent(window.location)+"&isfirsttime="+encodeURIComponent(isfirsttime_95d4135e)+"&sessionid="+encodeURIComponent(sessionid_95d4135e)+"&referrer="+encodeURIComponent(document.referrer)+"&resolution="+encodeURIComponent(screenWidth+"x"+screenHeight)+"&colordepth="+encodeURIComponent(colorDepth)+"&platform="+encodeURIComponent(navigator.platform)+"&appversion="+encodeURIComponent(navigator.appVersion)+"&appname="+encodeURIComponent(navigator.appName)+"&browsercode="+encodeURIComponent(browsercode)+"&browserversion="+encodeURIComponent(browserversion)+"&browsername="+encodeURIComponent(browsername)+"&operatingsys="+encodeURIComponent(operatingsys)+"&pagetitle="+encodeURIComponent(title)+"&country="+encodeURIComponent(country_95d4135e)+"&countrycode="+encodeURIComponent(countrycode_95d4135e)+"&hasnotes="+encodeURIComponent(hasnotes_95d4135e)+"&campaignid="+encodeURIComponent(campaignid_95d4135e)+"&campaigntitle="+encodeURIComponent(campaigntitle_95d4135e);
//	alert(updateurl);

	proactiveImageUse_95d4135e = new Image();
	proactiveImageUse_95d4135e.onload = imageLoaded_95d4135e;
	proactiveImageUse_95d4135e.src = updateurl_95d4135e;

//	window.location.href = updateurl_95d4135e;

	isfirsttime_95d4135e = 0;
}

function startChat_95d4135e(proactive)
{
	isChatRunning_95d4135e = 1;
	docWidth = (winW-500)/2;
	docHeight = (winH-480)/2;
	
	/**
	 * @author DMM added templateGroup to this function
	 */
	var kTemplateGroup = (typeof kayakoTemplateGroup != "undefined" && kayakoTemplateGroup != "") ? "&group=" + kayakoTemplateGroup : "";
	var kAcademy  = (typeof kayakoAcademy != "undefined" && kayakoAcademy != "") ? "&academy=" + kayakoAcademy : "";
	var kUsertype = (typeof kayakoUsertype != "undefined" && kayakoUsertype != "") ? "&usertype=" + kayakoUsertype : "";
	var kUserid        = (typeof kayakoUserid != "undefined" && kayakoUserid != "") ? "&userid=" + kayakoUserid : "";
	var kUserfullname  = (typeof kayakoUserfullname != "undefined" && kayakoUserfullname != "") ? kayakoUserfullname : "";
	var kUseremail     = (typeof kayakoUseremail != "undefined" && kayakoUseremail != "") ? "&email=" + kayakoUseremail : "";
	var kClassname     = (typeof kayakoClassname != "undefined" && kayakoClassname != "") ? "&classname=" + kayakoClassname : ""; 
	var departmentid   = (typeof proactiveDepartmentid != "undefined" && proactiveDepartmentid != "") ? proactiveDepartmentid : '3';
	
	chatwindow = window.open("http://memberservices.learningbygrace.org/visitor/index.php?_m=livesupport&_a=startclientchat&sessionid="+sessionid_95d4135e+"&proactive="+proactive+"&departmentid=" + departmentid + "&randno="+doRand_95d4135e()+"&fullname=" + ((kUserfullname != "") ? kUserfullname : "") + "&email=" + ((kUseremail != "") ? kUseremail : "") + kTemplateGroup + kAcademy + kUsertype + kUserid + kClassname,"customerchat"+doRand_95d4135e(), "toolbar=0,location=0,directories=0,status=1,menubar=0,scrollbars=0,resizable=1,width=500,height=480,left="+docWidth+",top="+docHeight);

	hideProactiveChatData_95d4135e();
}

function imageLoaded_95d4135e() {
	if (!proactiveImageUse_95d4135e)
	{
		return;
	}
	proactiveAction = proactiveImageUse_95d4135e.width;

	if (proactiveAction == 3)
	{
		doProactiveForced_95d4135e();
	} else if (proactiveAction == 4) {
		displayProactiveChatData_95d4135e();
	} else {
	}
}

function writeProactiveRequestData_95d4135e()
{
	docWidth = (winW-450)/2;
	docHeight = (winH-400)/2;
	classData = "DISPLAY: none; FLOAT: left; POSITION: absolute; TOP:"+docHeight+"px; LEFT:"+docWidth+"px; WIDTH: 450px; HEIGHT: 400px; Z-INDEX: 500;";
	writedata = "<style type=\"text/css\"> <!-- #proactivechatdiv { "+classData+" } --> </style>";
	writedata += "<div id=\"proactivechatdiv\" style=\""+classData+"\">";
	writedata += "<table width=\"450\" height=\"200\"  border=\"0\" cellpadding=\"1\" cellspacing=\"0\" style=\"border: #EDF4FF solid 1px;\">  <tr>    <td bgcolor=\"#3894E5\"><table width=\"450\" height=\"200\"  border=\"0\" cellpadding=\"0\" cellspacing=\"0\">      <tr>        <td align=\"left\" valign=\"top\" bgcolor=\"#EDF4FF\"><table width=\"100%\"  border=\"0\" cellpadding=\"0\" cellspacing=\"0\">          <tr bgcolor=\"#FFFFFF\">            <td height=\"29\" colspan=\"2\" align=\"center\" valign=\"top\"><img src=\"http://memberservices.learningbygrace.org/includes/chat_image_header.php?image=jubilee\"></td>          </tr>          <tr align=\"center\" bgcolor=\"#3894E5\">            <td height=\"1\" colspan=\"2\" valign=\"top\"><img src=\"http://memberservices.learningbygrace.org/themes/client_default/space.gif\" width=\"1\" height=\"1\"></td>          </tr>          <tr align=\"center\">            <td colspan=\"2\" valign=\"top\">                  <font size=\"2\" face=\"Verdana, Arial, Helvetica, sans-serif\"><br>                  <p style=\"font-size: 10pt;\">                      Greetings, in the name of the Lord!  I am available to answer any questions you might have-please ask!!                   </p>                  <p style=\"font-size: 10pt;\">                      - Krista, The Grace Academy Admissions Counselor                  </p>                  </font>                  <br/>                  <br/>            </td>          </tr>          <tr>            <td width=\"50%\" align=\"center\" valign=\"top\">                <a href=\"javascript:doProactiveRequest_95d4135e(\'91\');\" style=\"color: #FF3300; padding-bottom: 10px; text-decoration: none; font-weight: bold; font-size: 12pt; font-family: arial;\">Yes, please tell me more</a>               </td>            <td width=\"50%\" align=\"center\" valign=\"top\">                <a href=\"javascript:closeProactiveRequest_95d4135e();\" style=\"color: #6666FF; padding-bottom: 10px; text-decoration: none; font-weight: bold; font-size: 12pt; font-family: arial;\">No thank you</a>            </td>          </tr>        </table></td>      </tr>    </table></td>  </tr></table>";
	writedata += "</div>";
	document.write(writedata);
}

function displayProactiveChatData_95d4135e()
{
	writeObj = browserObject_95d4135e("proactivechatdiv");
	if (writeObj)
	{
		docWidth = (winW-450)/2;
		docHeight = (winH-400)/2;
		writeObj.top = docWidth;
		writeObj.left = docHeight;
	}
	switchDisplay_95d4135e("proactivechatdiv");
}

function hideProactiveChatData_95d4135e()
{
	hideDisplay_95d4135e("proactivechatdiv");
}

function doProactiveForced_95d4135e()
{
	switchDisplay_95d4135e("proactivechatdiv");
	startChat_95d4135e("6");
}

/**
 * @param string proactiveDepartmentid - the number, as a string, of the departmentid to send the proactive chat to
 */
function doProactiveRequest_95d4135e(departmentidToUse)
{
	if(typeof departmentidToUse != 'undefined') proactiveDepartmentid = departmentidToUse;
	
	startChat_95d4135e('0'); //"4"
}

function closeProactiveRequest_95d4135e()
{
	rejectProactive = new Image();
	date1 = new Date();
	rejectProactive.src = "http://memberservices.learningbygrace.org/visitor/index.php?_m=livesupport&_a=resetproactivestatus&time="+date1.getTime()+"&rand="+doRand_95d4135e()+"&sessionid="+sessionid_95d4135e;

	hideProactiveChatData_95d4135e();
}

function switchDisplay_95d4135e(objid)
{
	result = browserObject_95d4135e(objid);
	if (!result)
	{
		return;
	}

	if (result.style.display == "none")
	{
		result.style.display = "block";
	} else {
		result.style.display = "none";
	}
}

function hideDisplay_95d4135e(objid)
{
	result = browserObject_95d4135e(objid);
	if (!result)
	{
		return;
	}

	result.style.display = "none";
}

function resetChatStatus_95d4135e()
{
	isChatRunning_95d4135e = 0;
}

function runURL_95d4135e(url)
{
	runURLImg = new Image();
	date1 = new Date();
	runURLImg.src = url;
}

writeProactiveRequestData_95d4135e();
elapsedTime_95d4135e();
document.write("<a href=\"javascript:startChat_95d4135e(\'0\');\" onMouseOver=\"window.status=\'Live Support is away\'; return true;\" onMouseOut=\"window.status=\'\'; return true;\">            <img src=\"https://secure.learningbygrace.org/images/kayako/repoffline.gif\" border=\"0\" alt=\"Live Support is away\" title=\"Live Support is away\">    </a>");
