﻿// JavaScript Document
var cx = 0 , cy = 0;
function locate() {
	cx = event.x?event.x:event.pageX;
	cy = event.y?event.y:event.pageY;
	if ( typeof(cx) == "undefined" ) {
		cx = 0;
	}
	if ( typeof(cy) == "undefined" ) {
		cy = 0;
	}
	if ( $.browser.msie ) {
		if ( $.browser.version != "8.0" ) {
			cx += document.documentElement.scrollLeft;
			cy += document.documentElement.scrollTop;
		}
	}
	else if ( $.browser.safari ) {
		cx += document.body.scrollLeft;
		cy += document.body.scrollTop;
	}
}

/*firefox重写event*/
function __firefox() {
	HTMLElement.prototype.__defineGetter__("runtimeStyle", __element_style);
	window.constructor.prototype.__defineGetter__("event", __window_event);
	Event.prototype.__defineGetter__("srcElement", __event_srcElement);
}
function __element_style() {
	return this.style;
}
function __window_event() {
	return __window_event_constructor();
}
function __event_srcElement() {
	return this.target;
}
function __window_event_constructor() {
	if ( document.all ) {
		return window.event;
	}
	var _caller = __window_event_constructor.caller;
	while ( _caller != null ) {
		var _argument = _caller.arguments[0];
		if ( _argument ) {
			var _temp = _argument.constructor;
			if( _temp.toString().indexOf("Event") != -1 ) {
				return _argument;
			}
		}
		_caller = _caller.caller;
	}
	return null;
}
if ( window.addEventListener ) {
	__firefox();
}
/*end firefox*/

var scrollgoing , scrolltop , scrollstep;
function scrollgoto(top,step) {
	clearInterval(scrollgoing);
	scrolltop = top;
	scrollstep = step;
	scrollgoing = setInterval(scrollgoto1,50);
}
function scrollgoto1() {
	if ( document.body.scrollTop > scrolltop ) {
		if ( document.body.scrollTop - scrollstep < scrolltop ) {
			document.body.scrollTop = scrolltop;
			clearInterval(scrollgoing);
		}
		else {
			document.body.scrollTop -= scrollstep;
		}
	}
	else {
		if ( document.body.scrollTop + scrollstep > scrolltop ) {
			document.body.scrollTop = scrolltop;
			clearInterval(scrollgoing);
		}
		else {
			document.body.scrollTop += scrollstep;
		}
	}
}

$().ready( function() {
	$("#nav a").focus( function() {
		$(this).blur();
	} );
} );

function gettext(node) {
	if ( $.browser.msie ) {
		return node.text;
	}
	else {
		return node.textContent;
	}
}