function imgZoomIn(width, height) {
	imgURL = document.getElementById('original').value;
	browser = getBrowser();
	if(browser == "ie5" || browser == "ie6") {
		win = open("", "ImgWin", "width="+width+",height="+height+",resizable=no");
		win.document.write("<html><head><title>Image Zoom</title></head><body marginheight=0 marginwidth=0 topmargin=0 leftmargin=0>");
		win.document.write("<img src=\""+imgURL+"\" width=\""+width+"\" height=\""+height+"\">");
		win.document.write("</body></html>");
		win.document.close();
	}
	else {
		img = document.getElementById('original').value;
		var offset = 27;
		var zoom = document.getElementById("zoom");
		zoom.style.display = "block";
		var left = (getWidth()-width)/2;
		var top = (getHeight()-height)/2;
		var html = "<table border=\"0\" cellpadding=\"0\" cellspacing=\"0\" style=\"position:absolute; top:"+top+"px; left:"+left+"px; z-index:10\"><tr>";
		html += "<td style=\"background:url('images/zoom-shadow-top-left.png') no-repeat top left; width:"+offset+"px; height:"+offset+"px\"></td>";
		html += "<td style=\"background:url('images/zoom-shadow-top.png') repeat-x top left\"></td>";
		html += "<td style=\"background:url('images/zoom-shadow-top-right.png') no-repeat top left; width:"+offset+"px\"></td>";
		html += "</tr><tr>";
		html += "<td style=\"background:url('images/zoom-shadow-left.png') repeat-y top left\"></td>";
		html += "<td>";
		html += "<div style=\"width:"+width+"px; height:"+height+"px; background:url('"+img+"') no-repeat top left; cursor:pointer;\" title=\"Klicka för att stänga\">";
		html += "<img src=\"images/zoom-close.png\" style=\"margin-left:-13px; margin-top:-13px\"/>";
		html += "</div>";
		html += "</td>";
		html += "<td style=\"background:url('images/zoom-shadow-right.png') repeat-y top left\"></td>";
		html += "</tr><tr>";
		html += "<td style=\"background:url('images/zoom-shadow-bottom-left.png') no-repeat top left; width:"+offset+"px; height:"+offset+"px\"></td>";
		html += "<td style=\"background:url('images/zoom-shadow-bottom.png') repeat-x top left\"></td>";
		html += "<td style=\"background:url('images/zoom-shadow-bottom-right.png') no-repeat top left; width:"+offset+"px; height:"+offset+"px\"></td>";
		html += "</tr></table>";
		zoom.innerHTML = html;
	}
}
function imgZoomOut() {
	var zoom = document.getElementById("zoom");
	zoom.style.display = "none";
	zoom.innerHTML = "";
}

function getBounds() {
	var viewportwidth;
	var viewportheight;
 
	// the more standards compliant browsers (mozilla/netscape/opera/IE7) use window.innerWidth and window.innerHeight
	if (typeof window.innerWidth != 'undefined')
	{
		viewportwidth = window.innerWidth,
		viewportheight = window.innerHeight
	}
 
	// IE6 in standards compliant mode (i.e. with a valid doctype as the first line in the document)
	else if (typeof document.documentElement != 'undefined' && typeof document.documentElement.clientWidth != 'undefined' && document.documentElement.clientWidth != 0)
	{
		viewportwidth = document.documentElement.clientWidth,
		viewportheight = document.documentElement.clientHeight
	}
	
	// older versions of IE
	else
	{
		viewportwidth = document.getElementsByTagName('body')[0].clientWidth,
		viewportheight = document.getElementsByTagName('body')[0].clientHeight
	}
	
	bounds = Array();
	bounds[0] = viewportwidth;
	bounds[1] = viewportheight;
	return bounds;
}

function getWidth() {
	bounds = getBounds();
	return bounds[0];
}
function getHeight() {
	bounds = getBounds();
	return bounds[1];
}

function showImage(imgsrc, orgsrc) {
	document.getElementById('image').src = imgsrc;
	document.getElementById('original').value = orgsrc;
}

function getBrowser() {
	if(navigator.userAgent.toLowerCase().indexOf("msie 5") > 0)
		return "ie5";
	else if(navigator.userAgent.toLowerCase().indexOf("msie 6") > 0)
		return "ie6";
	else if(navigator.userAgent.toLowerCase().indexOf("msie 7") > 0)
		return "ie7";
	else if(navigator.userAgent.toLowerCase().indexOf("firefox/2") > 0)
		return "ff2";
	else
		return "";
}
