	function OpenLargeWindow(imageid, x, y, s) {
	    var maxwidth = 5000;
		var maxheight = 4000;

	 	if ((x > maxwidth) && (y > maxheight)) {
	    	y = y + 50;
			x = x + 18;
			var xsizepercent = maxwidth / x;
			var ysizepercent = maxheight / y;
			if (xsizepercent > ysizepercent) {
				x = x * xsizepercent;
				y = y * xsizepercent;
				window.open("/articles/enlarge_image.html?siteId=" + s + "&id=" + imageid,imageid,"width=" + x + ",height=" + y + ",siteid=" + siteid + ",resizable=no,status=no,scrollbars=yes,titlebar=0");
			}
			else {
				x = x * ysizepercent;
				y = y * ysizepercent;
				window.open("/articles/enlarge_image.html?siteId=" + s + "&id=" + imageid,imageid,"width=" + x + ",height=" + y + ",resizable=no,status=no,scrollbars=yes,titlebar=0");
			}
		}
		else if (x > maxwidth) {
			y = y + 50;
			x = x + 18;
			sizepercent = maxwidth / x;
			x = x * sizepercent;
			y = y * sizepercent;
	       	window.open("/articles/enlarge_image.html?siteId=" + s + "&id=" + imageid,imageid,"width=" + x + ",height=" + y + ",resizable=no,status=no,scrollbars=yes,titlebar=0");
	    }
		else if (y > maxheight) {
			y = y + 50;
			x = x + 18;
			sizepercent = maxheight / y;
			x = x * sizepercent;
			y = y * sizepercent;
	        window.open("/articles/enlarge_image.html?siteId=" + s + "&id=" + imageid,imageid,"width=" + x + ",height=" + y + ",resizable=no,status=no,scrollbars=yes,titlebar=0");
	    }
		else {
			y = y + 50;
			x = x + 18;
	 		window.open("/articles/enlarge_image.html?siteId=" + s + "&id=" + imageid,imageid,"width=" + x + ",height=" + y + ",resizable=no,scrollbars=yes,titlebar=no");
	    }
	}

	function changeSize(size) {
		$("paragraphs").setStyle({ fontSize : size + "px" });
	}
    function decreaseFontSize(){
      var fullSize = $("paragraphs").getStyle("font-size");
      var endNum = fullSize.indexOf("p");
      var size = (fullSize.substring(0,endNum))*1;
      size -= 1;
      if(size >= 8){
          $("paragraphs").setStyle({ fontSize : size + "px" });  
      }
    }
    function increaseFontSize(){
      var fullSize = $("paragraphs").getStyle("font-size");
      var endNum = fullSize.indexOf("p");
      var size = (fullSize.substring(0,endNum))*1;
      size += 1;
      if(size <= 50){
          $("paragraphs").setStyle({ fontSize : size + "px" });
      }

    }
    function showPage(pageNumber) {
		var pages = $("paragraphs").getElementsBySelector(".page");
		var anchors = $("pageNumbers").getElementsBySelector("a");
		for (var i = 0; i < pages.length; i++) {
			var page = $(pages[i]);
			var anchor = $(anchors[i]);
			if (page.id == "page" + pageNumber) {
				page.setStyle({ display : "block" });
				anchor.setStyle({ fontWeight : "bold" });
			} else {
				page.hide();
				anchor.setStyle({ fontWeight : "normal" });
			}
		}
	}