clusters = new Array();
loaded_images_id = new Array();


function Item(id, link_txt, desc, url, img) {
    this.id = id;
    this.link_txt = link_txt;
    this.desc = desc;
    this.url = url;
    this.img = img;
}

function Cluster(title, id_str, count) {
    this.title = title;
    this.id_str = id_str;
    this.count = count;
}


function showItems(id_str) {
    var all_id_bag = clusters[1].id_str.split(',');
    var all_id_bag_len = all_id_bag.length;
    var id_bag = id_str.split(',');
    var id_bag_len = id_bag.length;
    var d;

    for(var i = 0; i < all_id_bag_len; i++) {
        d = document.getElementById(all_id_bag[i]);
        if(d) {
            d.style.display = "none";
        }
    }

    for(var i = 0; i < id_bag_len; i++) {
        d = document.getElementById(id_bag[i]);
        if(d) {
            d.style.display = "";
            checkLoadImg(id_bag[i]);
        }
    }
}

function checkLoadImg(img_id) {
    if(document.images && !loaded_images_id[img_id]) {
        img_name = 'img_' + img_id;
        document.images[img_name].src = document.images[img_name].src;
    }
}

var prevClusterHighlight = null;

function clusterHighlight(clust_id, isMediaGroup) {
    document.getElementById(clust_id).style.background="#ddf";

    if(prevClusterHighlight) {
        document.getElementById(prevClusterHighlight).style.background="";
    }

    prevClusterHighlight = clust_id;

    if(arguments.length == 2 && isMediaGroup) {
        var d_val;

        d_val = document.getElementById('media_group').style.display;
        if(d_val == 'none') {
            document.getElementById('media_group').style.display = '';
        }else {
            document.getElementById('media_group').style.display = 'none';
        }
    }
}
