var item = 0;
var sImages = "";
var move = false;
var iid = 0;
var http = createRequestObject();
var links = "";

function createRequestObject() {
    var ro;
    var browser = navigator.appName;
    if(browser == "Microsoft Internet Explorer"){
        ro = new ActiveXObject("Microsoft.XMLHTTP");
    }else{
        ro = new XMLHttpRequest();
    }
    return ro;
}


function handleResponse() {

    if(http.readyState == 4) {
        var response = http.responseText;
        if(response != "0x1") {
            var images = response.split("|");
            var backHTML = "";
            var moreHTML = "";
            for (i=0; i < 2; i++) {
				if(images[i]){
					if(i == 0){
					    if(images[i].split(",")[2] < 0) {
                	    	backHTML += '<div style="position:relative;clear:left;height:50px;width:360px;background:#f5f5f5;padding:10px;"><div style="height:50px;width:70px;background:url(img/bg4.gif);overflow:hidden;float:left;"><img src="images/blank.gif" alt="" /></div><div style="float:left;width:280px;color:#a0a0a0;height:47px;padding:3px 0 0 0">&nbsp;&nbsp;Sie sind am Anfang der Bildergalerie!</div></div>';
					    } else {
                	        backHTML += '<div onmouseover="this.style.background=\'#ffffff\'" onmouseout="this.style.background=\'#f0f0f0\'" style="position:relative;clear:left;height:50px;width:360px;background:#f0f0f0;padding:10px;"><div style="height:50px;width:70px;background:url(img/bg3.gif);overflow:hidden;float:left;cursor:pointer;"><img id="img2" src="' + images[i].split(",")[0] + '" onClick="changeBig(this,' + images[i].split(",")[2] + ',\'' + images[i].split(",")[3] + '\');" alt="' + images[i].split(",")[1] + '" title="' + images[i].split(",")[1] + '" /></div><div style="cursor:pointer;float:left;width:280px;height:47px;padding:3px 0 0 0" onClick="changeBig(img2,' + images[i].split(",")[2] + ',\'' + images[i].split(",")[3] + '\');">&nbsp;&nbsp;zur&uuml;ck zum vorheriges Bild</div></div>';
            		    }
				    } else {
				    	if(images[i].split(",")[2] < 0) {
					         moreHTML += '<div style="position:relative;clear:left;height:50px;width:360px;background:#f5f5f5;padding:10px;margin-bottom:1px;"><div style="height:50px;width:70px;background:url(img/bg4.gif);overflow:hidden;float:left;"><img src="images/blank.gif" alt="" /></div><div style="float:left;width:280px;color:#a0a0a0;height:47px;padding:3px 0 0 0">&nbsp;&nbsp;Sie sind beim letzten Bild angelangt!</div></div>';
					    } else {
                	        moreHTML += '<div onmouseover="this.style.background=\'#ffffff\'" onmouseout="this.style.background=\'#e0e0e0\'" style="position:relative;clear:left;height:50px;width:360px;background:#e0e0e0;padding:10px;margin-bottom:1px;"><div style="height:50px;width:70px;background:url(img/bg4.gif);overflow:hidden;float:left;cursor:pointer;"><img id="img1" src="' + images[i].split(",")[0] + '" onClick="changeBig(this,' + images[i].split(",")[2] + ',\'' + images[i].split(",")[3] + '\');" alt="' + images[i].split(",")[1] + '" title="' + images[i].split(",")[1] + '" /></div><div style="cursor:pointer;float:left;width:280px;height:47px;padding:3px 0 0 0" onClick="changeBig(img1,' + images[i].split(",")[2] + ',\'' + images[i].split(",")[3] + '\');">&nbsp;&nbsp;weiter zum n&auml;chstes Bild</div></div>';
            		    }
				    } 
				}
			}
            sImages.innerHTML = moreHTML + backHTML;
        }

    }
}

function imgS(item) {

sImages = document.getElementById("imgSList");
    if(sImages) {
    http.open("get","rpc.aspx"+window.location.search+"&sItem="+item+"&sType=1");
    http.onreadystatechange = handleResponse;
    http.send(null);
    }
}
 
function changeBig (img,item,highRes) {
    var coitem = item + 1;
    document.getElementById('imgBig').src = img.src.replace("vorschau","normal");
    imgS(item);
    document.getElementById('imgBig').alt = img.alt;
    document.getElementById('imgBig').title = img.alt;
    document.getElementById('imgDesc').innerHTML = img.alt;
    document.getElementById('thisIMG').innerHTML = coitem;
    document.getElementById("HighRes").href = highRes;
}

function openHighRes()
{


}