function MultiContact() {
	this.callbackXmlScript = '';
	
	this.ShowLiveChat = ShowLiveChat;
	this.ShowCallBack = ShowCallBack;
	this.SendCallBack = SendCallBack;
	this.SetCallbackXmlScript = SetCallbackXmlScript;
	this.ShowContactOptions = ShowContactOptions;
	this.ShowPhoneAnim = ShowPhoneAnim;
}

function ShowLiveChat() {
	var contactContainer = document.getElementById('multiContactContainer'+this.gadgetId);
	var containerHeight = this.currentPage.GetObjectHeight(contactContainer);
	contactContainer.style.visibility = 'hidden';
	document.getElementById('chatStart'+this.gadgetId).style.height = containerHeight+'px';
	document.getElementById('chatWindow'+this.gadgetId).style.height = containerHeight+'px';
	document.getElementById('chatStart'+this.gadgetId).style.visibility = 'visible';
}

function ShowCallBack() {
	var contactContainer = document.getElementById('multiContactContainer'+this.gadgetId);
	var containerHeight = this.currentPage.GetObjectHeight(contactContainer);
	contactContainer.style.visibility = 'hidden';
	document.getElementById('callbackDiv'+this.gadgetId).style.height = containerHeight+'px';
	document.getElementById('callbackDiv'+this.gadgetId).style.visibility = 'visible';
}

function SendCallBack(callbackButton) {
	var customerNameCheck = document.getElementById('callbackCustomerName'+this.gadgetId).value;
	var telCheck = document.getElementById('callbackTel'+this.gadgetId).value;
	while (customerNameCheck.indexOf(' ') > -1) {
		customerNameCheck = customerNameCheck.replace(' ', '');
	}
	while (telCheck.indexOf(' ') > -1) {
		telCheck = telCheck.replace(' ', '');
	}
	var formError = '';
	if (customerNameCheck == '') formError += "\n- Your name";
	if (telCheck == '') formError += "\n- Your telephone number";
	if (formError != '') {
		alert("Please fill in the following information to continue:\n"+formError);
	} else {
		document.getElementById('callbackButtons'+this.gadgetId).style.display = 'none';
		document.getElementById('CallbackFormSendMessage'+this.gadgetId).style.display = '';
		
		var callbackXml = new XmlRead();
		callbackXml.SetXmlScript(this.callbackXmlScript);
		callbackXml.AddParameterField('customername', document.getElementById('callbackCustomerName'+this.gadgetId).value);
		callbackXml.AddParameterField('telephone', document.getElementById('callbackTel'+this.gadgetId).value);
		if (callbackXml.GetXmlRows()) {
			if (callbackXml.Read()) {
				document.getElementById('callbackDiv'+this.gadgetId).style.visibility = 'hidden';
				document.getElementById('callbackMessage'+this.gadgetId).style.visibility = 'visible';
				document.getElementById('callbackButtons'+this.gadgetId).style.display = '';
				document.getElementById('CallbackFormSendMessage'+this.gadgetId).style.display = 'none';
			}
		}
	}
}

function SetCallbackXmlScript(scriptName) {
	this.callbackXmlScript = scriptName;
}

function ShowContactOptions() {
	document.getElementById('multiContactContainer'+this.gadgetId).style.visibility = 'visible';
	var hideList = new Array('chatStart', 'chatWindow', 'callbackDiv', 'callbackMessage');
	var i;
	for (i = 0; i < hideList.length; i++) {
		if (document.getElementById(hideList[i]+this.gadgetId)) document.getElementById(hideList[i]+this.gadgetId).style.visibility = 'hidden';
	}
}

function ShowPhoneAnim(swfFile, width, height) {
	var phoneSwf = new SWFObject(swfFile, "AnimPhone"+this.gadgetId, width, height, "6,0,0,0", "#ffffff");
	phoneSwf.addParam("wmode", "transparent");
	phoneSwf.write("AnimPhone"+this.gadgetId);
}

MultiContact.prototype = new LiveChat();
