var weblog_touch_start_x = 0;
var weblog_touch_move_x = 0;
function weblogs_onLoad(){
	if(navigator.userAgent.indexOf('Mobile') > -1 && navigator.userAgent.indexOf('iPad') > -1){
		setTimeout("onloadScroll()",10);
		document.addEventListener("touchstart", weblog_multiTouch, false);
		document.addEventListener("touchend", weblog_multiTouch, false);
		document.addEventListener("touchmove", weblog_multiTouch, false);
	}
}
function weblog_multiTouch(event) {
	var d = window.document;
	switch (event.type) {
		case "touchstart":
			weblog_touch_start_x = event.touches[0].pageX;
			break;
		case "touchmove":
			weblog_touch_move_x = event.touches[0].pageX;
			break;
		case "touchend":
			var touch_move_lengh = weblog_touch_start_x - weblog_touch_move_x;
			if(touch_move_lengh > 100 && d.getElementById('weblog_prev_link')){
				location.href = d.getElementById('weblog_prev_link').href;
			}
			else if(touch_move_lengh < -100 && d.getElementById('weblog_next_link')){
				location.href = d.getElementById('weblog_next_link').href;
			}
			break;
	}
}
function touchstartHandler(event) {
	weblog_touch_x = event.touches[0].pageX;
	//alert(weblog_touch_x);
}
function touchendHandler(event) {
	var move_pos = weblog_touch_x - event.touches[0].pageX;
	alert(move_pos);
}
function onloadScroll(){
	window.scrollTo(0,10);
}
function addEventSet(elm,listener,fn){
	try{
		elm.addEventListener(listener,fn,false);
	}
	catch(e){
		elm.attachEvent("on"+listener,fn);
	}
}
addEventSet(window,"load",function(){weblogs_onLoad()});
