// ==============================================================================
// Client~ConneXion LiveStats & Chat Gateway script http://www.clientconnexion.com
// ==============================================================================
// This script should be placed in the root directory of your web site. It should
// be included in each page you want to track.
// Place the Include on your page at the place where you want the Click-To-Chat 
// graphic to appear.
// ===============================================================================

var sWOGateway       = "204.232.154.240:8080";    // specify the external address:port of the Client~ConneXion Gateway server
var sWOGatewaySSL    = "204.232.154.240:8443"; // specify the external address:port of the Client~ConneXion Gateway server SSL interface
var sWODomain        = "fordmercuryfloresville.ancira.com";  // the domain you are monitoring
var sWODepartment    = ""; // optional department
var sWOChatstart     = "http://204.232.154.240/chat/chatstart.htm"; // url to the chatstart.htm page 
var sWOLanguage      = ""; // language for the chat window
var sWOBackgroundURL = ""; // optional custom background url
var sWOResponse      = ""; // set to a blank string if you do NOT want a visible chat link
var sWOInvite        = "Y";  // set to a blank string if you do NOT want invite requests to be polled
var sWOPreselect     = "D"; // set to D to pre-select Department before starting chat, O to pre-select Operator

var sWOSession;
var sWOUrl;
var sWOUser="";
var sWOPage="";
var sWOProtocol=window.location.protocol;

// specify a user name here if you want a specific user name instead of a session cookie
// sWOUser="my user";

// specify a page name here if you want a specific page name shown in Client~ConneXion instead of the window.location
// sWOPage="my page";

var sWOCost=0;    // specify a visit cost 
var sWORevenue=0; // specify the revenue generated by the visitor

// optional contact information. Specify values for these variables if you want contact info for the visitor passed to Client~ConneXion
var sWOName="";
var sWOCompany="";
var sWOEmail="";
var sWOTelephone="";

if(sWOUser==""){
	// create a unique session cookie for the visitor
	var dt=new Date();
	var sWOCookie=document.cookie.toString();
	if(sWOCookie.indexOf("Client~ConneXion")==-1){
		sWOSession=parseInt(Math.random()*1000)+"-"+dt.getTime();
		document.cookie="Client~ConneXion="+sWOSession+";expires=Fri, 31-Dec-2010 00:00:00 GMT;";
	}
	sWOCookie=document.cookie.toString();
	if(sWOCookie.indexOf('Client~ConneXion')==-1){
		sWOSession="";
	} else {
		var s=sWOCookie.indexOf("Client~ConneXion=")+7;
		var e=sWOCookie.indexOf(";",s);
		if(e==-1)e=sWOCookie.length;
		sWOSession=sWOCookie.substring(s,e);
	}
}

if(sWOProtocol=="https:")sWOGateway=sWOGatewaySSL;
if(sWOUser!="")sWOSession=sWOUser;
if(sWOPage=="")sWOPage=escape(window.location);
if(sWOProtocol=="file:")sWOProtocol="http:";

sWOUrl=sWOProtocol+"//"+sWOGateway+"/stat.gif?u="+sWOSession+"&d="+sWODomain;
if(sWODepartment.length>0)sWOUrl+="&t="+escape(sWODepartment);
sWOUrl+="&p='"+sWOPage+"'&r='"+escape(document.referrer)+"'";
if(sWOCost!=0)sWOUrl+="&c="+sWOCost;
if(sWORevenue!=0)sWOUrl+="&v="+sWORevenue;
if(sWOName!="" || sWOCompany!="" || sWOEmail!="" || sWOTelephone!="")sWOUrl+="&n="+sWOName+"|"+sWOCompany+"|"+sWOEmail+"|"+sWOTelephone;
if(sWOResponse==""){
	if(document.layers)document.write("<layer name=\"Client~ConneXion\" visibility=hide><img src=\""+sWOUrl+"\" height=1 width=1><\/layer>");
	else document.write("<div id=\"Client~ConneXion\" STYLE=\"position:absolute;visibility:hidden;\"><img src=\""+sWOUrl+"\" height=1 width=1><\/div>");
} else {
	sWOUrl+="&response=g";sWOChatstart+="?domain="+sWODomain+"&lang="+sWOLanguage;
	if(sWOBackgroundURL!="")sWOChatstart+="&bg="+sWOBackgroundURL;
	if(sWODepartment.length>0)sWOChatstart+="&dept="+escape(sWODepartment);
	if(sWOPreselect.length>0)sWOChatstart+="&select="+sWOPreselect;
	document.write("<a target=\"_blank\" href=\""+sWOChatstart+"\" onclick=\"javascript:window.open('"+sWOChatstart+"','new_win','width=484,height=361');return false;\"><img border=\"0\" src=\""+sWOUrl+"\"><\/a>");
}
sWOUrl=sWOProtocol+"//"+sWOGateway+"/invite.js?domain="+sWODomain;
if(sWOInvite=="Y")document.write("<sc"+"ript language='Javascript' src='"+sWOUrl+"'><\/scr"+"ipt>");



//<<-- added by maxwell, on 2010/12/26

// configure the delay time for the overlay image's appearance in seconds.
var config_appearance_time = 4;

// configure where the overlay image is placed
// options
//		1 : bottom right (default)
//		2 : bottom left
//		3 : top right
//		4 : top left
var config_overlay_position = 1;

// time and day or operation, turn off the overlay image when the business is closed, like sunday or holiday.
// avaliable 
//		{ "2010/12/29 12:30:50", "2010/12/29 12:30", "2010/12/29 12", "2010/12/29", "2010/12", "2010" }   
var config_datetime_operation = new Array("2010/12/27 00:41", "2010/12/20");



var timer = null;
var turn_off = false;

if (config_datetime_operation.length > 0) {
	var now = new Date();

	for (var i = 0; i < config_datetime_operation.length; i++) {
		var date_time = config_datetime_operation[i].split(" ");
		var date = date_time[0];
		var time = (date_time[1] == null) ? "00:00:00" : date_time[1];

		var year_month_day = date.split("/");
		var year	= parseInt(year_month_day[0]);
		var month	= parseInt(year_month_day[1]);
		var day		= parseInt(year_month_day[2]);

		var hours_minutes_seconds = time.split(":");
		var hours	= parseInt(hours_minutes_seconds[0]);
		var minutes	= parseInt(hours_minutes_seconds[1]);
		var seconds	= parseInt(hours_minutes_seconds[2]);

		if (!isNaN(year) && isNaN(month) && isNaN(day) && isNaN(hours) && isNaN(minutes)) {
			if (year == now.getYear() + 1900) {
				turn_off = true;
			}
		} else if (!isNaN(year) && !isNaN(month) && isNaN(day) && isNaN(hours) && isNaN(minutes)) {
			if (year == now.getYear() + 1900 && month == now.getMonth() + 1) {
				turn_off = true;	
			}
		} else if (!isNaN(year) && !isNaN(month) && !isNaN(day) && isNaN(hours) && isNaN(minutes)) {
			if (year == now.getYear() + 1900 && month == now.getMonth() + 1 && day == now.getDate()) {
				turn_off = true;
			}
		} else if (!isNaN(year) && !isNaN(month) && !isNaN(day) && !isNaN(hours) && isNaN(minutes)) {
			if (year == now.getYear() + 1900 && month == now.getMonth() + 1 && day == now.getDate() && hours == now.getHours()) {
				turn_off = true;
			}
		} else if (!isNaN(year) && !isNaN(month) && !isNaN(day) && !isNaN(hours) && !isNaN(minutes)) {
			if (year == now.getYear() + 1900 && month == now.getMonth() + 1 && day == now.getDate() && hours == now.getHours() && minutes == now.getMinutes()) {
				turn_off = true;
			}
		}

	}
}

if (turn_off == false) {
	timer = setTimeout("displayOverlayImage()", config_appearance_time * 1000);
}

function displayOverlayImage()
{
	var overlay = document.getElementById("overlay").style;
	
	switch (config_overlay_position) {
		case 1: // bottom right
			overlay.right = "8px";
			overlay.bottom = "0px";
			
			break;
		case 2: // bottom left
			overlay.left = "8px";
			overlay.bottom = "0px";

			break;
		case 3: // top right
			overlay.right = "8px";
			overlay.top = "0px";

			break;
		case 4: // top left
			overlay.left = "8px";
			overlay.top = "0px";

			break;
		default: // bottom right
			overlay.right = "8px";
			overlay.bottom = "0px";
			
			break;
	}

	overlay.position = "fixed";
	overlay.width = "200px";
	overlay.height = "264px";

	overlay.borderStyle = "none";
	overlay.padding = "0";
	overlay.margin = "0";
	overlay.zIndex = "101010";
	overlay.display = "block";


	//var closebutton = document.getElementById("closebutton").style;
	//var overlayimage = document.getElementById("overlayimage").style;
	
	//closebutton.textAlign = "right";
	//closebutton.padding = "0px";

	//overlayimage.textAlign = "center";
	//overlayimage.padding = "0px";

	
	clearTimeout(timer);
}


document.write("<div id=\"overlay\" style=\"display:none;\"><img src=\"http://www.clientconnexion.com/clients/Ancira/floresville/js/closebutton.gif\" width=\"14\" height=\"14\" alt=\"close\" title=\"close\" border=\"0\" onclick=\"document.getElementById('overlay').style.display='none';\" style=\"position:absolute; top:0; right:0; \" /><a href=\"http://204.232.154.240/chat/chatstart.htm?domain=fordmercuryfloresville.ancira.com\" onclick=\"javascript:window.open('http://204.232.154.240/chat/chatstart.htm?domain=fordmercuryfloresville.ancira.com', 'wochat', 'width=484, height=361'); return false;\"><img src=\"http://www.clientconnexion.com/clients/Ancira/floresville/js/anciraford_overlay.gif\" width=\"200\" height=\"264\" border=\"0\" /></a></div>");
//document.write("<div id=\"overlay\" style=\"display:none;\"><div id=\"closebutton\"><a href=\"javascript:void(0);\" onclick=\"document.getElementById('overlay').style.display='none';\"><img src=\"closebutton.gif\" width=\"14\" height=\"14\" border=\"0\" /></a></div><div id=\"overlayimage\"><a href=\"http://204.232.154.240/chat/chatstart.htm?domain=www.clientconnexion.com\" onclick=\"javascript:window.open('http://204.232.154.240/chat/chatstart.htm?domain=www.clientconnexion.com', 'wochat', 'width=484, height=361'); return false;\"><img src=\"overlay_image.gif\" width=\"123\" height=\"40\" border=\"0\" /></a></div></div>");

//-->> added by maxwell, on 2010/12/26

