function __Year_Month_day_Check(__type,__yearId,__monthId,__dayId){
	__year = document.getElementById(__yearId);
	__month = document.getElementById(__monthId);
	__day = document.getElementById(__dayId);
	__yearValue = Number(__year.value);
	__monthValue = Number(__month.value);
	__dayValue = Number(__day.value);
	if(__type == 'year'){
		for (var i = __month.options.length;i > 1;i--){
			__month.remove(i-1);
		}
		for (var i = __day.options.length;i > 1;i--){
			__day.remove(i-1);
		}
		if (__yearValue != '0000') {
			for (var i = 0;i < 12;i++){
				var n = i<9?'0'+(i+1):(i+1);
				__month.options[i+1] = new Option(n,n);
			}
		}
	}else if(__type == 'month'){
		if (__monthValue == '00') {
			for (var i = __day.options.length;i > 1;i--){
				__day.remove(i-1);
			}
		}else{
			var __monthDays = new Array(31,29,31,30,31,30,31,31,30,31,30,31);
			__monthDays[1] = (__yearValue % 4 == 0)&&(__yearValue % 100 != 0)||(__yearValue % 400 == 0)?29:28;
			var __newDay = __monthDays[__monthValue-1];
			for (var i = __day.options.length;i > __newDay +1 ;i--){
				__day.remove(i-1);
			}
			for (var i = __day.options.length;i < __newDay +1 ;i++){
				var n = i<10?'0'+ i:i;
				__day.options[i] = new Option(n,n);
			}
		}
	}
};

function myScrollTo(e,callback){
	$('#'+e).xScroll(callback);
};



/**
 * Common Function
 * @author xwk
 * @since 2011-07-19
 * @qq 56433593
 * @version 0.7
 * @version $Id: common_fun.js 2599 2011-09-01 17:16:13Z xwk $
 * 
 */
(function ($) {
	$.fn.xEmptyVal = function (es, color1, color2) {
		if (!color1) {
			color1 = "#999";
		}
		if (!color2) {
			color2 = "#000";
		}
		return $(this).unbind("click.xEmptyVal focus.xEmptyVal blur.xEmptyVal").bind("click.xEmptyVal focus.xEmptyVal", function () {
			if ($(this).val() == es) {
				$(this).css("color", color2).val("");
			}
		}).bind("blur.xEmptyVal",function () {
			if ($(this).val() == "") {
				$(this).css("color", color1).val(es);
			}
			if ($(this).val() != es) {
				$(this).css("color", color2);
			}
		}).trigger("blur.xEmptyVal");
	};
	$.fn.xLazyLoad = function (options) {
		var _this = $(this);
		var defaults = {
			style: "top",
			offset: 150,
			trigger_element: null,
			callback: null,
			"": ""
		};
		var settings = $.extend({}, defaults, options);
		var stime = null;

		function loadImg() {
			_this.each(function () {
				if ($(this).attr("_src")) {
					var y = isIpad() ? window.pageYOffset : Math.max(document.documentElement.scrollTop, document.body.scrollTop);
					var x = isIpad() ? window.pageXOffset : Math.max(document.documentElement.scrollLeft, document.body.scrollLeft);
					if (settings.trigger_element) {
						y = $(settings.trigger_element).offset().top;
						x = $(settings.trigger_element).offset().left;
					}
					var test = false;
					if (settings.style == "top") {
						test = $(this).offset().top <= document.documentElement.clientHeight + y && $(this).offset().top >= y - settings.offset;
					} else {
						test = $(this).offset().left <= document.documentElement.clientWidth - x + settings.offset && $(this).offset().left >= x - settings.offset;
					}
					if (test) {
						var self = this;
						setTimeout(function () {
							$(self).attr("src", $(self).attr("_src")).removeAttr("_src");
							settings.callback && settings.callback.call($(self));
						}, 20);
					}
				}
			});
		}

		function isIpad() {
			return navigator.userAgent.match(/iPad/i) != null;
		}
		if (!settings.trigger_element) {
			$(window).bind("scroll.xLazyLoad", function () {
				if (stime) {
					clearTimeout(stime);
				}
				stime = setTimeout(function () {
					loadImg();
				}, 200);
			});
		}
		loadImg();
		return this;
	};
	
	$.fn.xScroll = function(callback){
		var _this = this;
		$('html,body').animate({
			scrollTop: $(this).offset().top
		}, 1000,function(){
			callback && callback.call($(_this));
		});
	};
})(jQuery);

