var Option_Server = "www.option-line.com";

function LiveChatObject(id)
{
	this.id = id;
	this.LiveChat = Option_LiveChat;
	this.Init = Option_LC_Init;
	this.WriteForm = Option_LC_WriteForm;
	this.Submit = Option_LC_SubmitForm;
	if(LC_Vars) {
		this.Init();
		this.WriteForm();
	}
	return this;
}
function GetChatButton() { return false; }
function GetMidi() { return ""; }
function Option_LC_Init()
{
	var r = /'/g;
	this.m_Owner = ("undefined" != typeof(LC_Owner)) ? LC_Owner.replace(r, '´') : "";
	this.m_Room = ("undefined" != typeof(LC_Room)) ? LC_Room.toString().replace(r, '´') : "";
	this.m_Skin = ("undefined" != typeof(LC_Skin)) ? LC_Skin.replace(r, '´') : "";
	this.m_SkinName = ("undefined" != typeof(LC_SkinName)) ? LC_SkinName.replace(r, '´') : "";
	this.m_Title = ("undefined" != typeof(LC_Title)) ? LC_Title.replace(r, '´') : "";
	this.m_Dir = ("undefined" != typeof(LC_Dir)) ? LC_Dir.replace(r, '´') : "";
	this.m_Avatars = ("undefined" != typeof(LC_Avatars)) ? LC_Avatars.replace(r, '´') : "";
	this.m_Actions = ("undefined" != typeof(LC_Actions)) ? LC_Actions.replace(r, '´') : "";
	this.m_Color = ("undefined" != typeof(LC_Color)) ? LC_Color.replace(r, '´') : "azul";
	this.m_ChatButton = ("undefined" != typeof(LC_Button)) ? LC_Button : 'http://' + Option_LC_Server() + '/livechat/images/option_livechat_logo_' + escape(this.m_Color) + '.gif';
	this.m_Midi = ("undefined" != typeof(LC_Midi)) ? LC_Midi : "";
	this.m_Callbacks = ("undefined" != typeof(LC_Callbacks)) ? LC_Callbacks : "";
	this.m_UseLink = ("undefined" != typeof(LC_UseLink)) ? LC_UseLink : false;
}
function Option_LC_WriteForm()
{
	document.write('<form id="' + this.id + '" name="' + this.id + '" method="POST" target="_LiveChat_Logon" action="http://' + Option_LC_Server() + '/livechat/livechat.asp" onsubmit="return Option_LiveChat()">');
	document.write('<input type="hidden" name="owner" value="' + this.m_Owner + '">');
	document.write('<input type="hidden" name="room_id" value="' + this.m_Room + '">'); 
	document.write('<input type="hidden" name="skin_name" value="' + this.m_SkinName + '">');
	document.write('<input type="hidden" name="skin" value="' + this.m_Skin + '">');
	document.write('<input type="hidden" name="room_title" value="' + this.m_Title + '">');
	document.write('<input type="hidden" name="dir" value="' + this.m_Dir + '">');
	document.write('<input type="hidden" name="avatars" value="' + this.m_Avatars + '">');
	document.write('<input type="hidden" name="actions" value="' + this.m_Actions + '">');
	document.write('<input type="hidden" name="midi" value="' + this.m_Midi + '">');
	document.write('<input type="hidden" name="headercallbacks" value="' + this.m_Callbacks + '">');
	if(this.m_UseLink == false) document.write('<input type="image" src="' + this.m_ChatButton + '" border=0>');
	document.write('</form>');
}
function Option_LC_SubmitForm()
{
	var frm = eval('document.' + this.id);
	if(typeof(frm) != "undefined" && frm != null) {
		Option_LiveChat();
		frm.submit();
	}
	else {
		alert('Chat configurado incorretamente');
	}
}
function Option_LiveChat()
{
	var w = window.screen.availWidth-10;
	var h = window.screen.availHeight-30;
	/*
	var ww = w - (w / 4);
	var hh = h - (h / 4);
	var ll = (w - ww) / 2;
	var tt = (h - hh) / 2;
	var wnd;
	ww = parseInt(ww + '');
	hh = parseInt(hh + '');
	ll = parseInt(ll + '');
	tt = parseInt(tt + '');
	*/
	wnd = window.open('about:blank', '_LiveChat_Logon', 'left=0,top=0,width=' + w + ',height=' + h + ',menubar=no,toolbar=no,status=no,directories=no,resizable=no');
	return (wnd ? true : false)
}
function Option_LC_Server() { return Option_Server; }
function GoChat(o, n, i)
{
	var oldOwner = document.LiveChat.owner.value;
	var oldRoom = document.LiveChat.room_id.value;
	var oldName = document.LiveChat.room_title.value;
	document.LiveChat.owner.value = o;
	document.LiveChat.room_id.value = i;
	document.LiveChat.room_title.value = n;
	document.LiveChat.loadxml.value = '1';
	Option_LiveChat();
	document.LiveChat.submit();
	document.LiveChat.owner.value = oldOwner;
	document.LiveChat.room_id.value = oldRoom;
	document.LiveChat.room_title.value = oldName;
	document.LiveChat.loadxml.value = '0';
	return false;
}
