var highlight_request = false;
var TimeToReloadHighlight = 2000;
var slidespeed = 40; // Geschwindigkeit des Sliders
var pos = 0;
var pictureHeight = 97;
var slideid;
var items;
var copyspeed = 1;
var arVersion = navigator.appVersion.split("MSIE");
var version = parseFloat(arVersion[1]);


function myPicture (href, rel, title) {
	this.href = href;
    this.rel = rel;
    this.title = title;
}

function GetHighlight() {
highlight_request = false;

if (window.XMLHttpRequest) { // Mozilla, Safari,...
	highlight_request = new XMLHttpRequest();
	if (highlight_request.overrideMimeType) {
		highlight_request.overrideMimeType('text/xml');
	}
} else if (window.ActiveXObject) { // IE
	try {
		highlight_request = new ActiveXObject("Msxml2.XMLHTTP");
	} catch (e) {
		try {
		highlight_request = new ActiveXObject("Microsoft.XMLHTTP");
		} catch (e) {}
	}
}


	if (!highlight_request) {
		alert('Giving up :( Cannot create an XMLHTTP instance');
		return false;
	}
	highlight_request.onreadystatechange = ChangeHighlight;
	highlight_request.open('GET', './shop/php/highlight_dhtml.php', true);
	highlight_request.send(null);

}

function ChangeHighlight() {

	if (highlight_request.readyState == 4) {
		if (highlight_request.status == 200) {
			items = highlight_request.responseText.split('<||>');
			

			if ((version >= 5.5) && (version < 7) && (document.body.filters)) {
				var img = document.getElementById("highlightpicture2");
				var imgID = (img.id) ? "id='" + img.id + "' " : "";
				var imgClass = (img.className) ? "class='" + img.className + "' " : "";
				var imgTitle = (img.title) ? "title='" + img.title + "' " : "title='" + img.alt + "' ";
				var imgStyle = "display:inline-block;" + img.style.cssText ;
				if (img.align == "left") imgStyle = "float:left;" + imgStyle;
				if (img.align == "right") imgStyle = "float:right;" + imgStyle;
				if (img.parentElement.href) imgStyle = "cursor:hand;" + imgStyle;
				var strNewHTML = "<span " + imgID + imgClass + imgTitle
				+ " style=\"" + "width:" + img.width + "px; height:" + img.height + "px;" + imgStyle + ";"
				+ "filter:progid:DXImageTransform.Microsoft.AlphaImageLoader"
				+ "(src=\'" + items[0] + "\', sizingMethod='scale');\"></span>";
				img.outerHTML = strNewHTML;
			} else {
					if(document.getElementById)	{
						document.getElementById("highlightpicture2").src = items[0];
						document.getElementById("highlightpicture2").title = items[1];
						document.getElementById("highlightpicture2").alt = items[1];
						document.getElementById("link2").href = items[4];
					} else {
						highlightpicture2.src = items[0];
						highlightpicture2.title = items[1];
						highlightpicture2.alt = items[1];
						link2.href = items[4];
					}
			}
			setTimeout("slideid = setInterval(\"slide()\",slidespeed)", TimeToReloadHighlight);						
		}
	}
}

function slide() {
	pos -= copyspeed;
	if(document.getElementById)	{
		document.getElementById("pic1").style.top = pos + "px";
		document.getElementById("pic2").style.top = pos + "px";
	} else {
		if(document.all) pic1.style.top = pos + "px";
		if(document.all) pic2.style.top = pos + "px";
	}
	if(-pos == pictureHeight) {
		clearInterval(slideid);
		pos = 0;

			if ((version >= 5.5) && (version < 7) && (document.body.filters)) {
				var img = document.getElementById("highlightpicture2");
				var img2 = document.getElementById("highlightpicture");

				var imgID = (img2.id) ? "id='" + img2.id + "' " : "";
				var imgClass = (img2.className) ? "class='" + img2.className + "' " : "";
				var imgTitle = (img.title) ? "title='" + img.title + "' " : "title='" + img.alt + "' ";
				var imgStyle = "display:inline-block;" + img2.style.cssText ;
				if (img.align == "left") imgStyle = "float:left;" + imgStyle;
				if (img.align == "right") imgStyle = "float:right;" + imgStyle;
				if (img.parentElement.href) imgStyle = "cursor:hand;" + imgStyle;

				var strNewHTML = "<span " + imgID + imgClass + imgTitle
				+ " style=\"" + "width:" + img.width + "px; height:" + img.height + "px;" + imgStyle + ";"
				+ "filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src=\'" + items[0] + "\', sizingMethod='scale');\"></span>" ;
				img2.outerHTML = strNewHTML;

				document.getElementById("link1").href = document.getElementById("link2").href;
				document.getElementById("pic1").style.top = "0px";
				document.getElementById("pic2").style.top = "0px";
				document.getElementById("product").innerHTML = items[2];
				document.getElementById("product").href = items[4];
				document.getElementById("preis").innerHTML = items[3];
		} else {
			if(document.getElementById)	{
				document.getElementById("highlightpicture").src = document.getElementById("highlightpicture2").src;
				document.getElementById("highlightpicture").title = document.getElementById("highlightpicture2").title;
				document.getElementById("highlightpicture").alt = document.getElementById("highlightpicture2").alt;
				document.getElementById("link1").href = document.getElementById("link2").href;
				document.getElementById("pic1").style.top = "0px";
				document.getElementById("pic2").style.top = "0px";
				document.getElementById("product").innerHTML = items[2];
				document.getElementById("product").href = items[4];
				document.getElementById("preis").innerHTML = items[3];
			} else {
				if(document.all) highlightpicture.src = highlightpicture2.src;
				if(document.all) highlightpicture.title = highlightpicture2.title;
				if(document.all) highlightpicture.alt = highlightpicture2.alt;
				if(document.all) link1.href = link2.href;
				if(document.all) pic1.style.top = "0px";
				if(document.all) pic2.style.top = "0px";
				if(document.all) product.innerHTML = items[2];
				if(document.all) product.href = items[4];
				if(document.all) preis.innerHTML = items[3];
			}
		}
		GetHighlight();
	}
}

