﻿//livequery插件
(function($) {
	$.extend($.fn, {
		livequery: function(type, fn, fn2) {
			var self = this, q;
			if ($.isFunction(type))
				fn2 = fn, fn = type, type = undefined;
			$.each( $.livequery.queries, function(i, query) {
				if ( self.selector == query.selector && self.context == query.context &&
					type == query.type && (!fn || fn.$lqguid == query.fn.$lqguid) && (!fn2 || fn2.$lqguid == query.fn2.$lqguid) )
						return (q = query) && false;
			});
			q = q || new $.livequery(this.selector, this.context, type, fn, fn2);
			q.stopped = false;
			$.livequery.run( q.id );
			return this;
		},
		expire: function(type, fn, fn2) {
			var self = this;
			if ($.isFunction(type))
				fn2 = fn, fn = type, type = undefined;
			$.each( $.livequery.queries, function(i, query) {
				if ( self.selector == query.selector && self.context == query.context && 
					(!type || type == query.type) && (!fn || fn.$lqguid == query.fn.$lqguid) && (!fn2 || fn2.$lqguid == query.fn2.$lqguid) && !this.stopped )
						$.livequery.stop(query.id);
			});
			return this;
		}
	});
	$.livequery = function(selector, context, type, fn, fn2) {
		this.selector = selector;
		this.context  = context || document;
		this.type     = type;
		this.fn       = fn;
		this.fn2      = fn2;
		this.elements = [];
		this.stopped  = false;
		this.id = $.livequery.queries.push(this)-1;
		fn.$lqguid = fn.$lqguid || $.livequery.guid++;
		if (fn2) fn2.$lqguid = fn2.$lqguid || $.livequery.guid++;
		return this;
	};
	$.livequery.prototype = {
		stop: function() {
			var query = this;
			if ( this.type )
				this.elements.unbind(this.type, this.fn);
			else if (this.fn2)
				this.elements.each(function(i, el) {
					query.fn2.apply(el);
				});
			this.elements = [];
			this.stopped = true;
		},
		run: function() {
			if ( this.stopped ) return;
			var query = this;
			var oEls = this.elements,
				els  = $(this.selector, this.context),
				nEls = els.not(oEls);
			this.elements = els;
			if (this.type) {
				nEls.bind(this.type, this.fn);
				if (oEls.length > 0)
					$.each(oEls, function(i, el) {
						if ( $.inArray(el, els) < 0 )
							$.event.remove(el, query.type, query.fn);
					});
			}
			else {
				nEls.each(function() {
					query.fn.apply(this);
				});
				if ( this.fn2 && oEls.length > 0 )
					$.each(oEls, function(i, el) {
						if ( $.inArray(el, els) < 0 )
							query.fn2.apply(el);
					});
			}
		}
	};
	$.extend($.livequery, {
		guid: 0,
		queries: [],
		queue: [],
		running: false,
		timeout: null,
		checkQueue: function() {
			if ( $.livequery.running && $.livequery.queue.length ) {
				var length = $.livequery.queue.length;
				while ( length-- )
					$.livequery.queries[ $.livequery.queue.shift() ].run();
			}
		},
		pause: function() {
			$.livequery.running = false;
		},
		play: function() {
			$.livequery.running = true;
			$.livequery.run();
		},
		registerPlugin: function() {
			$.each( arguments, function(i,n) {
				if (!$.fn[n]) return;
				var old = $.fn[n];
				$.fn[n] = function() {
					var r = old.apply(this, arguments);
					$.livequery.run();
					return r;
				}
			});
		},
		run: function(id) {
			if (id != undefined) {
				if ( $.inArray(id, $.livequery.queue) < 0 )
					$.livequery.queue.push( id );
			}
			else
				$.each( $.livequery.queries, function(id) {
					if ( $.inArray(id, $.livequery.queue) < 0 )
						$.livequery.queue.push( id );
				});
			if ($.livequery.timeout) clearTimeout($.livequery.timeout);
			$.livequery.timeout = setTimeout($.livequery.checkQueue, 20);
		},
		stop: function(id) {
			if (id != undefined)
				$.livequery.queries[ id ].stop();
			else
				$.each( $.livequery.queries, function(id) {
					$.livequery.queries[ id ].stop();
				});
		}
	});
	$.livequery.registerPlugin('append', 'prepend', 'after', 'before', 'wrap', 'attr', 'removeAttr', 'addClass', 'removeClass', 'toggleClass', 'empty', 'remove');
	$(function() { $.livequery.play(); });
	var init = $.prototype.init;
	$.prototype.init = function(a,c) {
		var r = init.apply(this, arguments);
		if (a && a.selector)
			r.context = a.context, r.selector = a.selector;
		if ( typeof a == 'string' )
			r.context = c || document, r.selector = a;
		return r;
	};
	$.prototype.init.prototype = $.prototype;
})(jQuery);
//目录树插件
(function($) {

	// classes used by the plugin
	// need to be styled via external stylesheet, see first example
	var CLASSES = {
		open: "open",
		closed: "closed",
		expandable: "expandable",
		collapsable: "collapsable",
		lastCollapsable: "lastCollapsable",
		lastExpandable: "lastExpandable",
		last: "last",
		hitarea: "hitarea"
	};
	
	$.extend($.fn, {
		swapClass: function(c1, c2) {
			return this.each(function() {
				var $this = $(this);
				if ( $.className.has(this, c1) )
					$this.removeClass(c1).addClass(c2);
				else if ( $.className.has(this, c2) )
					$this.removeClass(c2).addClass(c1);
			});
		},
		replaceClass: function(c1, c2) {
			return this.each(function() {
				var $this = $(this);
				if ( $.className.has(this, c1) )
					$this.removeClass(c1).addClass(c2);
			});
		},
		hoverClass: function(className) {
			className = className || "hover";
			return this.hover(function() {
				$(this).addClass(className);
			}, function() {
				$(this).removeClass(className);
			});
		},
		heightToggle: function(animated, callback) {
			animated ?
				this.animate({ height: "toggle" }, animated, callback) :
				this.each(function(){
					jQuery(this)[ jQuery(this).is(":hidden") ? "show" : "hide" ]();
					if(callback)
						callback.apply(this, arguments);
				});
		},
		heightHide: function(animated, callback) {
			if (animated) {
				this.animate({ height: "hide" }, animated, callback)
			} else {
				this.hide();
				if (callback)
					this.each(callback);				
			}
		},
		prepareBranches: function(settings) {
			// mark last tree items
			this.filter(":last-child").addClass(CLASSES.last);
			// collapse whole tree, or only those marked as closed, anyway except those marked as open
			this.filter((settings.collapsed ? "" : "." + CLASSES.closed) + ":not(." + CLASSES.open + ")").find(">ul").hide();
			// return all items with sublists
			return this.filter(":has(>ul)");
		},
		applyClasses: function(settings, toggler) {
			this.filter(":has(>ul):not(:has(>a))").find(">span").click(function(event) {
				if ( this == event.target ) {
					toggler.apply($(this).next());
				}
			}).add( $("a", this) ).hoverClass();
			
			// handle closed ones first
			this.filter(":has(>ul:hidden)")
					.addClass(CLASSES.expandable)
					.replaceClass(CLASSES.last, CLASSES.lastExpandable);
					
			// handle open ones
			this.not(":has(>ul:hidden)")
					.addClass(CLASSES.collapsable)
					.replaceClass(CLASSES.last, CLASSES.lastCollapsable);
					
            // create hitarea
			this.prepend("<div class=\"" + CLASSES.hitarea + "\"/>")
				.find("div." + CLASSES.hitarea).click( toggler )
		},
		treeview: function(settings) {
			
			// currently no defaults necessary, all implicit
			settings = $.extend({}, settings);
			
			if (settings.add) {
				return this.trigger("add", [settings.add]);
			}
			
			if (settings.toggle ) {
				var callback = settings.toggle;
				settings.toggle = function() {
					return callback.apply($(this).parent()[0], arguments);
				}
			}
		
			// factory for treecontroller
			function treeController(tree, control) {
				// factory for click handlers
				function handler(filter) {
					return function() {
						// reuse toggle event handler, applying the elements to toggle
						// start searching for all hitareas
						toggler.apply( $("div." + CLASSES.hitarea, tree).filter(function() {
							// for plain toggle, no filter is provided, otherwise we need to check the parent element
							return filter ? $(this).parent("." + filter).length : true;
						}) );
						return false;
					}
				}
				// click on first element to collapse tree
				$(":eq(0)", control).click( handler(CLASSES.collapsable) );
				// click on second to expand tree
				$(":eq(1)", control).click( handler(CLASSES.expandable) );
				// click on third to toggle tree
				$(":eq(2)", control).click( handler() ); 
			}
		
			// handle toggle event
			function toggler() {
				// this refers to hitareas, we need to find the parent lis first
				$(this).parent()
					// swap classes
					.swapClass( CLASSES.collapsable, CLASSES.expandable )
					.swapClass( CLASSES.lastCollapsable, CLASSES.lastExpandable )
					// find child lists
					.find( ">ul" )
					// toggle them
					.heightToggle( settings.animated, settings.toggle );
				if ( settings.unique ) {
					$(this).parent()
						.siblings()
						.replaceClass( CLASSES.collapsable, CLASSES.expandable )
						.replaceClass( CLASSES.lastCollapsable, CLASSES.lastExpandable )
						.find( ">ul" )
						.heightHide( settings.animated, settings.toggle );
				}
			}
			
			function serialize() {
				function binary(arg) {
					return arg ? 1 : 0;
				}
				var data = [];
				branches.each(function(i, e) {
					data[i] = $(e).is(":has(>ul:visible)") ? 1 : 0;
				});
				$.cookie("treeview", data.join("") );
			}
			
			function deserialize() {
				var stored = $.cookie("treeview");
				if ( stored ) {
					var data = stored.split("");
					branches.each(function(i, e) {
						$(e).find(">ul")[ parseInt(data[i]) ? "show" : "hide" ]();
					});
				}
			}
			
			// add treeview class to activate styles
			this.addClass("treeview");
			
			// prepare branches and find all tree items with child lists
			var branches = this.find("li").prepareBranches(settings);
			
			switch(settings.persist) {
			case "cookie":
				var toggleCallback = settings.toggle;
				settings.toggle = function() {
					serialize();
					if (toggleCallback) {
						toggleCallback.apply(this, arguments);
					}
				};
				deserialize();
				break;
			case "location":
				var current = this.find("a").filter(function() { return this.href == location.href; });
				if ( current.length ) {
					current.addClass("selected").parents("ul, li").add( current.next() ).show();
				}
				break;
			}
			
			branches.applyClasses(settings, toggler);
				
			// if control option is set, create the treecontroller
			if ( settings.control )
				treeController(this, settings.control);
			
			return this.bind("add", function(event, branches) {
				$(branches).prev().removeClass(CLASSES.last).removeClass(CLASSES.lastCollapsable).removeClass(CLASSES.lastExpandable);
				$(branches).find("li").andSelf().prepareBranches(settings).applyClasses(settings, toggler);
			});
		}
	});
	
	// provide backwards compability
	$.fn.Treeview = $.fn.treeview;
})(jQuery);
//层拖动插件
(function($){
	var dw=document.documentElement.clientWidth;
	var dh=document.documentElement.clientHeight;
	$.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});
				//if(M.X+v.pageX-M.pX<0)E.css('left',0);
				//if(M.Y+v.pageY-M.pY<0)E.css('top',0);
				//if(M.X+v.pageX-M.pX+M.W>dw)E.css('left',dw-M.W);
				//if(M.Y+v.pageY-M.pY+M.H>dh)E.css('top',dh-M.H);
			}else{
				E.css({width:Math.max(v.pageX-M.pX+M.W,0),height:Math.max(v.pageY-M.pY+M.H,0)});
			};
			return false;
		},
		stop:function(){
			E.children().show();
			E.css('opacity',1);
			//E.redrawShadow();
			$().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,W:f('width')||E[0].scrollWidth||0,H:f('height')||E[0].scrollHeight||0,pX:v.pageX,pY:v.pageY,k:d.k,o:E.css('opacity')};
				E.children().not(h).hide();
				$('.select_box').removeShadow().remove();
				//E.removeShadow();
				E.css({opacity:0.5,width:M.W,height:M.H});
				$().mousemove($.jqDnR.drag).mouseup($.jqDnR.stop);
				return false;
			});
		});
	},
	f=function(k){
		return parseInt(E.css(k))||false;
	};
})(jQuery);
//阴影插件
(function($){
	var dropShadowZindex = 1;  //z-index counter
	$.fn.dropShadow = function(options)
	{
		var opt = $.extend({
			left: 4,
			top: 4,
			blur: 2,
			opacity: .5,
			color: "black",
			swap: false
			}, options);
		var jShadows = $([]);  //empty jQuery collection
		this.not(".dropShadow").each(function()
		{
			var jthis = $(this);
			var shadows = [];
			var blur = (opt.blur <= 0) ? 0 : opt.blur;
			var opacity = (blur == 0) ? opt.opacity : opt.opacity / (blur * 8);
			var zOriginal = (opt.swap) ? dropShadowZindex : dropShadowZindex + 1;
			var zShadow = (opt.swap) ? dropShadowZindex + 1 : dropShadowZindex;
			var shadowId;
			if (this.id) {
				shadowId = this.id + "_dropShadow";
			}
			else {
				shadowId = "ds" + (1 + Math.floor(9999 * Math.random()));
			}
			$.data(this, "shadowId", shadowId); //store id in expando
			$.data(this, "shadowOptions", options); //store options in expando
			jthis
				.attr("shadowId", shadowId)
				.css("zIndex", zOriginal);
			if (jthis.css("position") != "absolute") {
				jthis.css({
					position: "relative",
					zoom: 1 //for IE layout
				});
			}
			bgColor = jthis.css("backgroundColor");
			if (bgColor == "rgba(0, 0, 0, 0)") bgColor = "transparent";  //Safari
			if (bgColor != "transparent" || jthis.css("backgroundImage") != "none" 
					|| this.nodeName == "SELECT" 
					|| this.nodeName == "INPUT"
					|| this.nodeName == "TEXTAREA") {		
				shadows[0] = $("<div></div>")
					.css("background", opt.color);								
			}
			else {
				shadows[0] = jthis
					.clone()
					.removeAttr("id")
					.removeAttr("name")
					.removeAttr("shadowId")
					.css("color", opt.color);
			}
			shadows[0]
				.addClass("dropShadow")
				.css({
					height: jthis.outerHeight(),
					left: blur,
					opacity: opacity,
					position: "absolute",
					top: blur,
					width: jthis.outerWidth(),
					zIndex: zShadow
				});
			var layers = (8 * blur) + 1;
			for (i = 1; i < layers; i++) {
				shadows[i] = shadows[0].clone();
			}
			var i = 1;			
			var j = blur;
			while (j > 0) {
				shadows[i].css({left: j * 2, top: 0});           //top
				shadows[i + 1].css({left: j * 4, top: j * 2});   //right
				shadows[i + 2].css({left: j * 2, top: j * 4});   //bottom
				shadows[i + 3].css({left: 0, top: j * 2});       //left
				shadows[i + 4].css({left: j * 3, top: j});       //top-right
				shadows[i + 5].css({left: j * 3, top: j * 3});   //bottom-right
				shadows[i + 6].css({left: j, top: j * 3});       //bottom-left
				shadows[i + 7].css({left: j, top: j});           //top-left
				i += 8;
				j--;
			}
			var divShadow = $("<div></div>")
				.attr("id", shadowId) 
				.addClass("dropShadow")
				.css({
					left: jthis.position().left + opt.left - blur,
					marginTop: jthis.css("marginTop"),
					marginRight: jthis.css("marginRight"),
					marginBottom: jthis.css("marginBottom"),
					marginLeft: jthis.css("marginLeft"),
					position: "absolute",
					top: jthis.position().top + opt.top - blur,
					zIndex: zShadow
				});
			for (i = 0; i < layers; i++) {
				divShadow.append(shadows[i]);
			}
			jthis.after(divShadow);
			jShadows = jShadows.add(divShadow);
			$(window).resize(function()
			{
				try {
					divShadow.css({
						left: jthis.position().left + opt.left - blur,
						top: jthis.position().top + opt.top - blur
					});
				}
				catch(e){}
			});
			dropShadowZindex += 2;
		});
		return this.pushStack(jShadows);
	};
	$.fn.redrawShadow = function()
	{
		this.removeShadow();
		return this.each(function()
		{
			var shadowOptions = $.data(this, "shadowOptions");
			$(this).dropShadow(shadowOptions);
		});
	};
	$.fn.removeShadow = function()
	{
		return this.each(function()
		{
			var shadowId = $(this).shadowId();
			$("div#" + shadowId).remove();
		});
	};
	$.fn.shadowId = function()
	{
		return $.data(this[0], "shadowId");
	};
	$(function()  
	{
		var noPrint = "<style type='text/css' media='print'>";
		noPrint += ".dropShadow{visibility:hidden;}</style>";
		$("head").append(noPrint);
	});
})(jQuery);
//FCKEditor插件
if(window.jQuery) (function($){
$.extend($, {
 fck:{
  waitFor:1,// in seconds, how long should we wait for the script to load?
  config: { Config: {} }, // default configuration
  path: '/fckeditor/', // default path to FCKEditor directory
  editors: [], // array of editor instances
  loaded: false, // flag indicating whether FCK script is loaded
  intercepted: null, // variable to store intercepted method(s)
  content: function(i, v){
   try{
    var x = FCKeditorAPI.GetInstance(i);
    if(v) x.SetHTML(v);
    return x.GetXHTML(true);
   }catch(e){ return ''; };
  }, // fck.content function
  setHTML: function(i, v){
   if(typeof i=='object'){
    v = i.html;
    i = i.InstanceName || i.instance;
   };
   return $.fck.content(i, v);
  },
  update: function(){
   var e = $.fck.editors;
   for(var i=0;i<e.length;i++){
    var ta = e[i].textarea;
    var ht = $.fck.content(e[i].InstanceName);
    ta.val(ht).filter('textarea').text(ht);
    if(ht!=ta.val())
     alert('Critical error in FCK plugin:'+'\n'+'Unable to update form data');
   }
  }, // fck.update
  clean: function(){
			var a = $.fck.editors, b = {}, c = [];
			$.each(a, function(){ if($('#'+this.InstanceName).length>0) b[this.InstanceName] = this; });
			$.each(b, function(){ c[c.length] = this; });
			$.fck.editors = c;
  }, // fck.clean
  create: function(option){
   var o = $.extend({}/* new object */, $.fck.config || {}, option || {});
   $.extend(o, {
    selector: (o.selector || 'textarea.fck, textarea.fckeditor'),
    BasePath: (o.path || o.BasePath || $.fck.path)
   });
   var e = $(o.e);
   if(!e.length>0) e = $(o.selector);
   if(!e.length>0) return;
			o = $.extend({}, o,
				($.meta ? e.data()/*NEW metadata plugin*/ :
				($.metadata ? e.metadata()/*OLD metadata plugin*/ : 
				null/*metadata plugin not available*/)) || {}
			);
   if(!$.fck.loading && !$.fck.loaded){
    $.fck.loading = true;
    $.getScript(
     o.BasePath+'fckeditor.js',
     function(){ $.fck.loaded = true; }
    );
   };
   var start = function(){//e){
    if($.fck.loaded){
     $.fck.editor(e,o);
    }
    else{
     if($.fck.waited<=0){
      alert('jQuery.fckeditor plugin error: The FCKEditor script did not load.');
     }
     else{
      $.fck.waitFor--;
      window.setTimeout(start,1000);
     };
    }
   };
   start(e);
   return e;
  },
  intercept: function(){
   if($.fck.intercepted) return;
   $.fck.intercepted = {
    ajaxSubmit: $.fn.ajaxSubmit || function(){}
   };
   $.fn.ajaxSubmit = function(){
    $.fck.update(); // update html
    return $.fck.intercepted.ajaxSubmit.apply( this, arguments );
   };
  },
  editor: function(e /* elements */, o /* options */){
   o = $.extend({}, $.fck.config || {}, o || {});
   $.extend(o,{
    Width: (o.width || o.Width || '100%'),
    Height: (o.height || o.Height|| '500px'),
    BasePath: (o.path || o.BasePath || $.fck.path),
    ToolbarSet: (o.toolbar || o.ToolbarSet || 'Default'),
    Config: (o.config || o.Config || {})
   });
   e = $(e);
   if(e.size()>0){
    var a = $.fck.editors;// || [];
    e.each(
     function(i,t){
						if((t.tagName||'').toLowerCase()!='textarea')
							return alert(['An invalid parameter has been passed to the $.fckeditor.editor function','tagName:'+t.tagName,'name:'+t.name,'id:'+t.id].join('\n'));
      var T = $(t);// t = element, T = jQuery
      if(!t.name) t.name = 'fck'+($.fck.editors.length+1);
      if(!t.id) t.id = t.name;
      if(t.id/* has id */ && !t.fck/* not already installed */){
       var n = a.length;
       a[n] = new FCKeditor(t.name);
	   //CKFinder.SetupFCKeditor( a[n], '/ckfinder' ) ;
       $.extend(a[n], o, o.Config || {});
       a[n].ReplaceTextarea();
       a[n].textarea = T;
       t.fck = a[n];
      };
     }
    );
    $.fck.editors = a;
				$.fck.clean();
   };
   return e;
  }, // fck.editor function
  start: function(o/* options */){
   $.fck.intercept();
   return $.fck.create(o);
  } // fck.start
  
 } // fck object
});
$.extend($.fn, {
 fck: function(o){
  $.fck.start($.extend(o || {}, {e: this}));
 }
});
})(jQuery);
//Cookie插件
(function (jQuery){
	jQuery.cookies=function(name,value,options,callback){
		name=name||{};
		value=value||{};
		options=options||{};
		callback=callback||function(){};
		if(typeof value=='object'){
			options=value;
			callback=options;
		};
		if(jQuery.isFunction(options)){
			callback=options;
			options=null;
		};
		var defaults={
			dataType:'string'
		};
		var dataType=options.dataType||defaults.dataType;
		if(typeof value=='string'){
			document.cookie=name+'='+value;
		}else{
			var c=document.cookie.split(';');
			for(var i in c){
				if(c[i].indexOf('=')>0){
					var v=c[i].split('=');
					if($.trim(v[0])==name){
						if(dataType=='json')return eval(decodeURIComponent(v[1]));
						return decodeURIComponent(v[1]);
					};
				};
			};
		};
		callback.apply(this);
	}
})(jQuery);
//获取地址中的参数插件
(function (jQuery){
	jQuery.getParam=function(name,url){
		var url=url||window.location;
		if(url==window.location){
			var reg=new RegExp('(^|&)'+name+'=([^&]*)(&|$)');
			var r=url.search.substr(1).match(reg);
			if(r!=null)var val=unescape(r[2]);
		}else{
			if(url.indexOf('?')>0){
				url=url.split('?')[1];
				url=url.split('&');
				for(var i in url){
					if(url[i].split('=')[0]==name)var val=decodeURIComponent(url[i].split('=')[1]);
				};
			};
		};
		return val||null;
	}
})(jQuery);

(function (jQuery){
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;
    }
};
})(jQuery);
//Ajax上传插件
(function($){
	jQuery.ajaxUpload=function(button,options,callback){
		button=button||{};
		options=options||{};
		callback=callback||function(){};
		if(jQuery.isFunction(options)){
			callback=options;
			options=null;
		};
		var defaults={
			action:'upload.asp',
			name:'userfile',
			data:{},
			onSubmit:function(file,extension){},
			onComplete:function(file,response){}
		};
		if(typeof button=='string')button=$(button);
		var action=options.action||defaults.action;
		var name=options.name||defaults.name;
		var data=options.data||defaults.data;
		var onSubmit=options.onSubmit||defaults.onSubmit;
		var onComplete=options.onComplete||defaults.onComplete;
		var width=button.width();
		var height=button.height();
		var filetype=button.attr('type')||'image';
		$('#'+name+'_form').remove();
		$('#'+name+'_iframe').remove();
		var form=$('<form method="post" id="'+name+'_form" enctype="multipart/form-data"><input type="hidden" name="upload_name" value="'+name+'" /></form>').css({position:'absolute',top:0,left:0}).attr({'action':action+'?type='+filetype,'target':name+'_iframe'}).appendTo('body');
		var iframe=$('<iframe id="'+name+'_iframe'+'" name="'+name+'_iframe'+'"></iframe>').css({display:'none'}).appendTo('body');
		var input=$('<input type="file" name="'+name+'" />').css({position:'absolute',cursor:'pointer',width:width,height:height,opacity:0}).appendTo(form);
		form.submit(function(){
			for (var i in data){
				$('<input type="hidden" />')
					.appendTo(form)
					.attr({
						'name':i,
						'value':data[i]
					});
			};
			var file=input.val().replace(/.*(\/|\\)/,'');
			if(onSubmit.call(form,file,form.ext(file))===false){
				return false;
			};
			iframe.one('load',function(){
				var response=iframe.contents().find('body').html();
				onComplete.call(form,file,response);
			});
		});
		button.mouseover(function(e){
			var offset=button.offset();
			input.css({left:offset.left,top:offset.top}).show();
		});
		input.change(function(){
			if(input.val()!=''){
				form.submit();
			};
		})
		.mouseout(function(){
			input.hide();
		});
	}
})(jQuery);

jQuery.fn.extend({
	/*
	settting:function(options,callback){
		options=options||{};
		callback=callback||function(){};
		var defaults={
			blank:'images/blank.gif',
			skinPath:'/skin/'
		};
		return blank=options.blank||defaults.blank,
				skinPath=options.skinPath||defaults.skinPath;
	},
	*/
	//用正则检查数据合法性
	ext:function(file){
		return (/[.]/.exec(file)) ? /[^.]+$/.exec(file.toLowerCase()) : '';
	},
	//PNG图片透明（for IE）
	png:function(options){
		options=options||{};
		if($.browser.msie){
			$(this).each(function(){
				var w=$(this).width();
				var h=$(this).height();
				var src=$(this).attr('src');
				$(this).attr('src','images/blank.gif').css({width:w,height:h,filter:'progid:DXImageTransform.Microsoft.AlphaImageLoader(enabled="true",sizingMethod="scale",src="'+src+'")'});
			});
		};
	},
	//元素居中插件
	center:function(){
		var me=$(this);
		var w=me.width();
		var h=me.height();
		var cliHeight=$(document).cliHeight();
		var docHeight=(cliHeight/2-h/2)+$(document).getScrollTop();
		var docWidth=$(document).docWidth()/2-w/2;
		me.css({position:'absolute',top:docHeight,left:docWidth}).show();
	},
	//获取网页可见区域高度
	docHeight:function(){
		if ($.browser.msie && $.browser.version<7){
			var scrollHeight=Math.max(document.documentElement.scrollHeight,document.body.scrollHeight);
			var offsetHeight=Math.max(document.documentElement.offsetHeight,document.body.offsetHeight);
			if(scrollHeight<offsetHeight){
				return $(window).height();
			}else{
				return scrollHeight;
			};
		}else{
			return $(document).height();
		};
	},
	//获取网页可见区域宽度
	docWidth:function(){
		if ($.browser.msie&&$.browser.version<7) {
			var scrollWidth=Math.max(document.documentElement.scrollWidth,document.body.scrollWidth);
			var offsetWidth=Math.max(document.documentElement.offsetWidth,document.body.offsetWidth);
			if (scrollWidth<offsetWidth){
				return $(window).width();
			}else{
				return scrollWidth;
			};
		} else {
			return $(document).width();
		};
	},
	//获取滚动条高度
	getScrollTop:function(){
		IeTrueBody=function(){
			return (document.compatMode&&document.compatMode!="BackCompat")?document.documentElement:document.body;
		};
		return $.browser.msie?IeTrueBody().scrollTop:window.pageYOffset;
	},
	//内容可视区域高度
	cliHeight:function(){
		return document.documentElement.clientHeight;
	},
	formatSelect:function(){
		var me=$(this);
		var name=$(this).attr('name');
		var w=$(this).width();
		me.hide().after('<input type="text" id="'+name+'_text" class="select" readonly />');
		var s=$('#'+name+'_text');
		s.val(me.find('option:selected').text());
		s.css({width:w}).hover(function(){
			$(this).addClass('selecto');
		},function(){
			if(!$(this).attr('isfocus'))$(this).removeClass('selecto');
		}).focus(function(){
			$(this).addClass('selecto');
		}).blur(function(){
			$(this).removeClass('selecto');
		}).click(function(){
			$('.select_box').remove();
			var sbox='<div id="'+name+'_box" class="select_box">';
			me.find('option').each(function(){
				var o=$(this);
				var text=o.text();
				var cls='';
				if(o.attr('selected'))cls=' class="selected"';
				sbox=sbox+'<a href="javascript:void(0);"'+cls+'>'+text+'</a>';
			});
			sbox=sbox+'</div>';
			var width=s.width();
			var p=s.offset();
			if($('#'+name+'_box').length==0){
				$('body').append(sbox);
				$('#'+name+'_box')
					.css({width:width,top:p.top+19,left:p.left})
					.show()
					.find('a').each(function(i){
						var opt=$(this);
						opt.click(function(){
							s.val(opt.text());
							me.find('option').removeAttr('selected').eq(i).attr('selected',true);
							//$('.select_box').removeShadow().remove();
							$('.select_box').remove();
						});
					});
					//$(this).dropShadow({left:1,top:1,blur:1,opacity:0.2});
			};
		});
	},
	tip:function(text){
		text=text||$(this).attr('title')||$(this).attr('alt')||$(this).attr('tip');
		$(this).attr('tip',text).removeAttr('alt').removeAttr('title');
		$(this).bind('mouseover',function(v){
			var M={pX:v.pageX,pY:v.pageY};
			$('.tip').removeShadow().remove();
			$('body').append('<div class="tip"><div>'+text+'</div></div>');
			if($('.tip').width()>250)$('.tip').width(250);
			$('.tip').css({left:M.pX+5,top:M.pY-$('.tip').height()-5}).fadeIn(10);
		}).bind('mouseout',function(){
			$('.tip').remove();
		});
	},
	popmenu:function(options,callback){
		options=options||{};
		callback=callback||function(){};
		if(jQuery.isFunction(options)){
			callback=options;
			options=null;
		};
		var defaults={
			html:'',
			width:100,
			position:'right'
		};
		var html=options.html||defaults.html;
		var width=options.width||defaults.width;
		var position=options.position||defaults.position;
		var me=$(this);
		var index=($('*').index(me));
		me.click(function(e){
			if(!$('#popmenu'+index).length>0){
				$('body').append('<div class="popmenu_box" id="popmenu'+index+'"><div class="popmenu_content">'+html+'</div></div>');
				var popmenu=$('#popmenu'+index);
				var w=me.width();
				var pw=parseInt(me.css('paddingLeft'))+parseInt(me.css('paddingRight'))+parseInt(me.css('borderLeftWidth'))+parseInt(me.css('borderRightWidth'));
				var offset=me.offset();
				popmenu.css({width:width,left:offset.left+w+pw,top:offset.top}).fadeIn('fast');
				$('.navover').removeClass('navover');
				me.addClass('navover');
			};
			if(event&&event.preventDefault)event.preventDefault();
			else window.event.returnValue=false;
		});
		callback.apply(this);
	}
});