var loadBigImage = '<br><br><br><center><img src="img/loading.gif" /></center><br><br><br>';

function galeryCodeHTML(name, title, maxSize) {
    hs.close();
    $("GaleryDIV").innerHTML = loadBigImage;
    setTimeout('galeryCodeHTMLShow("' + name + '", "' + title + '", ' + maxSize + ');', 500);
}

function galeryCodeHTMLShow(name, title, maxSize) {
	var lSize = 12;
	if(maxSize) lSize = maxSize;
    var code = '<?xml version="1.0" encoding="UTF-8"?>\n';
    code += '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">\n';
    code += '<html xmlns="http://www.w3.org/1999/xhtml">\n';
    code += '<head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"></head>\n';
    code += '<body>\n';
    code += '<table border="0" cellpadding="10" cellspacing="0" align="center">\n';
    code += ' <tr>\n';
    code += ' <th colspan="6" align="center"><font size="6">' + title + '</font></th>\n';
    code += ' </tr>\n';
    code += ' <tr>\n';
    for (var i = 1; i <= lSize; i++) {
        var broj = '0' + i;
        if (i > 9) broj = i;
        code += '<td align="center"><a href="galerie/' + name + '/img/' + broj + '.jpg" class="highslide" onclick="return hs.expand(this)"><img name="' + broj + '" border="0" src="galerie/' + name + '/thumb/' + broj + '.jpg" onError="hideImage(this)"></a><br /></td>\n';
        if (i % 6 == 0) {
            code += ' </tr>\n';
            code += ' <tr>\n';
        }
    }
    code += ' </tr>\n';
    code += '</table>\n';
    code += '<div class="highslide-caption" id="the-caption">\n';
    code += '<a href="#" onclick="return hs.previous(this)" class="control" style="float:left; display: block"><b>Vorheriges Bild</b><br/><small style="font-weight: normal; text-transform: none"><b><</b></small></a>\n';
    code += '<a href="#" onclick="return hs.next(this)" class="control" style="float:left; display: block; text-align: right; margin-left: 50px"><b>Nächstes Bild</b><br/><small style="font-weight: normal; text-transform: none"><b>></b></small></a>\n';
    code += '<a href="#" onclick="return hs.close(this)" class="control" style="float:right; display: block; text-align: right; margin-left: 50px"><b>Schliessen</b><br/><small style="font-weight: normal; text-transform: none"><i>Esc Knopf</i></small></a>\n';
    code += '<div style="clear:both"></div>\n';
    code += '</div>\n';
    code += '</body>\n';
    code += '</html>\n';
    $("GaleryDIV").innerHTML = code;
}

function hideImage(img) {
    img.style.display = 'none';
}
