$(function(){
	$("a[href^='#']").click(function(event){
		event.preventDefault();
		var name;
		if (window.location.href.indexOf('#') > -1) {
			var name = window.location.href.substr(0,window.location.href.indexOf('#'));
		} else {
			var name = window.location.href;
		}
		window.location = name+$(this).attr('href');
		//var name = $(this).attr('href').substr(1);
		//window.scrollTo(100, $("a[name='"+name+"']").y());
		return false;
	});
});

$.fn.x = function(n) {
	var result = null;
	this.each(function() {
		var o = this;
		if (n === undefined) {
			var x = 0;
			if (o.offsetParent) {
				while (o.offsetParent) {
					x += o.offsetLeft;
					o = o.offsetParent;
				}
			}
			if (result === null) {
				result = x;
			} else {
				result = Math.min(result, x);
			}
		} else {
			o.style.left = n + 'px';
		}
	});
	return result;
};

$.fn.y = function(n) {
	var result = null;
	this.each(function() {
		var o = this;
		if (n === undefined) {
			var y = 0;
			if (o.offsetParent) {
				while (o.offsetParent) {
					y += o.offsetTop;
					o = o.offsetParent;
				}
			}
			if (result === null) {
				result = y;
			} else {
				result = Math.min(result, y);
			}
		} else {
			o.style.top = n + 'px';
		}
	});
	return result;
};