//by st. 2010-1-18
$(function(){
	$(".inp_txt, .inp_atxt").live("mouseover",function(){$(this).addClass("inp_txt_active")}).live("mouseout",function(){$(this).removeClass("inp_txt_active")});
});

(function($) {
	$.dk_confim = function(title,message, options) {
		options = $.extend({},$.dk_confim.defaults,options);
		$.dk_confim.currentPrefix = "dk_confim";
		options.currentclass = (options.myclass) ? "dk_confirm "+ options.myclass : "dk_confirm";
		var ie6		= ($.browser.msie && $.browser.version < 7);
		var $body	= $(document.body);
		var $window	= $(window);

		//build the box and fade
		var msgbox = '<div class="dk_confim" id="dk_confimbox">';
		if(options.usefade){
			if(ie6) {
				msgbox +='	<div class="dk_confimfade" id="dk_confimfade"><iframe frameborder="0"></iframe></div>';
			}else{
				msgbox +='	<div class="dk_confimfade" id="dk_confimfade"></div>';
			}
		}		
		msgbox +='	<div class="'+ options.currentclass +'" id="dk_confim" style="display:none"><div class="dk_confimocont">';
		msgbox +='		<div class="dk_confim_add dk_confim_header"><span class="dk_confim_addleft"></span><h5>'+ title +'</h5><span class="dk_confim_addright"></span></div>';
		msgbox +='		<div class="dk_confimclose" title="关闭">关闭</div>';
		msgbox +='		<div id="dk_confimmain" class="dk_confimmain"></div>';
		msgbox +='		<div class="dk_confim_add dk_confim_footer"><span class="dk_confim_addleft"></span><span class="dk_confim_addright"></span></div>';
		msgbox +='	</div></div>';
		msgbox +='</div>';

		if($("#dk_confirmbox")){
			$("#dk_confirmbox").remove();
		}

		var $cbox	= $(msgbox).appendTo($body);
		var $cmain	= $cbox.children("#dk_confim");
		var $cfade	= $cbox.children("#dk_confimfade");

		$cmain.find("#dk_confimmain").html('<div class="dk_confirmmsg">' + message +'</div>');

		var positionConfim = function(){
			$cbox.css({
				display:"block",
				position: (ie6) ? "absolute" : "fixed",
				height: $window.height(),
				width: "100%",
				top: (ie6)? $window.scrollTop() : 0,
				left: 0,
				right: 0,
				bottom: 0
			});
			$cfade.css({
				position: (ie6) ? "absolute":"fixed",
				height: $window.height(),
				width: "100%",
				background:"#000000",
				opacity:0.4,
				top: 0,
				left: 0,
				right: 0,
				bottom: 0
			});
			if(ie6) {
				$cfade.find("iframe").css({
					width:"100%",
					height:"100%",
					opacity:0
				})
			};
			$cmain.css({
				position: "absolute",
				top: "50%",
				left: "50%",
				marginLeft: (($cmain.outerWidth()/2)*-1),
				marginTop: (($cmain.outerHeight()/2)*-1)
			});
		};

		var styleConfim = function(){
			$cfade.css({
				zIndex: options.zIndex,
				display: "none",
				opacity: options.opacity
			});
			$cmain.css({
				zIndex: options.zIndex+1,
				display: "none"
			});
			$cbox.css({
				zIndex: options.zIndex
			});
		};

		var removeConfim = function(callCallback){
			//ie6, remove the scroll event
			if(ie6) {
				$body.unbind('scroll',ie6scroll);
			}
			$cmain.hide(100)
			$window.unbind('resize',positionConfim);
			$cbox.hide(100,function(){
				$cfade.unbind();
				if(callCallback){
					options.callback();
				}
				$cbox.remove();
			});
		};

		//Events
		var ie6scroll = function(){
			$cbox.css({top: $window.scrollTop()});
		};

		var getKeyCode = function(e){
			var key = (window.event) ? event.keyCode : e.which;
			return key;
		};

		positionConfim();
		styleConfim();
		
		//ie6, add a scroll event to fix position:fixed
		if(ie6) {
			$window.scroll(ie6scroll);
		}

		$window.resize(positionConfim);
		$cmain.find('.dk_confimclose').click(function(){removeConfim(0)});
		$cmain.find('#dk_confirm_btn_sm').click(function(){removeConfim(1)});
		$cmain.find('#dk_confirm_btn_option').click(function(){removeConfim(0)});
		$(document).keydown(function(event) {
			if(getKeyCode(event) == 27){removeConfim()};
		});
		//Show it
		$cfade.show();
		$cmain.show().jqDrag('.dk_confim_header');
	};
	
	$.dk_confim.defaults = {
		callback: function(){},
		opacity: 0.4,
		zIndex: 999,
		usefade:true,
		button:"确定",
		cancel:"取消"
	};
	
	$.dk_confim.close = function() {
		$('#'+ $.dk_confim.currentPrefix +'box').fadeOut(100,function(){
			$(this).remove();
		});
	};
	
})(jQuery);


(function($) {
	$.fn.dk_modwin = function(options) {
		var opt = $.extend({},$.fn.dk_modwin.defaults,options);
		if(!opt.main) return;

		var ie6		= ($.browser.msie && $.browser.version < 7);
		var $body	= $(document.body);
		var $window	= $(window);
		var $win = $(this);
		var $winmain = $win.find(opt.main);
		var $modwinfade = $win.find(opt.fade);

		var popWin = function(){
			$modwinfade.css({
				position:"absolute",
				height: "100%",
				width:"100%",
				top: 0,
				top:0,
				left:0,
				bottom:0,
				right:0,
				zIndex:0
			});
			$win.css({
				display:"block",
				position: (ie6) ? "absolute" : "fixed",
				height: $window.height(),
				top: (ie6)? $window.scrollTop()+"px" : 0,
				width:"100%",
				left:0,
				bottom:0,
				right:0,
				zIndex:1000
			});
			$winmain.css({
				position: (ie6) ? "absolute" : "fixed",
				zIndex:1,
				top: "50%",
				left: "50%",
				marginLeft: (($winmain.width()/2)*-1),
				marginTop: (($winmain.height()/2)*-1)
			});
		};

		var removeModwin = function(){
			if(ie6) {
				$body.unbind('scroll',ie6scroll);
			}
			$window.unbind('resize',popWin);
			$win.hide(10,function(){
				opt.callback();
				$win.remove();
			});
		};

		var ie6scroll = function(){
			$win.css({top: $window.scrollTop()+"px"});
		};

		var getKeyCode = function(e){
			var key = (window.event) ? event.keyCode : e.which;
			return key;
		};

		popWin();
		
		if(ie6) {
			$window.scroll(ie6scroll);
		}

		$window.resize(popWin);
		$(document).keydown(function(event) {
			if(getKeyCode(event) == 27){removeModwin()};
		});
		$win.find(opt.close).click(function(){removeModwin()})
	};

	$.fn.dk_modwin.defaults = {
		callback: function(){}
	};
})(jQuery);

(function($) {
	$.fn.lightBox = function(settings) {
		settings = jQuery.extend({
			overlayBgColor: 		'#000',
			overlayOpacity:			0.5,
			imageLoading:			'http://www.yzdsb.com.cn/images/loading.gif',
			imageBtnClose:		'http://www.yzdsb.com.cn/images/btn-close.gif',
			containerBorderSize:	6,
			containerResizeSpeed:	200,
			txtImage:				'Image',
			imageArray:				[],
			activeImage:			0
		},settings);
		var jQueryMatchedObj = this;
		var ie6		= ($.browser.msie && $.browser.version < 7);
		var _event;

		function _initialize(){
			if(this.getAttribute('rel') == "sell"){
				return true;
			}else{
				_start(this,jQueryMatchedObj);
				$(document).bind("mouseover mousemove",function(e){_event = e;})
				return false;
			}
		}

		function _start(objClicked,jQueryMatchedObj){
			$('embed, object, select').css({ 'visibility' : 'hidden' });
			_set_interface();
			settings.imageArray.length = 0;
			settings.activeImage = 0;
			if(jQueryMatchedObj.length == 1 ){
				settings.imageArray.push(new Array(objClicked.getAttribute('href'),objClicked.getAttribute('title')));
			} else {
				for ( var i = 0; i < jQueryMatchedObj.length; i++ ) {
					settings.imageArray.push(new Array(jQueryMatchedObj[i].getAttribute('href'),jQueryMatchedObj[i].getAttribute('title')));
				}
			}
			while ( settings.imageArray[settings.activeImage][0] != objClicked.getAttribute('href') ) {
				settings.activeImage++;
			}
			_set_image_to_view();
		}
	
		function _set_interface() {
			$('body').append('<div id="jquery-overlay">&nbsp;</div><div id="jquery-lightbox"><div id="lightbox-container-image-box"><div id="lightbox-container-image"><img id="lightbox-image" /><div id="lightbox-loading"><a href="#" id="lightbox-loading-link"><img src="' + settings.imageLoading + '"></a></div></div></div><div id="lightbox-container-image-text-box"><div id="lightbox-image-details-caption"></div><span id="lightbox-image-details-currentNumber"></span><div id="lightbox-secNav" class="icon">关闭</div></div></div>');

			//<div id="lightbox-container-image-data-box"><div id="lightbox-container-image-data"><div id="lightbox-image-details"></div><div id="lightbox-secNav"><a href="#" class="icon" id="lightbox-secNav-btnClose">关闭</a></div></div></div>
			var arrPageSizes = ___getPageSize();
			$('#jquery-overlay').css({
				width:        arrPageSizes[0],
				height:       (ie6) ? $(window).height() + $(window).scrollTop() : $(window).height(),
				position:     (ie6) ? "absolute":"fixed"
				
			}).fadeIn();
			var arrPageScroll = ___getPageScroll();
			$('#jquery-lightbox').css({
				top:	arrPageScroll[1] + (arrPageSizes[3] / 10),
				left:	arrPageScroll[0]
			}).show();
			$('#jquery-overlay,#jquery-lightbox').click(function() {
				_finish();
			});
			$('#lightbox-loading-link,#lightbox-secNav-btnClose').click(function() {
				_finish();
				return false;
			});
			$(window).resize(function() {
				var arrPageSizes = ___getPageSize();
				$('#jquery-overlay').css({
					width:		arrPageSizes[0],
					height:		arrPageSizes[1]
				});
				var arrPageScroll = ___getPageScroll();
				$('#jquery-lightbox').css({
					top:	arrPageScroll[1] + (arrPageSizes[3] / 10),
					left:	arrPageScroll[0]
				});
			})
			if(ie6){
				$(window).scroll(function(){
					$("#jquery-overlay").css("top",$(window).scrollTop()+"px");
				});
			}
		}

		function _set_image_to_view(){
			$('#lightbox-loading').show();
			$('#lightbox-image,#lightbox-container-image-text-box').hide();
			var objImagePreloader = new Image();
			objImagePreloader.onload = function() {
				$('#lightbox-image').attr('src',settings.imageArray[settings.activeImage][0]);
				_resize_container_image_box(objImagePreloader.width,objImagePreloader.height);
				objImagePreloader.onload=function(){};
			};
			if(!settings.imageArray[settings.activeImage]){
				_finish();
			}else{
				objImagePreloader.src = settings.imageArray[settings.activeImage][0];
			}
		};

		function _resize_container_image_box(intImageWidth,intImageHeight) {
			var intCurrentWidth = $('#lightbox-container-image-box').width();
			var intCurrentHeight = $('#lightbox-container-image-box').height();
			var intWidth = (intImageWidth + (settings.containerBorderSize * 2));
			var intHeight = (intImageHeight + (settings.containerBorderSize));
			var intDiffW = intCurrentWidth - intWidth;
			var intDiffH = intCurrentHeight - intHeight;
			$('#lightbox-container-image-box').animate({ width: intWidth, height: intHeight },settings.containerResizeSpeed,function() { _show_image(); });
			$('#lightbox-container-image-data-box').animate({width:intImageWidth + 12},settings.containerResizeSpeed);
			if ( ( intDiffW == 0 ) && ( intDiffH == 0 ) ) {
				if ( $.browser.msie ) {
					___pause(250);
				} else {
					___pause(100);	
				}
			} 
			//$('#lightbox-container-image-data-box').css({ width: intImageWidth + 12});
			$('#lightbox-container-image-text-box').css({ width: intImageWidth + 12});
			$('#lightbox-nav-btnPrev,#lightbox-nav-btnNext').css({ height: intImageHeight + (settings.containerBorderSize * 2) });
		};
		
		function _show_image() {
			$('#lightbox-loading').hide();
			$('#lightbox-image').fadeIn(450,function() {
				_show_image_data();
			//不显示上一张、下一张的连接
			_set_navigation();
			})
			_preload_neighbor_images();
		};
		
		function _show_image_data(){
			$('#lightbox-container-image-text-box').slideDown('fast');
			if ( settings.imageArray[settings.activeImage][1] ) {
				$('#lightbox-image-details-caption').html(settings.imageArray[settings.activeImage][1]).show();
			}
			if ( settings.imageArray.length > 1 ) {
				$('#lightbox-image-details-currentNumber').html('<em>'+( settings.activeImage + 1 ) + '</em>/'+ settings.imageArray.length);
			}		
		}
		
		function _set_navigation() {
			var lightimg = $('#lightbox-image');
			lightimg.unbind("mousemove").bind("mousemove",function(e){
				__changeMousePosition($(this),e);
			});
			__changeMousePosition(lightimg,_event);
			_enable_keyboard_navigation();
		}

		function _enable_keyboard_navigation() {
			$(document).keydown(function(objEvent) {
				_keyboard_action(objEvent);
			});
		}

		function _disable_keyboard_navigation() {
			$(document).unbind();
		}
		
		function _keyboard_action(objEvent) {
			if ( objEvent == null ) {
				keycode = event.keyCode;
				escapeKey = 27;
			} else {
				keycode = objEvent.keyCode;
				escapeKey = objEvent.DOM_VK_ESCAPE;
			}
			key = String.fromCharCode(keycode).toLowerCase();
			if ( ( key == settings.keyToClose ) || ( key == 'x' ) || ( keycode == escapeKey ) ) {
				_finish();
			}
			if ( ( key == settings.keyToPrev ) || ( keycode == 37 ) ) {
				if ( settings.activeImage != 0 ) {
					settings.activeImage = settings.activeImage - 1;
					_set_image_to_view();
					_disable_keyboard_navigation();
				}
			}
			if ( ( key == settings.keyToNext ) || ( keycode == 39 ) ) {
				if ( settings.activeImage != ( settings.imageArray.length - 1 ) ) {
					settings.activeImage = settings.activeImage + 1;
					_set_image_to_view();
					_disable_keyboard_navigation();
				}
			}
		}

		function _preload_neighbor_images() {
			if ( (settings.imageArray.length -1) > settings.activeImage ) {
				objNext = new Image();
				objNext.src = settings.imageArray[settings.activeImage + 1][0];
			}
			if ( settings.activeImage > 0 ) {
				objPrev = new Image();
				objPrev.src = settings.imageArray[settings.activeImage -1][0];
			}
		}
		
		function _finish() {
			$('#jquery-lightbox').remove();
			$('#jquery-overlay').remove();
			$('embed, object, select').css({ 'visibility' : 'visible' });
			$(document).unbind();
			$('#lightbox-image').unbind();
		}
		
		function ___getPageSize() {
			var xScroll, yScroll;
			if (window.innerHeight && window.scrollMaxY) {	
				xScroll = window.innerWidth + window.scrollMaxX;
				yScroll = window.innerHeight + window.scrollMaxY;
			} else if (document.body.scrollHeight > document.body.offsetHeight){
				xScroll = document.body.scrollWidth;
				yScroll = document.body.scrollHeight;
			} else {
				xScroll = document.body.offsetWidth;
				yScroll = document.body.offsetHeight;
			}
			var windowWidth, windowHeight;
			if (self.innerHeight) {
				if(document.documentElement.clientWidth){
					windowWidth = document.documentElement.clientWidth; 
				} else {
					windowWidth = self.innerWidth;
				}
				windowHeight = self.innerHeight;
			} else if (document.documentElement && document.documentElement.clientHeight) {
				windowWidth = document.documentElement.clientWidth;
				windowHeight = document.documentElement.clientHeight;
			} else if (document.body) {
				windowWidth = document.body.clientWidth;
				windowHeight = document.body.clientHeight;
			}	
			
			if(yScroll < windowHeight){
				pageHeight = windowHeight;
			} else { 
				pageHeight = yScroll;
			}
			
			if(xScroll < windowWidth){	
				pageWidth = xScroll;		
			} else {
				pageWidth = windowWidth;
			}
			arrayPageSize = new Array(pageWidth,pageHeight,windowWidth,windowHeight);
			return arrayPageSize;
		};
		
		function ___getPageScroll() {
			var xScroll, yScroll;
			if (self.pageYOffset) {
				yScroll = self.pageYOffset;
				xScroll = self.pageXOffset;
			} else if (document.documentElement && document.documentElement.scrollTop) {
				yScroll = document.documentElement.scrollTop;
				xScroll = document.documentElement.scrollLeft;
			} else if (document.body) {
				yScroll = document.body.scrollTop;
				xScroll = document.body.scrollLeft;	
			}
			arrayPageScroll = new Array(xScroll,yScroll);
			return arrayPageScroll;
		};
		
		function ___pause(ms) {
			var date = new Date(); 
			curDate = null;
			do { var curDate = new Date(); }
			while ( curDate - date < ms);
		};

		function __changeMousePosition(obj,e){
			var _x = parseInt(obj.offset().left);
			var _y = parseInt(obj.offset().top);
			var _px = _x + (obj.width())/2;
			var _py = _y + (obj.height())/2;
			var _ex = _x + obj.width();
			var _ey = _y + obj.height();
			var _mx = getMousePosition(e).x;
			var _my = getMousePosition(e).y;
			if(_my > _y && _my < _ey){
				if(_mx >_x && _mx < _px){
					obj.css("cursor","url(http://www.yzdsb.com.cn/images/prev.cur), pointer");
					var prevpic = jQueryMatchedObj[settings.activeImage - 1];
					if(prevpic){
						if(prevpic.getAttribute('rel') == "sell"){
							obj.unbind("click").bind('click',function(){
								window.location.href = prevpic.getAttribute('href')
								_finish();
							})
						}else{
							obj.unbind("click").bind('click',function(e){
								settings.activeImage = settings.activeImage - 1;
								_set_image_to_view();
								return false;
							})
						}
					}
				}else if(_mx > _px && _mx < _ex){
					obj.css("cursor","url(http://www.yzdsb.com.cn/images/next.cur), pointer");
					var nextpic = jQueryMatchedObj[settings.activeImage + 1];
					if(nextpic){
						if(nextpic.getAttribute('rel') == "sell"){
							obj.unbind("click").bind('click',function(){
								window.location.href = nextpic.getAttribute('href')
								_finish();
							})
						}else{
							obj.unbind("click").bind('click',function(e){
								settings.activeImage = settings.activeImage + 1;
								_set_image_to_view();
								return false;
							})
						}
					}
				}
			}
		}
		return this.unbind('click').click(_initialize);
	};
})(jQuery);

(function($){
	$.fn.dk_showphoto = function(options){
		var pause, opt, $this, scrollWrapId, $scrollWrap, singleSize, overPlus, resetsize, bind, doanimate, showOption
		
		opt = $.extend({},$.fn.dk_showphoto.defaults,options);

		$this = $(this);
		$this.css({position:"relative",zIndex:0});

		$this.html("<div id='scrollWrap_"+$this.attr('id')+"' style='position:absolute;z-index:0;'>"+$this.html()+"</div>");
		
		$scrollWrap = $this.find("#scrollWrap_"+$this.attr('id'));

		$scrollWrap.css({left:0,top:0});
		
		singleSize = $scrollWrap.children().outerWidth(); //获得单个子节点尺寸
		
		//设置宽度
		resetsize = function(){
			var ChildSize = $scrollWrap.children().size(); //获得子节点数量
			$scrollWrap.width(singleSize*$scrollWrap.children().size());
			overPlus = $this.width() - ChildSize* singleSize;
		}

		//初始化
		bind = function(){
			//绑定事件
			if(opt.nextId){
				$(opt.nextId).click(function(){
					if(pause) return false;
					if(opt.action == "single"){
						doanimate(-1);
					}else	if(opt.action == "group"){
						doanimate(0-$this.width()/singleSize);
					}
					return false;
				});
			};
			if(opt.prevId){
				$(opt.prevId).click(function(){
					if(pause) return false;
					if(opt.action == "single"){
						doanimate(1);
					}else	if(opt.action == "group"){
						doanimate($this.width()/singleSize);
					}
					return false;
				});
			}
			
			if(opt.defaultgroup){
				doanimate((1- opt.defaultgroup)* ($this.width()/singleSize),1)
			}
		}

		//移动事件
		doanimate = function(n,type){
			if(!type){type = 0;}
			pause = true;
			var tmpPosVal = parseInt($scrollWrap.css("left"));
			if(tmpPosVal == 0  && n >0){return false;}
			if(tmpPosVal <= overPlus && n<0){return false;}
			if(type == 1){
				$scrollWrap.css("left",(tmpPosVal + n*singleSize)+"px");
				showOption();
			}else{
				$scrollWrap.animate({left:tmpPosVal + n*singleSize},opt.speed,function(){
					showOption();
				});
			}
		}
		
		showOption = function(){
			var nowPosVal = parseInt($scrollWrap.css("left"));
			if(nowPosVal < 0){
				$(opt.prevId).fadeIn(100);
			}else{
				$(opt.prevId).fadeOut(100);
			}
			if(nowPosVal <= overPlus){
				$(opt.nextId).fadeOut(100);
			}else{
				$(opt.nextId).fadeIn(100);
			}
			pause = false;
		}

		resetsize();
		
		if(overPlus >= 0) {return false} //内容不够多时候自动退出

		bind();
	}

	$.fn.dk_showphoto.defaults = {
		action: "single",    //滚动方式{single|group}单张、组 默认single
		speed: 500,          //速度 300 默认500毫秒(5秒)
		currentid:"active"  //当前class
	}
})(jQuery);

/*
==轮播{对象|对象属性}==
对象属性{宽度|高度|文字大小|自动切换时间}
*/
function dk_slideplayer(object,config){
	this.obj = object;
	this.config = config ? config : {width:"300px",height:"200px",fontsize:"12px",right:"10px",bottom:"10px",time:"5000"};
	this.pause = false;
	var _this = this;
	if(!this.config.right){
		this.config.right = "0px"
	}
	if(!this.config.bottom){
		this.config.bottom = "3px"
	}
	if(this.config.fontsize == "12px" || !this.config.fontsize){
		this.size = "12px";
		this.height = "21px";
		this.right = "6px";
		this.bottom = "10px";
	}else if(this.config.fontsize == "14px"){
		this.size = "14px";
		this.height = "23px";
		this.right = "6px";
		this.bottom = "15px";
	}
	this.count = jQuery(this.obj + " li").size();
	this.n =0;
	this.j =0;
	var t;
	this.factory = function(){
		jQuery(this.obj).css({position:"relative",zIndex:"0",margin:"0",padding:"0",width:this.config.width,height:this.config.height,overflow:"hidden"})
		jQuery(this.obj).prepend("<div style='position:absolute;z-index:20;right:"+this.config.right+";bottom:"+this.config.bottom+"'></div>");
		jQuery(this.obj + " li").css({width:"100%",height:"100%",overflow:"hidden"}).each(function(i){jQuery(_this.obj + " div").append("<a>"+(i+1)+"</a>")});

		jQuery(this.obj + " img").css({border:"none",width:"100%",height:"100%"})

		this.resetclass(this.obj + " div a",0);

		jQuery(this.obj + " p").each(function(i){			
			jQuery(this).parent().append(jQuery(this).clone(true));
			jQuery(this).html("");
			jQuery(this).css({position:"absolute",margin:"0",padding:"0",zIndex:"1",bottom:"0",left:"0",height:_this.height,width:"100%",background:"#000",opacity:"0.4",overflow:"hidden"})
			jQuery(this).next().css({position:"absolute",margin:"0",padding:"0",zIndex:"2",bottom:"0",left:"0",height:_this.height,lineHeight:_this.height,textIndent:"5px",width:"100%",textDecoration:"none",fontSize:_this.size,color:"#FFFFFF",background:"none",zIndex:"1",opacity:"1",overflow:"hidden"})
			if(i!= 0){jQuery(this).hide().next().hide()}
		});

		this.slide();
		this.addhover();
		t = setInterval(this.autoplay,this.config.time);
	}
	
	this.slide = function(){
		jQuery(this.obj + " div a").mouseover(function(){
			_this.j = jQuery(this).text() - 1;
			_this.n = _this.j;
			if (_this.j >= _this.count){return;}
			jQuery(_this.obj + " li").hide();
			jQuery(_this.obj + " p").hide();
			jQuery(_this.obj + " li").eq(_this.j).fadeIn("slow");
			jQuery(_this.obj + " li").eq(_this.j).find("p").show();
			_this.resetclass(_this.obj + " div a",_this.j);
		});
	}

	this.addhover = function(){
		jQuery(this.obj).hover(function(){clearInterval(t);}, function(){t = setInterval(_this.autoplay,_this.config.time)});
	}
	
	this.autoplay = function(){
		_this.n = _this.n >= (_this.count - 1) ? 0 : ++_this.n;
		jQuery(_this.obj + " div a").eq(_this.n).triggerHandler('mouseover');
	}
	
	this.resetclass =function(obj,i){
		jQuery(obj).css({float:"left",marginRight:"3px",width:"15px",height:"14px",lineHeight:"15px",textAlign:"center",fontWeight:"800",fontSize:"12px",color:"#000",background:"#FFFFFF",cursor:"pointer"});
		jQuery(obj).eq(i).css({color:"#FFFFFF",background:"#FF7D01",textDecoration:"none"});
	}

	this.factory();
}

(function($){
$.fn.jqDrag=function(h){return i(this,h,'d');};
$.fn.jqResize=function(h){return i(this,h,'r');};
$.jqDnR={dnr:{},e:0,
drag:function(v){
if(M.k == 'd')E.css({left:M.X+v.pageX-M.pX,top:M.Y+v.pageY-M.pY});
return false;},
stop:function(){E.css('opacity',M.o);$().unbind('mousemove',J.drag).unbind('mouseup',J.stop);}
};
var J=$.jqDnR,M=J.dnr,E=J.e,
i=function(e,h,k){return e.each(function(){h=(h)?$(h,e):e;
 h.bind('mousedown',{e:e,k:k},function(v){var d=v.data,p={};E=d.e;
 if(E.css('position') != 'relative'){try{E.position(p);}catch(e){}}
 M={X:p.left||f('left')||0,Y:p.top||f('top')||0,pX:v.pageX,pY:v.pageY,k:d.k,o:E.css('opacity')};
 E.css({opacity:0.8});$().mousemove($.jqDnR.drag).mouseup($.jqDnR.stop);
 return false;
 });
});},
f=function(k){return k=="left"? E.position().left:E.position().top};
})(jQuery);

//日历
var userAgent = navigator.userAgent.toLowerCase();
var is_webtv = userAgent.indexOf('webtv') != -1;
var is_kon = userAgent.indexOf('konqueror') != -1;
var is_mac = userAgent.indexOf('mac') != -1;
var is_saf = userAgent.indexOf('applewebkit') != -1 || navigator.vendor == 'Apple Computer, Inc.';
var is_opera = userAgent.indexOf('opera') != -1 && opera.version();
var is_moz = (navigator.product == 'Gecko') && userAgent.substr(userAgent.indexOf('firefox') + 8, 3);
var is_ie = (userAgent.indexOf('msie') != -1 && !is_opera) && userAgent.substr(userAgent.indexOf('msie') + 5, 3);

var controlid = null;
var currdate = null;
var startdate = null;
var enddate  = null;
var yy = null;
var mm = null;
var hh = null;
var ii = null;
var currday = null;
var addtime = false;
var today = new Date();
var lastcheckedyear = false;
var lastcheckedmonth = false;

function getposition(obj) {
	var r = new Array();
	r['x'] = obj.offsetLeft;
	r['y'] = obj.offsetTop;
	while(obj = obj.offsetParent) {
		r['x'] += obj.offsetLeft;
		r['y'] += obj.offsetTop;
	}
	return r;
}

function doane(event) {
    e = event ? event : window.event;
    if(is_ie) {
        e.returnValue = false;
        e.cancelBubble = true;
    } else if(e) {
        e.stopPropagation();
        e.preventDefault();
    }
}

function $i(id) {
	return document.getElementById(id);
}

function loadcalendar() {
	s = '';
	s += '<div id="calendar" style="display:none; position:absolute; z-index:9;" onclick="doane(event)">';
	s += '<div style="width:210px;"><table cellspacing="0" cellpadding="0" width="100%" style="text-align: center;">';
	s += '<tr align="center" id="calendar_week"><td><a href="###" class="calendar_week_prevmonth" onclick="refreshcalendar(yy, mm-1)" title="上一月">《</a></td><td colspan="5" style="text-align: center"><a href="###" onclick="showdiv(\'year\');doane(event)" class="dropmenu" title="点击选择年份" id="year"></a>&nbsp; - &nbsp;<a id="month" class="dropmenu" title="点击选择月份" href="###" onclick="showdiv(\'month\');doane(event)"></a></td><td><A href="###" class="calendar_week_nextmonth" onclick="refreshcalendar(yy, mm+1)" title="下一月">》</A></td></tr>';
	s += '<tr id="calendar_header"><td>日</td><td>一</td><td>二</td><td>三</td><td>四</td><td>五</td><td>六</td></tr>';
	for(var i = 0; i < 6; i++) {
		s += '<tr>';
		for(var j = 1; j <= 7; j++)
			s += "<td id=d" + (i * 7 + j) + ">0</td>";
		s += "</tr>";
	}
	s += '<tr id="hourminute"><td colspan="7" align="center"><input type="text" size="2" value="" id="hour" onKeyUp=\'this.value=this.value > 23 ? 23 : zerofill(this.value);controlid.value=controlid.value.replace(/\\d+(\:\\d+)/ig, this.value+"$1")\'> 点 <input type="text" size="2" value="" id="minute" onKeyUp=\'this.value=this.value > 59 ? 59 : zerofill(this.value);controlid.value=controlid.value.replace(/(\\d+\:)\\d+/ig, "$1"+this.value)\'> 分</td></tr>';
	s += '</table></div></div>';
	s += '<div id="calendar_year" onclick="doane(event)" style="display: none"><div class="col">';
	for(var k = 1930; k <= 2019; k++) {
		s += k != 1930 && k % 10 == 0 ? '</div><div class="col">' : '';
		s += '<a href="###" onclick="refreshcalendar(' + k + ', mm);$i(\'calendar_year\').style.display=\'none\'"><span' + (today.getFullYear() == k ? ' class="calendar_today"' : '') + ' id="calendar_year_' + k + '">' + k + '</span></a><br />';
	}
	s += '</div></div>';
	s += '<div id="calendar_month" onclick="doane(event)" style="display: none">';
	for(var k = 1; k <= 12; k++) {
		s += '<a href="###" onclick="refreshcalendar(yy, ' + (k - 1) + ');$i(\'calendar_month\').style.display=\'none\'"><span' + (today.getMonth()+1 == k ? ' class="calendar_today"' : '') + ' id="calendar_month_' + k + '">' + k + ( k < 10 ? '&nbsp;' : '') + ' 月</span></a><br />';
	}
	s += '</div>';
	if(is_ie && is_ie < 7) {
		s += '<iframe id="calendariframe" frameborder="0" style="display:none;position:absolute;filter:progid:DXImageTransform.Microsoft.Alpha(style=0,opacity=0)"></iframe>';
		s += '<iframe id="calendariframe_year" frameborder="0" style="display:none;position:absolute;filter:progid:DXImageTransform.Microsoft.Alpha(style=0,opacity=0)"></iframe>';
		s += '<iframe id="calendariframe_month" frameborder="0" style="display:none;position:absolute;filter:progid:DXImageTransform.Microsoft.Alpha(style=0,opacity=0)"></iframe>';
	}
	var appendparents = document.createElement('div');
	appendparents.setAttribute("id","append_parent");
	var div = document.createElement('div');
	div.innerHTML = s;
	appendparents.appendChild(div);
	document.body.appendChild(appendparents);
	document.onclick = function(event) {
		$i('calendar').style.display = 'none';
		$i('calendar_year').style.display = 'none';
		$i('calendar_month').style.display = 'none';
		if(is_ie && is_ie < 7) {
			$i('calendariframe').style.display = 'none';
			$i('calendariframe_year').style.display = 'none';
			$i('calendariframe_month').style.display = 'none';
		}
	}
	$i('calendar').onclick = function(event) {
		doane(event);
		$i('calendar_year').style.display = 'none';
		$i('calendar_month').style.display = 'none';
		if(is_ie && is_ie < 7) {
			$i('calendariframe_year').style.display = 'none';
			$i('calendariframe_month').style.display = 'none';
		}
	}
}

function parsedate(s) {
	/(\d+)\-(\d+)\-(\d+)\s*(\d*):?(\d*)/.exec(s);
	var m1 = (RegExp.$1 && RegExp.$1 > 1899 && RegExp.$1 < 2101) ? parseFloat(RegExp.$1) : today.getFullYear();
	var m2 = (RegExp.$2 && (RegExp.$2 > 0 && RegExp.$2 < 13)) ? parseFloat(RegExp.$2) : today.getMonth() + 1;
	var m3 = (RegExp.$3 && (RegExp.$3 > 0 && RegExp.$3 < 32)) ? parseFloat(RegExp.$3) : today.getDate();
	var m4 = (RegExp.$4 && (RegExp.$4 > -1 && RegExp.$4 < 24)) ? parseFloat(RegExp.$4) : 0;
	var m5 = (RegExp.$5 && (RegExp.$5 > -1 && RegExp.$5 < 60)) ? parseFloat(RegExp.$5) : 0;
	/(\d+)\-(\d+)\-(\d+)\s*(\d*):?(\d*)/.exec("0000-00-00 00\:00");
	return new Date(m1, m2 - 1, m3, m4, m5);
}

function settime(d) {
	$i('calendar').style.display = 'none';
	$i('calendar_month').style.display = 'none';
	if(is_ie && is_ie < 7) {
		$i('calendariframe').style.display = 'none';
	}
	controlid.value = yy + "-" + zerofill(mm + 1) + "-" + zerofill(d) + (addtime ? ' ' + zerofill($i('hour').value) + ':' + zerofill($i('minute').value) : '');
}

function showcalendar(event, controlid1, addtime1, startdate1, enddate1){
	//加载必要的日历模块
	if($("#append_parent").size() == 0){
		loadcalendar();
	}
	controlid = controlid1;
	addtime = addtime1;
	startdate = startdate1 ? parsedate(startdate1) : false;
	enddate = enddate1 ? parsedate(enddate1) : false;
	currday = controlid.value ? parsedate(controlid.value) : today;
	hh = currday.getHours();
	ii = currday.getMinutes();
	var p = getposition(controlid);
	$i('calendar').style.display = 'block';
	var s_width = document.documentElement.scrollWidth - 210;
	if(Math.abs(s_width - p['x']) < 80){
		$i('calendar').style.right = '10px';
	}else{
		$i('calendar').style.left = p['x']+'px';
	}
	$i('calendar').style.top	= (p['y'] + 20)+'px';
	doane(event);
	refreshcalendar(currday.getFullYear(), currday.getMonth());
	if(lastcheckedyear != false) {
		$i('calendar_year_' + lastcheckedyear).className = 'calendar_default';
		$i('calendar_year_' + today.getFullYear()).className = 'calendar_today';
	}
	if(lastcheckedmonth != false) {
		$i('calendar_month_' + lastcheckedmonth).className = 'calendar_default';
		$i('calendar_month_' + (today.getMonth() + 1)).className = 'calendar_today';
	}
	$i('calendar_year_' + currday.getFullYear()).className = 'calendar_checked';
	$i('calendar_month_' + (currday.getMonth() + 1)).className = 'calendar_checked';
	$i('hourminute').style.display = addtime ? '' : 'none';
	lastcheckedyear = currday.getFullYear();
	lastcheckedmonth = currday.getMonth() + 1;
	if(is_ie && is_ie < 7) {
		$i('calendariframe').style.top = $i('calendar').style.top;
		$i('calendariframe').style.left = $i('calendar').style.left;
		$i('calendariframe').style.width = $i('calendar').offsetWidth;
		$i('calendariframe').style.height = $i('calendar').offsetHeight;
		$i('calendariframe').style.display = 'block';
	}
}

function refreshcalendar(y, m) {
	var x = new Date(y, m, 1);
	var mv = x.getDay();
	var d = x.getDate();
	var dd = null;
	yy = x.getFullYear();
	mm = x.getMonth();
	$i("year").innerHTML = yy;
	$i("month").innerHTML = mm + 1 > 9  ? (mm + 1) : '0' + (mm + 1);

	for(var i = 1; i <= mv; i++) {
		dd = $i("d" + i);
		dd.innerHTML = "&nbsp;";
		dd.className = "";
	}

	while(x.getMonth() == mm) {
		dd = $i("d" + (d + mv));
		dd.innerHTML = '<a href="###" onclick="settime(' + d + ');return false">' + d + '</a>';
		if(x.getTime() < today.getTime() || (enddate && x.getTime() > enddate.getTime()) || (startdate && x.getTime() < startdate.getTime())) {
			dd.className = 'calendar_expire';
		} else {
			dd.className = 'calendar_default';
		}
		if(x.getFullYear() == today.getFullYear() && x.getMonth() == today.getMonth() && x.getDate() == today.getDate()) {
			dd.className = 'calendar_today';
			dd.firstChild.title = '今天';
		}
		if(x.getFullYear() == currday.getFullYear() && x.getMonth() == currday.getMonth() && x.getDate() == currday.getDate()) {
			dd.className = 'calendar_checked';
		}
		x.setDate(++d);
	}

	while(d + mv <= 42) {
		dd = $i("d" + (d + mv));
		dd.innerHTML = "&nbsp;";
		d++;
	}

	if(addtime) {
		$i('hour').value = zerofill(hh);
		$i('minute').value = zerofill(ii);
	}
}

function showdiv(id) {
	var p = getposition($i(id));
	$i('calendar_' + id).style.left = p['x']+'px';
	$i('calendar_' + id).style.top = (p['y'] + 16)+'px';
	$i('calendar_' + id).style.display = 'block';
	if(is_ie && is_ie < 7) {
		$i('calendariframe_' + id).style.top = $i('calendar_' + id).style.top;
		$i('calendariframe_' + id).style.left = $i('calendar_' + id).style.left;
		$i('calendariframe_' + id).style.width = $i('calendar_' + id).offsetWidth;
		$i('calendariframe_' + id ).style.height = $i('calendar_' + id).offsetHeight;
		$i('calendariframe_' + id).style.display = 'block';
	}
}

function zerofill(s) {
	var s = parseFloat(s.toString().replace(/(^[\s0]+)|(\s+$)/g, ''));
	s = isNaN(s) ? 0 : s;
	return (s < 10 ? '0' : '') + s.toString();
}

function setcopy(text, alertmsg){
	if(is_ie) {
		clipboardData.setData('Text', text);
		alert(alertmsg);
	} else {
		prompt('Please press "Ctrl+C" to copy this text', text);
	}
}

function getMousePosition(ev){
	if(ev.pageX || ev.pageY){
		return {x:ev.pageX, y:ev.pageY};
	}else return {
		x:ev.clientX + document.body.scrollLeft - document.body.clientLeft,
		y:ev.clientY + document.body.scrollTop - document.body.clientTop
	};
};

