/* Copyright(C) Yumeya,inc 2009/1/8
 *    author: Tomokazu ISHII <office@yumeya.net>
 */

var imageTable_files    = new Array();
var imageTable_current  = '';
var imageTable_alpha    = 90;
var imageTable_files_large;
var imageTable_alts;
var imageTable_products;

function imageTable_init(files, files_large, alts) {
    imageTable_files       = files.split(';');
    imageTable_files_large = files_large.split(';');
    imageTable_alts        = alts.split(';');
    imageTable_current     = imageTable_files[0];
}

function imageTable_onClick(f, c) {
    if (f == imageTable_current) {
        return;
    }
    MM_swapImage('imageTable_large', '', f, 0);
    var n = 0;
    for (var i=0; i < imageTable_files.length; i++) {
        if (f != imageTable_files[i]) {
            var c_old = document.getElementById('imageTable_t' + i);
            if (c_old) {
                c_old.style.filter = 'Alpha(opacity=' + imageTable_alpha + ')';
                 c_old.style.border = 'solid 1px #ccc';
            }
        }
        else {
            n = i;
        }
    }
    c.style.filter     = '';
    c.style.border     = 'solid 1px #00f';
    imageTable_current = f;

    c_comment = document.getElementById('photoComment');
    c_comment.innerHTML = imageTable_alts[n];
}

function imageTable_onMouseOver(f, c) {
    imageTable_onClick(f, c);
    //if (f == imageTable_current) {
    //    return;
    //}
    //c.style.filter = '';
    //c.style.border = 'solid 1px #00f';
}

function imageTable_onMouseOut(f, c) {
    if (f == imageTable_current) {
        return;
    }
    c.style.filter = 'Alpha(opacity=' + imageTable_alpha + ')';
    c.style.border = 'solid 1px #ccc';
}

function imageTableL_onClick(c) {
    for (var i=0; i < imageTable_files.length; i++) {
        if (imageTable_files[i] == imageTable_current) {
            window.open(imageTable_files_large[i],
                        'popupWindow',
                        'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=yes,copyhistory=no,width=820,height=620,screenX=100,screenY=40,top=40,left=100');
            return;
        }
    }
}


function imageTable2_init(files, files_large, products_html) {
    imageTable_files       = files.split(';');
    imageTable_files_large = files_large.split(';');
    imageTable_current     = imageTable_files[0];
    imageTable_products    = products_html.split(';');
}

function imageTable2_onClick(f, c) {
    if (f == imageTable_current) {
        return;
    }
    var imgL    = document.getElementById('imageTable_large');
    var itembox = document.getElementById('imageTable_itembox');
    for (var i=0; i < imageTable_files.length; i++) {
	if (f == imageTable_files[i]) {
            imgL.style.backgroundImage = 'url(' + imageTable_files_large[i] + ')';
            itembox.innerHTML          = imageTable_products[i];
        }
	else {
            var c_old = document.getElementById('imageTable_t' + i);
            c_old.style.filter = 'Alpha(opacity=' + imageTable_alpha + ')';
            c_old.style.border = 'solid 1px #ccc';
        }
    }
    c.style.filter     = '';
    c.style.border     = 'solid 1px #00f';
    imageTable_current = f;
}

function imageTable2_onMouseOver(f, c) {
    imageTable2_onClick(f, c);
}

function imageTable2_onMouseOut(f, c) {
    if (f == imageTable_current) {
        return;
    }
    c.style.filter = 'Alpha(opacity=' + imageTable_alpha + ')';
    c.style.border = 'solid 1px #ccc';
}

function imageTable2L_onClick(c) {
    for (var i=0; i < imageTable_files.length; i++) {
        if (imageTable_files[i] == imageTable_current) {
            window.open(imageTable_files_large[i],
                        'popupWindow',
                        'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=yes,copyhistory=no,width=620,height=620,screenX=100,screenY=100,top=100,left=100');
            return;
        }
    }
}
