//===================================================================
//
// Swingwaver Performance Report 
//
//===================================================================




// JavaScript Document
var graphtype = 1;
var chartid  = "performance";
var chartid2 = "performance2";


// 最適な横幅を算出
function graphwidth(){
	
  if (document.all){       gw = document.body.clientWidth;
  }else{                   gw = window.innerWidth; }
  if (gw<800){ gw=627; }else{gw=gw*0.81;}
  return gw;

}

// 最適な横幅を算出
function RadarSize(){
	
  if (document.all){       gw = document.body.clientWidth;
  }else{                   gw = window.innerWidth; }
  if (gw<800){ gw=627; }else{gw=gw*0.81;}
  return gw;

}


// 
function showPage( pagetype, gid, option ){
	
	var table = false;
	var graph = false;

 	gh = getWindowSize('h') - 30;
	
// プロフィール 
if ( pagetype == 1 ){ table = true; graph = false; phpcal = "performance/per_profile.php?gid="+gid; frameheight = gh; }

// サマリー
if ( pagetype == 2 ){ table = true; graph = false; phpcal = "performance/per_summary.php?gid="+gid; frameheight = gh; }

// 期間別のサマリー
if ( pagetype == 5 ){ table = true; graph = false; phpcal = "performance/per_period.php?gid="+gid+"&period="+option; frameheight = gh; }

// トレードリスト
if ( pagetype == 6 ){ table = true; graph = false; phpcal = "performance/per_tradelist.php?gid="+gid; frameheight = gh; }

// トレードリスト
if ( pagetype == 7 ){ 
	table   = true; 
	graph   = false;
	phpcal = "performance/graph_equity_dd.php?gid="+gid; 
	frameheight = gh;       
}
// トレードリスト
if ( pagetype == 8 ){ 
	table   = true; 
	graph   = false;
	phpcal = "performance/graph_equity_day2.php?gid="+gid; 
	frameheight = gh;       
}					   
// トレードリスト
if ( pagetype == 9 ){ 
	table   = false; 
	graph   = true; 
	 phpcal  = "performance/perdata_equitycurve_dd2.php?gid="+gid;
	swftype = "FusionCharts/Charts/MSCombi2D.swf";      }	
					   
// 分布図
if ( pagetype == 10 ){ 
	table   = true; 
	graph   = false;
	phpcal = "performance/graph_scatter.php?gid="+gid+"&period="+option;
	frameheight = gh;       
}	


// 期間ごと
if ( pagetype == 11 ){ 
	table   = false; 
	graph   = true; 
	phpcal  = "performance/perdata_bargraph.php?gid="+gid+"&option="+option;
	swftype = "FusionCharts/Charts/MSColumn2D.swf";      

}	

// 通貨ペアごと
if ( pagetype == 12 ){ 
	table   = false; 
	graph   = true; 
	phpcal  = "performance/perdata_bargraph_pair.php?gid="+gid+"&option="+option;
	swftype = "FusionCharts/Charts/MSColumn2D.swf";      

}

// レーダー
if ( pagetype == 13 ){ table = true; graph = false; phpcal = "performance/perdata_radarcharts.php?gid="+gid; frameheight = gh; }

// ポジション解析
if ( pagetype == 14 ){ table = true; graph = false; phpcal = "performance/per_position.php?gid="+gid; frameheight = gh; }

// ドーナツグラフ
if ( pagetype == 15 && option == 1){ 
	table   = false; 
	graph   = true; 
	phpcal  = "performance/perdata_doughnut_pair.php?gid="+gid+"&option="+option;
	swftype = "FusionCharts/Charts/Doughnut2D.swf";      
}

// ヒストリー
if ( pagetype == 16 ){ 
	table   = false; 
	graph   = true; 
	phpcal  = "performance/perdata_orderstatus.php?gid="+gid;
	swftype = "FusionCharts/Charts/MSCombi3D.swf";
}

// 含み損益
if ( pagetype == 17 ){ 
	table   = true; 
	graph   = false;
	phpcal = "performance/graph_runddstas.php?gid="+gid;
	frameheight = gh;       
}

// 効率
if ( pagetype == 18 ){ 
	table   = false; 
	graph   = true; 
	phpcal  = "performance/perdata_efficiency.php?gid="+gid+"&option="+option;
	swftype = "PowerCharts/Charts/SelectScatter.swf";   
}

// 移動平均値
if ( pagetype == 19 ){ 
	table   = false; 
	graph   = true; 
	phpcal  = "performance/perdata_ma1.php?gid="+gid+"&option="+option;
	swftype = "FusionCharts/Charts/MSLine.swf";      }
	
// 移動平均値
if ( pagetype == 20 ){ 
	table   = false; 
	graph   = true; 
	phpcal  = "performance/perdata_subscriber.php?gid="+gid+"&option="+option;
	swftype = "FusionCharts/Charts/MSLine.swf";      }

// 設定画面
if ( pagetype == 21 ){ 
table = true; graph = false; phpcal = "performance/displaysize.php?gid="+gid; frameheight = 450;     }
// 設定画面
if ( pagetype == 22 ){ 
table = true; graph = false; phpcal = "performance/configuration.php?gid="+gid; frameheight = 450;     }
// -------------------------------------------------------
//  横幅について
// -------------------------------------------------------
if (document.all){       gw = document.body.clientWidth; gh = document.body.clientHeight;
  }else{                   gw = window.innerWidth;         gh = window.innerHeight;}

  gw = getWindowSize('w');
  gh = getWindowSize('h');
				  
  gw *= 0.80; // 0.85 => too big, a bit.
  gh *= 0.95;
  gwt = gw;		
 
  if ( gw-200 < 900 ){ gw=900; }//gw-300;
  if ( gh < 650     ){ gh=650; }
  if ( gwt-200 < 900 ){ gwt=900; }//gw-300;
  
// -------------------------------------------------------
//  テーブルの表示
// -------------------------------------------------------
if ( table ){ 
  document.getElementById("tablearea").style.display="block";
  document.getElementById("grapharea").style.display="none";
  document.getElementById("tablearea").innerHTML = 
        '<IFRAME src="'+phpcal+'" width="'+gwt+'" height="'+frameheight+'" frameborder="0"></IFRAME>';
}

// -------------------------------------------------------
//  グラフの表示
// -------------------------------------------------------
if ( graph ){

   document.getElementById("tablearea").style.display="none";
  document.getElementById("grapharea").style.display="block";
  
  
  

  
  var chartX = new FusionCharts(swftype, chartid, gw, gh ,0,1);


  
    jx.load(
		phpcal,
		function(data){
		
			chartX.setDataXML(data);
			  
            chartX.render(chartid+"Div");	
			
			//$("result").innerHTML = data; //escape(data);
			
			//$("result").innerHTML = chartid+"Div"
			//$("result").innerHTML = "Here";
	     },'text','get');
   
  
  //chartX.setDataURL(phpcal);
  //$("result").innerHTML = phpcal;
  //chartX.render(chartid+"Div");
 
}
	
}

