pageInfo = {
        getResolutionWidth  : function() { return self.screen.width; },
        getResolutionHeight : function() { return self.screen.height; },
        getColorDepth       : function() { return self.screen.colorDepth; },

        getScrollLeft       : function() { var scrollLeft = 0; if (document.documentElement && document.documentElement.scrollLeft && document.documentElement.scrollLeft != 0) { scrollLeft = document.documentElement.scrollLeft; } if (document.body && document.body.scrollLeft && document.body.scrollLeft != 0) { scrollLeft = document.body.scrollLeft; } if (window.pageXOffset && window.pageXOffset != 0) { scrollLeft = window.pageXOffset; } return scrollLeft; },
        getScrollTop        : function() { var scrollTop = 0; if (document.documentElement && document.documentElement.scrollTop && document.documentElement.scrollTop != 0) { scrollTop = document.documentElement.scrollTop; } if (document.body && document.body.scrollTop && document.body.scrollTop != 0) { scrollTop = document.body.scrollTop; } if (window.pageYOffset && window.pageYOffset != 0) { scrollTop = window.pageYOffset; } return scrollTop; },

        getDocumentWidth    : function() { var documentWidth = 0; var w1 = document.body.scrollWidth; var w2 = document.body.offsetWidth; if (w1 > w2) { documentWidth = document.body.scrollWidth; } else { documentWidth = document.body.offsetWidth; } return documentWidth; },
        getDocumentHeight   : function() { var documentHeight = 0; var h1 = document.body.scrollHeight; var h2 = document.body.offsetHeight; if (h1 > h2) { documentHeight = document.body.scrollHeight; } else { documentHeight = document.body.offsetHeight; } return documentHeight; },
        getVisibleWidth     : function() { var visibleWidth = 0; if (self.innerWidth) { visibleWidth = self.innerWidth; } else if (document.documentElement && document.documentElement.clientWidth) { visibleWidth = document.documentElement.clientWidth; } else if (document.body) { visibleWidth = document.body.clientWidth; } return visibleWidth; },
        getVisibleHeight    : function() { var visibleHeight = 0; if (self.innerHeight) { visibleHeight = self.innerHeight; } else if (document.documentElement && document.documentElement.clientHeight) { visibleHeight = document.documentElement.clientHeight; } else if (document.body) { visibleHeight = document.body.clientHeight; } return visibleHeight; },

        getElementLeft      : function(element) { var element = (typeof element == "string") ? document.getElementById(element) : element; var left = element.offsetLeft; var oParent = element.offsetParent; while (oParent != null) { left += oParent.offsetLeft; oParent = oParent.offsetParent; } return left; },
        getElementTop       : function(element) { var element = (typeof element == "string") ? document.getElementById(element) : element; var top = element.offsetTop; var oParent = element.offsetParent; while (oParent != null) { top += oParent.offsetTop; oParent = oParent.offsetParent; } return top; },
        getElementWidth     : function(element) { var element = (typeof element == "string") ? document.getElementById(element) : element; return element.offsetWidth; },
        getElementHeight    : function(element) { var element = (typeof element == "string") ? document.getElementById(element) : element; return element.offsetHeight; },

        getMouseX           : function() { return PageInfo.mouseX; },
        getMouseY           : function() { return PageInfo.mouseY; },


        // HELPER CODE FOR TRACKING MOUSE POSITION
        mouseX: 0,
        mouseY: 0,
        onMouseMove: function(e) { e = (!e) ? window.event : e; PageInfo.mouseX = e.clientX + PageInfo.getScrollLeft(); PageInfo.mouseY = e.clientY + PageInfo.getScrollTop(); }
};


function runden(px) {
  var k = (Math.round(px * 100) / 100).toString();
  k += (k.indexOf('.') == -1)? '.00' : '00';
  return k.substring(0, k.indexOf('.') );
}

function closeAlertBox() {
	var body = document.getElementsByTagName("body")[0];
	body.removeChild(body.lastChild);
	body.removeChild(body.lastChild);
	}

function alertBox(value) {

	var http = null;
	var http = (window.XMLHttpRequest) ? new XMLHttpRequest() : new ActiveXObject("Microsoft.XMLHTTP");	

	if (http != null) {
		http.open("POST", "/aksellib/ajax/boxlib.ajax.include.php", true);
		http.onreadystatechange = ausgeben;
		http.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
		http.send('id=' + value);
		}

	function ausgeben() {
		if (http.readyState == 4) {
			var json = eval("(" + http.responseText + ")");
			var div = document.createElement("div");
			var div0 = document.createElement("div");
			var div1txt = document.createTextNode(json.head);
			var div1 = document.createElement("div");
			var div2 = document.createElement("div");
			var div3txt = document.createTextNode(json.content);
			var div3 = document.createElement("div");
			var backimg = document.createElement('img');
			var backa = document.createElement('a');
			var backatxt = document.createElement('a');
			var backatxtTxt = document.createTextNode('Zurück');
			var br = document.createElement('br');

			div.className = "alertBoxOverlay";
			div.setAttribute("id", "alertBoxOverlay");
			//div0.setAttribute("class", "alertBox");
			div0.className = 'alertBox';
			div0.setAttribute("id", "alertBox");
			div1.className = "aB1";
			div2.className = "aB2";
			div3.className = "aB3";
			div1.setAttribute("id", "aB1");
			div2.setAttribute("id", "aB2");
			div3.setAttribute("id", "aB3");

			backa.setAttribute("href","javascript: closeAlertBox()");
			backa.setAttribute("color","white");
			backatxt.setAttribute("color","white");
			backatxt.setAttribute("href","javascript: closeAlertBox()");


			backimg.setAttribute("src", "/aksellib/images/back.gif");
			backimg.setAttribute("height", "17px");
			backimg.setAttribute("width", "17px");


			div0.appendChild(div1);

			div1.appendChild(div1txt);
			div0.appendChild(div2);
			backa.appendChild(backimg);
			div2.appendChild(backa);
			div0.appendChild(div3);

			div3.appendChild(div3txt);
			div3.appendChild(br);
			backatxt.appendChild(backatxtTxt);
			div3.appendChild(backatxt);
	
			var body = document.getElementsByTagName("body")[0];

			body.appendChild(div);

//			body.appendChild(div0);

			alphaBackground("alertBoxOverlay","alertBox");
			} 

		}

	}

function alphaBackground(varBack,varBox) {

	var bgObj = document.getElementById(varBack);
	var abObj = document.getElementById(varBox);
	var rslt = navigator.appVersion.match(/MSIE (\d+\.\d+)/, '');
	var itsIE55to6 = (rslt != null && (Number(rslt[1]) >= 5.5 && Number(rslt[1] < 7)));
	var itsIE7 = (rslt != null && Number(rslt[1]) == 7);
	if (itsIE55to6) {

//		pageHeight = ((parseInt(document.body.offsetHeight)/2)-120) + parseInt(document.body.scrollTop)) + 'px';

		var abMargin = (parseInt(document.documentElement.scrollTop) + (parseInt(document.documentElement.offsetHeight)/2) - 45 ) + "px";
		pageHeight = parseInt(document.documentElement.scrollTop) + parseInt(document.documentElement.offsetHeight);
		pageWidth = document.documentElement.offsetWidth;

	   bgObj.style.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='aksellib/images/45grey.png', sizingMethod='scale')";
	   bgObj.style.width = parseInt(pageWidth) + 'px';
   	bgObj.style.height = parseInt(pageHeight) + 'px';
   	bgObj.style.position = 'absolute';

		abObj.style.marginTop = abMargin;

		abObj.style.width = '268px';
		abObj.style.height = '90px';
		abObj.style.padding = '1px';
		abObj.style.left = (parseInt(pageWidth)/ 2) + 'px';
		abObj.style.marginLeft = '-130px';
		abObj.style.marginBottom = '-25px';
		abObj.style.position = 'absolute';

		}
	else if (itsIE7) {
		bgObj.style.backgroundImage = "url('/aksellib/images/45grey.png')";
		bgObj.style.height = '100%';
		bgObj.style.width = '100%';
		bgObj.style.position = 'fixed';
		bgObj.style.visibility = 'visible';

		abObj.style.width = '268px';
		abObj.style.height = '90px';
		abObj.style.padding = '1px';
		abObj.style.top = '50%';
		abObj.style.left = '50%';
		abObj.style.margin = '0px 0px -25px -130px';
		abObj.style.position = 'fixed';
		}
	else {
		bgObj.style.backgroundColor = 'black';
		bgObj.style.opacity = '0.45';
		bgObj.style.height = '100%';
		bgObj.style.width = '100%';
		bgObj.style.position = 'fixed';
		bgObj.style.visibility = 'visible';

		abObj.style.width = '268px';
		abObj.style.height = '90px';
		abObj.style.padding = '1px';
		abObj.style.top = '50%';
		abObj.style.left = '50%';
		abObj.style.margin = '0px 0px -25px -130px';
		abObj.style.position = 'fixed';
		}

	}


function alertBox(value) {

	var http = null;
	var http = (window.XMLHttpRequest) ? new XMLHttpRequest() : new ActiveXObject("Microsoft.XMLHTTP");	

	if (http != null) {
		http.open("POST", "/aksellib/ajax/boxlib.ajax.include.php", true);
		http.onreadystatechange = ausgeben;
		http.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
		http.send('id=' + value);
		}

	function ausgeben() {
		if (http.readyState == 4) {
			var json = eval("(" + http.responseText + ")");
			var div = document.createElement("div");
			var div0 = document.createElement("div");
			var div1txt = document.createTextNode(json.head);
			var div1 = document.createElement("div");
			var div2 = document.createElement("div");
			var div3txt = document.createTextNode(json.content);
			var div3 = document.createElement("div");
			var backimg = document.createElement('img');
			var backa = document.createElement('a');
			var backatxt = document.createElement('a');
			var backatxtTxt = document.createTextNode('Zurück');
			var br = document.createElement('br');

			div.className = "alertBoxOverlay";
			div.setAttribute("id", "alertBoxOverlay");
			//div0.setAttribute("class", "alertBox");
			div0.className = 'alertBox';
			div0.setAttribute("id", "alertBox");
			div1.className = "aB1";
			div2.className = "aB2";
			div3.className = "aB3";
			div1.setAttribute("id", "aB1");
			div2.setAttribute("id", "aB2");
			div3.setAttribute("id", "aB3");

			backa.setAttribute("href","javascript: closeAlertBox()");
			backa.setAttribute("color","white");
			backatxt.setAttribute("color","white");
			backatxt.setAttribute("href","javascript: closeAlertBox()");


			backimg.setAttribute("src", "/aksellib/images/back.gif");
			backimg.setAttribute("height", "17px");
			backimg.setAttribute("width", "17px");


			div0.appendChild(div1);

			div1.appendChild(div1txt);
			div0.appendChild(div2);
			backa.appendChild(backimg);
			div2.appendChild(backa);
			div0.appendChild(div3);

			div3.appendChild(div3txt);
			div3.appendChild(br);
			backatxt.appendChild(backatxtTxt);
			div3.appendChild(backatxt);
	
			var body = document.getElementsByTagName("body")[0];

			body.appendChild(div);

			body.appendChild(div0);

			alphaBackground('alertBoxOverlay','alertBox');
			} 

		}

	}

function closeOnlineReader() {
	var body = document.getElementsByTagName("body")[0];
	body.removeChild(body.lastChild);
	body.removeChild(body.lastChild);
	}

function setPage(action, prodId) {
	var Obj = document.getElementById('readsheet');
	var imgNo = document.getElementById('imgNo').value;
	if ( action == 'prev') {
		if (imgNo == 1) {
			Obj.src = '/catalog/images/readsheets/' + prodId + '_4.gif';
			document.getElementById('imgNo').value = 4;
			}
		else {
			Obj.src = '/catalog/images/readsheets/' + prodId + '_' + (parseInt(imgNo) - 1) + '.gif';
			document.getElementById('imgNo').value = (parseInt(imgNo) - 1);
			}
		}

	if ( action == 'next' ) {
		if (imgNo == 4) {
			Obj.src = '/catalog/images/readsheets/' + prodId + '_1.gif';
			document.getElementById('imgNo').value = 1;
			}
		else {
			Obj.src = '/catalog/images/readsheets/' + prodId + '_' + (parseInt(imgNo) + 1) + '.gif';
			document.getElementById('imgNo').value = (parseInt(imgNo) + 1);
			}
		}
	}
	
function onlineReader(value) {

			var bgObj = document.createElement("div");
			var div0 = document.createElement("div");
			var div1 = document.createElement("div");
			var pfeil_links = document.createElement('img');
			var pfeil_rechts = document.createElement('img');
			var pfeil_links_div = document.createElement('div');
			var pfeil_rechts_div = document.createElement('div');
			var readsheetDiv = document.createElement('div');
			var readsheet = document.createElement('img');
			var back = document.createElement('a');
			var backimg = document.createElement('img');
			var next = document.createElement('a');
			var prev = document.createElement('a');
			var imgNo = document.createElement('input');
			var readerHeaderP = document.createElement('p');
			var readerHeader = document.createTextNode(document.getElementById('onlineReaderHeadingTxt').value + " - Leseprobe");


			readsheetDiv.className = "readSheetDiv";
			readsheetDiv.setAttribute("id", "readSheetDiv");		
			readsheetDiv.style.height = (parseInt(pageInfo.getVisibleHeight())-62) + 'px';
			readsheetDiv.style.width = (parseInt(document.getElementById("readSheetWidth").value)+30) + 'px';

			bgObj.className = "onlineReader_bg";
			bgObj.setAttribute("id", "onlineReader_bg");
			bgObj.style.height = pageInfo.getDocumentHeight()*2;
			bgObj.style.width = pageInfo.getDocumentWidth();
			bgObj.style.marginTop = '-' + pageInfo.getDocumentHeight();
			bgObj.style.paddingTop = '0';

			div1.className = "onlineReader_leiste"
			div0.className = "onlineReader";
			div0.setAttribute("id", "onlineReader");
			div0.style.width = (parseInt(document.getElementById("readSheetWidth").value)+165) + 'px';
			div0.style.height = (parseInt(pageInfo.getVisibleHeight())-40) + 'px';

			imgNo.setAttribute("type","hidden");
			imgNo.setAttribute("value","1");
			imgNo.setAttribute("id","imgNo");
			back.setAttribute("class","backImg");
			readerHeaderP.setAttribute("class","readerHeaderP");

			pfeil_links_div.className = 'pfeil_links_div';
			pfeil_rechts_div.className = 'pfeil_rechts_div';
			pfeil_links_div.style.paddingTop = runden((parseInt(pageInfo.getVisibleHeight())-83)/2) + 'px';
			pfeil_rechts_div.style.paddingTop = runden((parseInt(pageInfo.getVisibleHeight())-83)/2) + 'px';
			pfeil_links.setAttribute("src", "/aksellib/images/pfeil_links.gif");
			pfeil_rechts.setAttribute("src", "/aksellib/images/pfeil_rechts.gif");
			pfeil_links.className = 'pfeil_links';
			pfeil_rechts.className = 'pfeil_rechts';
			readsheet.setAttribute("src", "/catalog/images/readsheets/" + value + "_1.gif");
			readsheet.setAttribute("id", "readsheet");

			back.setAttribute("href","javascript: closeOnlineReader()");
			prev.setAttribute("href","javascript: setPage(\"prev\", " + value + ")");
			next.setAttribute("href","javascript: setPage(\"next\", " + value + ")");

			backimg.setAttribute("src", "/aksellib/images/back_invert.gif");


			back.appendChild(backimg);
			prev.appendChild(pfeil_links);
			next.appendChild(pfeil_rechts);			

			pfeil_rechts_div.appendChild(next);
			pfeil_links_div.appendChild(prev);
			readsheetDiv.appendChild(readsheet);			
			div0.appendChild(div1);			
			div0.appendChild(pfeil_links_div);
			div0.appendChild(readsheetDiv);
			div0.appendChild(pfeil_rechts_div);
			readerHeaderP.appendChild(readerHeader);
			div1.appendChild(readerHeaderP);
			div1.appendChild(back);

			var body = document.getElementsByTagName("body")[0];


			bgObj.appendChild(imgNo);
			body.appendChild(bgObj);

			body.appendChild(div0);
//			body.appendChild(imgNo);
			//alert(pageInfo.getVisibleHeight());
			alphaBackground2('onlineReader_bg','onlineReader');

			} 
function alphaBackground2(varBack,varBox) {

	var bgObj = document.getElementById(varBack);
	var abObj = document.getElementById(varBox);
	var rslt = navigator.appVersion.match(/MSIE (\d+\.\d+)/, '');
	var itsIE55to6 = (rslt != null && (Number(rslt[1]) >= 5.5 && Number(rslt[1] < 7)));
	var itsIE7 = (rslt != null && Number(rslt[1]) == 7);
	if (itsIE55to6) {

	   bgObj.style.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='aksellib/images/45grey.png', sizingMethod='scale')";

		}
	else if (itsIE7) {
		bgObj.style.backgroundImage = "url('/aksellib/images/45grey.png')";
		bgObj.style.position = 'fixed';
		bgObj.style.visibility = 'visible';


		}
	else {
		bgObj.style.backgroundColor = 'black';
		bgObj.style.opacity = '0.45';
		bgObj.style.visibility = 'visible';
		}

		abObj.style.top = '20px';
		abObj.style.left = '50%';
		abObj.style.margin = '0px 0px 0px -' + runden((parseInt(document.getElementById("readSheetWidth").value) / 2) + 50) + 'px';
		abObj.style.position = 'fixed';



	}

