﻿
var s = new solution_center();
var i = parseInt(1);

preload_imgs();

$(document).ready(function() {

    $('#viewer').html(s.html(1));

    resize_pics();
    align_pics();

    $('#left img').add('#right img').click(function() {
        me = this;

        if ($(me).parent().get(0).id == 'left')
            i -= 1;

        if ($(me).parent().get(0).id == 'right')
            i += 1;

        if (i <= 1) i = 1;
        if (i >= 6) i = 6;

        var t = s.html(i);
        $('#viewer').html(t).fadeIn();

        resize_pics();
        align_pics();
    });


    $('#content_solnctr_thumb img').click(function() {
        me = this;

        var t = me.id;
        $('#viewer').html(s.html(t));
        i = s.index;

        resize_pics();
        align_pics();
    });

    $(window).resize(function() {
        resize_pics();
        align_pics();
    })

});


function align_pics() {
    var p = $('#viewer').position();
    var h = $('#viewer').height();
    var w = $('#viewer').width();
    var w1 = $('#left').width();
    var h1 = $('#left').height();

    $('#left').add('#right').css({ top: (p.top + ((h - h1) / 2)) + 'px' });
    $('#right').css({ left: (p.left + w) + 'px' });
    $('#left').css({ left: (p.left - w1) + 'px' });

}

function resize_pics() {
    $('#viewer img').each(function(i) {
        me = this;
        if ($(me).parent().get(0).id != "viewer")
            me = $(me).parent().get(0);

        if (s.index != 5) {
            var w = $(window).width();
            $(me).width(w * .5);
        }
    });
}


function solution_center() {
    this.index = 0;
    this.html = function(s) {

        var htm = "";

        if (s == 1) s = "mazak";
        if (s == 2) s = "mitsubishi";
        if (s == 3) s = "amada";
        if (s == 4) s = "mitutoyo";
        if (s == 5) s = "hanel";
        if (s == 6) s = "trainings";

        switch (s) {
            case "mazak":
                htm += '<h2> Mazak Solution Center </h2>';
                htm += '<img class="pic_svc" src="../central/image/support/solnctr/pic_solnctr_mazak.jpg">';
                htm += '<p>A fully air-conditioned area equipped with Vertical Machining Centers, CNC lathes and multi-tasking CNC lathes with a total area of 210 square meters.';
                this.index = 1;
                break;
            case "mitsubishi":
                htm += '<h2> Mitsubishi/Renishaw Solution Center </h2>';
                htm += '<img class="pic_svc" src="../central/image/support/solnctr/pic_solnctr_mitsubishi_renishaw.jpg">';
                htm += '<p>MESCO is equipped with a Renishaw Laser that is used in calibrating WEDMs. We are the only dealer of Mitsubishi in the whole Asian Region that has this type of equipment.';
                this.index = 2;
                break;
            case "amada":
                htm += '<h2> Amada Solution Center </h2>';
                htm += '<img class="pic_svc" src="../central/image/support/solnctr/pic_solnctr_amada.jpg">';
                htm += '<p>Our Amada Solutions Center comes equipped with two CNC Turret Punch Presses and one CNC Press Brake.';
                this.index = 3;
                break;
            case "mitutoyo":
                htm += '<h2> Mitutoyo Solution Center </h2>';
                htm += '<div><img class="pic_svc" src="../central/image/support/solnctr/pic_solnctr_mitutoyo2_wd200.jpg">';
                htm += '<img class="pic_svc" src="../central/image/support/solnctr/pic_solnctr_mitutoyo3_wd200.jpg">';
                htm += '<img class="pic_svc" src="../central/image/support/solnctr/pic_solnctr_mitutoyo1_wd200.jpg"></div>';
                htm += '<p>A fully air-conditioned area covering 100 square meters equipped with CMMs, Vision machines, Form machines and other major precision measuring instruments.</p>';
                this.index = 4;
                break;
            case "hanel":
                htm += '<h2> Hanel Automatic Storage System </h2>';
                htm += '<img class="pic_svc" src="../central/image/support/solnctr/pic_solnctr_hanel_storage.jpg"/>';
                htm += '<p>Towering six meters high, our Hanel Leanlift storage system allows us to increase our storage space by 400% by allowing us to store our inventory vertically! .</p>';
                htm += '<p>By using its elevator type retrieval system, the item goes to the user, eliminating the use of a ladder.</p>';
                this.index = 5;
                break;
            case "trainings":
                htm += '<h2> Training Services</h2>';
                htm += '<img class="pic_svc" src="../central/image/support/solnctr/pic_trngsvc.jpg">';
                htm += "<p>Aside from the regular operator's training on the machines that we sell, we also offer product trainings and seminars.";
                this.index = 6;
                break;
        }
        return htm;
    }

    function _html_by_index(i) { 
    
    }
    
}



function preload_imgs() {

    var img_list = new Array(
                '../central/image/support/solnctr/pic_solnctr_mazak.jpg',
                '../central/image/support/solnctr/pic_solnctr_mitsubishi_renishaw.jpg',
                '../central/image/support/solnctr/pic_solnctr_amada.jpg',
                '../central/image/support/solnctr/pic_solnctr_mitutoyo2_wd200.jpg',
                '../central/image/support/solnctr/pic_solnctr_mitutoyo3_wd200.jpg',
                '../central/image/support/solnctr/pic_solnctr_mitutoyo1_wd200.jpg',
                '../central/image/support/solnctr/pic_solnctr_hanel_storage.jpg',
                '../central/image/support/solnctr/pic_trngsvc.jpg'
        )

    for (var i = 0; i < img_list.length; i++) {
        var pre_img = document.createElement('img');
        pre_img.src = img_list[i];
        pre_img.style.width = 1;
        pre_img.style.display = 'none';
    }

}


