         domain = 'www.ukiuki-club.com';
         
         function slideListDisp(mode){
            $(document).ready(function() {
                var time = 5000;	//切り替えのタイミング
                var speed = 500;	//スライドスピード
                var slideUl = $('#slide > ul');
                var slideList = $('li', slideUl);
                //ulの高さ分を上にずらす
                //slideUl.css('margin-top', '-'+slideUl.attr('offsetHeight')+'px');
                slideUl.css('margin-top', '0px');
                //リストのmargin
                var mBottom = parseInt(slideList.css('margin-bottom'));
                var count = slideList.length-1;
                var timer = setInterval(loop, time);
                
                // あらかじめタイムラインに情報を表示する
                slide_height = parseInt(slideUl.css('margin-top'))+slideList.eq(count).attr('offsetHeight') + mBottom;
                slideUl.css('margin-top', '-'+(slideUl.attr('offsetHeight') - slide_height * 4)+'px');

                //IEではmargin-bottomが取得できずNaNが返りエラーになる。
                // NaNの時0を代入する。
                if(isNaN(mBottom) == true){
                    mBottom = 0;
                }
                
                //ループ処理
                function loop() {
                    //最後のリストまで繰り返す
                    
                    if(0 <= count) {
                        slideUl.animate({
                            marginTop :  parseInt(slideUl.css('margin-top'))+slideList.eq(count).attr('offsetHeight') + mBottom +'px'
                        },speed);
                    } else {
                        //最後まできたら最初からやりなおし
                        clearInterval(timer);
                        Timeline(mode);
                    }
                    count--;
                }
                //マウスオーバーでストップ
                slideUl.hover(
                    function(){
                        if(0 <= count) clearInterval(timer);
                    },
                    function () {
                        if(0 <= count) timer = setInterval(loop, time);
                    }
                );
            });
        }

           function getTrialOrderTable(order_data){
                $(document).ready(function(){
                    var array_count = parseInt(order_data.length);
                        orderTimeLine = '';
                        orderTimeLine = '<ul>';
                    for(i = 0;i < array_count;i++){
                            orderTimeLine += '<li >';
                            //orderTimeLine += '<img src="http://' + domain + '/user_data/packages/default/img/icon/bibizou_pc.png" width=40px height=40px align=left>';
                            orderTimeLine += 'ご注文時間:';
                            orderTimeLine += order_data[i].create_date;
                            orderTimeLine += '<br>';
                            orderTimeLine += order_data[i].order_pref;
                            orderTimeLine += 'からご注文がありました。ありがとうございます！';
                            orderTimeLine += '  ';
                            if(order_data[i].order_reason == null){
                                order_data[i].order_reason = '';
                                orderTimeLine += '</li>';
                            }else{
                                orderTimeLine += '</li>';
                                orderTimeLine += '<li>';
                                orderTimeLine += 'お客様の声をいただきました！<br>';
                                orderTimeLine += order_data[i].order_reason;
                                orderTimeLine += '</li>';
                            }
                        
                        }
                        orderTimeLine += '</ul><div id="fade"></div>';
                        $('#slide').html(orderTimeLine);
                    });
            }

           function getSPOrderTable(order_data){
                $(document).ready(function(){
                        var array_count = parseInt(order_data.length);
                        orderTimeLine = '';
                        orderTimeLine = '<ul>';
                        for(i = 0;i < array_count;i++){
                                orderTimeLine += '<li>';
                                orderTimeLine += 'ご注文時間:';
                                orderTimeLine += order_data[i].create_date;
                                orderTimeLine += '<br>';
                                orderTimeLine += order_data[i].order_pref;
                                orderTimeLine += 'から以下のご注文がありました。ありがとうございます！';
                                orderTimeLine += '<br>';
                                for(j=0;j < order_data[i].product_name.length;j++){
                                    orderTimeLine += '<a href=https://' + domain +  '/products/detail.php?product_id='+ order_data[i].product_name[j].product_id +' >';
                                    orderTimeLine += order_data[i].product_name[j].product_name;
                                    orderTimeLine += '</a>';
                                    orderTimeLine += '<br>';
                                }

                                if(order_data[i].order_type == 3){
                                    orderTimeLine += order_data[i].regular_cycle + 'カ月ごと';
                                    orderTimeLine += '  <br>';
                                }

                                orderTimeLine += '';
                                
                            if(order_data[i].order_reason == null){
                                order_data[i].order_reason = '';
                                orderTimeLine += '</li>';
                            }else{
                                orderTimeLine += '</li>';
                                orderTimeLine += '<li>';
                                orderTimeLine += 'お客様の声をいただきました！<br>';
                                orderTimeLine += order_data[i].order_reason;
                                orderTimeLine += '</li>';
                            }
                        }
                        orderTimeLine += '</ul><div id="fade"></div>';
                        $('#slide').html(orderTimeLine);
                        });
            }

              function getUkiukiOrderTable(order_data){
                                $(document).ready(function(){
                        var array_count = parseInt(order_data.length);
                        orderTimeLine = '';
                        orderTimeLine = '<ul>';

                        for(i = 0;i < array_count;i++){
                                orderTimeLine += '<li>';
                                orderTimeLine += 'ご注文日:';
                                orderTimeLine += order_data[i].create_date;
                                orderTimeLine += '<br>';
                                orderTimeLine += order_data[i].order_pref;
                                orderTimeLine += 'から以下のご注文がありました。ありがとうございます！';
                                orderTimeLine += '<br>';
                                for(j=0;j < order_data[i].product_name.length;j++){
                                    orderTimeLine += '<a href=https://' + domain +  '/products/detail.php?product_id='+ order_data[i].product_name[j].product_id +' >';
                                    orderTimeLine += order_data[i].product_name[j].product_name;
                                    orderTimeLine += '</a>';
                                    orderTimeLine += '<br>';
                                }

                                if(order_data[i].order_type == 3){
                                    orderTimeLine += order_data[i].regular_cycle + 'カ月ごと';
                                    orderTimeLine += '  <br>';
                                }

                                orderTimeLine += '';

                            if(order_data[i].order_reason == null){
                                order_data[i].order_reason = '';
                                orderTimeLine += '</li>';
                            }else{
                                orderTimeLine += '</li>';
                                orderTimeLine += '<li>';
                                orderTimeLine += 'お客様の声をいただきました！<br>';
                                orderTimeLine += order_data[i].order_reason;
                                orderTimeLine += '</li>';
                            }
                        }
                        orderTimeLine += '</ul><div id="fade"></div>';
                        $('#slide').html(orderTimeLine);
                        });
            }

// サーバサイドから呼び出される関数
// modeの値に応じてサイトの区分が変わる。
function run(data,mode) {
    $(document).ready(function() {
        switch(mode){
            case 'otamesi':
                getTrialOrderTable(data);
                break;
            case 'sp':
                getSPOrderTable(data);
                break;
            case 'ukiuki':
                getUkiukiOrderTable(data);
                break;
            default:
                getTrialOrderTable(data);
                break;
        }
        slideListDisp(mode);
    });
}

function run_matrix(data,mode) {
    switch(mode){
        case 'otamesi':
            getTrialOrderMatrix(data);
            break;
        case 'sp':
            getSPOrderMatrix(data);
            break;
        case 'ukiuki':
            getUkiukiOrderMatrix(data);
            break;
        default:
            getTrialOrderMatrix(data);
            break;
    }
}

function Timeline(mode){
    switch(mode){
        case 'otamesi':
            var url = "http://"+domain+"/order_data/trial_order.js";
            break;
        case 'sp':
            var url = "http://" +domain+ "/order_data/sp_order.js";
            break;
        case 'ukiuki':
            var url = "http://" + domain + "/order_data/ukiuki_order.js";
            break;
        default:
            var url = "http://"+domain+"/order_data/trial_order.js";
            break;
    }
    $(document).ready(function() {
        var script = document.createElement('script');
        script.setAttribute('src', url);
        document.getElementsByTagName('head')[0].appendChild(script);
    });
}

function Matrix(mode){
    switch(mode){
        case 'otamesi':
            var url = "http://"+domain+"/order_data/trial_order_matrix.js";
            break;
        case 'sp':
            var url = "http://" +domain+ "/order_data/sp_order_matrix.js";
            break;
        case 'ukiuki':
            var url = "http://" + domain + "/order_data/ukiuki_order_matrix.js";
            break;
        default:
            var url = "http://"+domain+"/order_data/trial_order_matrix.js";
            break;
    }
    $(document).ready(function() {
        var script = document.createElement('script');
        script.setAttribute('src', url);
        document.getElementsByTagName('head')[0].appendChild(script);
    });
}

function getTrialOrderMatrix(order_data){
    $(document).ready(function(){
            var array_count = parseInt(order_data.length);
            orderTimeLine = '';
            orderTimeLine = '<table class="matrix">';
            orderTimeLine += '<tr><th>';
            orderTimeLine += '注文購入日';
            orderTimeLine += '</th><th>';
            orderTimeLine += '都道府県';
            orderTimeLine += '</th><th>';
            orderTimeLine += '購入した理由';
            orderTimeLine += '</th></tr>';

            for(i = 0;i < array_count;i++){
                orderTimeLine += '<tr><td>';
                orderTimeLine += order_data[i].create_date;
                orderTimeLine += '</td><td>';
                orderTimeLine += order_data[i].order_pref;
                orderTimeLine += '</td><td>';
                if(order_data[i].order_reason == null){
                    order_data[i].order_reason = '';
                    orderTimeLine += order_data[i].order_reason;
                }else{
                    orderTimeLine += order_data[i].order_reason;
                }
                orderTimeLine += '</td></tr>';

            }
            orderTimeLine += '</table>';
            $('#matrix').html(orderTimeLine);
            });
}

function getSPOrderMatrix(order_data){
    $(document).ready(function(){
            var array_count = parseInt(order_data.length);
            orderTimeLine = '';
            orderTimeLine = '<table class="matrix">';
            orderTimeLine += '<tr><th>';
            orderTimeLine += '注文購入日';
            orderTimeLine += '</th><th>';
            orderTimeLine += '都道府県';
            orderTimeLine += '</th><th>';
            orderTimeLine += '注文種別';
            orderTimeLine += '</th><th>';
            orderTimeLine += '購入した理由';
            orderTimeLine += '</th><th>';
            orderTimeLine += '商品名';
            orderTimeLine += '</th><th>';
            orderTimeLine += 'お届けの間隔';
            orderTimeLine += '</th></tr>';

            for(i = 0;i < array_count;i++){
                orderTimeLine += '<tr><td>';
                orderTimeLine += order_data[i].create_date;
                orderTimeLine += '</td><td>';
                orderTimeLine += order_data[i].order_pref;
                orderTimeLine += '</td><td>';
                
                if(order_data[i].order_type == 3){
                    orderTimeLine += '定期';
                }else{
                    orderTimeLine += '通常';
                }
                orderTimeLine += '</td><td>';
                
                
                if(order_data[i].order_reason == null){
                    order_data[i].order_reason = '';
                    orderTimeLine += order_data[i].order_reason;
                }else{
                    orderTimeLine += order_data[i].order_reason;
                }
                
                orderTimeLine += '</td><td>';
                for(j=0;j < order_data[i].product_name.length;j++){
                                    orderTimeLine += '<a href=http://' + domain +  '/products/detail.php?product_id='+ order_data[i].product_name[j].product_id +' >';
                                    orderTimeLine += order_data[i].product_name[j].product_name;
                                    orderTimeLine += '</a>';
                                    orderTimeLine += '<br>';
                                }
                
                orderTimeLine += '</td><td>';
                
                orderTimeLine += order_data[i].regular_cycle + 'カ月ごと';
                orderTimeLine += '</td></tr>';
               
            }
            orderTimeLine += '</table>';
            $('#matrix').html(orderTimeLine);
            });
}

function getUkiukiOrderMatrix(order_data){
    $(document).ready(function(){
            var array_count = parseInt(order_data.length);
            orderTimeLine = '';
            orderTimeLine = '<table class="matrix">';
            orderTimeLine += '<tr><th>';
            orderTimeLine += '注文購入日';
            orderTimeLine += '</th><th>';
            orderTimeLine += '都道府県';
            orderTimeLine += '</th><th>';
            orderTimeLine += '購入した理由';
            orderTimeLine += '</th><th>';
            orderTimeLine += '商品名';
            orderTimeLine += '</th><th>';
            orderTimeLine += 'お届けの間隔';
            orderTimeLine += '</th></tr>';

            for(i = 0;i < array_count;i++){
                orderTimeLine += '<tr"><td>';
                orderTimeLine += order_data[i].create_date;
                orderTimeLine += '</td><td>';
                orderTimeLine += order_data[i].order_pref;
                orderTimeLine += '</td><td>';
                
                if(order_data[i].order_reason == null){
                    order_data[i].order_reason = '';
                    orderTimeLine += order_data[i].order_reason;
                }else{
                    orderTimeLine += order_data[i].order_reason;
                }
                
                orderTimeLine += '</td><td>';
                for(j=0;j < order_data[i].product_name.length;j++){
                                    orderTimeLine += '<a href=http://' + domain +  '/products/detail.php?product_id='+ order_data[i].product_name[j].product_id +' >';
                                    orderTimeLine += order_data[i].product_name[j].product_name;
                                    orderTimeLine += '</a>';
                                    orderTimeLine += '<br>';
                                }
                orderTimeLine += '</td><td>';                
                if(order_data[i].order_type == 3){
                    orderTimeLine += order_data[i].regular_cycle + 'カ月ごと';
                    orderTimeLine += '</td></tr>';
                }else{
                    orderTimeLine += '</td></tr>';
                }               
            }
            orderTimeLine += '</table>';
            $('#matrix').html(orderTimeLine);
            });
}
