//===============================
// Kayako LiveResponse
// Copyright (c) 2001-2010
// http://www.kayako.com
// License: http://www.kayako.com/license.txt
//===============================

var sessionid_zxcav46c = "zyyvh1y57w2vd1yuuepfp1zefde8y1zx";
var country_zxcav46c = "United States";
var countrycode_zxcav46c = "us";
var hasnotes_zxcav46c = "0";
var campaignid_zxcav46c = "";
var campaigntitle_zxcav46c = "";
var isfirsttime_zxcav46c = 1;
var timer_zxcav46c = 0;
var imagefetch_zxcav46c = 19;
var updateurl_zxcav46c = "";
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_zxcav46c = 0;
var title = document.title;
var proactiveImageUse_zxcav46c = 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_zxcav46c(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_zxcav46c()
{
	var num;
	now=new Date();
	num=(now.getSeconds());
	num=num+1;
	return num;
}

function getCookie_zxcav46c(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_zxcav46c(name) {
	var expiry = new Date();
	document.cookie = name + "=" + "; expires=Thu, 01-Jan-70 00:00:01 GMT" +  "; path=/";
}

function elapsedTime_zxcav46c()
{
	if (timer_zxcav46c < 3600)
	{
		timer_zxcav46c++;
		imagefetch_zxcav46c++;

		if (imagefetch_zxcav46c > 20) {
			imagefetch_zxcav46c = 0;
			doStatusLoop_zxcav46c();
		}

		setTimeout("elapsedTime_zxcav46c();", 1000);
	}
}

function doStatusLoop_zxcav46c() {
	date1 = new Date();
	updateurl_zxcav46c = "//support.ticketseating.com/visitor/index.php?_m=livesupport&_a=updatefootprint&time="+date1.getTime()+"&rand="+doRand_zxcav46c()+"&url="+encodeURIComponent(window.location)+"&isfirsttime="+encodeURIComponent(isfirsttime_zxcav46c)+"&sessionid="+encodeURIComponent(sessionid_zxcav46c)+"&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_zxcav46c)+"&countrycode="+encodeURIComponent(countrycode_zxcav46c)+"&hasnotes="+encodeURIComponent(hasnotes_zxcav46c)+"&campaignid="+encodeURIComponent(campaignid_zxcav46c)+"&campaigntitle="+encodeURIComponent(campaigntitle_zxcav46c);
//	alert(updateurl);

	proactiveImageUse_zxcav46c = new Image();
	proactiveImageUse_zxcav46c.onload = imageLoaded_zxcav46c;
	proactiveImageUse_zxcav46c.src = updateurl_zxcav46c;

//	window.location.href = updateurl_zxcav46c;

	isfirsttime_zxcav46c = 0;
}

function startChat_zxcav46c(proactive)
{
	isChatRunning_zxcav46c = 1;

	docWidth = (winW-500)/2;
	docHeight = (winH-500)/2;

	chatwindow = window.open("http://support.ticketseating.com/visitor/index.php?_m=livesupport&_a=startclientchat&sessionid="+sessionid_zxcav46c+"&proactive="+proactive+"&departmentid=0&randno="+doRand_zxcav46c()+"&fullname=&email=","customerchat"+doRand_zxcav46c(), "toolbar=0,location=0,directories=0,status=1,menubar=0,scrollbars=0,resizable=1,width=500,height=500,left="+docWidth+",top="+docHeight);

	hideProactiveChatData_zxcav46c();
}

function imageLoaded_zxcav46c() {
	if (!proactiveImageUse_zxcav46c)
	{
		return;
	}
	proactiveAction = proactiveImageUse_zxcav46c.width;

	if (proactiveAction == 3)
	{
		doProactiveForced_zxcav46c();
	} else if (proactiveAction == 4) {
		displayProactiveChatData_zxcav46c();
	} else {
	}
}

function writeProactiveRequestData_zxcav46c()
{
	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+"\"></div>";

	if(livechatdiv) {
		var element = document.createElement("div"); 
		element.innerHTML = writedata; 
		livechatdiv.appendChild(element);
	}

}

function displayProactiveChatData_zxcav46c()
{

	var writedata = "";
	writedata += "<div style=\"width:443px;height:2227px;background:url(\'https://www.ticketseating.com/com/img/livechat/proactive-bg.png\') no-repeat;\"><div style=\"padding-top:170px;\" align=\"center\"><table cellpadding=\"0\" cellspacing=\"0\"><tr><td style=\"padding-right:50px;\"><a href=\"javascript:doProactiveRequest_zxcav46c();\"><img src=\"//www.ticketseating.com/com/img/livechat/chat-now.gif\" /></a></td><td><a href=\"javascript:closeProactiveRequest_zxcav46c();\"><img src=\"//www.ticketseating.com/com/img/livechat/no-thanks.gif\" /></a></td></tr></table></div></div>";
	document.getElementById("proactivechatdiv").innerHTML = writedata;

	writeObj = browserObject_zxcav46c("proactivechatdiv");
	if (writeObj)
	{
		docWidth = (winW-450)/2;
		docHeight = (winH-400)/2;
		writeObj.top = docWidth;
		writeObj.left = docHeight;
	}
	switchDisplay_zxcav46c("proactivechatdiv");
}

function hideProactiveChatData_zxcav46c()
{
	hideDisplay_zxcav46c("proactivechatdiv");
}

function doProactiveForced_zxcav46c()
{
	switchDisplay_zxcav46c("proactivechatdiv");
	startChat_zxcav46c("6");
}

function doProactiveRequest_zxcav46c()
{
	startChat_zxcav46c("4");
}

function closeProactiveRequest_zxcav46c()
{
	rejectProactive = new Image();
	date1 = new Date();
	rejectProactive.src = "http://support.ticketseating.com/visitor/index.php?_m=livesupport&_a=resetproactivestatus&time="+date1.getTime()+"&rand="+doRand_zxcav46c()+"&sessionid="+sessionid_zxcav46c;

	hideProactiveChatData_zxcav46c();
}

function switchDisplay_zxcav46c(objid)
{
	result = browserObject_zxcav46c(objid);
	if (!result)
	{
		return;
	}

	if (result.style.display == "none")
	{
		result.style.display = "block";
	} else {
		result.style.display = "none";
	}
}

function hideDisplay_zxcav46c(objid)
{
	result = browserObject_zxcav46c(objid);
	if (!result)
	{
		return;
	}

	result.style.display = "none";
}

function resetChatStatus_zxcav46c()
{
	isChatRunning_zxcav46c = 0;
}

function runURL_zxcav46c(url)
{
	runURLImg = new Image();
	date1 = new Date();
	runURLImg.src = url;
}


var livechatdiv = document.getElementById("livechat");
if(livechatdiv) livechatdiv.innerHTML = "";


writeProactiveRequestData_zxcav46c();
elapsedTime_zxcav46c();

if(livechatdiv) {
	var element = document.createElement("div"); 
	element.innerHTML = "<a href=\"javascript:startChat_zxcav46c(\'0\');\" onMouseOver=\"window.status=\'Live Support is offline. Click here to leave a message.\'; return true;\" onMouseOut=\"window.status=\'\'; return true;\"><img src=\"//www.ticketseating.com/com/img/livechat/call-toll-free.gif\" border=\"0\" alt=\"Live Support is offline. Click here to leave a message.\" title=\"Live Support is offline. Click here to leave a message.\"></a>";
	livechatdiv.appendChild(element);
}


