﻿﻿function embed_fusionchart(src, params) {
    var so = new FusionCharts(src, 'linechart', voa(params['width'],400), voa(params['height'],200), '0', '1', '#ffffff', 'noScale', 'JA');
    so.addParam('wmode', 'transparent');
    so.addVariable('chartWidth',voa(params['width'],400));
    so.addVariable('chartHeight',voa(params['height'],200));

	//改行を置換。改行リテラルはそのまま
    so.setDataXML(params['data']);
    so.render(params['id']);
}

function embed_stackLineChart(params){
    var src='http://chart.hottolink.com/swf/MSStackedColumn2DLineDY.swf';
    embed_fusionchart(src, params);
}


function embed_MultiLine(params){
    var src='http://chart.hottolink.com/swf/MSLine.swf';
    embed_fusionchart(src, params);
}

function embed_LineChart(params){
    var src='http://chart.hottolink.com/swf/Line.swf';
    embed_fusionchart(src, params);
}

function embed_AmountChart(params){
    var src='http://chart.hottolink.com/swf/MSCombiDY2D.swf';
    embed_fusionchart(src, params);
}
function embed_stackChart(params){
    var src='http://chart.hottolink.com/swf/StackedBar2D.swf';
    embed_fusionchart(src, params);
}

function embed_AreaChart(params){
    var src='http://chart.hottolink.com/swf/StackedArea2D.swf';
    embed_fusionchart(src, params);
}


function embed_PieChart(params){
    var src='http://chart.hottolink.com/swf/Pie2D.swf';
    embed_fusionchart(src, params);
}

function embed_type0x(src, params, id, width, height) {
    var so = new SWFObject(src, id, width, height, '8', '#ffffff');
    so.addParam('wmode', 'transparent');
    embed_common_param(so, params);
    so.write(params['id']);
}

//for genderFLASH
function embed_type01(params) {
    var src = 'flash/type01.swf';
    embed_type0x(src, params, 'type01', '450', '70');
}

//for genderFLASH_small
function embed_type01_s(params) {
    var src = 'flash/type01_s.swf';
    embed_type0x(src, params, 'type01_s', '340', '60');
}

//for maleFLASH
function embed_type03_m(params) {
    var src = 'flash/type03_m.swf';
    embed_type0x(src, params, 'type03_m', '340', '60');
}

//for femaleFLASH
function embed_type03_f(params) {
    var src = 'flash/type03_f.swf';
    embed_type0x(src, params, 'type03_f', '340', '60');
}

//for repurationFLASH
function embed_type02(params) {
    var src = 'flash/type02.swf';
    embed_type0x(src, params, 'type02', '450', '70');
}

//for reputationFLASH_small
function embed_type02_s(params) {
    var src = 'flash/type02_s.swf';
    embed_type0x(src, params, 'type02_s', '340', '60');
}

//for goodFLASH
function embed_type03_g(params) {
    var src = 'flash/type03_g.swf';
    embed_type0x(src, params, 'type03_g', '340', '60');
}

//for badFLASH
function embed_type03_b(params) {
    var src = 'flash/type03_b.swf';
    embed_type0x(src, params, 'type03_b', '340', '60');
}

//for gender&reputationFLASH
function embed_type04(params) {
    var src = 'flash/type04.swf';
    embed_type0x(src, params, 'type04', '235', '210');
}

function embed_common_param(swfObj, params) {
    for (key in params){
        if (null != params[key] && ('' != params[key] || 'number' == typeof(params[key]))) {
            swfObj.addVariable(key, params[key]);
        }
    }
    return swfObj;
}

//Value Or Alternative
function voa(value,alt) {
    if (value != undefined && value!=null){
        return value;
    } else {
        return alt;
    } 
}

//value1 + value2 ⇒ add to target
function add(value1, value2){
    a = value1.value!='undefined'? value1.value : value1;
    b = value2.value!='undefined'? value2.value : value2;
    return eval(a + ' + ' + b);
}