

var BSW=0;
var BSH=0;
var BSHs=0;
var BSHt=0;
var div;
var TXnewMaskdiv;
function gBS(){//获取窗口文本大小
    BSW=document.documentElement.clientWidth;//如果body样式没有设margin=0，则为：BSW=document.documentElement.clientWidth
    BSH=document.documentElement.clientHeight;
    BSHs=document.documentElement.scrollHeight;
    BSHt=document.documentElement.scrollTop;
}

function showBody(winW,winH){

	gBS();
	getbgDiv(1);
	//var winHtml="<iframe id=\"cf\" name=\"cf\" src=\"/zbh/newpop.jsp\" border=\"0\" marginheight=\"0\" marginwidth=\"0\" frameborder=\"0\" scrolling=\"no\" width=\"100%\"></iframe>";
	var relTop=(BSH-winH)/2 > 0 ? (BSH-winH)/2:0;
    //var objTop = parseInt(BSHt+relTop)+"px";
    var objTop = "100px";
    //var objLeft = parseInt(document.documentElement.scrollLeft+(BSW - winW)/2)+"px";
    var objLeft = 200+"px"
    
    //alert(document.documentElement.clientWidth);
    //alert(document.documentElement.clientHeight);
    //alert(document.documentElement.scrollHeight);
    //alert(document.documentElement.scrollTop);
    //alert(BSH);
    //alert(BSHt);
    //alert(relTop);
    
    //alert("高："+objTop);
    //alert("宽："+objLeft);
	div=document.getElementById('divContent');
	div.style.width=winW;
	div.style.height=winH;
	div.style.top=objTop;
	div.style.left=objLeft;
	div.style.display='';
	div.style.position = "absolute";
	div.style.zIndex = "999999";
	
	//div.innerHTML =winHtml;
	//alert($('myform').title.value);
	  var url="/zbh/newpop.jsp";
   			//	var pars="&tag="+tag+"&docId="+inputid; 
   				var myAjax=new Ajax.Updater("divContent",url,{method: 'post',parameters:$('myform').serialize(),evalScripts:true});	
 
}

	function getbgDiv(Hide) 
{ 

// 背景图层 
if(Hide==1) 
{ 
var TXnewMask = document.createElement("DIV"); 
TXnewMask.id = 'Tmask'; 
TXnewMask.style.position = "absolute"; 
TXnewMask.style.zIndex = "100"; 
TXnewMask.style.width =document.documentElement.scrollWidth+"px"; 
TXnewMask.style.height = document.documentElement.scrollHeight+80+"px"; 
TXnewMask.style.top = "0px"; 
TXnewMask.style.left = "0px"; 
TXnewMask.style.background ='#000000'; 
TXnewMask.style.filter = "alpha(opacity=50)"; 
TXnewMask.style.opacity = "0.50"; 
document.body.appendChild(TXnewMask); 
} 
else 
{ 
document.body.removeChild(document.getElementById('Tmask')); 
} 

TXnewMaskdiv=TXnewMask;
}

  function setValue(inputId,inputName,inputType,inputDate,inputContent,inputTitle,inputTp){
  
  				document.getElementById('docId').value=inputId;
           		document.getElementById('sendName').value=inputName;
           		document.getElementById('type').value=inputType;
           		document.getElementById('date').value=inputDate;
           		document.getElementById('content').value=inputContent;
           		document.getElementById('title').value=inputTitle;
           		document.getElementById('tp').value=inputTp;
           		
      }
      
      
      
      
 var form;
 var id; 
 var win; 
  function MyStock(){
   var count=document.getElementById('zxg').value;
   var input='自选股'+count;
 	form= new Ext.form.FormPanel({
        layout:'form',
        frame:true,
        labelAlign:'right',
        items: [{
        	name:'stockId',
            xtype: 'textfield',
            fieldLabel: '股票代码',
            autoWidth : false,
           // hideLabel :true,
            value:input,
            width:80,
            height:20,
           // handler:function(){alert(this.value);this.onBlur=function(){this.value=''};}
            onBlur: function (){if(form.find('stockId')[0].getValue()=='')form.find('stockId')[0].setValue(input);},
            onFocus:function(){form.find('stockId')[0].setValue('');}
			
        }]
    });

   win= new Ext.Window({
        title: '增加我的自选股',
        width: 230,
        height:120,
        minWidth: 230,
        minHeight: 120,
        layout: 'fit',
        plain:true,
        bodyStyle:'padding:5px;',
        buttonAlign:'center',
        items: form,
		modal:true,
        buttons: [{
            text: '保存',
            handler: addStock
        },{
            text: '取消',
            handler:function(){win.close();}
        }]
    });

    win.show();
}    

function MyzbhStock(){
 
    var count=document.getElementById('zxg').value;
   var input='自选股'+count;
 	form= new Ext.form.FormPanel({
        layout:'form',
        frame:true,
        labelAlign:'right',
        items: [{
        	name:'stockId',
            xtype: 'textfield',
            fieldLabel: '股票代码',
            autoWidth : false,
           // hideLabel :true,
            value:input,
            width:80,
            height:20,
           // handler:function(){alert(this.value);this.onBlur=function(){this.value=''};}
            onBlur: function (){if(form.find('stockId')[0].getValue()=='')form.find('stockId')[0].setValue(input);},
            onFocus:function(){form.find('stockId')[0].setValue('');}
			
        }]
    });

   win= new Ext.Window({
        title: '增加我的自选股',
        width: 230,
        height:120,
        minWidth: 230,
        minHeight: 120,
        layout: 'fit',
        plain:true,
        bodyStyle:'padding:5px;',
        buttonAlign:'center',
        items: form,
		modal:true,
        buttons: [{
            text: '保存',
            handler: addzbhStock
        },{
            text: '取消',
            handler:function(){win.close();}
        }]
    });

    win.show();
  
}    


function MyzbhStock1(){
 
    var count=document.getElementById('zxg').value;
   var input='自选股'+count;
 	form= new Ext.form.FormPanel({
        layout:'form',
        frame:true,
        labelAlign:'right',
        items: [{
        	name:'stockId',
            xtype: 'textfield',
            fieldLabel: '股票代码',
            autoWidth : false,
           // hideLabel :true,
            value:input,
            width:80,
            height:20,
           // handler:function(){alert(this.value);this.onBlur=function(){this.value=''};}
            onBlur: function (){if(form.find('stockId')[0].getValue()=='')form.find('stockId')[0].setValue(input);},
            onFocus:function(){form.find('stockId')[0].setValue('');}
			
        }]
    });



   win= new Ext.Window({
        title: '增加我的自选股',
        x: 260,
        y: 50,
        width: 230,
        height:120,
        minWidth: 330,
        minHeight: 220,
        layout: 'fit',
        plain:true,
        bodyStyle:'padding:5px;',
        buttonAlign:'center',
        items: form,
		modal:true,
        buttons: [{
            text: '保存',
            handler: addzbhStock
        },{
            text: '取消',
            handler:function(){win.close();}
        }]
    });
    

    win.show();
  
}



function addStock(){

	var stockid=form.find('stockId')[0].getValue();

	if(stockid=="") {
		alert("请输入证券代码");
		return false;
	}
	if(stockid.match(/^[0-9]\d*$/)==null){
		alert("证券代码只能包含数字");
		return false;
	}
	if(stockid.length !=6 ){
		alert("证券代码长度应该为6位");
		return false;
	}
		
	var url='/custom.do';
	   var paras='method=addTyStock&stockId='+stockid;
	 	new Ajax.Request(url,{method:'post',asynchronous:false,parameters:paras,onSuccess:function(request){
	 		var msg=request.responseText;
			
			alert(msg);
			if(msg.indexOf('成功')>=0) {win.close();document.getElementById('zxgframe').src='/tyyh/mySelectionList.jsp?'+Math.random();}
			
	 	},onFailure:function(){alert('系统异常')}});

}
function addzbhStock(){
var input=form.find('stockId')[0].getValue();
if(confirm('您确定要添加'+input+'为自选股？')){
	var stockid=input;
	if(stockid=="") {
		alert("请输入证券代码");
		return false;
	}
	if(stockid.match(/^[0-9]\d*$/)==null){
		alert("证券代码只能包含数字");
		return false;
	}
	if(stockid.length !=6 ){
		alert("证券代码长度应该为6位");
		return false;
	}
		
	var url='/custom.do';
	   var paras='method=addZbhStock&stockId='+stockid;
	 	new Ajax.Request(url,{method:'post',asynchronous:false,parameters:paras,onSuccess:function(request){
	 		var msg=request.responseText;
			
			alert(msg);
			if(msg.indexOf('成功')>=0) {win.close();document.getElementById('zxgframe').src='/tyyh/mySelectionList.jsp?'+Math.random();}
			
	 	},onFailure:function(){alert('系统异常')}});

}
}

var FFextraHeight = 0;
	if(window.navigator.userAgent.indexOf("Firefox")>=1)
	{
	 FFextraHeight = 16;
	}
	function ReSizeiFrame(iframe)
	{
		 if(iframe && !window.opera)
		 {
			  iframe.style.display = "block";
				  if(iframe.contentDocument && iframe.contentDocument.body.offsetHeight)
				  {
				 
				    iframe.height = iframe.contentDocument.body.offsetHeight + FFextraHeight;
				    
				  }
				  else if (iframe.Document && iframe.Document.body.scrollHeight)
				  {
				
				    iframe.height = iframe.Document.body.scrollHeight;
				    
				  }
		 }
	}

