﻿//Script: Chat Window Script
//Ver: 0.0.1
//Description: The purpose is to dynamically generate the chat window so that it is maintainable and upgradable without the hassle of contacting 
//the cusomter on each upgrade.

//--------creation of main floating div
var lc_floatDiv = document.getElementById("floatDiv");
//---------Creation of minDiv
var lc_minDiv = document.createElement("minDiv");
lc_minDiv.setAttribute("id", "minDiv");
//--------creation of maxBtn
var lc_maxBtn = document.createElement("div");
lc_maxBtn.setAttribute("id", "maxBTN");
//lc_maxBtn.setAttribute("onmouserover", "ddrivetip('Maximize','','52')");
//lc_maxBtn.setAttribute("onmouseout", "hideddrivetip()");
//--------creation of max Anchor
var lc_maxAnchor = document.createElement("a");
lc_maxAnchor.setAttribute("href", "javascript:maximizeWindow()");
//-------creation of max Anchor Image
var lc_maxAnchorImg = document.createElement("img");
lc_maxAnchorImg.setAttribute("id","maxTransImg");
lc_maxAnchorImg.setAttribute("src", _imageURL + "trans.gif");
lc_maxAnchorImg.setAttribute("alt", "");
lc_maxAnchorImg.setAttribute("border", "0");
lc_maxAnchor.appendChild(lc_maxAnchorImg);
lc_maxBtn.appendChild(lc_maxAnchor);
lc_minDiv.appendChild(lc_maxBtn);
lc_floatDiv.appendChild(lc_minDiv);
//--------creation of chatDiv        
var lc_chatDiv = document.createElement("div");
lc_chatDiv.setAttribute("id", "ChatDiv");
lc_floatDiv.appendChild(lc_chatDiv);
//--------Creation of close button
var lc_closeBtn = document.createElement("div");
lc_closeBtn.setAttribute("id", "closeBTN");
//lc_closeBtn.setAttribute("onmouserover", "ddrivetip('Close','','32')");
//lc_closeBtn.setAttribute("onmouseout", "hideddrivetip()");
var lc_closeAnchor = document.createElement("a");
lc_closeAnchor.setAttribute("href", "javascript:CloseChatWindow()");
var lc_closeAnchorImg = document.createElement("img");
lc_closeAnchorImg.setAttribute("src", _imageURL + "trans.gif");
lc_closeAnchorImg.setAttribute("id","closeTransImg");
lc_closeAnchorImg.setAttribute("alt", "Close");
lc_closeAnchorImg.setAttribute("width", "1");
lc_closeAnchorImg.setAttribute("height", "1");
lc_closeAnchorImg.setAttribute("border", "0");
lc_closeAnchor.appendChild(lc_closeAnchorImg);
lc_closeBtn.appendChild(lc_closeAnchor);
lc_chatDiv.appendChild(lc_closeBtn);
//-----Creation of minimize button
var lc_minBtn = document.createElement("div");
lc_minBtn.setAttribute("id", "minBTN");
//lc_minBtn.setAttribute("onmouserover", "ddrivetip('Minimize','','50')");
//lc_minBtn.setAttribute("onmouseout", "hideddrivetip()");
var lc_minAnchor = document.createElement("a");
lc_minAnchor.setAttribute("href", "javascript:minimizeWindow()");
var lc_minAnchorImg = document.createElement("img");
lc_minAnchorImg.setAttribute("src", _imageURL + "trans.gif");
lc_minAnchorImg.setAttribute("id","minTransImg");
lc_minAnchorImg.setAttribute("alt", "Close");
lc_minAnchorImg.setAttribute("width", "1");
lc_minAnchorImg.setAttribute("height", "1");
lc_minAnchorImg.setAttribute("border", "0");
lc_minAnchor.appendChild(lc_minAnchorImg);
lc_minBtn.appendChild(lc_minAnchor);
lc_chatDiv.appendChild(lc_minBtn);
//-------Creation of view complete conversation
var lc_convDiv = document.createElement("div");
if(typeof(lc_typing_status)!="undefined") // If Typing Status is activated
if(lc_typing_status && lc_typing_status!=null){
var lc_typingStatus=document.createElement("img");
lc_typingStatus.setAttribute("id","statusImage");
lc_typingStatus.setAttribute("src",_imageURL +"typingStatus.gif");
lc_typingStatus.style.display="none";
}
var lc_convAnchor = document.createElement("a");
//IF PRINT CONVERSATION OPTION IS PROVIDED INSTEAD OF VIEW COMPLETE CONVERSATION
if(typeof(lc_printstatus)!="undefined"){
	if(lc_printstatus && lc_printstatus!=null){
		
		lc_convAnchor.setAttribute("id", "conversationDIV");
		lc_convAnchor.setAttribute("href", "#");
		lc_convAnchor.innerHTML = "Print<br/> Conversation";
	}
}
else{
	lc_convAnchor.setAttribute("id", "conversationDIV");
	lc_convAnchor.setAttribute("href", "#");
	lc_convAnchor.innerHTML = "View Complete Conversation";
}
//lc_convH1.appendChild(lc_convAnchor);
if(typeof(lc_typing_status)!="undefined")
if(lc_typing_status && lc_typing_status!=null){
lc_convDiv.appendChild(lc_typingStatus);
}
lc_convDiv.appendChild(lc_convAnchor);
lc_chatDiv.appendChild(lc_convDiv);
//-------Creation of chat window textarea
var lc_txtChat = document.createElement("textarea");
lc_txtChat.setAttribute("id", "txtChatWin");
//lc_txtChat.setAttribute("class", "ConvWin");
lc_txtChat.setAttribute("rows", "12");
lc_txtChat.setAttribute("cols", "40");
lc_txtChat.setAttribute("readonly", "readonly");
lc_chatDiv.appendChild(lc_txtChat);
jQuery("#txtChatWin").addClass("ConvWin");
//-----------    
var lc_break = document.createElement("br");
lc_chatDiv.appendChild(lc_break);
//------------Creation of message window textarea
var lc_txtMsg = document.createElement("textarea");
lc_txtMsg.setAttribute("id", "txtMessageWin");
//lc_txtMsg.setAttribute("class", "MessageWin");
//lc_txtMsg.setAttribute("onkeypress", "javascript:ChkEnterKeyPress(event)");
//lc_txtMsg.setAttribute("onkeyup", "javascript:ClearMessageWindow(event)");
lc_txtMsg.setAttribute("rows", "2");
lc_txtMsg.setAttribute("cols", "40");
lc_chatDiv.appendChild(lc_txtMsg);
jQuery("#txtMessageWin").addClass("MessageWin");
//-----Creation of Send Button
var lc_btnSend = document.createElement("input");
lc_btnSend.setAttribute("id", "btnSend");
//lc_btnSend.setAttribute("class", "chatButton");
//lc_btnSend.setAttribute("onclick", "javascript:SendChatMessages()");
lc_btnSend.setAttribute("type", "button");
lc_chatDiv.appendChild(lc_btnSend);
jQuery("#btnSend").addClass("sendButton");
//------Creation of Open Link Button
var lc_btnURL = document.createElement("input");
lc_btnURL.setAttribute("id", "btnURL");
//lc_btnURL.setAttribute("class", "chatButton");
//lc_btnURL.setAttribute("onclick", "javascript:PopPushPage()");
lc_btnURL.setAttribute("type", "button");
lc_chatDiv.appendChild(lc_btnURL);
jQuery("#btnURL").addClass("openButton");

if(typeof(lc_img_anchor)!="undefined"){

 document.getElementById(liveChatStatus).appendChild(lc_anchor);
}







var lc_fadeTimer=null;
		function lc_fade() {
				jQuery("#rotator").fadeOut(2000, lc_callback);
				//image.src = "1.gif";
			}

function lc_callback() {

			var img = new Array();
			img = image.src.split('/');
			if (img[img.length - 1] === "1.png") {
				image.src = _imageURL+"2.png";
			}
			else {
				image.src = _imageURL+"1.png";
			}
			jQuery("#rotator").fadeIn(2000);
		lc_fadeTimer = setTimeout(lc_fade, 6000);

		}
	
//plz insert this code after chat div is created.//
if(typeof(lc_image_swap)!="undefined")
if(lc_image_swap!=null && lc_image_swap)
{
	/*var typing = document.createElement("img");
		typing.src = "typing.gif";
		typing.id = "typing";
		typing.style.zIndex = 10000;
		typing.style.position = "absolute";
		typing.style.left = '190px';
		typing.style.top = '250px';
		
		document.getElementById("ChatDiv").appendChild(typing);*/
	
		var image = document.createElement("img");
		image.src = _imageURL+"1.png";
		image.id = "rotator";
		image.style.position = "absolute";
		image.style.left = '270px';
		image.style.top = '185px';
		image.style.display='block';
		
		if (document.getElementById("ChatDiv") !== null) {
			document.getElementById("ChatDiv").appendChild(image);
			lc_fade();
		}
}	
