
function stockInvestmentLogList() {}



stockInvestmentLogList.init = function()
{
	var div = document.createElement("div");
	div.innerHTML = "<div style='position:absolute;width:516px;height:318px;background-color:white;border:2px #6D6D6D solid;display:none;left:0px;top:0px;' ></div>";
	
	stockInvestmentLogList.mainDiv = div.childNodes[0];
	
	var sb = new Array;
	sb.push ("<div id='eventDiv' onmousedown='stockInvestmentLogList.fDragging(this, event, true);' ><table width=100% border=0 cellspacing=0 cellpadding=0 ><tr>");
	sb.push ("<td  width=400 height=21 class='floatDivTop'><span id='stockInvestmentLogList_title' style='padding-left:5px;font-size:12px;font-weight:bold;'>市场雷达[运行中]</span></td>");
	sb.push ("<td  class='floatDivTop'><div align=right><a href='#' onclick='stockInvestmentLogList.writeLogs()'>撰写</a>&nbsp;&nbsp;<a href='#' onclick='stockInvestmentLogList.deleteLogs()'>删除</a>&nbsp;&nbsp;<img src='");
	sb.push ("../images/hqwt/close_a.gif' onmouseover=\"this.src='../images/hqwt/close_b.gif'\" onmouseout=\"this.src='../images/hqwt/close_a.gif'\" onmousedown=\"this.src='../images/hqwt/close_c.gif'\" onmouseup=\"this.src='../images/hqwt/close_b.gif'\"  border=0 onclick='stockInvestmentLogList.hiddenDiv()' style='cursor:hand;' /></div></td></tr></table></div>");
	sb.push ("<div onkeydown='stockInvestmentLogList.myonkeydownForMarkText()' style='width:512;height:274;background-color:#ffffff;overflow-x:auto;overflow-y:auto;display:none' id='logsValueDisplayID'></div><div onkeydown='stockInvestmentLogList.myonkeydownForMarkText()' id='logsListID' style='width:512;height:274;background-color:#ffffff;overflow-x:auto;overflow-y:auto'><table width='512' bgcolor='#ffffff' border='0' cellspacing='0' cellpadding='0' id='stockInvestmentLogListTable' ><tbody></tbody></table></div><table  width='512' border='0' bgcolor='#CCCCCC' cellspacing='0' cellpadding='0' height='30'><tr><td align='right'><input type='button' id='closeBtn'  value='关闭' onClick='stockInvestmentLogList.hiddenDiv()'/></td></tr></table>");
	stockInvestmentLogList.mainDiv.innerHTML = sb.join("");
	document.body.appendChild (stockInvestmentLogList.mainDiv);
}

stockInvestmentLogList.fDragging = function (obj, e, limit)
{ 
    if(!e) e=window.event;
     
    obj=stockInvestmentLogList.mainDiv;
    var x=parseInt(obj.style.left); 
    var y=parseInt(obj.style.top); 
     
    var x_=e.clientX-x; 
    var y_=e.clientY-y; 
     
    if(document.addEventListener)
    { 
        document.addEventListener('mousemove', inFmove, true); 
        document.addEventListener('mouseup', inFup, true); 
        window.captureEvents(Event.MOUSEMOVE | Event.MOUSEUP);
    } 
    else if(document.attachEvent)
    { 
        document.attachEvent('onmousemove', inFmove); 
        document.attachEvent('onmouseup', inFup); 
        
        obj.setCapture ();
    } 
     
    
    inFstop(e);     
    inFabort(e) 
    
    function inFmove(e)
    { 
        var evt; 
        if(!e)e=window.event; 
         
        if(limit)
        { 
            var op=obj.parentNode; 
            var opX=parseInt(op.style.left); 
            var opY=parseInt(op.style.top); 
             
            if((e.clientX-x_)<0)
            {
                return false; 
            }
            else if((e.clientX-x_+obj.offsetWidth+opX)>(opX+op.offsetWidth))
            {
                return false;
            }
             
            if(e.clientY-y_<0){
                return false; 
            }
            else if((e.clientY-y_+obj.offsetHeight+opY)>(opY+op.offsetHeight)){
                return false; 
            }
        } 
         
        obj.style.left=e.clientX-x_+'px'; 
        obj.style.top=e.clientY-y_+'px'; 
         
        inFstop(e); 
    } // shawl.qiu script 
    
    function inFup(e)
    { 
        var evt; 
        if(!e)e=window.event; 
         
        if(document.removeEventListener)
        { 
            document.removeEventListener('mousemove', inFmove, true); 
            document.removeEventListener('mouseup', inFup, true);
            window.captureEvents(Event.MOUSEMOVE|Event.MOUSEUP);
        }
         else if(document.detachEvent)
        { 
            document.detachEvent('onmousemove', inFmove); 
            document.detachEvent('onmouseup', inFup);
            obj.releaseCapture ();
        } 
         
        inFstop(e); 
    } // shawl.qiu script 

    function inFstop(e)
    { 
        if(e.stopPropagation) return e.stopPropagation(); 
        else return e.cancelBubble=true;             
    } // shawl.qiu script 
    
    function inFabort(e)
    { 
        if(e.preventDefault) return e.preventDefault(); 
        else return e.returnValue=false; 
    } // shawl.qiu script 
} 

stockInvestmentLogList.displayDiv = function (zqjc,stockid)
{
	
	stockInvestmentLogList.stockID = stockid;
	stockInvestmentLogList.ZQJC = zqjc;
  document.getElementById ("stockInvestmentLogList_title").innerHTML = "[" + zqjc + "] 投资日志";
 	stockInvestmentLogList.mainDiv.style.left = (parseInt(document.body.clientWidth) - 528) / 2;
	stockInvestmentLogList.mainDiv.style.top  = (parseInt(document.body.clientHeight) - 328) / 2;
 
	stockInvestmentLogList.mainDiv.style.display = "";
	document.getElementById("logsValueDisplayID").style.display = "none";
	document.getElementById("logsListID").style.display = "";
	document.getElementById("logsListID").focus();
	document.onkeydown=null;
	var logValueList = getCookie(stockInvestmentLogList.stockID+"_InvestmentLog");
	
	stockInvestmentLogList.addLogList(logValueList);
}

stockInvestmentLogList.addLogList = function (_logValueList)
{
	 var logs = _logValueList.split("<loglist>");
	 stockInvestmentLogList.logList = logs;
	 var tbl = document.getElementById("stockInvestmentLogListTable").tBodies[0];
	 
	 while(tbl.hasChildNodes())
	 {
	 		tbl.removeChild(tbl.firstChild);
	 }
	 
	 var tr = document.createElement("tr");
   tr.height=20;
	 tbl.appendChild(tr);
	 
	 for(var i = 0; i < logs.length; i++)
	 {
	 		 var propertyArr = logs[i].split("<log>");
	 			
	 		 tr = document.createElement("tr");
	 		 tr.id = propertyArr[2]+"_"+propertyArr[3];
	 		 tr.ondblclick=function(){stockInvestmentLogList.logsDbClick(this);};
	 		 tr.onmousedown=function(){stockInvestmentLogList.logsMouseDown(this);};
   		 tr.height=20;
	 		 tbl.appendChild(tr);
	 			
	 		 td = document.createElement("td");
   		 td.innerHTML = propertyArr[0];
	 		 tr.appendChild(td);
	 
		}
}

stockInvestmentLogList.hiddenDiv = function()
{
	document.onkeydown = keyDownForyinhe;
	act();
	stockInvestmentLogList.lastClickObj = null;
  stockInvestmentLogList.mainDiv.style.display = "none";
}

stockInvestmentLogList.deleteMarkText = function ()
{
		setCookie(stockInvestmentLogList.stockID+"_InvestmentLog","");
		stockInvestmentLogList.hiddenDiv();	
}

stockInvestmentLogList.myonkeydownForMarkText = function(e)
{
	if(e==null)
	  e=BrowserCompatible.getEvent(e);
	  
	var keycode=BrowserCompatible.getKeyCode(e);
	
	if(keycode==27)
	{
	  try
	  {
	    BrowserCompatible.fireKeyEvent(e);
	  }catch(E){}
	  
	  
	  if(document.getElementById("logsListID").style.display != "none")
	  {
	  	 stockInvestmentLogList.hiddenDiv();
	  }
	  else
	  {
	  	document.getElementById("logsListID").style.display = "";
	  	document.getElementById("logsValueDisplayID").style.display = "none";
	  	document.getElementById("logsListID").focus();
	  }
	  
	}
	else if (keycode==13)
	{
			if(document.getElementById("logsListID").style.display != "none")
	  	{
				if(stockInvestmentLogList.lastClickObj)
				{
						stockInvestmentLogList.showContent(stockInvestmentLogList.lastClickObj);
				}
			}
			else
			{
					document.getElementById("logsListID").style.display = "";
					document.getElementById("logsListID").focus();
	  			document.getElementById("logsValueDisplayID").style.display = "none";
			}
	}
}

stockInvestmentLogList.showContent = function(obj)
{
		var timeArr = obj.id.split("_");
		
		for(var i = 0; i < stockInvestmentLogList.logList.length; i++)
		{
				var propertyArr = stockInvestmentLogList.logList[i].split("<log>");
				
				if(propertyArr[2] == timeArr[0])
				{
					document.getElementById("logsValueDisplayID").innerHTML = propertyArr[1].replace(new RegExp("\r","gm"),"<br/>");
					break;
				}	
		}
		
  	document.getElementById("logsValueDisplayID").style.display = "";
  	document.getElementById("logsValueDisplayID").focus();
		document.getElementById("logsListID").style.display = "none";	
}

stockInvestmentLogList.logsDbClick = function (obj)
{
		stockInvestmentLogList.showContent(obj);
}

stockInvestmentLogList.lastClickObj = null;

stockInvestmentLogList.logsMouseDown = function (obj)
{
	 if(stockInvestmentLogList.lastClickObj!=null)
	 {
	     stockInvestmentLogList.lastClickObj.className = "logs1";
	 }
	 
	 stockInvestmentLogList.lastClickObj = obj;
	 obj.className = "logs2";
}

stockInvestmentLogList.deleteLogs = function ()
{
		if(stockInvestmentLogList.lastClickObj)
		{
			var temlogsArr = new Array();
			var temlogsStr = "";
			var timeArr = stockInvestmentLogList.lastClickObj.id.split("_");
			
			for(var i = 0; i < stockInvestmentLogList.logList.length; i++)
			{
				var propertyArr = stockInvestmentLogList.logList[i].split("<log>");
				
				if(propertyArr[2] != timeArr[0])
				{
					temlogsArr.push(stockInvestmentLogList.logList[i]);
					
					if(temlogsStr != "")
					{
							temlogsStr += "<loglist>";	
					}
					
					temlogsStr += stockInvestmentLogList.logList[i];
				}	
			}
			
			stockInvestmentLogList.logList = temlogsStr.split("<loglist>");
			setCookie(stockInvestmentLogList.stockID+"_InvestmentLog",temlogsStr);
			var tbl = document.getElementById("stockInvestmentLogListTable").tBodies[0];
	 		tbl.removeChild(stockInvestmentLogList.lastClickObj);
			stockInvestmentLogList.lastClickObj = null;
			
		}
}

stockInvestmentLogList.writeLogs = function ()
{
	addStockInvestmentLog.insertList = true;
	addStockInvestmentLog.displayDiv(stockInvestmentLogList.ZQJC,stockInvestmentLogList.stockID);
}


stockInvestmentLogList.addLog = function (_logValue)
{
	
	 	stockInvestmentLogList.logList.push(_logValue);
		var tbl = document.getElementById("stockInvestmentLogListTable").tBodies[0];
	 
	 
		var propertyArr = _logValue.split("<log>");
	 	tr = document.createElement("tr");
	 	tr.id = propertyArr[2]+"_"+propertyArr[3];
	 	tr.ondblclick=function(){stockInvestmentLogList.logsDbClick(this);};
	 	tr.onmousedown=function(){stockInvestmentLogList.logsMouseDown(this);};
   	tr.height=20;
	 	tbl.appendChild(tr);
	 			
	 	td = document.createElement("td");
   	td.innerHTML = propertyArr[0];
	 	tr.appendChild(td);
	 	addStockInvestmentLog.insertList = false;
}
