function getFlashFocus()
{ 
 thisMovie().focus();
}

String.prototype.Trim = function() 
{ 
    return this.replace(/(^\s*)|(\s*$)/g, ""); 
} 
String.prototype.LTrim = function() 
{ 
    return this.replace(/(^\s*)/g, ""); 
} 
String.prototype.Rtrim = function() 
{ 
    return this.replace(/(\s*$)/g, ""); 
}

function act() 
{
	document.body.focus();
}

var movieObject = null;

function thisMovie() 
{
  if (movieObject == null)
  {
   if (navigator.appName.indexOf("Microsoft") != -1) 
   {
        movieObject = window["myFlash"];
   }
   else 
   {
      if(document["myFlash"].length != undefined)
      {
          movieObject = document["myFlash"][1];
      }
      else
          movieObject = document["myFlash"];
   }
  }
  
  return movieObject;
}

var beResize = true;
window.onresize = resizeAcition;

function resizeAcition()
{ 
  thisMovie().reFlashSize(document.body.clientWidth,document.body.clientHeight);
	
}

function flashaa(args)
{
  document.getElementById("testDiv").value += args;
  //alert(args);
}

function flashaaa(args)
{
  window.status += "  m:"+args;
}

function changeColor(currentColor)
{
  if(currentColor=="black"){
    thisMovie().bgcolor="#000000";
    //document.body.bgColor="#000000";
    document.getElementById("flashTD").style.backgroundColor="#000000";
  }
  if(currentColor=="white"){
    thisMovie().bgcolor="#FFFFFF";
    //document.body.bgColor="#FFFFFF";
    document.getElementById("flashTD").style.backgroundColor="#FFFFFF";
  }
}

function reFlashSize(current_width,current_height)
{
    thisMovie().width=current_width;
    thisMovie().height=current_height;
 
}

function addMySelfChooseGP(stockID)
{
    //var addStockID = thisMovie().getCurrentStockID();
    //var addSCDM = thisMovie().getCurrentSCDM();
    //var url = "zxg.jsp?action=add&scdm="+addSCDM+"&ZQDM="+addStockID+"&userID="+userinfo.user[8].regid;
	   
//Ajax.sendGetRequest(url, true, "addZXGCallback(ME.responseText)");
    setCookie("zxg_cookie",stockID);
}

function addZXGCallback(responseText)
{
	
}

function deleteMySelfChooseGP(stockID)
{
   //var addStockID = thisMovie().getCurrentStockID();
   //var addSCDM = thisMovie().getCurrentSCDM();
   //var url = "zxg.jsp?action=del&scdm="+addSCDM+"&ZQDM="+addStockID+"&userID="+userinfo.user[8].regid;
   //Ajax.sendGetRequest(url, true, "addZXGCallback(ME.responseText)");   
   setCookie("zxg_cookie",stockID);
   displayMySelftChooseGP();
}

function getZXG()
{

  //getUserIDZXG(userinfo.user[8].regid);
  thisMovie().setZXGValue(getCookie("zxg_cookie"));
}

function displayMySelftChooseGP()
{
   thisMovie().displayMySelftChoose();
}

function displayMySelftChooseGpBack(responseText)
{ 
   thisMovie().displayMySelftChoose();
   thisMovie().allStockID(responseText.Trim());
}

function getRollInfoList()
{
Ajax.sendGetRequest("getRollInfoList.jsp",true,"getRollInfoListCallback(ME.responseText)");
}

function getRollInfoListCallback(responseText)
{

   var resultStr = responseText.Trim();

	thisMovie().showRollInfoContent(resultStr);
}

function getUserIDZXG(userid)
{ 
 Ajax.sendGetRequest("zxg.jsp?action=select&userID="+userid,true,"callBackZXG(ME.responseText)");
}

function callBackZXG(responseText)
{  
   if(responseText!=null&&responseText.Trim()!=""&&responseText!="null")
   {  
      
      var zqdmArr = responseText.split("|");
      var zxgstr="";
      for(var i = 0; i < zqdmArr.length;i++)
      {
	 if(zqdmArr[i] == "" || zqdmArr[i] == null || zqdmArr[i].indexOf(",") == -1)
	 {
            continue;
         }
	 var proArr = zqdmArr[i].split(",");
         var stocktype = "gp";

         if(proArr[1] == "10562")
	 {
		stocktype = "zs"
         }

	 var realStockId = proArr[0];

	if(proArr[0].length == 6)
	{
	   realStockId = thisMovie().getStockIDByZQDM(proArr[0],stocktype);
	}

         if(realStockId != "" && realStockId.length == 8)
	 {
		if(zxgstr != "")zxgstr+="|";
               zxgstr+=realStockId;
	 }
      }
     // alert(zxgstr);
      thisMovie().setZXGValue(zxgstr);
      setCookie("zxg_cookie",zxgstr);
   }
}

function addMark(mark_value)
{
   setCookie("mark_zq",mark_value);
}

function getMark()
{ 
  if(getCookie("mark_zq")!="")
  { 
     thisMovie().setMarkValue(getCookie("mark_zq"));
  }
}

/*function writeZQLog(log_value)
{
  setCookie("zq_log",log_value);
  cls(document.getElementById("div_cls"));
}

function getLogValue()
{ 
  if(getCookie("zq_log")!="")
  { 
    thisMovie().setLogValue(getCookie("zq_log"));
  }
}

function displayLogList(log_value)
{ 
  document.logSubmitForm.log_value.value=log_value;
  document.logSubmitForm.submit();
}

function displayLogForm()
{   
	 var	msg="<br><form METHOD=POST  name='formSS' onSubmit='return save_log()'>"
		  +"<table width='100%'><tr>"
			+"<td ><textarea name='log_area' rows='11' cols='50'></textarea></td></tr>"
		  +"<tr><td   align='center'>"
			+"<input type='submit' name='submit' value='提交'>&nbsp;"
			+"<input type='reset' name='reset' value='重置'></td></tr></table>"
			+"</form>";
			
			var c = new xWin(400,260,270,100,"撰写股票日志",msg);	
}

function save_log()
{

	if(document.formSS.log_area.value=="")
	{
		  alert("请填写内容");
		  return false;
	}

	thisMovie().logSubmit(document.formSS.log_area.value);
	
	return false;
}

function close_logForm()
{
	cls(document.getElementById("div_cls"));
}
*/

var parseAllStockFlag=false;

function setParseAllStockSuccess()
{
  parseAllStockFlag=true;
}

function getAllStock()
{ 
  if(parseAllStockFlag)
     return;
  try
  {
   
    if(beResize)
		{
			beResize = false;
		}
		
		thisMovie().reFlashSize1(document.body.clientWidth,document.body.clientHeight);
//getRollInfoList();   
 parseAllStockFlag = true;
    thisMovie().setMarkValue(getCookie("mark_zq"));
	
  	thisMovie().setZXGValue(getCookie("zxg_cookie"));
   	thisMovie().setLogValue(getCookie("zq_log"));
   	thisMovie().setIsOpenMarketRadar(getCookie("marketRadarStatus"));
   
  }catch(e)
  {
   		setTimeout ("getAllStock()" ,10);
  }
}


function displayRadarInfo(radarStatus)
{
  if(radarStatus==false)
  {
    if(!confirm("市场雷达还没打开,您是否想打开?"))
      return false;
    
    thisMovie().openRadar();
    setCookie("marketRadarStatus","true");
  }
  
  marketRadar.displayDiv("市场雷达[运行中]");
  
}


function qiuckBuy(ZQDM, SCDM, price)
{ 
  //hqlogin.displayDiv("闪电买入");
}

function quickSell(ZQDM, SCDM, price)
{ 
  //hqlogin.displayDiv("闪电卖出");
}

function commonBuy(ZQDM)
{ 
  //hqlogin.displayDiv("普通买入");
}

function commonSell(ZQDM)
{ 
  //hqlogin.displayDiv("普通卖出");
}


function cdTW()
{ 
  //hqlogin.displayDiv("撤单查询");
}

function getCookie(cookie_name)
{
	
  var strCookie=document.cookie;
	var arrCookie=strCookie.split(";");
	
	for(var i=0;i<arrCookie.length;i++)
	{
		var index = arrCookie[i].indexOf( cookie_name );
		if( index >= 0 ) {
				var v = unescape(arrCookie[i].substring( index + cookie_name.length + 1 ));
				
		    return v
		}
	}
	
	return "";
}
function setCookie(name,value)
{
   var days=365;
   var exp=new Date();
   exp.setTime(exp.getTime()+days*24*60*60*1000);
   document.cookie=name+"="+escape(value)+";expires="+exp.toGMTString()+";path=/";
}

function openTrade()
{
	window.open("https://trade.hrsec.com.cn","");	
}


function addLocalInvestmentLog(title,content,stockid)
{
		var date = new Date();
		var month = date.getMonth()+1;
		var d = date.getFullYear()+"-"+month+"-"+date.getDate()+" "+date.getHours()+":"+date.getMinutes()+":"+date.getSeconds();
		var logValue = title+"<log>"+content+"<log>"+d+"<log>"+stockid;
		var logValueList = getCookie(stockid+"_InvestmentLog");
		
		if(logValueList != "")
		{
					logValueList += "<loglist>";
		}
		
		logValueList += logValue;
		
		setCookie(stockid+"_InvestmentLog",logValueList);
		
		var msg ="<m><c>addinvestlog</c><id>"+stockid+"</id></m>";
  	thisMovie().receiveMessage(msg);
}

function showLocalInvestmentLogList(stockid)
{
		
		var logValueList = getCookie(stockid+"_InvestmentLog");
		
		var logs = logValueList.split("<loglist>");
		var investDiaryList = "";
		
		for(var i = 0; logValueList!="" && i < logs.length; i++)
	 	{
	 		 var propertyArr = logs[i].split("<log>");
	 			
	 		 if(i > 0)
	 		 {
	 		 		investDiaryList += "|";
	 		 }
	 		 
	 		 investDiaryList+=propertyArr[2]+","+propertyArr[0]+","+propertyArr[2]+","+propertyArr[3];
	 
		}
		
		var msg ="<m><c>getinvestloglist</c><content>"+investDiaryList+"</content></m>";
		thisMovie().receiveMessage(msg);
}

function deleteLocalInvestDiary(stockid,_id)
{
			var temlogsArr = new Array();
			var temlogsStr = "";
			
			var logValueList = getCookie(stockid+"_InvestmentLog");
			var logs = logValueList.split("<loglist>");
			
			for(var i = 0; i < logs.length; i++)
			{
				var propertyArr = logs[i].split("<log>");
				
				if(propertyArr[2] != _id)
				{
					temlogsArr.push(logs[i]);
					
					if(temlogsStr != "")
					{
							temlogsStr += "<loglist>";	
					}
					
					temlogsStr += logs[i];
				}	
			}
			
			setCookie(stockid+"_InvestmentLog",temlogsStr);
}

function showLocalInvestDirayContent(stockid,_id)
{
		
		var logValueList = getCookie(stockid+"_InvestmentLog");
		var logs = logValueList.split("<loglist>");
			
		for(var i = 0; i < logs.length; i++)
		{
				var propertyArr = logs[i].split("<log>");
				
				if(propertyArr[2] == _id)
				{
					var msg ="<m><c>getinvestlogcontent</c><content>"+propertyArr[1]+"</content></m>";
  				thisMovie().receiveMessage(msg);
					break;
				}	
		}
		
}
