/*
Author: mg12
Update: 2009/06/24
Author URI: http://www.neoease.com/
*/
(function() {
function goTop(a, t) {
	a = a || 0.1;
	t = t || 16;
	var x1 = 0;
	var y1 = 0;
	var x2 = 0;
	var y2 = 0;
	var x3 = 0;
	var y3 = 0;
	if (document.documentElement) {
		x1 = document.documentElement.scrollLeft || 0;
		y1 = document.documentElement.scrollTop || 0;
	}
	if (document.body) {
		x2 = document.body.scrollLeft || 0;
		y2 = document.body.scrollTop || 0;
	}
	var x3 = window.scrollX || 0;
	var y3 = window.scrollY || 0;
	var x = Math.max(x1, Math.max(x2, x3));
	var y = Math.max(y1, Math.max(y2, y3));
	var speed = 1 + a;
	window.scrollTo(Math.floor(x / speed), Math.floor(y / speed));
	if(x > 0 || y > 0) {
		var f = "MGJS.goTop(" + a + ", " + t + ")";
		window.setTimeout(f, t);
	}
}
window['MGJS'] = {};
window['MGJS']['goTop'] = goTop;
/*wp-recentcomments*/
var xmlHttp;
function getXmlHttpObject() {
	var xmlHttp = null;
	try {
		xmlHttp = new XMLHttpRequest();
	} catch(e) {
		try {
			xmlHttp = new ActiveXObject("Msxml2.XMLHTTP");
		} catch(e) {
			xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
		}
	}
	return xmlHttp;
}
function page(wpurl, args, start, loading) {
	xmlHttp = getXmlHttpObject();
	if (xmlHttp == null) {
		alert ("Oop! Browser does not support HTTP Request.")
		return;
	}
	var url = wpurl;
	url += "?action=rc_ajax";
	url += "&args=" + args;
	url += "&start=" + start;

	xmlHttp.onreadystatechange = function(){runChange(loading)};
	xmlHttp.open("GET", url, true);
	xmlHttp.setRequestHeader("Content-type", "charset=UTF-8");
	xmlHttp.send(null);
}
function detail(id, wpurl, args, start, loading) {
	xmlHttp = getXmlHttpObject();
	if (xmlHttp == null) {
		alert ("Oop! Browser does not support HTTP Request.")
		return;
	}
	var url = wpurl;
	url += "?action=rc_detail_ajax";
	url += "&id=" + id;
	url += "&args=" + args;
	url += "&start=" + start;
	xmlHttp.onreadystatechange = function(){runChange(loading)};
	xmlHttp.open("GET", url, true);
	xmlHttp.setRequestHeader("Content-type", "charset=UTF-8");
	xmlHttp.send(null);
}
function runChange(loading) {
	var firstItem = document.getElementById('rc_item_1');
	var parent = firstItem.parentNode;
	var navigator = document.getElementById('rc_nav');
	if (xmlHttp.readyState < 4) {
		document.body.style.cursor = 'wait';
		if (navigator) {
			navigator.innerHTML = '<span class="rc_ajax_loader">' + ((loading == undefined) ? 'Loading...' : loading + '...') + '</span>';
		}
	} else if (xmlHttp.readyState == 4 || xmlHttp.readyState=="complete") {
		parent.innerHTML = xmlHttp.responseText;
		document.body.style.cursor = 'auto';
	}
}
window['RCJS'] = {};
window['RCJS']['page'] = page;
window['RCJS']['detail'] = detail;
})();
