$(document).ready(function(){



jQuery.get(
    'startimg.php',
    function(xml) {
        jQuery('image', xml).each(function(i, domEle) {
                addimage(i, jQuery(domEle).text())
        });
    },
    'xml'
    );
});

//function addimage(i, url)
//{
//    var s = getItemHTML(url,i);
//    $("#imagegallery ul").append(s);
//    //console.log(s);
//    $("#image" + i + " img").load(resize(i))
//
//
//}

function addimage(i, url)
{
    var s = getItemHTML(url,i);
    $("#imagegallery ul").append(s);
    //console.log(s);
    $("#image" + i + " img").load(resize(i))

}
function getItemHTML(url, i)
{
    return '<li id="image'+ i + '"><img src="' + url + '" alt="' + i + '" style="display:none" /></li>';
}

function resize(i)
{
    var image = $("#image" + i + " img");

    //console.log("w: " + $(image).width() + ", h: " + $(image).height());

    //if ($(image).width() >= $(image).height()) { //landscape
        $(image).css({
			width: 187
//            maxWidth: 200,
//            maxHeight: 200
//                marginLeft: 0,
//                marginTop: 32
        });
    //}
//        else { //portrait
//            $(image).css({
//                width: 'auto',
//                height: 300,
//                marginLeft: 32,
//                marginTop: 0
//            });
//        }

    $(image).show(200);
}
