//---------------------------------------------------------------------------------------------
//
// Web chat function to detect if instanthchatoption divs are on page - Hannah 15/04/2008
//
//---------------------------------------------------------------------------------------------

function checkWebChatDiv() {
	var div1 = document.getElementById('instantchatoption');
	var div2 = document.getElementById('instantchatoption2');
	var div3 = document.getElementById('instantchatoption3');

	if (div1) {
		document.write('<'+'img src="https://admin.instantservice.com/resources/smartbutton/5982/18940/available.gif?'+Math.floor(Math.random()*10001)+'"style="width:0;height:0;visibility:hidden;position:absolute;" onload="Javascript: document.getElementById(\'instantchatoption\').style.display = \'block\';" onerror="Javascript: document.getElementById(\'instantchatoption\').style.display = \'none\';">');
	}
	if (div2) {
		document.write('<'+'img src="https://admin.instantservice.com/resources/smartbutton/5982/18940/available.gif?'+Math.floor(Math.random()*10001)+'"style="width:0;height:0;visibility:hidden;position:absolute;" onload="Javascript: document.getElementById(\'instantchatoption2\').style.display = \'block\';" onerror="Javascript: document.getElementById(\'instantchatoption2\').style.display = \'none\';">');
	}
	if (div3) {
		document.write('<'+'img src="https://admin.instantservice.com/resources/smartbutton/5982/18940/available.gif?'+Math.floor(Math.random()*10001)+'"style="width:0;height:0;visibility:hidden;position:absolute;" onload="Javascript: document.getElementById(\'instantchatoption3\').style.display = \'block\';" onerror="Javascript: document.getElementById(\'instantchatoption3\').style.display = \'none\';">');
	}
}

function readCookie(cookieName) {
	var theCookie = "" + document.cookie;
	var ind = theCookie.indexOf(cookieName);
	if (ind==-1 || cookieName=="") return ""; 
	var ind1 = theCookie.indexOf(';',ind);
	if (ind1==-1) ind1 = theCookie.length; 
	return unescape(theCookie.substring(ind+cookieName.length+1,ind1));
}

function launchChat() {
	var SIVISITOR = readCookie("SIVISITOR");
	if (SIVISITOR != null && SIVISITOR != '') {
		window.open('http://axapppquote.metafaq.com/templates/axapppquote/main/chatpage?simigvis=' + SIVISITOR,'custclient','width=500,height=320,scrollbars=0');
	} else {
		window.open('http://axapppquote.metafaq.com/templates/axapppquote/main/chatpage','custclient','width=500,height=320,scrollbars=0');
	}

}
