function showDiscussionSbox(obj)
{
    //var _divDiscussionSboxTop = document.getElementById("divDiscussionSboxTop");
    //var _divDiscussionSboxBottom = document.getElementById("divDiscussionSboxBottom");
    
    _divDiscussionSboxTop.style.display = "none";
    _divDiscussionSboxBottom.style.display = "inline-block";
    
    
    //var _divDiscussionList = document.getElementById("divDiscussionList");
    //var _hfDiscussionList = document.getElementById("hfDiscussionList");

    var str = _hfDiscussionList.value;
    var arrLines = str.split("||");
    var sTable = "<table cellspacing='0' cellpadding='0' border='0' width='100%'>";
    for(var i=0;i<arrLines.length-1;i++)
    {
        var items = arrLines[i].split('|');
        sTable += "<tr onclick='discuGoto("+items[0]+");'><td class='DiscuTdCss' width='100px'>"+items[1]+"</td></tr>";
    }
    sTable += "</table>";

    _divDiscussionList.innerHTML = sTable;

}
function hideDiscussionSbox(obj)
{
    //var _divDiscussionSboxTop = document.getElementById("divDiscussionSboxTop");
    //var _divDiscussionSboxBottom = document.getElementById("divDiscussionSboxBottom");
    
    _divDiscussionSboxTop.style.display = "inline-block";
    _divDiscussionSboxBottom.style.display = "none";
    
}

var discuTimer = null;
//Cette fonction ne semble plus utilisée
function showDiscussionList(obj)
{
    clearTimeout(discuTimer);
    //var _divDiscussionList = document.getElementById("divDiscussionList");
    //var _hfDiscussionList = document.getElementById("hfDiscussionList");
    
    var _divCboDiscussion = document.getElementById("divCboDiscussion");
    
    var str = _hfDiscussionList.value;
    var arrLines = str.split("||");
    var sTable = "<table cellspacing='0' cellpadding='0' border='0' width='100%'>";
    for(var i=0;i<arrLines.length-1;i++)
    {
        var items = arrLines[i].split('|');
        sTable += "<tr onmouseover='discuTrOver(this);' onclick='discuGoto("+items[0]+");'><td class='DiscuTdCss' width='100px'>"+items[1]+"</td></tr>";
    }
    sTable += "</table>";
    
    _divDiscussionList.innerHTML = sTable;
    _divDiscussionList.style.display = "inline-block";
    _divDiscussionList.style.position = "absolute";
    _divDiscussionList.style.left = findPosX(_divCboDiscussion);
    _divDiscussionList.style.top = findPosY(_divCboDiscussion)+_divCboDiscussion.offsetHeight;    
    _divDiscussionList.style.width = _divCboDiscussion.offsetWidth;
    
    obj.onmouseout = function()
    {
        discuTimer = setTimeout("closeDiscuDiv()", 50);
    }
    //"../Discussion/DiscusssionCompiled.aspx?discussionID=" + row.LastDiscussionID.ToString();
}
function closeDiscuDiv()
{
        clearTimeout(discuTimer);
        //var _divDiscussionList = document.getElementById("divDiscussionList");
        _divDiscussionList.style.display = "none";
}
function divDiscuOver(obj)
{
   clearTimeout(discuTimer);
   obj.onmouseout = function()
   {
        discuTimer = setTimeout("closeDiscuDiv()", 50);
   }    
}
function discuGoto(id)
{
    document.location = "../Discussion/DiscusssionCompiled.aspx?discussionID=" + id;
}
function discuTrOver(obj)
{

    for(var i=0;i<obj.cells.length;i++)
    {
        var cell = obj.cells[i];
        if(!obj._bkBG)
            obj._bkBG = cell.style.backgroundColor;
        
        cell.style.backgroundColor = "#edf1fb";
        //cell.style.fontWeight = "bold";
    }
    obj.onmouseout = function()
    {
       for(var i=0;i<this.cells.length;i++)
       {
            var cell = this.cells[i];
            cell.style.backgroundColor = this._bkBG;
            //cell.style.fontWeight = "";
       }
    }
}


function OpenChooseLetter(RetailerID)
{
	var strFeatures = "DialogWidth=477px;DialogHeight=153px;center=yes;help=no;status=yes;";
	var myObject = new Object();
	myObject.ReturnValue = "0";
	myObject.parametersString = "";
	var ChildWindow = window.showModalDialog("../Credit/ChooseLetters.aspx?RetailerID=" + RetailerID, myObject, strFeatures);
	
	if(myObject.ReturnValue == "1")
	{
		window.open("../Credit/LetterViewer.aspx?Parameters="+myObject.parametersString);
				
	}	
}

function OpenReportPrintList()
{
	var strFeatures = "width=920,height=400,center=yes,help=no,menu=no,status=yes,scrollbars=yes,resizable=no";
	window.open("../Credit/CreditReportPrintList.aspx", null, strFeatures);
}

function OpenReportPrintListModal()
{
	GenericOpenModal("../Credit/CreditReportPrintList.aspx",920,400,null);
}

function OpenReportPrintListRetailer(RetailerID)
{
	var strFeatures = "width=920,height=400,center=yes,help=no,menu=no,status=yes,scrollbars=yes,resizable=no";
	window.open("../Credit/CreditReportPrintList.aspx?RetailerID=" + RetailerID, null, strFeatures);

}

function ConfirmName(pFrom, pAccountFoundListHF)
{
	var list = document.getElementById(pAccountFoundListHF).value;
	document.getElementById(pAccountFoundListHF).value = "";
	var msg = "The "+pFrom+" already exists for at least another retailer as his LegalName, DBA1 or DBA2. ";
	msg += "<br><br>Accounts found:";
	msg += "<br>"+list;
	msg += "<br><br>Would you like to continue the creation?<br> If you choose No, you will be asked to change the "+pFrom;
	var result = ShowStdDialogBox(msg,false, 400,350);
	if(result ==1)
	{
		document.getElementById("hfValidateName").value = 2; // Vrai
	}
	else
	{
		document.getElementById("hfValidateName").value = 3; // Faux
	}
	
	__doPostBack('lbSave', '');
}

function ConfirmCancel()
{
	if (confirm("Are you sure?") == true)
	{
		document.forms[0].reset(); 
		return true;
	}
	else
	{
		return false;
	}
}

function EditField(fieldName)
{
	document.getElementById("hidFieldName").value = fieldName;
	document.forms[0].submit();
	
}

function BodyOnLoad(fieldName, reportURL)
{
	MM_preloadImages('../images/online_on.jpg','../images/site_on.jpg','../images/contacts_on.jpg','../images/trianglehaut.jpg', '../images/trianglebas.jpg');
	
	if (fieldName != "")
	{
		var el = document.getElementById(fieldName);
		
		if (el)
		{
			el.focus();
		}
	}
	
	if (reportURL != "")
	{
		//window.open(reportURL, "CrystalReport", "width=800,height=600,toolbar=no,status=yes,location=no,directories=no,menubar=no,resizable=yes,scrollbars=no,left=0,top=0,dependent=yes");
		window.open(reportURL, "CrystalReport", "width=800,height=600,toolbar=yes,status=yes,location=no,directories=yes,menubar=yes,resizable=yes,scrollbars=yes,left=0,top=0,dependent=yes");
	}
	
}


function ChangeColor(color)
{
	event.srcElement.style.color=color;
}


function openCorporateFile(strCorporateFile){
	try{
	window.open("../Corporate/" + strCorporateFile);
	}catch(e){};
	
	
}

function openSecurityFile(strSecurityFile){
	try{
	window.open("../Security/" + strSecurityFile);
	}catch(e){};
	
	
}

// cursor functions for meeting graphs
function showCursor(sid, tid)
{
    document.getElementById(sid).style.cursor = tid;
}

function clearCursor(sid)
{
      document.getElementById(sid).style.cursor = 'default';
}


