document.domain = "e-hentai.org";

function popUp(URL,w,h) {
	window.open(URL, "_new", "toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=0,width="+w+",height="+h+",left="+((screen.width-w)/2)+",top="+((screen.height-h)/2));
}

var old_scoll = 0;

function open_galleries(url, xres, yres) {
	old_scroll = get_scroll();
	
	document.getElementById("viewer_outer").style.display = "";
	document.getElementById("viewer_inner").innerHTML = '<iframe src="' + url + '" style="width:99%; height:100%; border:0px; padding:0; margin:auto" />';
	
	set_viewer_extents(xres, yres);
	reset_scroll();
}

function close_galleries() {
	document.getElementById("viewer_outer").style.display = "none";
	document.getElementById("viewer_inner").innerHTML = "";
	document.getElementById("maindiv").style.height = "";

	setTimeout(function() { window.scrollTo(0, old_scroll); }, 10);
}

function set_viewer_extents(xres, yres) {
	var minWidth = (Math.max(780, xres) + 42) + "px";
	var height = (yres + 145) + "px";

	document.getElementById("viewer_outer").style.minWidth = minWidth;
	document.getElementById("viewer_inner").style.minWidth = minWidth;
	document.getElementById("viewer_outer").style.height = height;
	document.getElementById("maindiv").style.height = height;
}

function reset_scroll() {
	window.scrollTo(0, 0);
}

function get_scroll() {
	return document.documentElement.scrollTop ? document.documentElement.scrollTop : document.body.scrollTop;
}

function set_scroll(ypos) {
	window.scrollTo(0, ypos);
}

var _gaq = _gaq || [];
_gaq.push(["_setAccount", "UA-775202-1"]);
_gaq.push(["_setDomainName",".e-hentai.org"]);
_gaq.push(["_trackPageview"]);

(function() {
	var ga=document.createElement("script");
	ga.src="http://www.google-analytics.com/ga.js";
	ga.setAttribute("async","true");
	document.documentElement.firstChild.appendChild(ga);
})();
