function mvAddImageFields()
{
    var Div = document.getElementById('mv-additional-images')
    var Box = document.createElement('input');
    Box.type = 'file';
    Box.name = 'uploadfile_add[]';
    Div.appendChild(document.createElement('br'));
    Div.appendChild(document.createElement('br'));
    Div.appendChild(Box);

}



function popUpUrl(pageURL, title,w,h) {
    var left = (screen.width/2)-(w/2);
    var top = (screen.height/2)-(h/2);
    var targetWin = window.open (pageURL, title, 'toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=no, resizable=yes, copyhistory=no, width='+w+', height='+h+', top='+top+', left='+left);
}


function popImage(pageURL, title,w,h) {
    var left = (screen.width/2)-(w/2);
    var top = (screen.height/2)-(h/2);
    var targetWin = window.open (pageURL, title, 'toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=no, resizable=yes, copyhistory=no, width='+w+', height='+h+', top='+top+', left='+left);
}

// these first two functions are using fixed parameters for the names
// and number of columns, these can be used for a layout where


function sortNumeric(a,b)
{
    return a - b
}

function getLongest(cl) {
    // parentDiv = document.getElementById("container");
    //cols = parentDiv.getElementsByTagName("div");
    cols = getElementsByClassName('\\b'+cl+'\\b');
    colLength = new Array(cols.length);
    for (x=0; x < cols.length; x++) {
        colLength[x] = document.getElementById(cols[x].id).offsetHeight;
    }
    colLength.sort(sortNumeric);
    colLength.reverse();
    return colLength[0];
}
function setColumns(cl) {
    divLen = getLongest(cl);
    // parentDiv = document.getElementById("container");
    cols = getElementsByClassName('\\b'+cl+'\\b');
    //cols = parentDiv.getElementsByTagName("div");
    for (x=0; x < cols.length; x++) {
        document.getElementById(cols[x].id).style.height = divLen+"px";
    }
}



function getElementsByClassName(cl) {
    var retnode = [];
    var myclass = new RegExp('\\b'+cl+'\\b');
    var elem = document.getElementsByTagName("*");
    for (var i = 0; i < elem.length; i++) {
        var classes = elem[i].className;
        if (myclass.test(classes)) retnode.push(elem[i]);
    }
    // alert(retnode.offsetHeight);
    return retnode;
}



window.onload = function()
{
    setColumns("mv-item-body");
}
