﻿$.extend({
getUrlVars: function(){
var vars = [], hash;
var hashes = window.location.href.slice(window.location.href.indexOf('?') + 1).split('&');
for(var i = 0; i < hashes.length; i++)
{
hash = hashes[i].split('=');
vars.push(hash[0]);
vars[hash[0]] = hash[1];
}
return vars;
},
getUrlVar: function(name){
return $.getUrlVars()[name];
}
});
//鼠标提示
$(function(){
  var x=10;
  var y=20;
  $(".tooltip").mouseover(function(e){
  this.myTitle=this.title;
  this.title="";
  var tooltip="<div id='tooltip' style='position:absolute;border:1px solid #3597B2;background:#fff;font-size:12px;padding:10px;'>"+this.myTitle+"</div>";
  $("body").append(tooltip);
  
  $("#tooltip").css(
  {
  
   "top": (e.pageY+y) + "px",
   "left": (e.pageX+x) + "px" 
  }
  ).show("fast");
  }).mouseout(function(){
     this.title=this.myTitle;
     $("#tooltip").remove(); 
  }).mousemove(function(e){
    $("#tooltip").css({
  "top": (e.pageY+y) + "px",
  "left": (e.pageX+x) + "px"
  }); 
  });
});
//invest页自动高度
function investAutoHight(){
	var h_left = $("ul.applist1").height()+80;
	var h_right = $("div.trade > div:visible").height()+80;
	var h_all = $("div.box-body").height();
	if (h_left>h_right)
	{
		$("div.box-body").height(h_left);
	}
	else
	{
		$("div.box-body").height(h_right);
	}
	$(hsxSetFooterToBottom);
};
//base 查询按钮
function clickBaseGoto(){
	var menu_search=$("input#menu-search").val();
	if (menu_search.length==8)
	{
	window.location.href=("/products/"+menu_search);
	}
};
//清空表单
function reset() {
$(':input')
.not(':button, :submit, :reset, :hidden, #code, #validity')
.val('')
.removeAttr('checked')
//.removeAttr('selected');
	$("input#buybutton").attr("disabled","true");
	$("input#sellbutton").attr("disabled","true");
	$("input#shortbutton").attr("disabled","true");
	$("input#coverbutton").attr("disabled","true");
}
//得到今日日期
function BtnGetToday(){
	var   d   =   new   Date();   
  return (d.getFullYear() +appendZero(d.getMonth() +1) + appendZero(d.getDate()));
}
function checkTradeInput(){
	if($("form input#price").val() == '')
	{
		$("form span#price_x").html("*");
		$("form span#price_x").css("color","red");
		$("form span#trade_x").html('* 为必填项');
		$("form span#trade_x").css("color","red");
	}
	if($("form input#amount").val() == '')
	{
		$("form span#amount_x").html("*");
		$("form span#amount_x").css("color","red");
		$("form span#trade_x").html('* 为必填项');
		$("form span#trade_x").css("color","red");
	}
	if($("form input#code").val() == '')
	{
		$("form span#code_x").html("*");
		$("form span#code_x").css("color","red");
		$("form span#trade_x").html('* 为必填项');
		$("form span#trade_x").css("color","red");
	}
};

//消息显示
function infoShow(message){
	var info = message;
	info += '<center>';
  info += "<br /><input id='infoclose' value='确定' type='button'>";
  info += '</center>';
	$("div#info_div").html(info);
	$("input#infoclose").click(clickInfoCloseBtn);
	setInfoDivInMiddle();
	$("div#blackback").show();
	$("div#info_div").show();
};
(function($) {
  $.fn.extend({ 
    adminify: function(url, count, seq, tr_clicked, build_td) {
      var query_str = function(page) {
          return url+"&count="+count+"&start="+(Number(page)-1)*count;
      };
      var obj = this;
      var html = function(cur, total) {
        return $('<p class="page_ctl"><a id ="prev_page">上一页</a>&nbsp;<span id ="curr_page">'+cur+'</span>&nbsp;/&nbsp;<span id="total_page">'+total+'</span>&nbsp;<a id ="next_page">下一页</a>&nbsp;第<input id="goto_page_no" autocomplete="off" type="text" value="' + total + '"/>页&nbsp;<input id="goto_page" type="button" value="前往"/></p>');
      };
      var html_count = function(total_all ,count) {
        return $('<p id="page_count">每页显示'+count+'行&nbsp;&nbsp;&nbsp;共'+ total_all +'行</p>');
      };
      $("p.page_ctl").detach();
      $("p#page_count").detach();
      obj.after('<p class="page_ctl"></p>');
      obj.before('<p id="page_count"></p>');
      var getPage = function(page) {
        obj.children("tbody").html("");
        $.getJSON(query_str(page), function(data) {
          var total = Number(data.count);
          var total_all = data.count;
          if (total==0)
          {
          	$("p.page_ctl").html('共0页');
          	$("p#page_count").html('每页显示'+count+'行&nbsp;&nbsp;&nbsp;共'+ total_all +'行');
          	obj.children('tbody').html('<tr>无查询记录</tr>');
          }
          else
          {
          $("p.page_ctl").html(html(page, (total%count ? total/count+1 : total/count).toFixed(0)));
          $("p#page_count").html(html_count(total_all,count));
          $.each(data.records, function(index) {
            var tr=$('<tr/>');
            if(typeof tr_clicked == "function") tr.click(tr_clicked);
            for(item in seq)
            {
            	if(/^#/.test(seq[item]))
            	{
            		var real = seq[item].replace("#","");
            		if(data.records[index][real] < 0.01 && data.records[index][real] > -0.01)
            		{
            			tr.append($('<td id="'+real+'">0.00</td>'));
            		}
            		else
            		{
            			tr.append($('<td id="'+real+'">'+admincc(data.records[index][real].toString())+'</td>'));
            		}
            	}
            	else
            	{
            		tr.append($('<td id="'+seq[item]+'">'+data.records[index][seq[item]]+'</td>'));
            	}
            }
            if(typeof build_td == "function") {
              td = $('<td/>');
              build_td(td, data.records[index]);
              tr.append(td);
            }
            obj.children('tbody').append(tr);
          });
          $("#prev_page").click(function() {
            var cur = Number($("#curr_page").html());
            if(cur == 1) return;
            getPage(cur-1);
          });
          $("#next_page").click(function() {
            var cur = Number($("#curr_page").html());
            var total = Number($("#total_page").html());
            if(cur == total) return;
            getPage(cur+1);
          });
          $("#goto_page").click(function() {
            var cur = Number($("#curr_page").html());
            var page = Number($("#goto_page_no").val());
            var total = Number($("#total_page").html());
            if(typeof page != "number" || page == cur) return;
            if(page < 1) page = 1;
            if(page > total) page = total;
            getPage(page);
          });
          }
        });
      };
      getPage(1);
    }
  });
})(jQuery);
//检查输入框input
function CheckRegusername(){
  var id_email = $("input#id_email").val();
	$.post("/user/validate", {username: id_email}, function(data){
		switch (data.username){
			case 0:
			$("span#emailResult").html("");
			$("input#regsub").attr("disabled","");
			break
			case 1:
			$("span#emailResult").html("邮箱重复");
			$("input#regsub").attr("disabled","true");
			break
		};
	});
};
function CheckRegnickname(){
  var id_nickname = $("input#id_nickname").val();
  $.post("/user/validate", {nickname: id_nickname}, function(data){
		switch (data.nickname){
			case 0:
			$("span#nicknameResult").html("");
			$("input#regsub").attr("disabled","");
			break
			case 1:
			$("span#nicknameResult").html("昵称重复");
			$("input#regsub").attr("disabled","true");
			break
		};
	});
};
function CheckRegmobile(){
	var id_mobile = $("input#id_mobile").val();
	$.post("/user/validate", {mobile: id_mobile}, function(data){
		switch (data.mobile){
			case 0:
			$("span#phonenumberResult").html("");
			$("input#regsub").attr("disabled","");
			break
			case 1:
			$("span#phonenumberResult").html("手机重复");
			$("input#regsub").attr("disabled","true");
			break
		};
	});
};
//短信验证码按钮
function sendPhoneChkNo(){
	var id_mobile = $("input#id_mobile").val();
	if (id_mobile.length==11)
	{
	$.post('/user/sms_verify',{
			  mobile: id_mobile
			  },
			show_result_noreset);
	$('#sendphonechkno').attr("disabled", "ture");
  var timeout;
  var count = 60; // 倒数60s
  //$(function() {
  //	timeout = setTimeout(BtnCount, 1000); // 1s执行一次BtnCount
  //});
  BtnCount = function() {           
    // 启动按钮
    if (count == 0) {
      $('#sendphonechkno').attr("disabled", "");
      $('#sendphonechkno').val("发送短信验证码");
      clearTimeout(timeout);           // 可取消由 setTimeout() 方法设置的 timeout
    }
    else {
    count--;
    $('#sendphonechkno').val(count.toString() + "秒后可再次发送");
      setTimeout(BtnCount, 1000); 
    }
  };
  timeout = setTimeout(BtnCount, 1000);
  }
  else{
  	infoShow("请输入正确的手机号码");
  	$("input#id_mobile").css("background-color","#ffc5c5");
  	$("input#id_mobile").focus();
  }
};
//推荐上市
function ckrecom_name(){
	var val=$("input#recom_name").val();
	if (val.length>0)
	{
		//$("input#recom_name").after('<img src="/static/images/result_ok.gif" />');
		$("span#recom_name_result").html("&nbsp;");
		$("span#recom_name_result").removeClass();
		$("span#recom_name_result").addClass("result_ok");
	}
	else
	{
		$("span#recom_name_result").html("&nbsp;");
		$("span#recom_name_result").removeClass();
		$("span#recom_name_result").addClass("result_fail");
		$("span#recom_name_result").html("请输入内容");
	}
};
function ckrecom_code(){
	var val=$("input#recom_code").val();
	if (val.length==8)
	{
		$("span#recom_code_result").html("&nbsp;");
		$("span#recom_code_result").removeClass();
		$("span#recom_code_result").addClass("result_ok");
	}
	else
	{
		$("span#recom_code_result").html("&nbsp;");
		$("span#recom_code_result").removeClass();
		$("span#recom_code_result").addClass("result_fail");
		$("span#recom_code_result").html("请输入8位代码");
	}
};
function ckrecom_price(){
	var val=$("input#recom_price").val();
	if (val.length>0)
	{
		$("span#recom_price_result").html("&nbsp;");
		$("span#recom_price_result").removeClass();
		$("span#recom_price_result").addClass("result_ok");
	}
	else
	{
		$("span#recom_price_result").html("&nbsp;");
		$("span#recom_price_result").removeClass();
		$("span#recom_price_result").addClass("result_fail");
		$("span#recom_price_result").html("请输入正确金额");
	}
};
function ckrecom_amount(){
	var val=$("input#recom_amount").val();
	if (val.length>0)
	{
		$("span#recom_amount_result").html("&nbsp;");
		$("span#recom_amount_result").removeClass();
		$("span#recom_amount_result").addClass("result_ok");
	}
	else
	{
		$("span#recom_amount_result").html("&nbsp;");
		$("span#recom_amount_result").removeClass();
		$("span#recom_amount_result").addClass("result_fail");
		$("span#recom_amount_result").html("请输入正确份额");
	}
};
//权证
function ckturbine_name(){
	var val=$("input#turbine_name").val();
	if (val.length>0)
	{
		$("span#turbine_name_result").html("&nbsp;");
		$("span#turbine_name_result").removeClass();
		$("span#turbine_name_result").addClass("result_ok");
	}
	else
	{
		$("span#turbine_name_result").html("&nbsp;");
		$("span#turbine_name_result").removeClass();
		$("span#turbine_name_result").addClass("result_fail");
		$("span#turbine_name_result").html("请输入正确名称");
	}
};
function ckturbine_code(){
	var val=$("input#turbine_code").val();
	if (val.length==8)
	{
		$("span#turbine_code_result").html("&nbsp;");
		$("span#turbine_code_result").removeClass();
		$("span#turbine_code_result").addClass("result_ok");
	}
	else
	{
		$("span#turbine_code_result").html("&nbsp;");
		$("span#turbine_code_result").removeClass();
		$("span#turbine_code_result").addClass("result_fail");
		$("span#turbine_code_result").html("请输入8位代码");
	}
};
function ckturbine_stock(){
	var val=$("input#turbine_stock").val();
	if (val.length>0)
	{
		$("span#turbine_stock_result").html("&nbsp;");
		$("span#turbine_stock_result").removeClass();
		$("span#turbine_stock_result").addClass("result_ok");
	}
	else
	{
		$("span#turbine_stock_result").html("&nbsp;");
		$("span#turbine_stock_result").removeClass();
		$("span#turbine_stock_result").addClass("result_fail");
		$("span#turbine_stock_result").html("请输入正确正股");
	}
};
function ckturbine_stock_code(){
	var val=$("input#turbine_stock_code").val();
	if (val.length==8)
	{
		$("span#turbine_stock_code_result").html("&nbsp;");
		$("span#turbine_stock_code_result").removeClass();
		$("span#turbine_stock_code_result").addClass("result_ok");
	}
	else
	{
		$("span#turbine_stock_code_result").html("&nbsp;");
		$("span#turbine_stock_code_result").removeClass();
		$("span#turbine_stock_code_result").addClass("result_fail");
		$("span#turbine_stock_code_result").html("请输入8位正股代码");
	}
};
function ckturbine_date(){
	var val=$("input#turbine_date").val();
	if (val.length>0)
	{
		$("span#turbine_date_result").html("&nbsp;");
		$("span#turbine_date_result").removeClass();
		$("span#turbine_date_result").addClass("result_ok");
	}
	else
	{
		$("span#turbine_date_result").html("&nbsp;");
		$("span#turbine_date_result").removeClass();
		$("span#turbine_date_result").addClass("result_fail");
		$("span#turbine_date_result").html("请输入正确日期如：20110307");
	}
};
function cklast_turbine_date(){
	var val=$("input#last_turbine_date").val();
	if (val.length>0)
	{
		$("span#last_turbine_date_result").html("&nbsp;");
		$("span#last_turbine_date_result").removeClass();
		$("span#last_turbine_date_result").addClass("result_ok");
	}
	else
	{
		$("span#last_turbine_date_result").html("&nbsp;");
		$("span#last_turbine_date_result").removeClass();
		$("span#last_turbine_date_result").addClass("result_fail");
		$("span#last_turbine_date_result").html("请输入正确日期如：20110307");
	}
};
function ckturbine_ipoprice(){
	var val=$("input#turbine_ipoprice").val();
	if (val.length>0)
	{
		$("span#turbine_ipoprice_result").html("&nbsp;");
		$("span#turbine_ipoprice_result").removeClass();
		$("span#turbine_ipoprice_result").addClass("result_ok");
	}
	else
	{
		$("span#turbine_ipoprice_result").html("&nbsp;");
		$("span#turbine_ipoprice_result").removeClass();
		$("span#turbine_ipoprice_result").addClass("result_fail");
		$("span#turbine_ipoprice_result").html("请输入正确价格");
	}
};
function ckturbine_price(){
	var val=$("input#turbine_price").val();
	if (val.length>0)
	{
		$("span#turbine_price_result").html("&nbsp;");
		$("span#turbine_price_result").removeClass();
		$("span#turbine_price_result").addClass("result_ok");
	}
	else
	{
		$("span#turbine_price_result").html("&nbsp;");
		$("span#turbine_price_result").removeClass();
		$("span#turbine_price_result").addClass("result_fail");
		$("span#turbine_price_result").html("请输入正确价格");
	}
};
function ckturbine_ratio(){
	var val=$("input#turbine_ratio").val();
	if (val.length>0)
	{
		$("span#turbine_ratio_result").html("&nbsp;");
		$("span#turbine_ratio_result").removeClass();
		$("span#turbine_ratio_result").addClass("result_ok");
	}
	else
	{
		$("span#turbine_ratio_result").html("&nbsp;");
		$("span#turbine_ratio_result").removeClass();
		$("span#turbine_ratio_result").addClass("result_fail");
		$("span#turbine_ratio_result").html("请输入正确比例：如10:1");
	}
};
function ckturbine_amount(){
	var val=$("input#turbine_amount").val();
	if (val.length>0)
	{
		$("span#turbine_amount_result").html("&nbsp;");
		$("span#turbine_amount_result").removeClass();
		$("span#turbine_amount_result").addClass("result_ok");
	}
	else
	{
		$("span#turbine_amount_result").html("&nbsp;");
		$("span#turbine_amount_result").removeClass();
		$("span#turbine_amount_result").addClass("result_fail");
		$("span#turbine_amount_result").html("请输入正确份额");
	}
};
//设置footer在底端函数
var hsxSetFooterToBottom = function () {
 $('#footer')
 .css({
 visibility: 'visible',
 marginTop: (Math.max(0, $(window).height() - $('div#container').height() - 183)) +'px'
 });
};
// IE8 fires this resize on every mouseover that redraws the page!
// $(window).bind('resize', hsxSetFooterToBottom); 
//千位分隔符+取两位小数
function cc(s){
        //if(/^-/.test(s)) return "-";
        if(/[^0-9\.-]/.test(s)) return "invalid value";
        if(/-/.test(s))
        {
        	s=s.replace("-","");
        	s=s.replace(/^(\d*)$/,"$1.");
        	s=(s+"00").replace(/(\d*\.\d\d)\d*/,"$1");
        	s=s.replace(".",",");
        	var re=/(\d)(\d{3},)/;
        	while(re.test(s))
        	        s=s.replace(re,"$1,$2");
        	s=s.replace(/,(\d\d)$/,".$1");
        	return "-" + s.replace(/^\./,"0.")
        }
        else
        	{
        s=s.replace(/^(\d*)$/,"$1.");
        s=(s+"00").replace(/(\d*\.\d\d)\d*/,"$1");
        s=s.replace(".",",");
        var re=/(\d)(\d{3},)/;
        while(re.test(s))
                s=s.replace(re,"$1,$2");
        s=s.replace(/,(\d\d)$/,".$1");
        return s.replace(/^\./,"0.")
      		}
        }
//千位符，去小数
function ccg(s){
        if(/[^0-9\.-]/.test(s)) return "invalid value";
        if(/-/.test(s))
        {
        	s=s.replace("-","");
        	s=s.replace(/^(\d*)$/,"$1.");
        	s=(s+"00").replace(/(\d*\.\d\d)\d*/,"$1");
        	s=s.replace(".",",");
        	var re=/(\d)(\d{3},)/;
        	while(re.test(s))
        	        s=s.replace(re,"$1,$2");
        	s=s.replace(/,(\d\d)$/,"");
        	return "-" + s.replace(/^\./,"0.")
        }
        else
        	{
        s=s.replace(/^(\d*)$/,"$1.");
        s=(s+"00").replace(/(\d*\.\d\d)\d*/,"$1");
        s=s.replace(".",",");
        var re=/(\d)(\d{3},)/;
        while(re.test(s))
                s=s.replace(re,"$1,$2");
        s=s.replace(/,(\d\d)$/,"");
        return  s.replace(/^\./,"0.")
      		}
        }
//计算函数.
function range(close_price,current_price)
	{
x=Math.abs(((current_price-close_price)/close_price*100).toFixed(2))
return x
};
function cheng(a,b)
	{
x=(a*b)
return x
};
function jian(close_price,current_price)
	{
x=current_price-close_price
return x.toFixed(2)
};
function getRecomCap(){
	var recomcap = cc(cheng($("input#recom_price").val(),$("input#recom_amount").val()).toString());
	$("input#recom_cap").val(recomcap);
};
function getTurbineCap(){
	var turbinecap = cc(cheng($("input#turbine_ipoprice").val(),$("input#turbine_amount").val()).toString());
	$("input#turbine_cap").val(turbinecap);
};
//买卖公用函数
function entrust_detail() {
	var use_bonus
	if($("#bonus").attr("checked")==true)
	{use_bonus = 1}
	else
		use_bonus = 0
  return {
    "stock_code": $("#code").val(),
    "amount": $("#amount").val(),
    "price": $("#price").val(),
    "duration": $("#validity").val(),
    "use_bonus": use_bonus
  };
}
function show_result_noreset(data) {
	var info = data.content;
	switch (data.result){
		case 0:
		var info = "短信发送成功，请注意查收。";
		break;
	};
	infoShow(info);
};
//输出返回结果
function show_result(data) {
	//alert (data);
  var info = data.content;
  switch (data.result){
  case 0:
    if(info.match(/^[A-Z]{2}[0-9]{12}$/)) {
      info = '<h2>委托已受理</h2>';
      info += '<h5>'+'委托序号：'+data.content+'</h5>';
      info += '<br />'
      info += '<h5>'+'<a href="/invest/?btn=2">立即查看委托结果</a>'+'</h5>';
      reset();
      $("#entrust_no").text(data.entrust_no);
      $("form span#amount_x").html("");
      $("form span#code_x").html("");
      setTimeout('$("li#li10_1").click()', 2000);
      var code = $("input#code").val();
      setTimeout('showEntrustFive($("input#code").val())', 3000);
      setTimeout('showEntrustFive($("input#code").val())', 6000);
    }
    reset();
    $(".edittable span").removeClass();
    break;
  case 1:
    info += "<br />立即<a href='/invest/?btn=88'>增加购买力</a>";
    break;
  case 4:
    info += "<br />";
    break;
  case 5:
    info += "<br />";
    break;
  case 15:
    info += "<br />";
    break;
  case 16:
    info += "<br />";
    break;
  };
  //var info = data.result;
  info += '<center>';
  info += "<br /><input id='infoclose' value='确定' type='button'>";
  info += '</center>';
  $("div#info_div").html(info);
  if (typeof(data.post_margin) == "undefined")
  {}
  else
  {
  	$("span#can_out_balance").html(cc(data.post_margin.toString()));
  }
  $(document).ready(function(){
    $("input#infoclose").click(clickInfoCloseBtn);
    $("input#infobuybutton").click(clickInfoBuyBtn);
  });
  setInfoDivInMiddle();
  $("div#blackback").show();
$("div#info_div").show();
//$("div#info_div").css({left:50px;top:(document.documentElement.clientHeight)/2+document.documentElement.scrollTop;});
//$("div#info_div").css({left:$(this).offset().left,top:$(this).offset().top+$(this).outerHeight()});
};
function backInventBtn(){
  $("ul.applist1 li a").css("color","");
  $("div.trade div").hide();
};
//显示充值页面
function clickInventBtn88(){
	$.getJSON("/invest/assets.json?time="+new Date().getTime(),function(data){
		$("td#available_cash").html(cc(data.rmb.toString()));
		$("td#available_v_cash").html(cc(data.swd.toString()));
		});
  $("ul.applist1 li a").css("color","");
  $("#btn88").css("color","#84B84B");
  $("div.trade div").hide();
  $("div#charge").show();
  $("div#charge div").show();
  investAutoHight();
  };
//显示设置账户信息页面
function clickInventBtn99(){
  $("ul.applist1 li a").css("color","");
  $("#btn99").css("color","#84B84B");
  $("div.trade div").hide();
  $("div#myaccount").show();
  $("div#myaccount div").show();
  investAutoHight();
  };
//显示我的证书页面
function clickInventBtnMyLicense(){
  $("ul.applist1 li a").css("color","");
  $("#btnmylicense").css("color","#84B84B");
  $("div.trade div").hide();
  $("div#mylicense").show();
  $("div#mylicense div").show();
  $.get("/misc/land_cert/", function(data){
  	if (data==0)
  	{
  		//$("div#mylicense").html("请先购买<a href='/products/00700001'>钓鱼岛土地</a>！");
  	}
  	else
  	{
  		$("img#yangben1").remove();
  		$("img#yangben3").remove();
  		var aera=(data.amount*0.0047).toFixed(4)+"㎡"
  		$("p#lic1name").html(data.name+"&nbsp;");
  		$("p#lic1no").html(data.serial);
  		$("p#lic1id").html(data.id_no+"&nbsp;");
  		$("p#lic1date").html(data.get_date);
  		$("p#lic3name").html(data.name+"&nbsp;");
  		$("p#lic3holding").html(data.amount);
  		$("p#lic3aera").html(aera);
  		$("p#lic3date").html(data.get_date);
  	}
	});
  investAutoHight();
  };
//显示历史委托查询页面
function clickInventBtnHisEntrust(){
  $("ul.applist1 li a").css("color","");
  $("#btnhisentrust").css("color","#84B84B");
  $("div.trade div").hide();
  $("div#myhistrade").show();
  $("div#myhistrade div").show();
  if ($(".listbtn4_1").css("display")=="none")
  {
  	clickInventListBtn4();
  }
  investAutoHight();
  };
//历史委托查询按钮
function clickHisEntrustBtn(){
	$("tr.hisentrustempty").remove();
	var emp = '<tr class="hisentrustempty"><td colspan="10"><img src="/static/images/waiting.gif" height="25px"/></td></tr>'
	$('table#hisentrusttable').append(emp);
  $.getJSON("/invest/entrust_jour.json?time="+new Date().getTime()+"&start="+$("input#hisentrustfrom").val()+"&end="+$("input#hisentrustto").val(),function(data){
    $("tr.hisentrustempty").remove();
    $.each(data,function(entryIndex,entry){
      var html = '<tr class="hisentrustempty">';
      html += '<td>' + entry['occur_time'] + '</td>';
      html += '<td>' + entry['entrust_no'] + '</td>';
      html += '<td>' + entry['entrust_type'] + '</td>';
      html += '<td><a href="/products/'+entry['stock_code']+'">' + entry['stock_name'] + '</a></td>';
      html += '<td>' + entry['entrust_price'] + '</td>';
      html += '<td>' + entry['entrust_amount'] + '</td>';
      html += '<td>' + entry['dealed_amount'] + '</td>';
      html += '<td>' + entry['dealed_price'] + '</td>';
      html += '<td>' + entry['deal_status'] + '</td>';
      html += '<td>' + entry['expire'] + '</td>';
      html += '</tr>'
      $('table#hisentrusttable').append(html);
    });
    investAutoHight();
  });
};
function clickInventBtnHisFundjour(){
  $("ul.applist1 li a").css("color","");
  $("#btnhisfundjour").css("color","#84B84B");
  $("div.trade div").hide();
  $("div#hisfundjour").show();
  $("div#hisfundjour div").show();
  if ($(".listbtn4_1").css("display")=="none")
  {
  	clickInventListBtn4();
  }
  investAutoHight();
  };
function clickHisFundjourBtn(){
		   $.getJSON("/invest/fund_jour.json?time="+new Date().getTime()+"&start="+$("input#hisfundjourfrom").val()+"&end="+$("input#hisfundjourto").val(),function(data){
			     $("tr.hisfundjourempty").remove();
			     $.each(data,function(entryIndex,entry){
				    var html = '<tr class="hisfundjourempty">';
				    html += '<td>' + entry['occur_time'] + '</td>';
				    html += '<td>' + entry['reason'] + '</td>';
				    html += '<td>' + entry['occur_v_cash'] + '</td>';
				    html += '<td>' + entry['post_v_cash'] + '</td>';
				    html += '<td>' + entry['occur_cash'] + '</td>';
				    html += '<td>' + entry['post_cash'] + '</td>';
				    html += '</tr>'
				    $('table#hisfundjourtable').append(html);
				    });
  investAutoHight();
			     });
};
function clickInventBtnHisStockjour(){
  $("ul.applist1 li a").css("color","");
  $("#btnhisstockjour").css("color","#84B84B");
  $("div.trade div").hide();
  $("div#hisstockjour").show();
  $("div#hisstockjour div").show();
  if ($(".listbtn4_1").css("display")=="none")
  {
  	clickInventListBtn4();
  }
  investAutoHight();
  };
function clickInventBtnIntroduce(){
  $("ul.applist1 li a").css("color","");
  $("#btnintroduce").css("color","#84B84B");
  $("div.trade div").hide();
  $("div#introduce").show();
  $("div#introduce div").show();
  investAutoHight();
  };
function clickIntroduceBtn(){
	/*
	$("table#myintr").adminify("/user/recommender_info.json?time="+new Date().getTime()+"&start_date="+$("input#intrfrom").val()+"&end_date="+$("input#intrto").val(), 20, "nickname,realname,id_no,email,mobile,status,date_joined".split(","), function() {
      //console.debug($(this).children("#nickname").html());
      //alert($(this).children("#nickname").html());
      investAutoHight();
  });
  setTimeout('investAutoHight()', 1000);
  setTimeout('investAutoHight()', 2000);
  setTimeout('investAutoHight()', 3000);
  */
	$("tr.myintrempty").remove();
	var emp = '<tr class="myintrempty"><td colspan="7"><img src="/static/images/waiting.gif" height="25px"/></td></tr>'
	$('table#myintr').append(emp);
  $.getJSON("/user/recommender_info.json?time="+new Date().getTime()+"&start_date="+$("input#intrfrom").val()+"&end_date="+$("input#intrto").val(),function(data){
    $("tr.myintrempty").remove();
    $("span#total_intr").html(data.count);
    $.each(data.records,function(entryIndex,entry){
      var html = '<tr class="myintrempty">';
      html += '<td>' + entry['nickname'] + '</td>';
      html += '<td>' + entry['realname'] + '</td>';
      html += '<td>' + entry['id_no'] + '</td>';
      html += '<td>' + entry['email'] + '</td>';
      html += '<td>' + entry['mobile'] + '</td>';
      html += '<td>' + entry['status'] + '</td>';
      html += '<td>' + entry['date_joined'] + '</td>';
      html += '</tr>'
      $('table#myintr').append(html);
    });
    investAutoHight();
  });
};
function clickInventBtnBroker(){
  $("ul.applist1 li a").css("color","");
  $("#btnbroker").css("color","#84B84B");
  $("div.trade div").hide();
  $("div#broker").show();
  $("div#broker div").show();
  investAutoHight();
  };
function clickBrokerBtn(){
	$.getJSON("/invest/broker_info.json?time="+new Date().getTime()+"&startdate="+$("input#brokerfrom").val()+"&enddate="+$("input#brokerto").val(),function(data){
		$("span#total_commision").html(data.total_commision);
		$("span#unchecked_commision").html(jian(data.checked_commision,data.total_commision));
	});
	$("table#brokertable").adminify("/invest/broker_info.json?time="+new Date().getTime()+"&startdate="+$("input#brokerfrom").val()+"&enddate="+$("input#brokerto").val(), 20, "nickname,volume,commision".split(","), function() {
      //console.debug($(this).children("#nickname").html());
      //alert($(this).children("#nickname").html());
      investAutoHight();
  });
  setTimeout('investAutoHight()', 1000);
  setTimeout('investAutoHight()', 2000);
  setTimeout('investAutoHight()', 3000);
};
function clickHisStockjourBtn(){
		   $.getJSON("/invest/holding_jour.json?time="+new Date().getTime()+"&start="+$("input#hisstockjourfrom").val()+"&end="+$("input#hisstockjourto").val(),function(data){
			     $("tr.hisstockjourempty").remove();
			     $.each(data,function(entryIndex,entry){
				    var html = '<tr class="hisstockjourempty">';
				    html += '<td>' + entry['occur_time'] + '</td>';
				    html += '<td><a href="/products/'+entry['stock_code']+'">' + entry['stock_name'] + '</a></td>';
				    html += '<td><a href="/products/'+entry['stock_code']+'">' + entry['stock_code'] + '</a></td>';
				    html += '<td>' + entry['reason'] + '</td>';
				    html += '<td>' + entry['amount'] + '</td>';
				    html += '<td>' + entry['post_balance'] + '</td>';
				    html += '</tr>'
				    $('table#hisstockjourtable').append(html);
				    });
  investAutoHight();
			     });
	
};
function clickInventBtnBankjour(){
  $("ul.applist1 li a").css("color","");
  $("#btnbankjour").css("color","#84B84B");
  $("div.trade div").hide();
  $("div#bankjour").show();
  $("div#bankjour div").show();
  if ($(".listbtn1_1").css("display")=="none")
  {
  	clickInventListBtn1();
  }
  investAutoHight();
  };
function clickInventBtnGetgoodsjour(){
  $("ul.applist1 li a").css("color","");
  $("#btngetgoodsjour").css("color","#84B84B");
  $("div.trade div").hide();
  $("div#getgoodsjour").show();
  $("div#getgoodsjour div").show();
  if ($(".listbtn1_1").css("display")=="none")
  {
  	clickInventListBtn1();
  }
  investAutoHight();
  };
function clickInventBtnDeliver(){
  $("ul.applist1 li a").css("color","");
  $("#btndeliver").css("color","#84B84B");
  $("div.trade div").hide();
  $("div#deliver").show();
  $("div#deliver div").show();
  $("li#li11_0").click();
  if ($(".listbtn1_1").css("display")=="none")
  {
  	clickInventListBtn1();
  }
  investAutoHight();
  };
//查询转账流水
function clickBankjourBtn(){
	$("tr.bankjourempty").remove();
	var td_no = $('table#bankjourtable>thead>tr').children().length;
	var loading = '<tr class="bankjourempty"><td colspan="'+td_no+'"><img src="/static/images/waiting.gif" height="25px"/></td></tr>'
	$('table#bankjourtable').append(loading);
	$.getJSON("/invest/cashing_jour.json?time="+new Date().getTime()+"&start="+$("input#bankjourfrom").val()+"&end="+$("input#bankjourto").val(),function(data){
		$("tr.bankjourempty").remove();
		if(data.length>0)
		{
			$.each(data,function(entryIndex,entry){
				var html = '<tr class="bankjourempty">';
				html += '<td>' + entry['occur_time'] + '</td>';
				html += '<td>' + entry['_id'] + '</td>';
				html += '<td>' + entry['bank_name'] + '</td>';
				html += '<td>' + entry['bank_account'] + '</td>';
				html += '<td>' + entry['direction'] + '</td>';
				html += '<td>' + entry['amount'] + '</td>';
				html += '<td>' + entry['post_margin'] + '</td>';
				html += '<td>' + entry['status'] + '</td>';
				html += '</tr>';
				$('table#bankjourtable').append(html);
			});
		}
		else
		{
			var html = '<tr class="bankjourempty"><td colspan="'+td_no+'">无查询结果</td></tr>';
			$('table#bankjourtable').append(html);
		}
		investAutoHight();
	});
}
//查询提货流水
function clickGetgoodsjourBtn(){
	$("tr.getgoodsjourempty").remove();
	var td_no = $('table#getgoodsjourtable>thead>tr').children().length;
	var loading = '<tr class="getgoodsjourempty"><td colspan="'+td_no+'"><img src="/static/images/waiting.gif" height="25px"/></td></tr>'
	$('table#getgoodsjourtable').append(loading);
	$.getJSON("/invest/gooddelivery.json?time="+new Date().getTime()+"&start="+$("input#getgoodsjourfrom").val()+"&end="+$("input#getgoodsjourto").val(),function(data){
		$("tr.getgoodsjourempty").remove();
		if(data.length>0)
		{
			$.each(data,function(entryIndex,entry){
				var html = '<tr class="getgoodsjourempty">';
				html += '<td>' + entry['occur_time'] + '</td>';
				html += '<td>' + entry['serial'] + '</td>';
				html += '<td>' + entry['stock_name'] + '</td>';
				html += '<td>' + entry['amount'] + '</td>';
				html += '<td>' + entry['post_amount'] + '</td>';
				html += '<td>' + entry['receiver_name'] + '</td>';
				html += '<td>' + entry['receiver_address'] + '</td>';
				html += '<td>' + entry['receiver_zip'] + '</td>';
				html += '<td>' + entry['receiver_phone'] + '</td>';
				html += '<td>' + entry['status'] + '</td>';
				html += '</tr>';
				$('table#getgoodsjourtable').append(html);
			});
		}
		else
		{
			var html = '<tr class="getgoodsjourempty"><td colspan="'+td_no+'">无查询结果</td></tr>';
			$('table#getgoodsjourtable').append(html);
		}
		investAutoHight();
	});
}
//clickDeliverBtn
function clickDeliverBtn(){
  $("tr.11_0empty").remove();
  $("tr.11_1empty").remove();
  var td_no = $('table#11_0>thead>tr').children().length
	var emp0 = '<tr class="11_0empty"><td colspan="'+td_no+'"><img src="/static/images/waiting.gif" height="25px"/></td></tr>'
	var emp1 = '<tr class="11_1empty"><td colspan="'+td_no+'"><img src="/static/images/waiting.gif" height="25px"/></td></tr>'
	$('table#11_0').append(emp0);
	$('table#11_1').append(emp1);
		   $.getJSON("/invest/delivery_order.json?time="+new Date().getTime()+"&start="+$("input#deliverfrom").val()+"&end="+$("input#deliverto").val(),function(data){
			     $("tr.11_0empty").remove();
			     $("tr.11_1empty").remove();
			     if(data.length>0)
			     {
			     $.each(data,function(entryIndex,entry){
			     	if (entry['currency']=='RMB')
			     	{
				    var html = '<tr class="11_0empty">';
				    html += '<td>' + entry['occur_time'] + '</td>';
				    html += '<td>' + entry['deal_type'] + '</td>';
				    html += '<td><a href="/products/'+entry['stock_code']+'">' + entry['stock_code'] + '</a></td>';
				    html += '<td><a href="/products/'+entry['stock_code']+'">' + entry['stock_name'] + '</a></td>';
				    html += '<td>' + cc(entry['deal_price'].toString()) + '</td>';
				    html += '<td>' + ccg(entry['deal_amount'].toString()) + '</td>';
				    html += '<td>' + ccg(entry['post_holding'].toString()) + '</td>';
				    html += '<td>' + cc(entry['cost'].toString()) + '</td>';
				    html += '<td>' + cc(entry['charge'].toString()) + '</td>';
				    html += '<td>' + cc(entry['transfer_fee'].toString()) + '</td>';
				    html += '<td>' + cc(entry['clear_fee'].toString()) + '</td>';
				    html += '<td>' + cc(entry['sum_cost'].toString()) + '</td>';
				    html += '<td>' + cc(entry['post_balance'].toString()) + '</td>';
				    html += '<td>' + entry['currency'] + '</td>';
				    html += '</tr>'
				    $('table#11_0').append(html);
				  	}
			     	else
			     	{
				    var v_html = '<tr class="11_1empty">';
				    v_html += '<td>' + entry['occur_time'] + '</td>';
				    v_html += '<td>' + entry['deal_type'] + '</td>';
				    v_html += '<td><a href="/products/'+entry['stock_code']+'">' + entry['stock_code'] + '</a></td>';
				    v_html += '<td><a href="/products/'+entry['stock_code']+'">' + entry['stock_name'] + '</a></td>';
				    v_html += '<td>' + cc(entry['deal_price'].toString()) + '</td>';
				    v_html += '<td>' + ccg(entry['deal_amount'].toString()) + '</td>';
				    v_html += '<td>' + ccg(entry['post_holding'].toString()) + '</td>';
				    v_html += '<td>' + cc(entry['cost'].toString()) + '</td>';
				    v_html += '<td>' + cc(entry['charge'].toString()) + '</td>';
				    v_html += '<td>' + cc(entry['transfer_fee'].toString()) + '</td>';
				    v_html += '<td>' + cc(entry['clear_fee'].toString()) + '</td>';
				    v_html += '<td>' + cc(entry['sum_cost'].toString()) + '</td>';
				    v_html += '<td>' + cc(entry['post_balance'].toString()) + '</td>';
				    v_html += '<td>' + entry['currency'] + '</td>';
				    v_html += '</tr>'
				    $('table#11_1').append(v_html);
				  	}
				    });
				    }
				    else
				    	{
				    		var html = '<tr class="11_0empty"><td colspan="'+td_no+'">无查询结果</td></tr>';
				    		var v_html = '<tr class="11_1empty"><td colspan="'+td_no+'">无查询结果</td></tr>';
				    		$('table#11_0').append(html);
				    		$('table#11_1').append(v_html);
				    	}
  investAutoHight();
			     });
	
};
//产品页查询历史行情
function clickHisPriceBtn(stock_code){
		   $.getJSON("/products/history_price.json?time="+new Date().getTime()+"&start="+$("input#hispricefrom").val()+"&end="+$("input#hispriceto").val()+"&stock_code="+stock_code,function(data){
			     $("tr.hispriceempty").remove();
			     $.each(data,function(entryIndex,entry){
				    var html = '<tr class="hispriceempty">';
				    html += '<td>' + entry['date'] + '</td>';
				    html += '<td>' + entry['start_price'] + '</td>';
				    html += '<td>' + entry['highest_price'] + '</td>';
				    html += '<td>' + entry['lowest_price'] + '</td>';
				    html += '<td>' + entry['close_price'] + '</td>';
				    html += '<td>' + entry['volume'] + '</td>';
				    html += '</tr>'
				    $('table#hispricetable').append(html);
				    });
			     });
	
};
function clickHisPrice(){
	$("div#entrustfivedetail").hide();
	$("div#description").hide();
	$("div#hisprice").show();
};
function clickEntrustFiveDetail(stock_code){
	$("div#description").hide();
	$("div#hisprice").hide();
	$("div#entrustfivedetail").show();
	$.getJSON("/entrust/entrusts5_detail.json?time="+new Date().getTime()+"&stock_code="+stock_code,function(data){
		$("tr.entrust5detailempty").remove();
		$.each(data,function(entryIndex,entry){
			var html = '<tr class="entrust5detailempty">';
			html += '<td>' + entry['occur_time'] + '</td>';
			html += '<td>' + entry['nickname'] + '</td>';
			html += '<td>' + entry['entrust_price'] + '</td>';
			html += '<td>' + entry['entrust_amount'] + '</td>';
			html += '<td>' + entry['entrust_type'] + '</td>';
			html += '</tr>'
			$('table#entrust5detailtable').append(html);
		});
	});
};
function clickInventBtn0(){
	showInvestHot();
  $("ul.applist1 li a").css("color","");
  $("#btn0").css("color","#84B84B");
  $("ul#entrustbuttonul li a").css("color","");
  $("a#btn0_0").css("color","#84B84B");
  $("div.trade div").hide();
  $("div#myentrust").show();
  $("div#myentrust div").hide();
  $("div#entrustbutton").show();
  $("div#entrustblock").show();
  $("div#buy").show();
  $("div#buy div").show();
  if ($(".listbtn1_1").css("display")=="none")
  {
  	clickInventListBtn1();
  }
  clickInventBtn0_0();
  investAutoHight();
  $("li#li10_0").click();
  };
function clickInventBtn1(){
		   $.getJSON("/invest/assets2.json?time="+new Date().getTime(),function(data){
			     $("td#v_current_balance").html(cc((data.v.margin+data.v.long_value+data.v.short_value-data.v.debt+data.v.long_frozen+data.v.short_frozen).toString()));
			     $("td#v_stock_balance").html(cc((data.v.long_value+data.v.short_value).toString()));
			     $("td#v_margin_rate").html(data.v.margin_rate*100+"%");
			     $("td#v_cash_balance").html(cc(data.v.balance.toString()));
			     $("td#v_margin_balance").html(cc(data.v.margin.toString()));
			     $("td#v_bonus").html(cc(data.v.bonus.toString()));
			     $("td#v_debt_balance").html(cc(data.v.debt.toString()));
			     $("td#v_frozen_balance").html(cc(data.v.frozen.toString()));
                             //
			     $("td#current_balance").html(cc((data.r.margin+data.r.long_value+data.r.short_value-data.r.debt+data.r.long_frozen+data.r.short_frozen).toString()));
			     $("td#stock_balance").html(cc((data.r.long_value+data.r.short_value).toString()));
			     $("td#margin_rate").html(data.r.margin_rate*100+"%");
			     $("td#cash_balance").html(cc(data.r.balance.toString()));
			     $("td#margin_balance").html(cc(data.r.margin.toString()));
			     $("td#bonus").html(cc(data.r.bonus.toString()));
			     $("td#debt_balance").html(cc(data.r.debt.toString()));
			     $("td#frozen_balance").html(cc(data.r.frozen.toString()));
			     //
			     $("td#v_margin_2").html(cc(data.v.margin.toString()));
			     $("td#v_frozen_2").html(cc(data.v.frozen.toString()));
			     $("td#v_long_frozen_2").html(cc(data.v.long_frozen.toString()));
			     $("td#v_short_frozen_2").html(cc(data.v.short_frozen.toString()));
			     $("td#v_long_value_2").html(cc(data.v.long_value.toString()));
			     $("td#v_short_value_2").html(cc(data.v.short_value.toString()));
			     $("td#v_margin_rate_2").html(data.v.margin_rate*100+"%");
			     $("td#v_debt_2").html(cc(data.v.debt.toString()));
			     $("td#v_interest_2").html(cc(data.v.interest.toString()));
			     $("td#v_balance_2").html(cc(data.v.balance.toString()));
			     //
			     $("td#r_margin_2").html(cc(data.r.margin.toString()));
			     $("td#r_frozen_2").html(cc(data.r.frozen.toString()));
			     $("td#r_long_frozen_2").html(cc(data.r.long_frozen.toString()));
			     $("td#r_short_frozen_2").html(cc(data.r.short_frozen.toString()));
			     $("td#r_long_value_2").html(cc(data.r.long_value.toString()));
			     $("td#r_short_value_2").html(cc(data.r.short_value.toString()));
			     $("td#r_margin_rate_2").html(data.r.margin_rate*100+"%");
			     $("td#r_debt_2").html(cc(data.r.debt.toString()));
			     $("td#r_interest_2").html(cc(data.r.interest.toString()));
			     $("td#r_balance_2").html(cc(data.r.balance.toString()));
			     });
		   $.getJSON("/invest/holdings.json?time="+new Date().getTime(),function(data){
			     $("tr.stockempty").remove();
			     var shizhi=0;
			     var yingkui=0;
			     var v_shizhi=0;
			     var v_yingkui=0;
			     $.each(data,function(entryIndex,entry){
			     	if (entry['currency_display']=='W$' )
			     	{
			     	  shizhi += cheng(entry['current_price'],entry['total']);
			     	  if (entry['holding_type']=='多头')
			     	  {
			     	  	yingkui += entry['total']*(entry['current_price']-entry['avr_cost']);
			     	  }
			     	  else
			     	  {
			     	  	yingkui += entry['total']*(entry['avr_cost']-entry['current_price']);
			     	  }
			     	}
			     	else
			     	{
			     		v_shizhi += cheng(entry['current_price'],entry['total']);
			     	  if (entry['holding_type']=='多头')
			     	  {
			     	  	v_yingkui += entry['total']*(entry['current_price']-entry['avr_cost']);
			     	  }
			     	  else
			     	  {
			     	  	v_yingkui += entry['total']*(entry['avr_cost']-entry['current_price']);
			     	  }
			     	}
				    var html = '<tr class="stockempty">';
				    html += '<td><a href="/products/'+entry['stock_code']+'">' + entry['stock_code'] + '</a></td>';
				    html += '<td><a href="/products/'+entry['stock_code']+'">' + entry['stock_name'] + '</a></td>';
				    //html += '<td><a href="/products/'+entry['stock_code']+'">' + entry['stock_alias'] + '</a></td>';
				    html += '<td>' + ccg(entry['total'].toString()) + '</td>';
				    html += '<td>' + entry['holding_type'] + '</td>';
				    html += '<td>' + ccg(entry['avialable'].toString()) + '</td>';
				    html += '<td>' + entry['avr_cost'] + '</td>';
				    html += '<td>' + entry['current_price'] + '</td>';
				    html += '<td>' + cheng(entry['current_price'],entry['total']).toFixed(2) + '</td>';
				    if ((entry['current_price'] - entry['close_price'])>0) 
				    {html += '<td><span class=up>' + range(entry['close_price'],entry['current_price']).toFixed(2) +'%' + '</span></td>';}
				    else if ((entry['current_price'] - entry['close_price'])==0)
				    {html += '<td><span class=nochange>' + range(entry['close_price'],entry['current_price']).toFixed(2) +'%' + '</span></td>';}
				    else
				    {html += '<td><span class=down>' + range(entry['close_price'],entry['current_price']).toFixed(2) +'%' + '</span></td>';}
				    if (entry['holding_type']=='多头')
				    {
				    if ((entry['total']*(entry['current_price']-entry['avr_cost']))>0)
				    {html += '<td><span class=up>' + cc((entry['total']*(entry['current_price']-entry['avr_cost'])).toFixed(2))+ '</span></td>';}
				    else if ((entry['total']*(entry['current_price']-entry['avr_cost']))==0)
				    {html += '<td><span class=nochange>' + cc((entry['total']*(entry['current_price']-entry['avr_cost'])).toFixed(2))+ '</span></td>';}
				    else
				    {html += '<td><span class=down>' + cc((entry['total']*(entry['avr_cost']-entry['current_price'])).toFixed(2))+ '</span></td>';}
				  	}
				  	else
				  		{
				  			if ((entry['total']*(entry['current_price']-entry['avr_cost']))<0)
				    		{html += '<td><span class=up>' + cc((entry['total']*(entry['avr_cost']-entry['current_price'])).toFixed(2))+ '</span></td>';}
				    		else if ((entry['total']*(entry['current_price']-entry['avr_cost']))==0)
				    		{html += '<td><span class=nochange>' + cc((entry['total']*(entry['current_price']-entry['avr_cost'])).toFixed(2))+ '</span></td>';}
				    		else
				    		{html += '<td><span class=down>' + cc((entry['total']*(entry['current_price']-entry['avr_cost'])).toFixed(2))+ '</span></td>';}
				  		}
				    html += '<td><a class="trade_button" code = '+entry['stock_code']+' price = ' + entry['current_price'] + ' amount = ' + entry['avialable'] + '>交易</a></td>'
				    //html += '<td><a href="/products/'+entry['stock_code']+'">交易</a></td>'
				    html += '</tr>'
				    $('table#stock').append(html);
				    $("a.trade_button").click(function(){
				    	var amount = $(this).attr("amount");
				    	var code = $(this).attr("code");
				    	var price = $(this).attr("price");
				    	$("input#code").val(code);
				    	$("input#price").val(price);
				    	$("input#amount").val(amount);
				    	getTradePrice();
				    	getTradeCanDo();
				    	showEntrustFive(code);
				    	clickInventBtn0();
				    	});
				    });
				    if (yingkui>0)
				    {
				    	var lastline='<tr class="stockempty"><td></td><td></td><td></td><td></td><td></td><td colspan="2">合计期酒币市值：</td><td>' + cc(shizhi.toString()) + '</td><td>累积期酒币盈亏：</td><td><span class=up>' + cc(yingkui.toString()) + '</span></td><td></td></tr>'
				    }
				    else if (yingkui==0)
				    {
				    	var lastline='<tr class="stockempty"><td></td><td></td><td></td><td></td><td></td><td colspan="2">合计期酒币市值：</td><td>' + cc(shizhi.toString()) + '</td><td>累积期酒币盈亏：</td><td><span class=nochange>' + cc(yingkui.toString()) + '</span></td><td></td></tr>'
				    }
				    else
				    {
				    	var lastline='<tr class="stockempty"><td></td><td></td><td></td><td></td><td></td><td colspan="2">合计期酒币市值：</td><td>' + cc(shizhi.toString()) + '</td><td>累积期酒币盈亏：</td><td><span class=down>' + cc(Math.abs(yingkui).toString()) + '</span></td><td></td></tr>'
				    }
				    if (v_yingkui>0)
				    {
				    	var v_lastline='<tr class="stockempty"><td></td><td></td><td></td><td></td><td></td><td colspan="2">合计人民币市值：</td><td>' + cc(v_shizhi.toString()) + '</td><td>累积人民币盈亏：</td><td><span class=up>' + cc(v_yingkui.toString()) + '</span></td><td></td></tr>'
				    }
				    else if (v_yingkui==0)
				    {
				    	var v_lastline='<tr class="stockempty"><td></td><td></td><td></td><td></td><td></td><td colspan="2">合计人民币市值：</td><td>' + cc(v_shizhi.toString()) + '</td><td>累积人民币盈亏：</td><td><span class=nochange>' + cc(v_yingkui.toString()) + '</span></td><td></td></tr>'
				    }
				    else
				    {
				    	var v_lastline='<tr class="stockempty"><td></td><td></td><td></td><td></td><td></td><td colspan="2">合计人民币市值：</td><td>' + cc(v_shizhi.toString()) + '</td><td>累积人民币盈亏：</td><td><span class=down>' + cc(Math.abs(v_yingkui).toString()) + '</span></td><td></td></tr>'
				    }
				    $('table#stock').append(lastline);
				    $('table#stock').append(v_lastline);
  if ($(".listbtn1_1").css("display")=="none")
  {
  	clickInventListBtn1();
  }
  investAutoHight();
			     });
  $("ul.applist1 li a").css("color","");
  $("#btn1").css("color","#84B84B");
  $("div.trade div").hide();
  $("div#myport").show();
  $("div#myport div").show();
  $("li#li9_0").addClass("select");
  $("#9_1").hide();
  $("li#li9_0").click();
  };
function clickInventBtn2(){
		   $.getJSON("/invest/entrust_jour.json?time="+new Date().getTime(),function(data){
			     $("tr.entrustempty").remove();
			     $.each(data,function(entryIndex,entry){
				    var html = '<tr class="entrustempty">';
				    html += '<td>' + entry['occur_time'] + '</td>';
				    html += '<td>' + entry['entrust_type'] + '</td>';
				    html += '<td><a href="/products/'+entry['stock_code']+'">' + entry['stock_name'] + '</a></td>';
				    html += '<td>' + entry['entrust_price'] + '</td>';
				    html += '<td>' + entry['entrust_amount'] + '</td>';
				    html += '<td>' + entry['dealed_amount'] + '</td>';
				    html += '<td>' + entry['dealed_price'] + '</td>';
				    html += '<td>' + entry['deal_status'] + '</td>';
				    html += '<td>' + entry['expire'] + '</td>';
				    if (entry['deal_status']=="已提交")
				    	{
				    		html += '<td><input type="button" class="changebutton" value="修改" entrust_no="' + entry['entrust_no'] + '" stock_code="' + entry['stock_code'] + '" entrust_amount="' + entry['entrust_amount'] + '" entrust_price="' + entry['entrust_price'] + '"entrust_type="' + entry['entrust_type'] + '"/><input type="button" class="cancelbutton" value="撤单" entrust_no="' + entry['entrust_no'] + '"entrust_amount="' + entry['entrust_amount']+ '"entrust_type="' + entry['entrust_type']+ '"stock_name="' + entry['stock_name'] + '" /></td>';
				  		}
				    else if (entry['deal_status']=="部分成交")
				    	{
				    		html += '<td><input type="button" class="changebutton" value="修改" entrust_no="' + entry['entrust_no'] + '" stock_code="' + entry['stock_code'] + '" entrust_amount="' + (entry['entrust_amount']-entry['dealed_amount']) + '" entrust_price="' + entry['entrust_price'] + '"entrust_type="' + entry['entrust_type'] + '"/><input type="button" class="cancelbutton" value="撤单" entrust_no="' + entry['entrust_no'] + '"entrust_amount="' + entry['entrust_amount']+ '"entrust_type="' + entry['entrust_type']+ '"stock_name="' + entry['stock_name'] + '" /></td>';
				  		}
				  	else
				  		{
				    		html += '<td>无可操作项</td>';
				  		}
				    html += '</tr>'
				    $('table#entrust').append(html);
  					$(document).ready(function(){
  								$("input.cancelbutton").click(clickInventCancelBtn);
  								$("input.changebutton").click(clickChangeBtn);
							   	});
				    });
  if ($(".listbtn1_1").css("display")=="none")
  {
  	clickInventListBtn1();
  }
  investAutoHight();
			     });
  $("ul.applist1 li a").css("color","");
  $("#btn2").css("color","#84B84B");
  $("div.trade div").hide();
  $("div#mytrade").show();
  $("div#mytrade div").show();
  };
function clickInventBtn3(){
		   $.getJSON("/invest/fund_jour.json?time="+new Date().getTime(),function(data){
			     $("tr.fundjourempty").remove();
			     $.each(data,function(entryIndex,entry){
				    var html = '<tr class="fundjourempty">';
				    html += '<td>' + entry['occur_time'] + '</td>';
				    html += '<td>' + entry['reason'] + '</td>';
				    html += '<td>' + entry['occur_v_cash'] + '</td>';
				    html += '<td>' + entry['post_v_cash'] + '</td>';
				    html += '<td>' + entry['occur_cash'] + '</td>';
				    html += '<td>' + entry['post_cash'] + '</td>';
				    html += '</tr>'
				    $('table#fundjourtable').append(html);
				    });
  if ($(".listbtn1_1").css("display")=="none")
  {
  	clickInventListBtn1();
  }
  investAutoHight();
			     });
  $("ul.applist1 li a").css("color","");
  $("#btn3").css("color","#84B84B");
  $("div.trade div").hide();
  $("div#fundjour").show();
  $("div#fundjour div").show();
  }
function clickInventBtn4(){
		   $.getJSON("/invest/holding_jour.json?time="+new Date().getTime(),function(data){
			     $("tr.stockjourempty").remove();
			     $.each(data,function(entryIndex,entry){
				    var html = '<tr class="stockjourempty">';
				    html += '<td>' + entry['occur_time'] + '</td>';
				    html += '<td><a href="/products/'+entry['stock_code']+'">' + entry['stock_name'] + '</a></td>';
				    html += '<td><a href="/products/'+entry['stock_code']+'">' + entry['stock_code'] + '</a></td>';
				    html += '<td>' + entry['reason'] + '</td>';
				    html += '<td>' + entry['amount'] + '</td>';
				    html += '<td>' + entry['post_balance'] + '</td>';
				    html += '</tr>'
				    $('table#stockjourtable').append(html);
				    });
  if ($(".listbtn1_1").css("display")=="none")
  {
  	clickInventListBtn1();
  }
  investAutoHight();
			     });
  $("ul.applist1 li a").css("color","");
  $("#btn4").css("color","#84B84B");
  $("div.trade div").hide();
  $("div#stockjour").show();
  $("div#stockjour div").show();
  };
function clickInventBtn5(){
  $("ul.applist1 li a").css("color","");
  $("#btn5").css("color","#84B84B");
  $("div.trade div").hide();
  $("div#issuebond").show();
  $("div#issuebond div").show();
  investAutoHight();
  };
function clickInventBtn6(){
  $("ul.applist1 li a").css("color","");
  $("#btn6").css("color","#84B84B");
  $("div.trade div").hide();
  $("div#recommendmarket").show();
  $("div#recommendmarket div").show();
  if ($(".listbtn2_1").css("display")=="none")
  {
  	clickInventListBtn2();
  }
  investAutoHight();
  };
function clickInventBtn7(){
  $("ul.applist1 li a").css("color","");
  $("#btn7").css("color","#84B84B");
  $("div.trade div").hide();
  $("div#organizeturbine").show();
  $("div#organizeturbine div").show();
  if ($(".listbtn2_1").css("display")=="none")
  {
  	clickInventListBtn2();
  }
  investAutoHight();
  };
function clickInventBtn8(){
  $("ul.applist1 li a").css("color","");
  $("#btn8").css("color","#84B84B");
  $("div.trade div").hide();
  $("div#mystockcompany").show();
  $("div#mystockcompany div").show();
  if ($(".listbtn2_1").css("display")=="none")
  {
  	clickInventListBtn2();
  }
  investAutoHight();
  };
function clickInventBtn9(){
  $("ul.applist1 li a").css("color","");
  $("#btn9").css("color","#84B84B");
  $("div.trade div").hide();
  $("div#myfundcompany").show();
  $("div#myfundcompany div").show();
  investAutoHight();
  };
function clickInventBtn10(){
  $("ul.applist1 li a").css("color","");
  $("#btn10").css("color","#84B84B");
  $("div.trade div").hide();
  $("div#mybank").show();
  $("div#mybank div").show();
  if ($(".listbtn2_1").css("display")=="none")
  {
  	clickInventListBtn2();
  }
  investAutoHight();
  };
function clickInventBtn11(){
  $("ul.applist1 li a").css("color","");
  $("#btn11").css("color","#84B84B");
  $("div.trade div").hide();
  $("div#invite").show();
  $("div#invite div").show();
  if ($(".listbtn3_1").css("display")=="none")
  {
  	clickInventListBtn3();
  }
  investAutoHight();
  };
function clickInventBtn12(){
  $("ul.applist1 li a").css("color","");
  $("#btn12").css("color","#84B84B");
  $("div.trade div").hide();
  $("div#employment").show();
  $("div#employment div").show();
  if ($(".listbtn3_1").css("display")=="none")
  {
  	clickInventListBtn3();
  }
  investAutoHight();
  };
function clickInventBtn0_0(){
  investAutoHight();
  $("ul#entrustbuttonul li a").css("color","");
  $("a#btn0_0").css("color","#84B84B");
  $("div#entrustblock div").hide();
  $("div#entrustbutton").show();
  $("div#buy").show();
  $("div#tradehelp").show();
  $("div#buy div").show();
  $("div#tradehelp div").show();
  $("div#investhot").show();
  $("div#investhot div").show();
  $("div#auto").css("display","");
  investAutoHight();
  };
function clickInventBtn0_1(){
  $("ul#entrustbuttonul li a").css("color","");
  $("a#btn0_1").css("color","#84B84B");
  $("div#entrustblock div").hide();
  $("div#entrustbutton").show();
  $("div#sell").show();
  $("div#sell div").show();
  };

function clickInventBtn0_2(){
	$.getJSON("/invest/entrust_jour.json?time="+new Date().getTime(),function(data){
			     $("tr.entrust1empty").remove();
			     $.each(data,function(entryIndex,entry){
				    var html = '<tr class="entrust1empty">';
				    html += '<td>' + entry['occur_time'] + '</td>';
				    html += '<td>' + entry['entrust_type'] + '</td>';
				    html += '<td><a href="/products/'+entry['stock_code']+'">' + entry['stock_name'] + '</a></td>';
				    html += '<td>' + entry['entrust_price'] + '</td>';
				    html += '<td>' + entry['entrust_amount'] + '</td>';
				    html += '<td>' + entry['dealed_amount'] + '</td>';
				    html += '<td>' + entry['dealed_price'] + '</td>';
				    html += '<td>' + entry['deal_status'] + '</td>';
				    html += '<td>' + entry['expire'] + '</td>';
				    if (entry['deal_status']=="已提交")
				    	{
				    		html += '<td><input type="button" class="changebutton" value="修改" entrust_no="' + entry['entrust_no'] + '" stock_code="' + entry['stock_code'] + '" entrust_amount="' + entry['entrust_amount'] + '" entrust_price="' + entry['entrust_price'] + '"entrust_type="' + entry['entrust_type'] + '"/><input type="button" class="cancelbutton" value="撤单" entrust_no="' + entry['entrust_no'] + '"entrust_amount="' + entry['entrust_amount']+ '"entrust_type="' + entry['entrust_type']+ '"stock_name="' + entry['stock_name'] + '" /></td>';
				  		}
				    else if (entry['deal_status']=="部分成交")
				    	{
				    		html += '<td><input type="button" class="changebutton" value="修改" entrust_no="' + entry['entrust_no'] + '" stock_code="' + entry['stock_code'] + '" entrust_amount="' + (entry['entrust_amount']-entry['dealed_amount']) + '" entrust_price="' + entry['entrust_price'] + '"entrust_type="' + entry['entrust_type'] + '"/><input type="button" class="cancelbutton" value="撤单" entrust_no="' + entry['entrust_no'] + '"entrust_amount="' + entry['entrust_amount']+ '"entrust_type="' + entry['entrust_type']+ '"stock_name="' + entry['stock_name'] + '" /></td>';
				  		}
				  	else
				  		{
				    		html += '<td>无可操作项</td>';
				  		}
				    html += '</tr>'
				    $('table#entrust1').append(html);
  					$(document).ready(function(){
  								$("input.cancelbutton").click(clickInventCancelBtn);
  								$("input.changebutton").click(clickChangeBtn);
							   	});
				    });
  investAutoHight();
			     });
  $("ul#entrustbuttonul li a").css("color","");
  $("#btn0_2").css("color","#84B84B");
  $("div#entrustblock div").hide();
  $("div#entrustbutton").show();
  $("div#cancel").show();
  $("div#cancel div").show();
  };
function clickInventBtn0_3(){
  $("ul#entrustbuttonul li a").css("color","");
  $("#btn0_3").css("color","#84B84B");
  $("div#entrustblock div").hide();
  $("div#entrustbutton").show();
  $("div#real").show();
  $("div#real div").show();
  };
function clickLi10_0(){
	$.getJSON("/invest/holdings.json?time="+new Date().getTime(),function(data){
		$("tr.10_0empty").remove();
		var shizhi=0;
		var yingkui=0;
		var v_shizhi=0;
		var v_yingkui=0;
		$.each(data,function(entryIndex,entry){
			if (entry['currency_display']=='W$' )
			{
			  shizhi += cheng(entry['current_price'],entry['total']);
			  if (entry['holding_type']=='多头')
			  {
			  	yingkui += entry['total']*(entry['current_price']-entry['avr_cost']);
			  }
			  else
			  {
			  	yingkui += entry['total']*(entry['avr_cost']-entry['current_price']);
			  }
			}
			else
			{
				v_shizhi += cheng(entry['current_price'],entry['total']);
			  if (entry['holding_type']=='多头')
			  {
			  	v_yingkui += entry['total']*(entry['current_price']-entry['avr_cost']);
			  }
			  else
			  {
			  	v_yingkui += entry['total']*(entry['avr_cost']-entry['current_price']);
			  }
			}
			var html = '<tr class="10_0empty" code = '+entry['stock_code']+' price = ' + entry['current_price'] + ' amount = ' + entry['avialable'] + '>';
			html += '<td><a href="/products/'+entry['stock_code']+'">' + entry['stock_code'] + '</a></td>';
			html += '<td><a href="/products/'+entry['stock_code']+'">' + entry['stock_name'] + '</a></td>';
			//html += '<td><a href="/products/'+entry['stock_code']+'">' + entry['stock_alias'] + '</a></td>';
			html += '<td>' + ccg(entry['total'].toString()) + '</td>';
			html += '<td>' + entry['holding_type'] + '</td>';
			html += '<td>' + ccg(entry['avialable'].toString()) + '</td>';
			html += '<td>' + entry['avr_cost'] + '</td>';
			html += '<td>' + entry['current_price'] + '</td>';
			html += '<td>' + cheng(entry['current_price'],entry['total']).toFixed(2) + '</td>';
			if ((entry['current_price'] - entry['close_price'])>0) 
			{html += '<td><span class=up>' + range(entry['close_price'],entry['current_price']).toFixed(2) +'%' + '</span></td>';}
			else if ((entry['current_price'] - entry['close_price'])==0)
			{html += '<td><span class=nochange>' + range(entry['close_price'],entry['current_price']).toFixed(2) +'%' + '</span></td>';}
			else
			{html += '<td><span class=down>' + range(entry['close_price'],entry['current_price']).toFixed(2) +'%' + '</span></td>';}
			if (entry['holding_type']=='多头')
				    {
				    if ((entry['total']*(entry['current_price']-entry['avr_cost']))>0)
				    {html += '<td><span class=up>' + cc((entry['total']*(entry['current_price']-entry['avr_cost'])).toFixed(2))+ '</span></td>';}
				    else if ((entry['total']*(entry['current_price']-entry['avr_cost']))==0)
				    {html += '<td><span class=nochange>' + cc((entry['total']*(entry['current_price']-entry['avr_cost'])).toFixed(2))+ '</span></td>';}
				    else
				    {html += '<td><span class=down>' + cc((entry['total']*(entry['avr_cost']-entry['current_price'])).toFixed(2))+ '</span></td>';}
				  	}
				  	else
				  		{
				  			if ((entry['total']*(entry['current_price']-entry['avr_cost']))<0)
				    		{html += '<td><span class=up>' + cc((entry['total']*(entry['avr_cost']-entry['current_price'])).toFixed(2))+ '</span></td>';}
				    		else if ((entry['total']*(entry['current_price']-entry['avr_cost']))==0)
				    		{html += '<td><span class=nochange>' + cc((entry['total']*(entry['current_price']-entry['avr_cost'])).toFixed(2))+ '</span></td>';}
				    		else
				    		{html += '<td><span class=down>' + cc((entry['total']*(entry['current_price']-entry['avr_cost'])).toFixed(2))+ '</span></td>';}
				  		}
			html += '<td><a>交易</a></td>'
			html += '</tr>'
//easytrade
			$('table#10_0').append(html);
			  $("tr.10_0empty").click(function(){
  	var amount = $(this).attr("amount");
  	var code = $(this).attr("code");
  	var price = $(this).attr("price");
  	$("input#code").val(code);
  	$("input#price").val(price);
  	$("input#amount").val(amount);
  	getTradePrice();
  	getTradeCanDo();
  	showEntrustFive(code);
  });
		});
		if (yingkui>0)
		{
			var lastline='<tr class="10_0empty"><td></td><td></td><td></td><td></td><td></td><td colspan="2">合计期酒币市值：</td><td>' + cc(shizhi.toString()) + '</td><td>累积期酒币盈亏：</td><td><span class=up>' + cc(yingkui.toString()) + '</span></td><td></td></tr>'
		}
		else if (yingkui==0)
		{
			var lastline='<tr class="10_0empty"><td></td><td></td><td></td><td></td><td></td><td colspan="2">合计期酒币市值：</td><td>' + cc(shizhi.toString()) + '</td><td>累积期酒币盈亏：</td><td><span class=nochange>' + cc(yingkui.toString()) + '</span></td><td></td></tr>'
		}
		else
		{
			var lastline='<tr class="10_0empty"><td></td><td></td><td></td><td></td><td></td><td colspan="2">合计期酒币市值：</td><td>' + cc(shizhi.toString()) + '</td><td>累积期酒币盈亏：</td><td><span class=down>' + cc(Math.abs(yingkui).toString()) + '</span></td><td></td></tr>'
		}
		if (v_yingkui>0)
		{
			var v_lastline='<tr class="10_0empty"><td></td><td></td><td></td><td></td><td></td><td colspan="2">合计人民币市值：</td><td>' + cc(v_shizhi.toString()) + '</td><td>累积人民币盈亏：</td><td><span class=up>' + cc(v_yingkui.toString()) + '</span></td><td></td></tr>'
		}
		else if (v_yingkui==0)
		{
			var v_lastline='<tr class="10_0empty"><td></td><td></td><td></td><td></td><td></td><td colspan="2">合计人民币市值：</td><td>' + cc(v_shizhi.toString()) + '</td><td>累积人民币盈亏：</td><td><span class=nochange>' + cc(v_yingkui.toString()) + '</span></td><td></td></tr>'
		}
		else
		{
			var v_lastline='<tr class="10_0empty"><td></td><td></td><td></td><td></td><td></td><td colspan="2">合计人民币市值：</td><td>' + cc(v_shizhi.toString()) + '</td><td>累积人民币盈亏：</td><td><span class=down>' + cc(Math.abs(v_yingkui).toString()) + '</span></td><td></td></tr>'
		}
		$('table#10_0').append(lastline);
		$('table#10_0').append(v_lastline);
		investAutoHight();
	});
};
function clickLi10_1(){
	$.getJSON("/invest/entrust_jour.json?time="+new Date().getTime(),function(data){
			     $("tr.10_1empty").remove();
			     $.each(data,function(entryIndex,entry){
				    var html = '<tr class="10_1empty">';
				    html += '<td>' + entry['occur_time'] + '</td>';
				    html += '<td>' + entry['entrust_type'] + '</td>';
				    html += '<td><a href="/products/'+entry['stock_code']+'">' + entry['stock_name'] + '</a></td>';
				    html += '<td>' + entry['entrust_price'] + '</td>';
				    html += '<td>' + entry['entrust_amount'] + '</td>';
				    html += '<td>' + entry['dealed_amount'] + '</td>';
				    html += '<td>' + entry['dealed_price'] + '</td>';
				    html += '<td>' + entry['deal_status'] + '</td>';
				    html += '<td>' + entry['expire'] + '</td>';
				    if (entry['deal_status']=="已提交")
				    	{
				    		html += '<td><input type="button" class="changebutton" value="修改" entrust_no="' + entry['entrust_no'] + '" stock_code="' + entry['stock_code'] + '" entrust_amount="' + entry['entrust_amount'] + '" entrust_price="' + entry['entrust_price'] + '"entrust_type="' + entry['entrust_type'] + '"/><input type="button" class="cancelbutton" value="撤单" entrust_no="' + entry['entrust_no'] + '"entrust_amount="' + entry['entrust_amount']+ '"entrust_type="' + entry['entrust_type']+ '"stock_name="' + entry['stock_name'] + '" /></td>';
				  		}
				    else if (entry['deal_status']=="部分成交")
				    	{
				    		html += '<td><input type="button" class="changebutton" value="修改" entrust_no="' + entry['entrust_no'] + '" stock_code="' + entry['stock_code'] + '" entrust_amount="' + (entry['entrust_amount']-entry['dealed_amount']) + '" entrust_price="' + entry['entrust_price'] + '"entrust_type="' + entry['entrust_type'] + '"/><input type="button" class="cancelbutton" value="撤单" entrust_no="' + entry['entrust_no'] + '"entrust_amount="' + entry['entrust_amount']+ '"entrust_type="' + entry['entrust_type']+ '"stock_name="' + entry['stock_name'] + '" /></td>';
				  		}
				  	else
				  		{
				    		html += '<td>无可操作项</td>';
				  		}
				    html += '</tr>'
				    $('table#10_1').append(html);
  					$(document).ready(function(){
  								$("input.cancelbutton").click(clickInventCancelBtn);
  								$("input.changebutton").click(clickChangeBtn);
							   	});
				    });
  investAutoHight();
			     });
};
function clickInventListBtn1(){
  $("li.listbtn1_1").toggle();
  investAutoHight();
  };
function clickInventListBtn2(){
  $("li.listbtn2_1").toggle();
  investAutoHight();
  };
function clickInventListBtn3(){
  $("li.listbtn3_1").toggle();
  investAutoHight();
  };
function clickInventListBtn4(){
  $("li.listbtn4_1").toggle();
  investAutoHight();
  };
function setInfoDivInMiddle(){
		var o=$("div#info_div");
        var itop;
        var ileft;
        /*if (document.body && document.body.scrollTop && document.body.scrollLeft)
        {
        	itop=(document.documentElement.clientHeight-o.height())/2+document.body.scrollTop;
        	ileft=(document.documentElement.clientWidth-o.width())/2+document.body.scrollLeft;
        }
        if (document.documentElement && document.documentElement.scrollTop && document.documentElement.scrollLeft)
        {
        */
        	itop=(document.documentElement.clientHeight-o.height())/2+document.documentElement.scrollTop+document.body.scrollTop;
        	ileft=(document.documentElement.clientWidth-o.width())/2+document.documentElement.scrollLeft;
        //}
        o.css({
            position:"absolute",
            top:itop+"px",
            left:ileft+"px"
        })
}
function clickInventBuyBtn(){
	checkTradeInput();
	if (($("form input#price").val() != '')&&($("form input#amount").val() != '')&&($("form input#code").val() != ''))
	{
			     $("div#info_div").html("");
			     var info = '<h2>买入</h2>';
			     info += '<h5>'+'证券代码：'+$('#code').val()+'</h5>';
			     info += '<br />';
			     info += '<h5>'+'委托价格：'+$('#price').val()+'</h5>';
			     info += '<br />';
			     info += '<h5>'+'委托数量：'+$('#amount').val()+'</h5>';
			     info += '<br />';
			     info += '<center>';
			     info += "<input id='infobuybutton' value='确定买入' type='button'><input id='infoclose' value='取消' type='button'>";
			     info += '</center>';
			     $("div#info_div").html(info);
			     //$("div#info_div").css({left:$(this).offset().left,top:$(this).offset().top+$(this).outerHeight()});
			     setInfoDivInMiddle();
			     $(document).ready(function(){
  								$("input#infoclose").click(clickInfoCloseBtn);
  								$("input#infobuybutton").click(clickInfoBuyBtn);
							   	});
			     $("div#blackback").show();
			     $("div#info_div").show();
	}
};
function clickInfoBuyBtn(){
			     	clickInfoCloseBtn();
			     	$.post("/entrust/buy/", entrust_detail(), show_result);
			     	showEntrustFive($("#code").val());
};
function clickInventSellBtn(){
	checkTradeInput();
	if (($("form input#price").val() != '')&&($("form input#amount").val() != '')&&($("form input#code").val() != ''))
	{
	$("div#info_div").html("");
	var info = '<h2>卖出</h2>';
	info += '<h5>'+'证券代码：'+$('#code').val()+'</h5>';
	info += '<br />';
	info += '<h5>'+'委托价格：'+$('#price').val()+'</h5>';
	info += '<br />';
	info += '<h5>'+'委托数量：'+$('#amount').val()+'</h5>';
	info += '<br />';
	info += '<center>';
	info += '<input id="infosellbutton" value="确定卖出" type="button"><input id="infoclose" value="取消" type="button">';
	info += '</center>';
	$("div#info_div").html(info);
	//$("div#info_div").css({left:$(this).offset().left,top:$(this).offset().top+$(this).outerHeight()});
	setInfoDivInMiddle();
	$(document).ready(function(){
				$("input#infoclose").click(clickInfoCloseBtn);
				$("input#infosellbutton").click(clickInfoSellBtn);
		   	});
	$("div#blackback").show();
	$("div#info_div").show();
	}
};
function clickInfoSellBtn(){
			     	clickInfoCloseBtn();
			     	$.post("/entrust/sell/", entrust_detail(), show_result);
			     	showEntrustFive($("#code").val());
};
function clickInventShortBtn(){
	checkTradeInput();
	if (($("form input#price").val() != '')&&($("form input#amount").val() != '')&&($("form input#code").val() != ''))
	{
			     $("div#info_div").html("");
	var info = '<h2>卖空</h2>';
	info += '<h5>'+'证券代码：'+$('#code').val()+'</h5>';
	info += '<br />';
	info += '<h5>'+'委托价格：'+$('#price').val()+'</h5>';
	info += '<br />';
	info += '<h5>'+'委托数量：'+$('#amount').val()+'</h5>';
	info += '<br />';
	info += '<center>';
	info += "<input id='infoShortbutton' value='确定卖空' type='button'><input id='infoclose' value='取消' type='button'>";
	info += '</center>';
			     $("div#info_div").html(info);
	setInfoDivInMiddle();
			     $(document).ready(function(){
  								$("input#infoclose").click(clickInfoCloseBtn);
  								$("input#infoShortbutton").click(clickInfoShortBtn);
							   	});
			     $("div#blackback").show();
			     $("div#info_div").show();
	}
};
function clickInfoShortBtn(){
			     	clickInfoCloseBtn();
			     	$.post("/entrust/short/", entrust_detail(), show_result);
			     	showEntrustFive($("#code").val());
};
function clickInventCoverBtn(){
	checkTradeInput();
	if (($("form input#price").val() != '')&&($("form input#amount").val() != '')&&($("form input#code").val() != ''))
	{
			     $("div#info_div").html("");
	var info = '<h2>平空</h2>';
	info += '<h5>'+'证券代码：'+$('#code').val()+'</h5>';
	info += '<br />';
	info += '<h5>'+'委托价格：'+$('#price').val()+'</h5>';
	info += '<br />';
	info += '<h5>'+'委托数量：'+$('#amount').val()+'</h5>';
	info += '<br />';
	info += '<center>';
	info += "<input id='infoCoverbutton' value='确定平空' type='button'><input id='infoclose' value='取消' type='button'>";
	info += '</center>';
			     $("div#info_div").html(info);
	setInfoDivInMiddle();
			     $(document).ready(function(){
  								$("input#infoclose").click(clickInfoCloseBtn);
  								$("input#infoCoverbutton").click(clickInfoCoverBtn);
							   	});
			     $("div#blackback").show();
			     $("div#info_div").show();
	}
};
function clickInfoCoverBtn(){
			     	clickInfoCloseBtn();
			     	$.post("/entrust/cover/", entrust_detail(), show_result);
			     	showEntrustFive($("#code").val());
};
function clickInventCancelBtn(){
			     $("div#info_div").html("");
			     var entrust_no = $(this).attr("entrust_no");
			     var entrust_amount = $(this).attr("entrust_amount");
			     var entrust_type = $(this).attr("entrust_type");
			     var stock_name = $(this).attr("stock_name");
			     var info = '撤销'+entrust_type+'<'+stock_name+'>'+'这笔委托？';
			     info += '<center>';
			     info += "<br /><input id='infocancelbutton' value='确定撤销' type='button'><input id='infoclose' value='取消' type='button'>";
			     info += '</center>';
			     $("div#info_div").html(info);
			     setInfoDivInMiddle();
			     $(document).ready(function(){
  								$("input#infoclose").click(clickInfoCloseBtn);
  								$("input#infocancelbutton").click(
  								function(){
  									clickInfoCancelBtn(entrust_no,entrust_amount);
  								});
							   	});
			     $("div#blackback").show();
			     $("div#info_div").show();
};
function clickInfoCancelBtn(entrust_no,entrust_amount){
			     clickInfoCloseBtn();
			     var entrust_no;
			     var entrust_amount;
			     $.post('/entrust/cancel/',{
			     	entrust_no:entrust_no,
			     	amount:entrust_amount
			     	},
			     	function(result){
			     		switch (result.result)
{
case 0:
  var info = "委托已撤销";
  clickLi10_1();
  break
case 6:
  var info = "委托不存在";
  break
case 7:
  var info = "委托已完成";
  break
case 8:
  var info = "委托已过期";
  break
default:
  var info = "委托已受理";
};
info += '<center>';
			     		info += "<br /><input id='infoclose' value='确定' type='button'>";
			     		info += '</center>';
			     		$("div#info_div").html(info);
			     		$(document).ready(function(){
			     			$("input#infoclose").click(clickInfoCloseBtn);
			     			$("input#infobuybutton").click(clickInfoBuyBtn);
			     			});
			     			$("div#blackback").show();
			     			$("div#info_div").show();
			     			$("div#info_div").css({left:$(this).offset().left,top:$(this).offset().top+$(this).outerHeight()});
			     		},
			     		"json"
			     		);
};
function clickInfoCloseBtn(){
							   $("div#info_div").hide();
							   $("div#info_div").html("");
							   $("div#blackback").hide();
							   };
          	function clickProductsBtn0_7(){
																	//back
																	$("ul#productsbutton li").css("border","0px solid #fff");
																	$("ul#productsbutton li a").css("color","");
																	$("div#productsclass div").hide();
																	//do
																	$(this).parent().css("border-left","1px solid #CCC");
																	$(this).parent().css("border-top","1px solid #CCC");
																	$(this).parent().css("border-right","1px solid #CCC");
																	$(this).parent().css("border-bottom","2px solid #84B84B");
																	$("#pbtn0_7").css("color","#84B84B");
																	$("div#pro7").show();
																	$("div#pro7 div").show();
																	$("div#pro7 ul.tabs li:eq(0)").click();
																	$(hsxSetFooterToBottom);
																 }
          	function clickProductsBtn0_6(){
																	//back
																	$("ul#productsbutton li").css("border","0px solid #fff");
																	$("ul#productsbutton li a").css("color","");
																	$("div#productsclass div").hide();
																	//do
																	$(this).parent().css("border-left","1px solid #CCC");
																	$(this).parent().css("border-top","1px solid #CCC");
																	$(this).parent().css("border-right","1px solid #CCC");
																	$(this).parent().css("border-bottom","2px solid #84B84B");
																	$("#pbtn0_6").css("color","#84B84B");
																	$("div#pro6").show();
																	$("div#pro6 div").show();
																	$("div#pro6 ul.tabs li:eq(0)").click();
																	$(hsxSetFooterToBottom);
																 }
          	function clickProductsBtn0_5(){
																	//back
																	$("ul#productsbutton li").css("border","0px solid #fff");
																	$("ul#productsbutton li a").css("color","");
																	$("div#productsclass div").hide();
																	//do
																	$(this).parent().css("border-left","1px solid #CCC");
																	$(this).parent().css("border-top","1px solid #CCC");
																	$(this).parent().css("border-right","1px solid #CCC");
																	$(this).parent().css("border-bottom","2px solid #84B84B");
																	$("#pbtn0_5").css("color","#84B84B");
																	$("div#pro5").show();
																	$("div#pro5 div").show();
																	$("div#pro5 ul.tabs li:eq(0)").click();
																	$(hsxSetFooterToBottom);
																 }
          	function clickProductsBtn0_4(){
																	//back
																	$("ul#productsbutton li").css("border","0px solid #fff");
																	$("ul#productsbutton li a").css("color","");
																	$("div#productsclass div").hide();
																	//do
																	$(this).parent().css("border-left","1px solid #CCC");
																	$(this).parent().css("border-top","1px solid #CCC");
																	$(this).parent().css("border-right","1px solid #CCC");
																	$(this).parent().css("border-bottom","2px solid #84B84B");
																	$("#pbtn0_4").css("color","#84B84B");
																	$("div#pro4").show();
																	$("div#pro4 div").show();
																	$("div#pro4 ul.tabs li:eq(0)").click();
																	$(hsxSetFooterToBottom);
																 }
          	function clickProductsBtn0_3(){
																	//back
																	$("ul#productsbutton li").css("border","0px solid #fff");
																	$("ul#productsbutton li a").css("color","");
																	$("div#productsclass div").hide();
																	//do
																	$(this).parent().css("border-left","1px solid #CCC");
																	$(this).parent().css("border-top","1px solid #CCC");
																	$(this).parent().css("border-right","1px solid #CCC");
																	$(this).parent().css("border-bottom","2px solid #84B84B");
																	$("#pbtn0_3").css("color","#84B84B");
																	$("div#pro3").show();
																	$("div#pro3 div").show();
																	$("div#pro3 ul.tabs li:eq(0)").click();
																	$(hsxSetFooterToBottom);
																 }
          	function clickProductsBtn0_2(){
																	//back
																	$("ul#productsbutton li").css("border","0px solid #fff");
																	$("ul#productsbutton li a").css("color","");
																	$("div#productsclass div").hide();
																	//do
																	$(this).parent().css("border-left","1px solid #CCC");
																	$(this).parent().css("border-top","1px solid #CCC");
																	$(this).parent().css("border-right","1px solid #CCC");
																	$(this).parent().css("border-bottom","2px solid #84B84B");
																	$("#pbtn0_2").css("color","#84B84B");
																	$("div#pro2").show();
																	$("div#pro2 div").show();
																	$("div#pro2 ul.tabs li:eq(0)").click();
																	$(hsxSetFooterToBottom);
																 }
          	function clickProductsBtn0_1(){
																	//back
																	$("ul#productsbutton li").css("border","0px solid #fff");
																	$("ul#productsbutton li a").css("color","");
																	$("div#productsclass div").hide();
																	//do
																	$(this).parent().css("border-left","1px solid #CCC");
																	$(this).parent().css("border-top","1px solid #CCC");
																	$(this).parent().css("border-right","1px solid #CCC");
																	$(this).parent().css("border-bottom","2px solid #84B84B");
																	$("#pbtn0_1").css("color","#84B84B");
																	$("div#pro1").show();
																	$("div#pro1 div").show();
																	$("div#pro1 ul.tabs li:eq(0)").click();
																	$(hsxSetFooterToBottom);
																 }
          	function clickProductsBtn0_0(){
																	//back
																	$("ul#productsbutton li").css("border","0px solid #fff");
																	$("ul#productsbutton li a").css("color","");
																	$("div#productsclass div").hide();
																	//do
																	$(this).parent().css("border-left","1px solid #CCC");
																	$(this).parent().css("border-top","1px solid #CCC");
																	$(this).parent().css("border-right","1px solid #CCC");
																	$(this).parent().css("border-bottom","2px solid #84B84B");
																	$("#pbtn0_0").css("color","#84B84B");
																	$("div#pro0").show();
																	$("div#pro0 div").show();
																	$("div#pro0 ul.tabs li:eq(0)").click();
																	$(hsxSetFooterToBottom);
																 };
//选项卡
$(document).ready(function(){
  $("ul.tabs li").click(function(){
    $("ul.tabs li").removeClass();
    $(this).addClass("select");
    $("div#productsclass table:visible").hide();
    $(".tab_s:visible").hide();
    var table_no = $(this).attr("ll");
    $("#"+table_no).show();
    $(hsxSetFooterToBottom);
  });
  $("ul.tabss li").click(function(){
    $("ul.tabss li").removeClass();
    $(this).addClass("select");
    $(".tab_s:visible").hide();
    var table_no = $(this).attr("ll");
    $("#"+table_no).show();
    investAutoHight();
  });
  $("ul.bigtab li").click(function(){
    $("ul.bigtab li").removeClass();
    $(this).addClass("select");
    $(".bigtab_s:visible").hide();
    var div_name = $(this).attr("ll");
    $("#"+div_name).show();
    $(hsxSetFooterToBottom);
  });
  if (typeof(tab_eq) == "undefined")
  {
  	tab_btn = $.getUrlVar("tabbtn");
  	if (typeof(tab_btn) == "undefined")
  	{
  		$("ul.bigtab li:eq(0)").click();
  	}
  	else
  		{
  			$("ul.bigtab li:eq(" + tab_btn + ")").click();
  		}
  }
  else
  	{
  	$("ul.bigtab li:eq(" + tab_eq + ")").click();
  	}
});
//首页广告变换
function indexMouseOver()
{
	$("div#index_mid_mov_btn ul li").removeClass();
	$(this).addClass("overed");
	var index_mov_no = $(this).attr("nn");
	indexMovAutoChange_no(index_mov_no);
  //$("div#index_mid_mov a").fadeOut();
	//$("#index_mov_"+index_mov_no).fadeIn();
}
function indexMovAutoChange_no(no)
{
	eq = no - 1;
	$("div#index_mid_mov_btn ul li").removeClass();
	$("div#index_mid_mov_btn ul li:eq("+eq+")").addClass("overed");
	$("div#index_mid_mov a").fadeOut();
	$("#index_mov_"+no).fadeIn();
	getIndexAdvPrice1($("#index_mov_"+no).attr("stock_code"));
}
function indexMovAutoChange()
{
	indexMovAutoChange_no(1);
	setTimeout("indexMovAutoChange_no(2)", 10000);
	setTimeout("indexMovAutoChange_no(3)", 20000);
	setTimeout("indexMovAutoChange_no(4)", 30000);
	setTimeout("indexMovAutoChange_no(5)", 40000);
}
//兑换按钮
function show_duihuan_confirm()
{
	var m=$("form#duihuan input#id_amount_").val();
	var mm=m.toString();
	var rmb=parseInt($("td#available_cash").html());
	if (mm.length>0)
	{
		if (m <= rmb)
		{
      $("div#info_div").html("");
      var info = "将 "+m+"RMB 兑换为 "+(m*settings.exchange_rate)+"W$ ？"
      info += '<center>';
      info += "<br /><input id='duihuanbutton' value='确定兑换' type='button'><input id='infoclose' value='取消' type='button'>";
      info += '</center>';
      $("div#info_div").html(info);
      setInfoDivInMiddle();
      $(document).ready(function(){
      	$("input#infoclose").click(clickInfoCloseBtn);
      	$("input#duihuanbutton").click(function(){
      		$("form#duihuan").submit();
      	});
      });
      $("div#blackback").show();
      $("div#info_div").show();
		}
		else
		{
			alert("人民币余额不足，请先充值，或直接购买W$")
		}
	}
	else
	{
		alert("请输入兑换金额！")
	}
};
//转出资金按钮
function outCommit()
{
	var o=$("input#out_balance").val();
	var oo=o.toString();
	var can_out=parseFloat($("span#can_out_balance").attr("can_out_int"));
	//alert(o);
	//alert(can_out);
	if (oo.length>0)
	{
		if (can_out>=o)
		{
      $("div#info_div").html("");
      var info = '<h2>资金转出确认</h2>'
      info += '<h5>'+'转出金额：'+ o +'</h5>';
			info += '<br />';
      info += "<br /><input id='outbalancebutton' value='确定转出' type='button'><input id='infoclose' value='取消' type='button'>";
      info += '</center>';
      $("div#info_div").html(info);
      setInfoDivInMiddle();
      $(document).ready(function(){
      	$("input#infoclose").click(clickInfoCloseBtn);
      	$("input#outbalancebutton").click(function(){
			    clickInfoCloseBtn();
      		$.post('/order/cashing/',{
      			'amount':o
      		},
			    show_result);
      	});
      });
      $("div#blackback").show();
      $("div#info_div").show();
		}
		else
		{
			alert("可转出金额不足！");
			$("input#out_balance").focus();
		}
	}
	else
	{
		alert("请输入兑换金额！");
		$("input#out_balance").focus();
	}
};
//绑定银行信息
function bankaccountSubmit()
{
	var bank_realname = $("input#id_bank_realname").val();
	var bank_name = $("input#id_bank_name").val();
	var bank_province = $("input#id_bank_province").val();
	var bank_city = $("input#id_bank_city").val();
	var subbank_name = $("input#id_subbank_name").val();
	var bank_account = $("input#id_bank_account").val();
	var bank_account2 = $("input#id_bank_account2").val();
	if (bank_realname.length>0&&bank_name.length>0&&bank_province.length>0&&bank_city.length>0&&subbank_name.length>0&&bank_account.length>0&&bank_account2.length>0)
	{
		if(bank_account==bank_account2)
		{
			$("input#id_bank_account").css("background-color","");
			$("input#id_bank_account2").css("background-color","");
			$("div#info_div").html("");
			var info = '<h2>确认银行信息</h2>';
			info += '<h5>'+'姓名：'+ bank_realname +'</h5>';
			info += '<br />';
			info += '<h5>'+'银行名称：'+bank_name+'</h5>';
			info += '<br />';
			info += '<h5>'+'开户省份：'+bank_province+'</h5>';
			info += '<br />';
			info += '<h5>'+'开户城市：'+bank_city+'</h5>';
			info += '<br />';
			info += '<h5>'+'开户支行：'+subbank_name+'</h5>';
			info += '<br />';
			info += '<h5>'+'银行卡号：'+bank_account2+'</h5>';
			info += '<br />';
			info += '<center>';
			info += "<input id='banksubbutton' value='确定' type='button'><input id='infoclose' value='取消' type='button'>";
			info += '</center>';
			$("div#info_div").html(info);
			setInfoDivInMiddle();
			$(document).ready(function(){
				$("input#infoclose").click(clickInfoCloseBtn);
				$("input#banksubbutton").click(function(){
					$("form#bankaccount_form").submit();
				});
			});
			$("div#blackback").show();
      $("div#info_div").show();
		}
		else
		{
			//alert("银行账号不一致");
			$("input#id_bank_account").css("background-color","#ffc5c5");
			$("input#id_bank_account2").css("background-color","#ffc5c5");
			$("input#id_bank_account").focus();
		}
	}
	else
		{
			alert("请输入完整信息！");
		}
}
//得到可提货数量
function getCanGetgoodsAmount()
{
	var canget = $(":selected").attr("canget_amount");
	$("input#getgoods_amount").val(canget);
}
//提货提交
function getgoodsSubmit()
{
	var getgoods_stkcode = $("select#id_stock").val();
	var getgoods_num = $("input#id_good_amount").val();
	var getgoods_name = $("input#id_receiver_name").val();
	var getgoods_addr = $("input#id_receiver_address").val();
	var getgoods_code = $("input#id_receiver_zip").val();
	var getgoods_phone = $("input#id_receiver_phone").val();
	if (getgoods_stkcode!=0&&getgoods_num.length>0&&getgoods_name.length>0&&getgoods_addr.length>0&&getgoods_code.length>0&&getgoods_phone.length>0)
	{
			$("div#info_div").html("");
			var info = '<h2>确认提货信息</h2>';
			info += '<h5>'+'提货产品代码：'+ getgoods_stkcode +'</h5>';
			info += '<br />';
			info += '<h5>'+'提货数量：'+getgoods_num+'</h5>';
			info += '<br />';
			info += '<h5>'+'收货人姓名：'+getgoods_name+'</h5>';
			info += '<br />';
			info += '<h5>'+'收货人地址：'+getgoods_addr+'</h5>';
			info += '<br />';
			info += '<h5>'+'收货人邮编：'+getgoods_code+'</h5>';
			info += '<br />';
			info += '<h5>'+'收货人联系电话：'+getgoods_phone+'</h5>';
			info += '<br />';
			info += '<center>';
			info += "<input id='getgoodssubbtn' value='确定' type='button'><input id='infoclose' value='取消' type='button'>";
			info += '</center>';
			$("div#info_div").html(info);
			setInfoDivInMiddle();
			$(document).ready(function(){
				$("input#infoclose").click(clickInfoCloseBtn);
				$("input#getgoodssubbtn").click(function(){
					$("form#tihuo").submit();
				});
			});
			$("div#blackback").show();
      $("div#info_div").show();
	}
	else
		{
			alert("请输入完整信息！");
		}
}
//转账信息提交
function orderCommit()
{
	var order_name=$("input#order_name").val();
	var order_idno=$("input#order_idno").val();
	var order_phone=$("input#order_phone").val();
	var order_cash=$("input#order_cash").val();
	var order_date=$("input#order_date").val();
	if(order_name.length>0&&order_idno.length>0&&order_phone.length>10&&order_cash.length>0&&order_date.length>7)
	{
	$.post('/order/pay',{
			    order_name:order_name,
			    order_idno:order_idno,
			    order_phone:order_phone,
			    order_cash:order_cash,
			    order_date:order_date
			    },
			    show_result);
	}
	else
		{
			alert("请输入完整信息！");
		}
}
//弹出交易框
function clickBsBtn(stock_code){
								 var stock_code = $(this).attr("stock_code");
								 $("div#bs_div").html("");
								 $("div#bs_div").html("<a title='关闭窗口' id='close'>×</a><form class='visible' action='' method='post'><ul><li><label for='code'>商品代码: </label><input id='code' name='code' type='text' readonly/></li><li><label for='price'>委托价格: </label><input id='price' name='price' type='text' onblur='getCanBuy();'/><span id='price_x'></span></li><li><label for='amount'>委托数量: </label><input id='amount' name='price' type='text' /><span id='amount_x'></span></li><li style='display: none;'><label for='validity'>有效期限: </label><select name='validity' id='validity'><option value='1' selected='selected'>一天有效</option></select></li><li><input type='checkbox' id='bonus' name='bonus' value='0' checked='checked' /> 优先使用电子券</li><li><span id='trade_x'></span></li><li><input type='button' id='buybutton' value='买入' /><input type='button' id='sellbutton' value='卖出' /><input type='button' id='shortbutton' value='卖空' /><input type='button' id='coverbutton' value='平空' /></li></ul></form>");
							   $("div#bs_div").css({left:$(this).offset().left+$(this).outerWidth(),top:$(this).offset().top});
							   //clickInventBtn0_0();
							   $("div#bs_div").show(300);
							   $("a.bs_btn").css("color","#0089d2");
							   $(this).css("color","#84B84B");
							   $("input#code").val(stock_code);
							   $(document).ready(function(){
  								$("div#bs_div a#close").click(clickBsCloseBtn);
  								$("input#buybutton").click(clickInventBuyBtn);
  								$("input#sellbutton").click(clickInventSellBtn);
  								$("input#shortbutton").click(clickInventShortBtn);
  								$("input#coverbutton").click(clickInventCoverBtn);
							   	});
							   };
function clickBsCloseBtn(){
							   $("a.bs_btn").css("color","");
							   $("div#bs_div").hide(300);
							   $("div#bs_div").html("");
							   };
//弹出修改委托框
function clickChangeBtn(stock_code){
								 var stock_code = $(this).attr("stock_code");
								 var entrust_no = $(this).attr("entrust_no");
								 var entrust_amount = $(this).attr("entrust_amount");
								 var entrust_price = $(this).attr("entrust_price");
								 var entrust_type = $(this).attr("entrust_type");
								 $("div#bs_div").html("");
								 $("div#bs_div").html("<a title='关闭窗口' id='close'>×</a><form class='visible' action='' method='post'><ul><li><label for='entrust_no'>委托序号: </label><input id='entrust_no_mod' name='entrust_no' type='text' readonly='readonly'/></li><li><label for='code'>商品代码: </label><input id='code_mod' name='code' type='text' readonly='readonly'/></li><li><label for='amount'>委托数量: </label><label><input type='radio' name='RadioGroup1' value='buy' id='buyradio' />买</label><label><input type='radio' name='RadioGroup1' value='sell' id='sellradio' />卖</label><input id='amount_mod' name='price' type='text' style='width:73px'/></li><li><label for='price'>委托价格: </label><input id='price_mod' name='price' type='text' /><span id='change_price_x'>&nbsp;</span></li><li style='display: none;'><label for='validity'>有效期限: </label><select name='validity' id='validity'><option value='1' selected='selected'>一天有效</option></select></li><li><input type='checkbox' id='bonus' name='bonus' value='0' checked='checked' /> 优先使用电子券</li><li><input type='button' id='change' value='发送' /></li></ul></form>");
							   $("div#bs_div").css({left:($(this).offset().left+$(this).outerWidth()-327),top:$(this).offset().top+$(this).outerHeight()});
							   //clickInventBtn0_0();
							   $("div#bs_div").show(300);
							   //$("a.bs_btn").css("color","#0089d2");
							   //$(this).css("color","#84B84B");
							   $("input#entrust_no_mod").val(entrust_no);
							   $("input#code_mod").val(stock_code);
							   $("input#amount_mod").val(entrust_amount);
							   $("input#price_mod").val(entrust_price);
		$.getJSON("/products/current_price.json?stock_code="+stock_code+"&time="+new Date().getTime(),function(data){
			var html = " 最新: "+data.current_price;
			$("form span#change_price_x").html(html);
		});
							   if (entrust_type == "卖出")
							   		{
							   		$("input#sellradio").attr("checked" , true); 
							   		}
							   else if (entrust_type == "买入")
							   		{
							   		$("input#buyradio").attr("checked" , true); 
							   		}
							   else if (entrust_type == "卖空")
							   		{
							   		$("input#shortradio").attr("checked" , true); 
							   		}
							   else if (entrust_type == "平空")
							   		{
							   		$("input#coverradio").attr("checked" , true); 
							   		}
							   $(document).ready(function(){
  								$("div#bs_div a#close").click(clickBsCloseBtn);
      $("#change").click(function() {
        $.post("/entrust/change/", {
          "entrust_no": $("#entrust_no_mod").val(),
          "amount": $("#amount_mod").val(),
          "price": $("#price_mod").val(),
          "next":$("input[name=RadioGroup1]:checked").val(),
        	"duration": $("#validity").val()
        }, show_result);
        clickBsCloseBtn();
      });
							   	});
							   };
function aMouseOver(){
								$(this).css("color","#84B84B");
							};
//
function clickFullP(){
														  $("tr.full").slideToggle();
														 };
function clickMoreBtn(){
	if ($(this).html()=="更多 »")
	{
		$(this).html("收回");
	}
	else
	{
		$(this).html("更多 »");
	}
		
														  $(".hide").slideToggle();
														 };
//推荐上市IPO提交
function clickRecomSubmit(){
        $.post("/misc/recommend_stock/", {
          "rec_name": $("#recom_name").val(),
          "rec_code": $("#recom_code").val(),
          "ipo_price": $("#recom_price").val(),
          "amount":$("#recom_amount").val(),
        	"reason": $("#recom_reason").val()
        }, show_result);
}
//发行权证
function clickTurbineSubmit(){
        $.post("/misc/warrent_apply/", {
          "margin": $("#turbine_fund").val(),
          "warrent_type": $("#turbine_type").val(),
          "amount": $("#turbine_amount").val(),
          "due_date":$("#turbine_date").val(),
        	"last_trade_date": $("#last_turbine_date").val(),
        	"exersise_rate": $("#turbine_ratio").val(),
        	"exersise_price": $("#turbine_price").val(),
        	"start_price": $("#turbine_firstprice").val()
        }, show_result);
}
function clickHotMoreBtn(){
														  $("ul#hot_ul li.hide").slideToggle();
														 };
function clickIdxBtnLi(stock_type){
	var stock_type = $(this).attr("stock_type");
	var idx = new SWFObject("/static/amline/amline.swf", "amline", "395", "200", "8", "#FFFFFF");
			idx.addVariable("path", "/static/amline/");
			idx.addVariable("settings_file", encodeURIComponent("/static/amline/amline_settings_his.xml"));                // you can set two or more different settings files here (separated by commas)
			idx.addVariable("data_file", encodeURIComponent("/products/"+stock_type+"/history_index.xml"));
			idx.write("indexflash");
	//back
	$("ul#main_idx_btn li").removeClass("selected");
	$(this).addClass("selected");
	//do
		
	};
	function clickTikerHide(){
		$("div#ticker-logo").hide();
		$("div#ticker-scroll").hide();
		$("div#ticker-show").show();
		$("div#ticker-hide").hide();
		/*
		if ($("div#ticker-close").css("background-image").indexOf("hide") > 0)
			{
				$("div#ticker-close").css("background-image","url('/static/images/ticker-show.gif')");
			}
		else
			{
				$("div#ticker-close").css("background-image","url('/static/images/ticker-hide.gif')");
			}
			*/
	};
	function clickTikerShow(){
		$("div#ticker-logo").show();
		$("div#ticker-scroll").show();
		$("div#ticker-hide").show();
		$("div#ticker-show").hide();
	}
$(document).ready(function(){
	$("#btn88").click(clickInventBtn88);
	$("#btn99").click(clickInventBtn99);
	$("#btnhisentrust").click(clickInventBtnHisEntrust);
	$("#btnhisfundjour").click(clickInventBtnHisFundjour);
	$("#btnhisstockjour").click(clickInventBtnHisStockjour);
	$("#btnmylicense").click(clickInventBtnMyLicense);
	$("#btndeliver").click(clickInventBtnDeliver);
	$("#btnbankjour").click(clickInventBtnBankjour);
	$("#btngetgoodsjour").click(clickInventBtnGetgoodsjour);
	$("#btnintroduce").click(clickInventBtnIntroduce);
	$("#btnbroker").click(clickInventBtnBroker);
	$("#hisentrustbutton").click(clickHisEntrustBtn);
	$("#hisfundjourbutton").click(clickHisFundjourBtn);
	$("#hisstockjourbutton").click(clickHisStockjourBtn);
	$("#deliverbutton").click(clickDeliverBtn);
	$("#bankjourbutton").click(clickBankjourBtn);
	$("#getgoodsjourbutton").click(clickGetgoodsjourBtn);
	$("#intrbutton").click(clickIntroduceBtn);
	$("#brokerbutton").click(clickBrokerBtn);
  $("#btn0").click(clickInventBtn0);
  $("#btn1").click(clickInventBtn1);
  $("#btn2").click(clickInventBtn2);
  $("#btn3").click(clickInventBtn3);
  $("#btn4").click(clickInventBtn4);
  $("#btn5").click(clickInventBtn5);
  $("#btn6").click(clickInventBtn6);
  $("#btn7").click(clickInventBtn7);
  $("#btn8").click(clickInventBtn8);
  $("#btn9").click(clickInventBtn9);
  $("#btn10").click(clickInventBtn10);
  $("#btn11").click(clickInventBtn11);
  $("#btn12").click(clickInventBtn12);
  $("a#btn0_0").click(clickInventBtn0_0);
  $("a#btn0_1").click(clickInventBtn0_1);
  $("#btn0_2").click(clickInventBtn0_2);
  $("#btn0_3").click(clickInventBtn0_3);
  $("li#li10_0").click(clickLi10_0);
  $("li#li10_1").click(clickLi10_1);
  $("a#listbtn1").click(clickInventListBtn1);
  $("a#listbtn2").click(clickInventListBtn2);
  $("a#listbtn3").click(clickInventListBtn3);
  $("a#listbtn4").click(clickInventListBtn4);
  $("input#buybutton").click(clickInventBuyBtn);
  $("input#sellbutton").click(clickInventSellBtn);
  $("input#shortbutton").click(clickInventShortBtn);
  $("input#coverbutton").click(clickInventCoverBtn);
  $("input.cancelbutton").click(clickInventCancelBtn);
  $("input.changebutton").click(clickChangeBtn);
  $("a.bs_btn").click(clickBsBtn);
  $("div#bs_div a#close").click(clickBsCloseBtn);
	$("#pbtn0_0").click(clickProductsBtn0_0);
	$("#pbtn0_1").click(clickProductsBtn0_1);
	$("#pbtn0_2").click(clickProductsBtn0_2);
	$("#pbtn0_3").click(clickProductsBtn0_3);
	$("#pbtn0_4").click(clickProductsBtn0_4);
	$("#pbtn0_5").click(clickProductsBtn0_5);
	$("#pbtn0_6").click(clickProductsBtn0_6);
	$("#pbtn0_7").click(clickProductsBtn0_7);
	$("p#full").click(clickFullP);
	$("li.idxbtn").click(clickIdxBtnLi);
	$("a.amore").click(clickMoreBtn);
	$("a#ticker-hidebt").click(clickTikerHide);
	$("a#ticker-showbt").click(clickTikerShow);
	$("a#printlicense1").click(clickPrintLicense1);
	$("a#printlicense2").click(clickPrintLicense2);
	$("a#printlicense3").click(clickPrintLicense3);
	$("a#printlicense4").click(clickPrintLicense4);
	$("a#applylicense1").click(clickApplyLicense1);
	$("input#recom_submit").click(clickRecomSubmit);
	$("input#turbine_submit").click(clickTurbineSubmit);
	$("div#index_mid_mov_btn ul li").click(indexMouseOver);
	$(hsxSetFooterToBottom);
});
//以下是各种右边列生成函数.
function showHelpList(){
	$.getJSON("/about/list.json?time="+new Date().getTime(),function(data){
		$('div#right').append('<div id="rightblock"><div class="box-top"><span class="left"></span><span class="right"></span></div><div class="box-body"><h3>帮助迈向华尔街</h3><ul class="box" id="aboutrlist"></ul></div><div class="box-foot"><span class="left"></span><span class="right"></span></div></div>');
		$.each(data,function(entryIndex,entry){
			var html = '<li>';
			html += '<a href="' + entry['url'] + '">' + entry['title'] + '</a>';
			html += '</li>';
			$('ul#aboutrlist').append(html);
		});
	});
};
function showNewList(){
	$.getJSON("/products/new_list.json?time="+new Date().getTime(),function(data){
		$('div#opening').append('<div class="box-top"><span class="left"></span><span class="right"></span></div><div class="box-body"><h3 class="block blue"><span></span>最新上市<a class="more" href="/products/">更多 »</a></h3><!--<h4>星期六, 9月11日</h4>--><ul class="securities" id="opening_ul"></ul></div><div class="box-foot"><span class="left"></span><span class="right"></span></div>');
		$.each(data,function(entryIndex,entry){
			var html = '<li>';
			html += '<span class="security" style="width:47px;height:68px">';
			html += '<img src="'+entry['stock_poster']+'" style="width:47px;height:68px" alt="pic"/>';
			html += '</span>';
			html += '<h5>';
			html += '<a href="/products/'+entry['stock_code']+'">'+entry['stock_name']+'</a>';
			html += '</h5>';
			html += '<p>字母代码：'+entry['stock_alias']+'</p>';
			html += '<p class="trade_info">';
			html += 'SW$'+entry['stock_current_price'];
							if (entry['stock_current_price'] > entry['stock_close_price'])
							{
      html += '<span class="up range" close_price='+entry['stock_close_price']+' current_price='+entry['stock_current_price']+'>3.21%</span>';
    }
              else if (entry['stock_current_price'] < entry['stock_close_price'])
              	{
      html += '<span class="down range" close_price='+entry['stock_close_price']+' current_price='+entry['stock_current_price']+'>3%</span>';
    }
              else
              	{
      html += '<span class="nochange range" close_price='+entry['stock_close_price']+' current_price='+entry['stock_current_price']+'>0%</span>';
    }
			html += '<a href="/products/'+entry['stock_code']+'">交易 »</a>';
//			html += '<a class="bs_btn" stock_code='+entry['stock_code']+'>交易 »</a>';
			html += '</p>';
			html += '</li>';
			$('ul#opening_ul').append(html);
			//$("#opening h4").html(entry['list_date']);
		});
			//$("#opening h4").html(data.list_date);
	});
	$(document).ready(function(){
		$("a.bs_btn").click(clickBsBtn);
	});
};
function showActUser(){
	$.getJSON("/user/activists.json?time="+new Date().getTime(),function(data){
		$('div#actuser').append('<div class="box-top"><span class="left"></span><span class="right"></span></div><div class="box-body"><h3 class="block blue"><span></span>活跃交易者<a class="more" href="/misc/top10/user">更多 »</a></h3><ul class="securities" id="actuser_ul"></ul></div><div class="box-foot"><span class="left"></span><span class="right"></span></div>');
		$.each(data,function(entryIndex,entry){
			var html = '<li>';
			html += '<span class="security" style="width:47px;height:68px">';
			html += '<img src="'+entry['avatar']+'" style="width:47px;height:68px" alt="pic"/>';
			html += '</span>';
			html += '<h5>';
			html += '<a>'+entry['name']+'</a>';
			html += '</h5>';
			//html += '<p>现金盈利：'+entry['profit']+'</p>';
			//html += '<p>购买力盈利：'+entry['v_profit']+'</p>';
			html += '<p>昨日交易量：'+entry['volume']+'</p>';
			html += '<p class="trade_info">';
			html += '盈利：'+entry['v_profit'].toFixed(2);
							if (entry['v_profits'] > 0)
							{
      html += '<span class="up">'+entry['v_profits'].toFixed(2)+'%</span>';
    }
              else if (entry['v_profits'] < 0)
              	{
      html += '<span class="down">'+entry['v_profits'].toFixed(2)+'%</span>';
    }
              else
              	{
      html += '<span class="nochange">'+entry['v_profits'].toFixed(2)+'%</span>';
    }
			html += '</p>';
			html += '</li>';
			$('ul#actuser_ul').append(html);
		});
	});
};
function showMidHot(){
	$.getJSON("/products/pop_list.json?time="+new Date().getTime(),function(data){
		$('div#index_mid_hot').append('<ul id="mid_hot_ul"></ul>');
		$.each(data,function(entryIndex,entry){
			if (entryIndex<5)
			{
			var html = '<li>';
			html += '<a href="/products/'+entry['stock_code']+'">'+entry['stock_name']+' ('+entry['stock_alias']+')&nbsp;&nbsp;&nbsp;'+entry['stock_currency']+':'+entry['stock_current_price']+'</a>';
							if (entry['stock_current_price'] > entry['stock_close_price'])
							{
      html += '<span class="up range right" close_price='+entry['stock_close_price']+' current_price='+entry['stock_current_price']+'>3.21%</span>';
    }
              else if (entry['stock_current_price'] < entry['stock_close_price'])
              	{
      html += '<span class="down range right" close_price='+entry['stock_close_price']+' current_price='+entry['stock_current_price']+'>3%</span>';
    }
              else
              	{
      html += '<span class="nochange range right" close_price='+entry['stock_close_price']+' current_price='+entry['stock_current_price']+'>0%</span>';
    }
			html += '</li>';
			$('ul#mid_hot_ul').append(html);
			}
		});
    $("span.range").each(function() {
      $(this).html(range($(this).attr("close_price"), $(this).attr("current_price"))+"%");
    });
	});
};
function showInvestHot(){
	$.getJSON("/products/pop_list.json?time="+new Date().getTime(),function(data){
		$("tr.hottableempty").remove();
		$.each(data,function(entryIndex,entry){
			var html = '<tr class="hottableempty" code = '+entry['stock_code']+' price = ' + entry['stock_current_price'] + '>';
			html += '<td>' + entry['stock_code'] + '</td>';
			html += '<td>' + entry['stock_name'] + '</td>';
			html += '<td>' + entry['stock_alias'] + '</td>';
			html += '<td>' + entry['stock_currency'] + '</td>';
			html += '<td>' + entry['stock_current_price'] + '</td>';
			if (entry['stock_current_price'] > entry['stock_close_price'])
							{
      html += '<td><span class="up range" close_price='+entry['stock_close_price']+' current_price='+entry['stock_current_price']+'>3.21%</span></td>';
    }
              else if (entry['stock_current_price'] < entry['stock_close_price'])
              	{
      html += '<td><span class="down range" close_price='+entry['stock_close_price']+' current_price='+entry['stock_current_price']+'>3%</span></td>';
    }
              else
              	{
      html += '<td><span class="nochange range" close_price='+entry['stock_close_price']+' current_price='+entry['stock_current_price']+'>0%</span></td>';
    }
			html += '</tr>'
			$('table#hottable').append(html);
    $("span.range").each(function() {
      $(this).html(range($(this).attr("close_price"), $(this).attr("current_price"))+"%");
    });
			$("tr.hottableempty").click(function(){
  		var code = $(this).attr("code");
  		var price = $(this).attr("price");
  		$("input#code").val(code);
  		$("input#price").val(price);
  		$("input#amount").val("");
  		getTradePrice();
  		getTradeCanDo();
  		showEntrustFive(code);
  		});
		});
		investAutoHight();
	});
};
function showHotTrade(){
	$.getJSON("/products/pop_list.json?time="+new Date().getTime(),function(data){
		$('div#hot').append('<div class="box-top"><span class="left"></span><span class="right"></span></div><div class="box-body"><h3 class="block blue"><span></span>热门产品<a class="more" id="hotmore" href="/misc/top10/stock">更多 »</a></h3><ul class="securities" id="hot_ul"></ul></div><div class="box-foot"><span class="left"></span><span class="right"></span></div>');
		$.each(data,function(entryIndex,entry){
			if (entryIndex<5)
			{
			var html = '<li>';
			html += '<span class="security" style="width:47px;height:68px">';
			html += '<img src="'+entry['stock_poster']+'" style="width:47px;height:68px" alt="pic"/>';
			html += '</span>';
			html += '<h5>';
			html += '<a href="/products/'+entry['stock_code']+'">'+entry['stock_name']+'</a>';
			html += '</h5>';
			html += '<p>字母代码：'+entry['stock_alias']+'</p>';
			html += '<p class="trade_info">';
			html += 'SW$'+entry['stock_current_price'];
							if (entry['stock_current_price'] > entry['stock_close_price'])
							{
      html += '<span class="up range" close_price='+entry['stock_close_price']+' current_price='+entry['stock_current_price']+'>3.21%</span>';
    }
              else if (entry['stock_current_price'] < entry['stock_close_price'])
              	{
      html += '<span class="down range" close_price='+entry['stock_close_price']+' current_price='+entry['stock_current_price']+'>3%</span>';
    }
              else
              	{
      html += '<span class="nochange range" close_price='+entry['stock_close_price']+' current_price='+entry['stock_current_price']+'>0%</span>';
    }
    	html += '<a href="/products/'+entry['stock_code']+'">交易 »</a>';
//			html += '<a class="bs_btn" stock_code='+entry['stock_code']+'>交易 »</a>';
			html += '</p>';
			html += '</li>';
			$('ul#hot_ul').append(html);
			}
			else
			{
			var html = '<li class="hide">';
			html += '<span class="security" style="width:47px;height:68px">';
			html += '<img src="'+entry['stock_poster']+'" style="width:47px;height:68px" alt="pic"/>';
			html += '</span>';
			html += '<h5>';
			html += '<a href="/products/'+entry['stock_code']+'">'+entry['stock_name']+'</a>';
			html += '</h5>';
			html += '<p>字母代码：'+entry['stock_alias']+'</p>';
			html += '<p class="trade_info">';
			html += 'SW$'+entry['stock_current_price'];
							if (entry['stock_current_price'] > entry['stock_close_price'])
							{
      html += '<span class="up range" close_price='+entry['stock_close_price']+' current_price='+entry['stock_current_price']+'>3.21%</span>';
    }
              else if (entry['stock_current_price'] < entry['stock_close_price'])
              	{
      html += '<span class="down range" close_price='+entry['stock_close_price']+' current_price='+entry['stock_current_price']+'>3%</span>';
    }
              else
              	{
      html += '<span class="nochange range" close_price='+entry['stock_close_price']+' current_price='+entry['stock_current_price']+'>0%</span>';
    }
			html += '<a class="bs_btn" stock_code='+entry['stock_code']+'>交易 »</a>';
			html += '</p>';
			html += '</li>';
			$('ul#hot_ul').append(html);
			}
		});
	});
	$(document).ready(function(){
		$("a.bs_btn").click(clickBsBtn);
		$("a#hotmore").click(clickHotMoreBtn);
	});
};
//补0函数  
function appendZero(s){
return   ("00"+   s).substr((s+"").length);
} 
function GetToday(){
	var   d   =   new   Date();   
  return (d.getFullYear() +appendZero(d.getMonth() +1) + appendZero(d.getDate()));
}
function showEntrustFive(a){
	var today=new Date();
	var h=today.getHours();
	var m=today.getMinutes();
	var s=today.getSeconds();
	if (settings.exchange_status == false)
	{
		$('span.amount').html("0");
		$('span.price').html("--");
		$('input#shua5').attr("disabled","true");
		$('input#shua5').val("非交易时间");
	}
	else
	{
		$('input#shua5').attr("disabled","");
		$('input#shua5').val("刷新");
	$.getJSON("/entrust/entrusts5.json?stock_code="+a+"&time="+new Date().getTime(),function(data){
		$('span.amount').html("0");
		$('span.price').html("--");
		$('td#jiage1').html(cc(data.price.toString()));
		$("td#zsz").html(cc(cheng($("td#zsz").attr("current_amount"),data.price).toString()));
		if (data.price>$("em#jiage").attr("close_price"))
		{
		$('em#jiage').html(cc((data.price).toString()))
		$('span#rangechange').html(jian($("em#jiage").attr("close_price"), data.price)+"("+range($("em#jiage").attr("close_price"), data.price)+"%)");
		$('span#rangechange').removeClass();
		$('span#rangechange').addClass("up");
		}
		else if (data.price<$("em#jiage").attr("close_price"))
		{
		$('em#jiage').html(cc((data.price).toString()))
		$('span#rangechange').html(jian($("em#jiage").attr("close_price"), data.price)+"("+range($("em#jiage").attr("close_price"), data.price)+"%)");
		$('span#rangechange').removeClass();
		$('span#rangechange').addClass("down");
		}
		else
		{
		$('em#jiage').html(cc((data.price).toString()))
		$('span#rangechange').html(jian($("em#jiage").attr("close_price"), data.price)+"("+range($("em#jiage").attr("close_price"), data.price)+"%)");
		$('span#rangechange').removeClass();
		$('span#rangechange').addClass("nochange");
		}
		$.each(data.sell,function(entryIndex,entry){
			if (entryIndex==0)
			{
				$('span#sellamount1').html(data.sell[0].entrust_amount);
				$('span#sellprice1').html(data.sell[0].entrust_price);
			}
			else if (entryIndex==1)
			{
				$('span#sellamount2').html(data.sell[1].entrust_amount);
				$('span#sellprice2').html(data.sell[1].entrust_price);
			}
			else if (entryIndex==2)
			{
				$('span#sellamount3').html(data.sell[2].entrust_amount);
				$('span#sellprice3').html(data.sell[2].entrust_price);
			}
			else if (entryIndex==3)
			{
				$('span#sellamount4').html(data.sell[3].entrust_amount);
				$('span#sellprice4').html(data.sell[3].entrust_price);
			}
			else if (entryIndex==4)
			{
				$('span#sellamount5').html(data.sell[4].entrust_amount);
				$('span#sellprice5').html(data.sell[4].entrust_price);
			}
		});
		$.each(data.buy,function(entryIndex,entry){
			if (entryIndex==0)
			{
				$('span#buyamount1').html(data.buy[0].entrust_amount);
				$('span#buyprice1').html(data.buy[0].entrust_price);
			}
			else if (entryIndex==1)
			{
				$('span#buyamount2').html(data.buy[1].entrust_amount);
				$('span#buyprice2').html(data.buy[1].entrust_price);
			}
			else if (entryIndex==2)
			{
				$('span#buyamount3').html(data.buy[2].entrust_amount);
				$('span#buyprice3').html(data.buy[2].entrust_price);
			}
			else if (entryIndex==3)
			{
				$('span#buyamount4').html(data.buy[3].entrust_amount);
				$('span#buyprice4').html(data.buy[3].entrust_price);
			}
			else if (entryIndex==4)
			{
				$('span#buyamount5').html(data.buy[4].entrust_amount);
				$('span#buyprice5').html(data.buy[4].entrust_price);
			}
		});
	});
	}
};
//easytrade
$(document).ready(function(){
  $("span.price").mouseover(function(){
    $(this).css("border","1px solid #00558A");
  });
  $("span.price").mouseout(function(){
    $(this).css("border","0px");
  });
  $("span.price").click(function(){
  	var price=$(this).html();
  	if (price != "--")
  	{
  		$("input#price").val(price);
  		getCanBuy();
  	}
  });
  /*
  $("tr.10_0empty").mouseover(function(){
  	var amount = $(this).attr("amount");
  	var code = $(this).attr("code");
  	var price = $(this).attr("price");
  	alert(price);
  	$("input#code").val(code);
  	$("input#price").val(price);
  	$("input#amount").val(amount);
  	getTradeCanDo();
  	getCanBuy();
  });
  */
});
function showScrollUl(){
	var today=new Date();
	var h=today.getHours();
	var m=today.getMinutes();
	var s=today.getSeconds();
	if (settings.exchange_status == false)
	{
		$('div#ticker-scroll').html("");
		$('div#ticker-scroll').append('<ul id="ul_scroll"></ul>');
		$('ul#ul_scroll').html('<li><span style="color: rgb(88, 203, 72);">非交易时间</span></li>');
	}
	else
	{
	$.getJSON("/products/all_prices.json?time="+new Date().getTime()+"&all",function(data){
		$('div#ticker-scroll').html("");
		$('div#ticker-scroll').append('<ul id="ul_scroll"></ul>');
		$.each(data,function(entryIndex,entry){
			if (entryIndex<10)
			{
			var html = '<li>';
			html += '<a href="/products/'+entry['stock_code']+'">'+entry['stock_name']+'&nbsp;('+entry['stock_alias']+')&nbsp;'
			if (entry['current_price'] > entry['close_price'])
			{
			html += '<span style="color: rgb(204, 61, 67);">'+entry['current_price']+'&nbsp;('+range(entry['close_price'],entry['current_price'])+'%)</span>'
			}
			else if (entry['current_price'] < entry['close_price'])
			{
			html += '<span style="color: rgb(88, 203, 72);">'+entry['current_price']+'&nbsp;('+range(entry['close_price'],entry['current_price'])+'%)</span>'
			}
			else
			{
			html += '<span>'+entry['current_price']+'&nbsp;('+range(entry['close_price'],entry['current_price'])+'%)</span>'
			}
			html += '</a>';
			html += '</li>';
			$('ul#ul_scroll').append(html);
			}
		});
		setTimeout(jQuery(function($) {
		function ScrollAction(listObj, listElem, speed, isSeries) {	//listObj为需要滚动的列表，  speed为滚动速度
			var pos, left, aniLeft, width;
			var id = '';  //记录setInterval的标记id
			
			pos = listObj.position();	
			left = pos.left;			//列表的top
			aniLeft = left;				//记录当前运动时的top
			width = listObj.width();	//列表的高度
			
			var scrollUp = function() {
				aniLeft--;
				if(!isSeries) {	//isSeries变量控制是否连续滚动，false不连续，true连续
					if(aniLeft == -width) {	//不连续，滚动玩重新滚动
						listObj.css({'left': left});
						aniLeft = left;
					};
				} else {
					if(aniLeft == -listObj.children().eq(0).width()) {	//连续滚动
						var firstItem = '<' + listElem +'>' + listObj.children().eq(0).html() + '</' + listElem +'>';
						listObj.children().eq(0).remove();
						listObj.append(firstItem);
						aniLeft = 4;
					};
				};
				listObj.css({'left': aniLeft + 'px'});
			};
			
			var hover = function(id) {
				listObj.hover(function() {
					clearInterval(id);
				}, function() {
					id = setInterval(scrollUp, speed);
				});
			};
			
			this.start = function() {
				id = setInterval(scrollUp, speed);
				hover(id);
			};
			
		};
		var sa = new ScrollAction($('#ul_scroll'), 'li', 30, false);
		sa.start();
	}),2000);
	});
	}
};
function getIndexAdvPrice1(stock_code){
		code = stock_code;
		$("span#index_mid_mov_price").html("");
		$.getJSON("/products/current_price.json?stock_code="+code+"&time="+new Date().getTime(),function(data){
			if (data.currency == 1)
			{
			var html = data.current_price + ' RMB';
			}
			else
				{
					var html = data.current_price + ' W$';
				}
			$("span#index_mid_mov_price").html(html);
			$("span#index_mid_mov_price").removeClass();
			if (data.current_price > data.close_price)
			{
			$("span#index_mid_mov_price").addClass("up");
			}
			else if (data.current_price < data.close_price)
				{
					$("span#index_mid_mov_price").addClass("down");
				}
				else
					{
						$("span#index_mid_mov_price").addClass("nochange");
					}
		});
}
function getIndexAdvPrice(){
		code = $("span#index_mid_mov_price").attr("stock_code");
		$.getJSON("/products/current_price.json?stock_code="+code+"&time="+new Date().getTime(),function(data){
			if (data.currency == 1)
			{
			var html = data.current_price + ' RMB';
			}
			else
				{
					var html = data.current_price + ' W$';
				}
			$("span#index_mid_mov_price").html(html);
			$("span#index_mid_mov_price").removeClass();
			if (data.current_price > data.close_price)
			{
			$("span#index_mid_mov_price").addClass("up");
			}
			else if (data.current_price < data.close_price)
				{
					$("span#index_mid_mov_price").addClass("down");
				}
				else
					{
						$("span#index_mid_mov_price").addClass("nochange");
					}
		});
}
function getTradePrice(){
	var code = $("input#code").val();
	if (code.length==8)
	{
		$.getJSON("/products/current_price.json?stock_code="+code+"&time="+new Date().getTime(),function(data){
			var html = " "+data.name+" 昨收: "+data.close_price+" 最新: "+data.current_price;
			showEntrustFive(code);
			$("form span#code_x").html(html);
			$("form input#price").val(data.current_price);
			getCanBuy();
			$("form span#code_x").css("color","");
		});
	}
	else
		{
			$("form span#code_x").html("* 请输入正确的商品代码");
			$("form span#code_x").css("color","red");
		}
};
function getTradeCanDo(){
	$("input#buybutton").attr("disabled","true");
	$("input#sellbutton").attr("disabled","true");
	$("input#shortbutton").attr("disabled","true");
	$("input#coverbutton").attr("disabled","true");
	var code = $("input#code").val();
	if (code.length==8)
	{
		$.getJSON("/invest/holdings.json?stock_code="+code+"&time="+new Date().getTime(),function(data){
			if (data.length>0)
			{
			$.each(data,function(entryIndex,entry){
					if (entry['holding_type']=='多头')
					{
						$("input#buybutton").attr("disabled","");
						$("input#sellbutton").attr("disabled","");
					}
					else
					{
						$("input#shortbutton").attr("disabled","");
						$("input#coverbutton").attr("disabled","");
					}
				});
			}
			else
			{
				$("input#buybutton").attr("disabled","");
				$("input#shortbutton").attr("disabled","");
			}
			});
	}
	else
		{
			$("form span#code_x").html("* 请输入正确的商品代码");
			$("form span#code_x").css("color","red");
		}
};
function getCanBuy2(code, price) {
  var bu = 0;
  var se = 0;
  var sh = 0;
  var co = 0;
  var balance, price, assets, currency, amount, code;
  $.ajax({type: "get", url: "/invest/assets2.json?time="+new Date().getTime(),
    async: false, success: function(data){
      assets = data;
    }
  });
  $.ajax({type: "get", url: "/invest/holdings.json?time="+new Date().getTime()+"&stock_code="+code,
    async: false, success: function(data){
      if(data.length == 0) {
        $.ajax({type: "get", url: "/products/current_price.json?stock_code="+code+"&time="+new Date().getTime(),
          async: false, success: function(data){
            currency = data.currency;
            amount = 0;
          }
        });
      } else {
        currency = data[0].currency;
        avialable = data[0].avialable;
        if(data[0].holding == 1) {
          amount = data[0].total; // long
        } else {
          amount = -data[0].total; // short
        }
      }
    }
  });
  if(currency == 0) {
    balance = assets.v.balance;
  } else {
    balance = assets.r.balance;
  }
  if(amount == 0) {
    bu = sh = balance / (price * (1 + settings.charge_rate));
  } else if(amount > 0) {
    bu = balance / (price * (1 + settings.charge_rate));
    se = avialable;
  } else if(amount < 0) {
    sh = balance / (price * (1 + settings.charge_rate));
    co = avialable;
  }
  return {buy: parseInt(bu), sell: parseInt(se), short: parseInt(sh), cover: parseInt(co)};
}
function getCanBuy3() {
	$("form span#amount_x").html("");
	var price = $("input#price").val();
	var code = $("input#code").val();
  var bu = 0;
  var se = 0;
  var sh = 0;
  var co = 0;
  var balance, assets, currency, amount;
  if (price.length>0)
  {
  $.getJSON("/invest/assets2.json?time="+new Date().getTime(),function(data){
  	assets = data;
  	$.getJSON("/products/current_price.json?stock_code="+code+"&time="+new Date().getTime(),function(data){
  		currency = data.currency;
  		if(currency == 0)
  		{
  			balance = assets.v.balance;
  		}
  		else
  		{
  			balance = assets.r.balance;
  		}
  		$.getJSON("/invest/holdings.json?time="+new Date().getTime()+"&stock_code="+code,function(data){
  			if(data.length == 0)
  			{
      		amount = 0;
      		bu = sh = balance / (price * (1 + settings.charge_rate));
      		var html="&nbsp;";
      		html += "<br /> 可买数量: "+parseInt(bu);
      		html += "<br /> 可卖空数量: "+parseInt(sh);
      		$("form span#amount_x").html(html);
      		$("form span#amount_x").css("color","");
      		$("form span#price_x").html("");
      	}
      	else
      	{
      		currency = data[0].currency;
      		if(data[0].holding == 1)
      		{
      			amount = data[0].avialable; // long
      			bu = balance / (price * (1 + settings.charge_rate));
      			se = amount;
      			var html="";
      			html += "<br /> 可买数量: "+parseInt(bu);
      			html += "<br /> 可卖数量: "+parseInt(se);
      			$("form span#amount_x").html(html);
      			$("form span#amount_x").css("color","");
      			$("form span#price_x").html("");
      		}
      		else
      		{
      			amount = -data[0].avialable; // short
      			sh = -amount;
      			co = balance / (price * (1 + settings.charge_rate));
      			var html="";
      			html += "<br /> 可卖空数量: "+parseInt(sh);
      			html += "<br /> 可平空数量: "+parseInt(co);
      			$("form span#amount_x").html(html);
      			$("form span#amount_x").css("color","");
      			$("form span#price_x").html("");
      		}
      	}
      });
    });
  });
	}
	else
	{
		$("form span#price_x").html("* <br />请输入正确的价格");
		$("form span#price_x").css("color","red");
		$("form span#amount_x").html("");
	}
}
function getCanBuy(){
	$("form span#amount_x").html("");
	var price = $("input#price").val();
	var code = $("input#code").val();
	if (price.length>0)
	{
		var getdata = getCanBuy2(code, price);
		var html="";
//		alert(getdata.buy);
//		alert(getdata.sell);
//		alert(getdata.short);
//		alert(getdata.cover);
		if (getdata.buy>=0)
		{
		html += "<br /> 可买数量: "+getdata.buy;
		}
		if (getdata.sell>=0)
		{
		html += "<br /> 可卖数量: "+getdata.sell;
		}
		if (getdata.short>=0)
		{
		html += "<br /> 可卖空数量: "+getdata.short;
		}
		if (getdata.cover>=0)
		{
		html += "<br /> 可平空数量: "+getdata.cover;
		}
		if (getdata.buy<0)
		{
		html += "<br /> 可买数量: 0";
		}
		if (getdata.sell<0)
		{
		html += "<br /> 可卖数量: 0";
		}
		if (getdata.short<0)
		{
		html += "<br /> 可卖空数量: 0";
		}
		if (getdata.cover<0)
		{
		html += "<br /> 可平空数量: 0";
		}
		$("form span#amount_x").html(html);
		$("form span#amount_x").css("color","");
		$("form span#price_x").html("");
	}
	else
		{
			$("form span#price_x").html("* <br />请输入正确的价格");
			$("form span#price_x").css("color","red");
			$("form span#amount_x").html("");
		}
}
function getCanBuy_old(){
	$("form span#amount_x").html("");
	var price = $("input#price").val();
	var code = $("input#code").val();
	$.getJSON("/products/current_price.json?stock_code="+code+"&time="+new Date().getTime(),function(data){
		var money_type = data.currency;
		if (money_type==0)
	{
	if (price.length>0)
	{
		$.getJSON("/invest/assets.json?time="+new Date().getTime(),function(data){
			var html = "<br /> 可买数量: "+Math.floor(data.v_balance/(price * (1 + settings.charge_rate)));
			$("form span#amount_x").append(html);
			$("form span#amount_x").css("color","");
			$("form span#price_x").html("");
		});
		$.getJSON("/invest/holdings.json?time="+new Date().getTime(),function(data){
			$.each(data,function(entryIndex,entry){
			if (entry['stock_code']==code)
			{
				var htm = "<br /> 可卖数量: "+entry['avialable'];
				$("form span#amount_x").append(htm);
			}
			/*else
				{
					var html = " 可卖数量: 0";
					$("form span#amount_x").append(html);
				}*/
			});
		});
	}
	else
		{
			$("form span#price_x").html("* <br />请输入正确的价格");
			$("form span#price_x").css("color","red");
			$("form span#amount_x").html("");
		}
	}
	if (money_type==1)
	{
	if (price.length>0)
	{
		$.getJSON("/invest/assets.json?time="+new Date().getTime(),function(data){
			var html = "<br /> 可买数量: "+Math.floor(data.balance/(price * (1 + settings.charge_rate)));
			$("form span#amount_x").append(html);
			$("form span#amount_x").css("color","");
			$("form span#price_x").html("");
		});
		$.getJSON("/invest/holdings.json?time="+new Date().getTime(),function(data){
			$.each(data,function(entryIndex,entry){
			if (entry['stock_code']==code)
			{
				var htm = "<br /> 可卖数量: "+entry['avialable'];
				$("form span#amount_x").append(htm);
			}
			/*else
				{
					var html = " 可卖数量: 0";
					$("form span#amount_x").append(html);
				}*/
			});
		});
	}
	else
		{
			$("form span#price_x").html("* <br />请输入正确的价格");
			$("form span#price_x").css("color","red");
			$("form span#amount_x").html("");
		}
	}
	});
};
function getAllCode(){
	$.getJSON("/products/all_prices.json?time="+new Date().getTime()+"&all",function(data){
		$("div#allcode").html("");
			$.each(data,function(entryIndex,entry){
				codes="'";
				codes+=entry['stock_code']+" "+entry['stock_alias']+" "+entry['stock_name'];
				codes+="',"
				$("div#allcode").append(codes);
			});
		});
}
function getAllCode2(){
  var ret = new Array;
  $.ajax({type: "get",
    url: "/products/all_prices.json?time="+new Date().getTime()+"&count=200",
    async: false,
    success: function(data){
    $.each(data, function(entryIndex, entry){
      ret.push({"id": entry.stock_code, 
      	"label": entry.stock_code+" "+entry.stock_alias+" "+entry.stock_name, 
      	"value": entry.stock_code});
    });
  }});
  return ret;
}
//打印函数
function clickPrintLicense1(){
	$("div.license1").printArea();
}
function clickPrintLicense2(){
	$("div.license2").printArea();
}
function clickPrintLicense3(){
	$("div.license3").printArea();
}
function clickPrintLicense4(){
	$("div.license4").printArea();
}
function clickApplyLicense1(){
								 $("div#bs_div").html("");
								 $("div#bs_div").html("<a title='关闭窗口' id='close'>×</a><form class='visible' action='' method='post'><ul><li><label>制作价格: </label>50元</li><li><label>寄运费用: </label>25元</li><li><label>总计价格: </label>75元</li><li><label>收货地址: </label><input type='text' /></li><li><label>收货人: </label><input type='text' /></li><li><label>联系电话: </label><input type='text' /></li><li><input type='button' value='立即申请' /></li></ul></form>");
							   $("div#bs_div").css({left:($(this).offset().left+$(this).outerWidth()-242),top:$(this).offset().top+$(this).outerHeight()});
							   //clickInventBtn0_0();
							   $("div#bs_div").show(300);
							   $(document).ready(function(){
  								$("div#bs_div a#close").click(clickBsCloseBtn);
							   	});
							   };
//小消息框的函数
function clickMsgCloseBtn(){
  $("div#msg").hide();
  $("div#msgbox-body").html("");
  clearInterval(int);
};
//消息显示函数
function showMessages(message){
	var msg = message;
	$("div#msg_body").html("");
	$("div#msg_body").append(msg);
	$("div#msg").show();
	$("div#msg a#msgclose").click(clickMsgCloseBtn);
}
//chinapay第一次提交
function chinapayPost1(){
	var chinapay_amount = $("input#chinapay_cash").val();
	var bank_company = $("input[name=bank_company]:checked").val()
	if ($("input#chinapay_cash").val().length>0)
	{
		$("input#chinapay_cash").css("background-color","");
		$.post('/order/' + bank_company,{
			amount: chinapay_amount,
			subject: 0
		},
		chinapay_return
		);
	}
	else
			{
				alert("输入金额！");
				$("input#chinapay_cash").css("background-color","#ffc5c5");
				$("input#chinapay_cash").focus();
			}
}
function chinapayPost11(){
	var chinapay_amount = $("input#chinapay_cash").val();
	if ($("input#chinapay_cash").val().length>0)
	{
		$("input#chinapay_cash").css("background-color","");
		$.post('/order/chinapay',{
			amount: chinapay_amount,
			subject: 1
		},
		chinapay_return11
		);
	}
	else
			{
				alert("输入金额！");
				$("input#chinapay_cash").css("background-color","#ffc5c5");
				$("input#chinapay_cash").focus();
			}
}
function chinapay_return11(data){
	var chinapay_amount = $("input#chinapay_cash").val();
	var info = data
	var chinapay_btn = '<center>';
  chinapay_btn += '<h3>购买期酒币确认：</h3><br /><strong>购买金额：'+ chinapay_amount +'</strong><br /><br /><input value="确定" type="submit"><input id="infoclose" value="取消" type="button">';
  chinapay_btn += '</center>';
  $("div#info_div").html(info);
  $("form#chinaPayConfirm").append(chinapay_btn);
  $(document).ready(function(){
    $("input#infoclose").click(clickInfoCloseBtn);
  });
  setInfoDivInMiddle();
  $("div#blackback").show();
$("div#info_div").show();
};
function chinapay_return(data){
	var chinapay_amount = $("input#chinapay_cash").val();
	var bank_company_name = $("input[name=bank_company]:checked").attr("bkname");
	var info = data
	//var info = '<form action="https://payment.chinapay.com/pay/TransGet" METHOD=POST><input type=hidden name="MerId" value=MerId ><input type=hidden name="OrdId" value=OrdId ><input type=hidden name="TransAmt" value="000000001234"><input type=hidden name="CuryId" value="156"><input type=hidden name="TransDate" value="20040315"><input type=hidden name="TransType" value=TransType ><input type=hidden name="Version" value="20040916"><input type=hidden name="BgRetUrl" value="http://www.XX.com/pay/payback1.php"><input type=hidden name="PageRetUrl" value="http://www.XX.com/pay/payback2.php"><input type=hidden name="GateId" value="0001"><input type=hidden name="Priv1" value="Memo"><input type=hidden name="ChkValue" value=ChkValue></form>'
	var chinapay_btn = '<center>';
  chinapay_btn += '<h3>资金转入确认：</h3><br /><strong>转入人民币金额：'+ chinapay_amount +'</strong><br /><br /><strong>转入方式：'+ bank_company_name +'</strong><br /><br /><input value="确定" type="submit"><input id="infoclose" value="取消" type="button">';
  chinapay_btn += '</center>';
  $("div#info_div").html(info);
  $("form#chinaPayConfirm").append(chinapay_btn);
  $(document).ready(function(){
    $("input#infoclose").click(clickInfoCloseBtn);
  });
  setInfoDivInMiddle();
  $("div#blackback").show();
$("div#info_div").show();
};

