/*
	[Stone PHP] (C)2008-2009 REDSTONE.
	This is NOT a freeware, use is subject to license terms
*/

//note 全局变量
var clipboardswfdata = '';
var lastval = '';

function setMyHome(obj, vrl) {
	try{
		obj.style.behavior='url(#default#homepage)';obj.setHomePage(vrl);
	}
	catch(e){
		if(window.netscape) {
			try {
				netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
			} catch(e) {
				alert("抱歉！您的浏览器不支持直接设为首页。请在浏览器地址栏输入“about:config”并回车然后将[signed.applets.codebase_principal_support]设置为“true”，点击“加入收藏”后忽略安全提示，即可设置成功。");
			}
			var prefs = Components.classes['@mozilla.org/preferences-service;1'].getService(Components.interfaces.nsIPrefBranch);
			prefs.setCharPref('browser.startup.homepage',vrl);
		}
	}
}

function AddFavorite(url, title) {
	try {
	    window.external.addFavorite(url, title);
	} catch (e) {
		try {
			window.sidebar.addPanel(title, url, "");
	    } catch (e) {
			alert("加入收藏失败，请使用Ctrl+D进行添加");
		}
	}
}

function getVars(attr){
	var url = window.location.search;
	var vars = {};
	if(url){
		url = url.substring(1); //去掉?
		var tvars = url.split('&'); //拆分成块数组 如 id=1 name =zhangsna   age=10
		for(var i=0;i<tvars.length;i++){
			ttvars = tvars[i].split('='); //提取一个get 变量到数组 ttvars[0] = 'id'   ttvars[1] = '1'
			vars[ttvars[0]] = ttvars[1];
		}
		if(attr){
			if(vars[attr]) {
				return vars[attr];
			} else {
				if(attr == 'aid') {
					return aid_cid.aid;
				} else if(attr == 'cid') {
					return aid_cid.cid;
				}
			}
		}else{
			return vars;
		}
	}
	if(attr == 'm') {
		return m_a.m;
	} else if(attr == 'a') {
		return m_a.a;
	}
	return false;
}

function display_toggle(o, tag) {
	if(!tag) tag = 'h4';
	$(tag, o)
	.click(function() {
		$(this).next().slideToggle('1000');
	});
}

function display_tab() {
	$lis = $("#city_header h3,#city_header li a");
	$divs = $("#citybody > ul").children();
	$lis.eq(0).click(function() {
		$lis.removeClass('current');
		$(this).addClass('current');
		$divs.show();
	});
	$lis.not($lis[0]).click(function() {
		$lis.removeClass('current');
		$(this).addClass('current');
		$divs.hide();
		$divs.eq(($lis.index($(this)) - 1)).show();
	});
}

function ajaxshow(url, dst) {
	dst.html('Loading…………');
	$.get(url, function(data) {
		dst.html(data);
	})
}

jQuery.cookie = function(name, value, options) {
    if (typeof value != 'undefined') { // name and value given, set cookie
        options = options || {};
        if (value === null) {
            value = '';
            options.expires = -1;
        }
        var expires = '';
        if (options.expires && (typeof options.expires == 'number' || options.expires.toUTCString)) {
            var date;
            if (typeof options.expires == 'number') {
                date = new Date();
                date.setTime(date.getTime() + (options.expires * 24 * 60 * 60 * 1000));
            } else {
                date = options.expires;
            }
            expires = '; expires=' + date.toUTCString(); // use expires attribute, max-age is not supported by IE
        }
        var path = options.path ? '; path=' + options.path : '';
        var domain = options.domain ? '; domain=' + options.domain : '';
        var secure = options.secure ? '; secure' : '';
        document.cookie = [name, '=', encodeURIComponent(value), expires, path, domain, secure].join('');
    } else { // only name given, get cookie
        var cookieValue = null;
        if (document.cookie && document.cookie != '') {
            var cookies = document.cookie.split(';');
            for (var i = 0; i < cookies.length; i++) {
                var cookie = jQuery.trim(cookies[i]);
                // Does this cookie string begin with the name we want?
                if (cookie.substring(0, name.length + 1) == (name + '=')) {
                    cookieValue = decodeURIComponent(cookie.substring(name.length + 1));
                    break;
                }
            }
        }
        return cookieValue;
    }
};

function setCopy(text, msg) {
	if($.browser.msie) {
		clipboardData.setData('Text', text);
		if(msg) {
			alert(msg);
		}
	} else {
		var content = 'text:<div style="text-decoration:underline;" id="clickcopy">点此复制到剪贴板</div>';
		content += '<div id="clipboardswf"><embed height="40" width="120" type="application/x-shockwave-flash" style="margin-top: -20px;" wmode="transparent" swliveconnect="true" allowscriptaccess="sameDomain" menu="false" src="data/clipboard.swf" devicefont="false" name="clipboardswf" /></div>';
		dialog('复制到剪切板',content,"200px","auto", "text");
		text = text.replace(/[\xA0]/g, ' ');
		clipboardswfdata = text;
		$("#clickcopy").click(function() {
			alert(msg);
			dialogclose();
		});
	}
}

function getClipboardData() {
	window.document.clipboardswf.SetVariable('str', clipboardswfdata);
}

function hideMenu() {
	alert('已复制到剪贴板');
	dialogclose();
}

function tab_node(obj, forobj, i, addclass) {
	obj.children().removeClass(addclass);
	obj.children().eq(i).addClass(addclass);
	forobj.children().hide();
	forobj.children().eq(i).show();
}


function tab_enable(obj) {
	var operate = obj.attr('operate');
	var addclass = obj.attr('addclass');
	var forobj = $("#"+obj.attr('forobj'));
	if(!obj.attr('noinit')) {
		tab_node(obj, forobj, 0, addclass);
	}
	obj.children().each(function(i) {
		if(operate == 'click') {
			$(this).click(function() {
				tab_node(obj, forobj, i, addclass)
			});
		} else {
			$(this).mouseover(function() {
				tab_node(obj, forobj, i, addclass)
			});
		}
	});
}

function stonephpjsinit() {

	//note 验证码
	$(".seccode").each(function() {
		$this = $(this);
		if($this.html()) return;
		var showtype = $(this).attr('showtype');
		showtype = showtype == 'output' ? 'output' : 'click';
		if(showtype == 'click') {
			var seccode_html = '<input type="text" name="seccode" class="txt" default="验证码" style="display:block;width:50px;" size="6" /><img title="点击更换" src="" style="display:none;position:absolute;cursor:pointer;" />';
		} else {
			var seccode_html = '<img title="点击更换" src="" style="cursor:pointer;" /><input type="text" name="seccode" class="txt" default="验证码" style="display:block;width:50px;" size="6" />';
		}

		$this.append(seccode_html);
		$img = $("img", $this);
		$img.css({'border':'1px solid #bebebe','padding':'2px','background':'#fff'});
		$input = $("input", $this);
		$img.live('click', function() {
			$img.attr('src', 'index.php?m=user&a=seccode&random=' + Math.random());
			$img.load(function() {
				$(this).show()
			});
		});
		if(showtype == 'click') {
			$input.live('focus', function() {
				if(!$img.attr('src')) {
					$img.trigger('click');
				}
				$("img", $this).show('fast');
	
			});
			$("body").live('click', function() {
				$img.hide();
			});
		} else {
			$img.trigger('click');
		}
	});

	//note 表格行换色
	var changecolor = $("table[changecolor] tr");
	changecolor.live('mouseover', function() {
		if($(this).attr('trclick') != "true") {
			$(this).css('background', '#eee');
		}
	}).live('mouseout', function() {
		if($(this).attr('trclick') != "true") {
			$(this).css('background', '#ffffff');
		}
	}).live('click', function() {
		if($(this).attr('trclick') == "true") {
			$(this).attr('trclick', "false");
			$(this).css('background', '#ffffff')
		} else {
			$(this).attr('trclick', "true");
			$(this).css('background', '#c9eb6e')
		}
	});

	//note ajax加载操作
	var ajaxload = $("a.ajaxload");
	ajaxload.each(function() {
		var conf = [];
		conf['href'] = $(this).attr('href')+'&in_ajax=yes&'+Math.random();
		conf['centerOnScroll'] = true;
		var width = $(this).attr('winwidth');
		if(width) {
			conf['width'] = width;
			conf['autoDimensions'] = false;
		}
		var height = $(this).attr('winheight');
		if(height) {
			conf['height'] = height;
			conf['autoDimensions'] = false;
		}
		$(this).fancybox(conf);
	});

	//note 输入框提示
	$inputs = $("input[default], textarea[default]");
	$inputs.each(function() {
		//在是输入框上加浮动span *** 2011.3.15 ***
		var inputObject = $(this);
		var spanAfterInput = '<div>' + inputObject.attr('default') + '</div>';
		if(inputObject.is(":hidden")) {
			inputObject.show();
			var inputWeight = -$(this).height();
			var inputWidth = '150px';
			inputObject.hide();
		} else {
			var inputWeight = -$(this).height();
		}
		inputObject.after(spanAfterInput);
		inputObject.next().css({'color':'#BEBEBE','position':'relative','top':inputWeight,'left':'0px', 'height':'0px','text-indent':'5px','line-height':'10px'}).hide();
		inputObject.focus(function(){
			inputObject.next().hide();
		});

		inputObject.next().click(function(){
			inputObject.trigger("focus");
		});
		if(inputObject.val()) {
			inputObject.next().hide();
		} else {
			inputObject.next().show();
		}
		inputObject.blur(function(){
			if(!inputObject.val()){
				inputObject.next().show();
			}
		})
		inputObject.removeAttr('default');
	});

	//note 输入框提示title  *** 2011.3.15 ***
	$getTitleInInput = $("input[title], select[title], textarea[title]");
	$getTitleInInput.each(function() {
		var o = $(this);
		var tips = o.attr('title');
		o.poshytip({
			'content':function() {
				return tips;
			},
			'showOn':'focus',
			'alignTo': 'target',
			'alignX': 'inner-left',
			'offsetX': 0,
			'offsetY': 5
		});
		o.removeAttr('title');
	});

	//note tab 切换
	$("[tab='enabled']").each(function() {
		tab_enable($(this));
	});

	//note Checkbox 全选
	$(".checkall").toggle(function() {
		var trgname = $(this).attr('rel');
		$(":checkbox[name^='"+trgname+"']").attr('checked', true);
	}, function() {
		var trgname = $(this).attr('rel');
		$(":checkbox[name^='"+trgname+"']").attr('checked', false);
	});
	//note Checkbox 反选
	$(".checkreverse").click(function() {
		var trgname = $(this).attr('rel');
		$(":checkbox[name^='"+trgname+"']").each(function() {
			$(this).attr('checked', $(this).attr('checked') ? false : true);
		});
	});

	//note Checkbox 反选
	$(".checkcancel").live('click', function() {
		var trgname = $(this).attr('rel');
		$(":checkbox[name^='"+trgname+"']").attr('checked', false);
	});
}


function postFormByAjax(formObj) {
	formObj = $(formObj);
	formObj.attr('title', '');
	var btn_name = formObj.find("input[type='submit']").attr('name');
	var formAction = formObj.attr('action')+"&"+btn_name+"=yes&in_ajax=1&datatype=json&"+Math.random();
	var postData = formObj.serialize();
	$.post(formAction, postData, function(data) {
		if(data) {
			if(data.status) {//note 成功
				if(data.forward) {
					if(data.redirect) {
						window.location.href = data.forward;
						return;
					} else {
						var content = '<h3>'+data.msg+'</h3>';
						content += '<div class="msg_forward"><a href="'+data.forward+'">如果您的浏览器没有自动跳转，请点击此链接</a></div>';
						formObj.fancybox({
							'content' : content
						});
						formObj.trigger('click');
						setTimeout("window.location.href ='"+data.forward+"';", 4000);
					}
				} else {
					alert(data.msg);
					$.fancybox.close();
				}
			} else {
				alert(data.msg);
				if(data.value && data['value']['inputname']) {
					if(data['value']['inputname'] == 'seccode') {
						$("[name='"+data['value']['inputname']+"']", formObj).val('');
					}
					$("[name='"+data['value']['inputname']+"']", formObj).trigger('focus');
				}
			}
		} else {
			alert('请求错误，请重试');
		}
	}, 'json');
	return false;
}

$(function() {
	stonephpjsinit();
	$("body").ajaxStart(function() {
		$("#ajaxloading").show();
	}).ajaxStop(function() {
		$("#ajaxloading").hide();
		stonephpjsinit();
	});
	//note 导航条处理
	$tempnavigation = $("#tempnavigation");
	if($tempnavigation.size()) {
		$("#navigation").addClass("navigation");
		$("#navigation").html($tempnavigation.html());
		$tempnavigation.remove();
	}

	//note 根据URL参数值自动加class
	$("[autoselect]").each(function() {
		$this = $(this);
		var conf = $this.attr('autoselect').split("|");
		var v = getVars(conf[0]);
		if(!v) return;
		$this.find(conf[1]).each(function() {
			var rel = $(this).attr('rel');
			if((conf[0] == 'cid' || conf[0] == 'aid') && rel && v.indexOf(rel) == 0) {
				$(this).addClass(conf[2]);
			} else if(rel == v) {
				$(this).addClass(conf[2]);
			}
		})
	});

});

;(function($) {
	$.fn.extend({
		"editgrid" : function(conf) {
			var obj = $(this);
			obj.find('tr').each(function(i) {
				if(i) {
					var item_id = $(this).find('td').eq(conf.id).html();
					$(this).find('td').each(function(j) {
						var td = $(this);
						$.each(conf.grid, function(key, val) {
							if(j == key) {
								td.css('background', 'url(static/image/girdbtbg.gif) no-repeat left bottom #ffffff');
								if(typeof(val) == 'object') {
									if(val.type == 'select') {
										var orig_html = td.html();
										td.html(val.range[orig_html]);
									}
								}
								td.dblclick(function() {
									if(td.html() != td.text()) return;
									var orig_html = td.html();
									if(typeof(val) == 'string') {
										var input_width = td.innerWidth() - 10;
										var input_html = '<input type="text" class="txt" style="width:'+input_width+'px;" name="value" value="'+td.html()+'" />';
										td.html(input_html);
										td.find('input').trigger('focus').blur(function() {
											var real_value = $(this).val();
											if(orig_html == real_value) {
												td.html(real_value);
												return;
											}
											var postdata = {
													'itemid':item_id,
													'val':val,
													'value':real_value,
													'formhash':conf.formhash,
													'modifysubmit':'yes',
													'in_ajax':1,
													'datatype':'json'
													};
											$.post(conf.baseurl, postdata, function(ret) {
												if(ret.status == 1) {
													td.html(real_value);
												} else {
													alert(ret.msg);
													td.find('input').trigger('focus');
												}
											}, 'json');
										});
									} else if(typeof(val) == 'object') {
										if(val.type == 'select') {
											var input_html = '<select name="value">';
											$.each(val.range, function(op, va) {
												input_html += '<option value="'+op+'"'+(orig_html == va ? ' selected="selected"' : '')+'>'+va+'</option>';
											});
											input_html += '</select>';
											td.html(input_html);
											td.find('select').change(function() {
												var real_value = $(this).val();
												var real_txt = $(":selected", this).html();
												if(orig_html == real_txt) {
													td.html(real_txt);
													return;
												}
												var postdata = {
														'itemid':item_id,
														'val':val.val,
														'value':real_value,
														'formhash':conf.formhash,
														'modifysubmit':'yes',
														'in_ajax':1,
														'datatype':'json'
														};
												$.post(conf.baseurl, postdata, function(ret) {
													if(ret.status == 1) {
														td.html(real_txt);
													} else {
														alert(ret.msg);
														td.find('input').trigger('focus');
													}
												}, 'json');
											}).blur(function() {
												td.html(orig_html);
											});
										}
									}
								});
							}
						});
					});
				}
			});
		}
	});
})(jQuery);

/**
* EasyDrag 1.5 - Drag & Drop jQuery Plug-in
*
* Thanks for the community that is helping the improvement
* of this little piece of code.
*
* For usage instructions please visit http://fromvega.com/scripts
*/

;(function($){

	// to track if the mouse button is pressed
	var isMouseDown    = false;

	// to track the current element being dragged
	var currentElement = null;

	// callback holders
	var dropCallbacks = {};
	var dragCallbacks = {};

	// bubbling status
	var bubblings = {};

	// global position records
	var lastMouseX;
	var lastMouseY;
	var lastElemTop;
	var lastElemLeft;

	// track element dragStatus
	var dragStatus = {};

	// if user is holding any handle or not
	var holdingHandler = false;

	// returns the mouse (cursor) current position
	$.getMousePosition = function(e){
		var posx = 0;
		var posy = 0;

		if (!e) var e = window.event;

		if (e.pageX || e.pageY) {
			posx = e.pageX;
			posy = e.pageY;
		}
		else if (e.clientX || e.clientY) {
			posx = e.clientX + document.body.scrollLeft + document.documentElement.scrollLeft;
			posy = e.clientY + document.body.scrollTop  + document.documentElement.scrollTop;
		}

		return { 'x': posx, 'y': posy };
	};

	// updates the position of the current element being dragged
	$.updatePosition = function(e) {
		var pos = $.getMousePosition(e);

		var spanX = (pos.x - lastMouseX);
		var spanY = (pos.y - lastMouseY);

		$(currentElement).css("top",  (lastElemTop + spanY));
		$(currentElement).css("left", (lastElemLeft + spanX));
	};

	// when the mouse is moved while the mouse button is pressed
	$(document).mousemove(function(e){
		if(isMouseDown && dragStatus[currentElement.id] != 'false'){
			// update the position and call the registered function
			$.updatePosition(e);
			if(dragCallbacks[currentElement.id] != undefined){
				dragCallbacks[currentElement.id](e, currentElement);
			}

			return false;
		}
	});

	// when the mouse button is released
	$(document).mouseup(function(e){
		if(isMouseDown && dragStatus[currentElement.id] != 'false'){
			isMouseDown = false;
			if(dropCallbacks[currentElement.id] != undefined){
				dropCallbacks[currentElement.id](e, currentElement);
			}

			return false;
		}
	});

	// register the function to be called while an element is being dragged
	$.fn.ondrag = function(callback){
		return this.each(function(){
			dragCallbacks[this.id] = callback;
		});
	};

	// register the function to be called when an element is dropped
	$.fn.ondrop = function(callback){
		return this.each(function(){
			dropCallbacks[this.id] = callback;
		});
	};

	// disable the dragging feature for the element
	$.fn.dragOff = function(){
		return this.each(function(){
			dragStatus[this.id] = 'off';
		});
	};

	// enable the dragging feature for the element
	$.fn.dragOn = function(){
		return this.each(function(){
			dragStatus[this.id] = 'on';
		});
	};

	// set a child element as a handler
	$.fn.setHandler = function(handlerId){
		return this.each(function(){
			var draggable = this;

			// enable event bubbling so the user can reach the handle
			bubblings[this.id] = true;

			// reset cursor style
			$(draggable).css("cursor", "");

			// set current drag status
			dragStatus[draggable.id] = "handler";

			// change handle cursor type
			$("#"+handlerId).css("cursor", "move");

			// bind event handler
			$("#"+handlerId).mousedown(function(e){
				holdingHandler = true;
				$(draggable).trigger('mousedown', e);
			});

			// bind event handler
			$("#"+handlerId).mouseup(function(e){
				holdingHandler = false;
			});
		});
	}

	// set an element as draggable - allowBubbling enables/disables event bubbling
	$.fn.easydrag = function(allowBubbling){

		return this.each(function(){

			// if no id is defined assign a unique one
			if(undefined == this.id || !this.id.length) this.id = "easydrag"+(new Date().getTime());

			// save event bubbling status
			bubblings[this.id] = allowBubbling ? true : false;

			// set dragStatus
			dragStatus[this.id] = "on";

			// change the mouse pointer
			$(this).css("cursor", "move");

			// when an element receives a mouse press
			$(this).mousedown(function(e){

				// just when "on" or "handler"
				if((dragStatus[this.id] == "off") || (dragStatus[this.id] == "handler" && !holdingHandler))
					return bubblings[this.id];

				// set it as absolute positioned
				$(this).css("position", "absolute");

				// set z-index
				$(this).css("z-index", parseInt( new Date().getTime()/1000 ));

				// update track variables
				isMouseDown    = true;
				currentElement = this;

				// retrieve positioning properties
				var pos    = $.getMousePosition(e);
				lastMouseX = pos.x;
				lastMouseY = pos.y;

				lastElemTop  = this.offsetTop;
				lastElemLeft = this.offsetLeft;

				$.updatePosition(e);

				return bubblings[this.id];
			});
		});
	};

})(jQuery);


function synlogin() {
		
}

//note 自动上传图片，并显示

function autouploadimg(action, $file, $show, $showipt, uptype) {
	var form_html = '<form id="autouploadform" method="post" target="autouploadframe" action="'+action+'&datatype=json" enctype="multipart/form-data" style="display:none;"></form>';
	var iframe_html = '<iframe id="autouploadframe" name="autouploadframe" width="0" height="0"></iframe>';
	$("body").append(form_html);
	$file.change(function() {
		$("body").append(iframe_html);
		var $ifmo = $("#autouploadframe");
		$ifmo.load(function() {
			var strText=$($ifmo[0].contentWindow.document.body).text(),data=Object;
			try{eval("data=" + strText);}catch(ex){};
			if(data.err!=undefined&&data.msg!=undefined) {
				$showipt.val(data.file);
				$.getJSON('index.php?m=file&a=viewimg&fid='+data.file+'&datatype=json', function(data) {
					if(data.status == 1 && data.forward) {
						if(!uptype || uptype == 'image') {
							$show.html('<img src="'+data.forward+'" width="'+$show.attr('imgwidth')+'" height="'+$show.attr('imgheight')+'" />');
						} else {
							$show.html('<a href="'+data.forward+'">'+data.value['filename']+'</a>');
						}
					} else {
						alert(data.msg);
					}
				});
			} else {
				alert(data.msg);
			}
			setTimeout(function(){
				 $("#autouploadframe").remove();
			}, 1000);
		});
		var $fomo = $("#autouploadform");
		$fomo.html('');
		$file.attr('name', 'filedata');
		$parent = $file.parent();
		$fomo.append($file);
		$fomo.trigger('submit');
		$parent.append($file);
	});
}

//note 提示信息函数
var promptFirst=true;
function showprompt(content) {
	if(promptFirst==true){
		var temp_float=new String;
		temp_float="<div id=\"promptBox\" class=\"promptBox\">";
		temp_float+="<div id=\"promptBox_title\" class=\"title\"><h4>提示信息</h4><span title=\"点击关闭\">x</span></div>";
		temp_float+="<div class=\"content\"></div>";
		temp_float+="</div>";
		$("body").append(temp_float);
		$hideselect = $("select:visible");
		$("#promptBox").easydrag();
		$("#promptBox").setHandler('promptBox_title');
		promptFirst=false;
		$("#promptBox .title span").click(function() {
			$("#promptBox").hide();
			$(".seccode").find("img").attr('src', 'index.php?m=user&a=seccode&random=' + Math.random());
		});
	}

	contentType=content.substring(0,content.indexOf(":"));
	content=content.substring(content.indexOf(":")+1,content.length);
	switch(contentType){
		case "url":
		var content_array=content.split("?");
		$.ajax({
			type:content_array[0],
			url:content_array[1],
			data:content_array[2],
			error:function(){
				$("#promptBox .content").html("error...");
				return false;
			},
			success:function(html){
				$("#promptBox .content").html(html);
				return false;
			}
		});
		break;
		case "text":
		$("#promptBox .content").html(content);
		break;
		case "id":
		$("#promptBox .content").html($("#"+content+"").html());
		break;
		case "iframe":
		$("#promptBox .content").html("<iframe src=\""+content+"\" width=\"100%\" height=\""+(parseInt(height)-30)+"px"+"\" scrolling=\"auto\" frameborder=\"0\" marginheight=\"0\" marginwidth=\"0\"></iframe>");
	}
	var winheight = $.browser.msie ? document.documentElement.clientHeight : window.innerHeight;
	var top = ((winheight - 100)/4 + $(document).scrollTop())+"px";
	var width = '300px';
	$("#promptBox").css({display:"block",'left':(($(document).width())/2-(parseInt(width)/2))+"px",'top':top,'width':width,'height':'auto','z-index':13,'overflow':'hidden'});
	$("#promptBox .content").css('max-height', $(document).height() - 60);
	$("#promptBox .content").html('Loading…………');
	return false;
}

function promptclose() {
	$("#promptBox .title span").trigger('click');
}

//note 前台特效
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 = $(this.obj + " li").size();
	this.n =0;
	this.j =0;
	var t;
	this.factory = function(){
		$(this.obj).css({position:"relative",zIndex:"0",margin:"0",padding:"0",width:this.config.width,height:this.config.height,overflow:"hidden"})
		$(this.obj).prepend("<div style='position:absolute;z-index:20;right:"+this.config.right+";bottom:"+this.config.bottom+"'></div>");
		$(this.obj + " li").css({width:"100%",height:"100%",overflow:"hidden"}).each(function(i){$(_this.obj + " div").append("<a>"+(i+1)+"</a>")});
		$(this.obj + " img").css({border:"none",width:"100%",height:"100%"})
		this.resetclass(this.obj + " div a",0);
		$(this.obj + " p").each(function(i){			
			$(this).parent().append($(this).clone(true));
			$(this).html("");
			$(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"})
			$(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){$(this).hide().next().hide()}
		});
		this.slide();
		this.addhover();
		t = setInterval(this.autoplay,this.config.time);
	}
	
	this.slide = function(){
		$(this.obj + " div a").click(function(){
			_this.j = $(this).text() - 1;
			_this.n = _this.j;
			if (_this.j >= _this.count){return;}
			$(_this.obj + " li").hide();
			$(_this.obj + " p").hide();
			$(_this.obj + " li").eq(_this.j).fadeIn("slow");
			$(_this.obj + " li").eq(_this.j).find("p").show();
			_this.resetclass(_this.obj + " div a",_this.j);
		});
		$(this.obj + " div a").mouseover(function(){
			$(this).trigger('click');
		});
	}
	this.addhover = function(){
		$(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;
		$(_this.obj + " div a").eq(_this.n).trigger('click');
	}
	
	this.resetclass =function(obj,i){
		$(obj).css({float:"left",marginRight:"3px",width:"15px",height:"14px",lineHeight:"15px",textAlign:"center",fontWeight:"800",fontSize:"12px",color:"#000",background:"#FFFFFF",cursor:"pointer"});
		$(obj).eq(i).css({color:"#FFFFFF",background:"#FF7D01",textDecoration:"none"});
	}
	this.factory();
}
