﻿/*
Javascript Framework V1.0.0.2
*/
(function(){
var $ = function(a){
	return $.init($.p,a);
};
$.init = function (a,b){
	function p(){a.init.call(this,b)};
	p.prototype = a;
	return new p();
};
window.$ = $;
$.d = document;
$.dialogue = []; 
$.a = function(a){
	if(a) alert(a);
};
/*StringToObject*/
$.o = function(a){
 	 return eval("(" + a + ")"); 
};
$.n = function(a,b){
	return b ? a ? b : "" : a ? a :	"";  
};
$.v = function(a,b){
	return a == null ? b : a;
};
$.r = function(a,b){
	$.f(b,function(f){
 		a = $.replace(a,"{"+f.i+"}",f.n);
	});
	return a;
};
$.swapNode = function(a,b){
	var g = a.parentNode; 
	var g1 = a.nextSibling; 
	var g2 = b.nextSibling;
	g1 ? g.insertBefore(b,g1) : g.appendChild(b);
	g2 ? g.insertBefore(a,g2) : g.appendChild(a);
};
/*removeWhiteSpace*/
$.w = function(a){
	var g =  a.childNodes;
	for (var n = 0 ; n < g.length ; n++){	 
		if (g[n].nodeType == 3 && !/\S/.test(g[n].nodeValue)) {
			g[n].parentNode.removeChild(g[n]);
		}
	}
	return a;
};
$.sv = function () {  
	if($.d.all) return window.event;
		var g = $.sv.caller;        
		while(g!=null){  
			var g1 = g.arguments[0];
			if(g1){
				if((g1.constructor==Event || g1.constructor==MouseEvent) || (typeof g1=="object" && g1.preventDefault && g1.stopPropagation)){  
				return g1;
			}
		}
		g = g.caller;
	}
	return null;
}; 


$.inArray = function(a,b){
	for(var n = 0;n < b.length ; n++){	 
		if(b[n]==a){
			return n;
		}
	}
	return -1;
};
/*x,y,l,t,w,h*/
$.ic = function(a,b,c,d,e,f){
	return (a>c)&&(a<(c+e))&&(b>d)&&(b<(d+f));   
};
$.include = function(a,b){
	var g = a.point();
	var g1 = [];
	g1[0] = b.offset().left;g1[1] = b.offset().top;g1[2] = b.element().clientWidth;g1[3] = b.element().scrollHeight;
	return $.ic(g[0],g[1],g1[0],g1[1],g1[2],g1[3]) || $.ic(g[2],g[3],g1[0],g1[1],g1[2],g1[3]) || $.ic(g[4],g[5],g1[0],g1[1],g1[2],g1[3]) || $.ic(g[6],a[7],g1[0],g1[1],g1[2],g1[3]);
};
/*stopPropagation*/
$.s = function (){
	if($.browser.safari || $.browser.opera){window.event.stopPropagation();}
	$.browser.msie ? $.sv().cancelBubble = true : $.sv().stopPropagation();
};
$.replace = function (a,b,c){ 	
	$.p.f(b.split(","),function(f){ 	
		if($.test(a,f.n)){
			while($.test(a,f.n)){a = a.replace(f.n,c)}
		}
	});
	return a;
};
$.trim = function(a){
	return a.replace(/(^\s*)|(\s*$)/g, "");  
};
$.u = navigator.userAgent.toLowerCase();
$.browser = { 
	version: ($.u.match( /.+(?:rv|it|ra|ie)[\/: ]([\d.]+)/ ) || [0,'0'])[1],
	safari: /webkit/.test( $.u ),
	opera: /opera/.test( $.u ),
	msie: /msie/.test( $.u ) && !/opera/.test( $.u ),
	mozilla: /mozilla/.test( $.u ) && !/(compatible|webkit)/.test( $.u ),
	chrome: /chrome/.test( $.u )
};

$.addPx = function (a){ 	
	return $.test(a,"px") ? a : a+="px"; 
}; 
$.removePx = function(a){ 	
	return !isNaN(a = $.replace(a,"px","")) ? a*1 : a ; 
};
$.test = function (a,b){
	return (a += "").indexOf(b)>=0;
};
$.push = function(a,b){	
	if(b!=null){
		if(b.type != "select-one"){
			if(b.length>0){
				$.p.f(b,function(f){
					a.push(f.n);
				});
			}else{
				a.push(b);
			}
		}else {
			a.push(b)
		}
	}
	return a;

};
$.keyCode = function(a,b){
	var g = b;
	$(document).bind("keydown",function(b){
 		if(b.e.keyCode == a){
			g.call(b);
		}
	})
};
$.setCookie = function(a,b,c){
	$.d.cookie = a + "=" 
	+ encodeURI(b)
	+ $.n(c,";expires=" + new Date((new Date()).getTime() + c * 3600000).toGMTString())
	+ ";Path=/";
	/*+ "domain="+domain*/;
}; 
$.getCookie = function (a){
    return $.n(unescape($.n($.d.cookie.match(new RegExp("(^| )"+a+"=([^;]*)(;|$)")))[2])) ;
};
$.getElement = function(a,b){	 
	if(!a) return;
	var g = $.replace(b,"#,.,:","");
	var g1 = [];
	if($.test(b,"#")){
		return [a.getElementById(g)];
	}else if($.test(b,".")){
		$.p.f(a.getElementsByTagName("*"),function(f){
			if(f.n.className==g){
				g1.push(f.n);
			}
		});
		return g1;
	}else if($.test(b,":")){
		$.p.f(a.getElementsByTagName("input"),function(f){
			if(f.n.type==g){
				g1.push(f.n);
			}
		});
		return g1;
	}
	else{
		return a.getElementsByTagName(g);
	} 
};
$.style = function (a,b,c){
 	return $.removePx(a.style[b]= !isNaN(c) && b!="opacity" ? c = $.addPx(c) : c); 
}; 
$.css = function (a,b){ 	
	for(var n in b){
		if(b[n]) $.style(a,n,b[n]);
	} 
};
$.m = function (a){
	var g = $.d.body;
	var g1 = a || window.event;
 	return g1.pageX ? {x:g1.pageX, y:g1.pageY} : {x:g1.clientX + g.scrollLeft - g.clientLeft,y:g1.clientY + g.scrollTop - g.clientTop}
};
$.call = function(a,b){
	if(a){a.call(b);}
};

$.ajax = function (a,b){
	var x;
	try { x=new XMLHttpRequest; }
		catch(e) {
	try { x=new ActiveXObject("MSXML2.XMLHTTP"); }
		catch(e) {
	try { x=new ActiveXObject("Microsoft.XMLHTTP"); }
		catch(e) { x=false;}}};
	x.open(a.type,a.url+$.n(!a.random,($.test(a.url,"?") ? "&" :"?") +"timeStamp=" + new Date().getTime()), true); 
	x.onreadystatechange = function (){
		if(x.readyState==4){
			if(a.id){a.success ? a.success.call(this,x.responseText):$("#"+a.id).html(x.responseText)}
			if(b){b.call(x.responseText);}
			x.abort();
			x = null;	 
		};
	};
	!a.query ? a.query = "": a.query;
	!a.type ? x.send(null): 
	x.setRequestHeader("Content-Type","application/x-www-form-urlencoded; charset=UTF-8");
	x.send(a.query);
};
 
$.g = function(a){
	return $.removePx($.d.documentElement[a]);
};
$.remove = function(){};
$.q = function (){
	$.f($.dialogue,function(f){
		if(f.n){
			if(!$.test(f.n.attr("className"),"q")){
				f.n.remove();
				$.dialogue.splice(f.i,1);
			} 
		}
	});
	$.remove();
};


$.p = {
 	init:function(a){
		var g = [];
		var g1 = [];
		if($.test(a,",")){
			this.f(a.split(","),function(f){
				$.push(g1,$.getElement($.d,f.n));
			})	 
		}else if(typeof a=="string"){
			this.f(a.split(" "),function(f){
				if(g.length<1){
				 	g1 = $.push(g,$.getElement($.d,f.n));
				}else{
					g1 = [];
					this.f(g,function(f1){
						g = $.push(g1,$.getElement(f1.n,f.n));
					});
				} 
			},this)
		}else{
 			g1 = [a]; 
		}
		$.push(this.o = [],g1);
		return this;	
	},
	c:function(a){
		this.f(this.o,function(f){
			 if(f.n) a.call(this,f.n,f.i);
		},this);
		return this;
	},
	v:function (a,b){
		return (typeof b == "string" || typeof b == "number") ? this.c( 
			function (w){
				w[a] =b;
			}
		):this.get(this.o,a);
	},
	f:function(a,b,c){
		var g,g1,g2="";
		if(a) for(g = 0,g1 =  typeof a == "number" ? a : a.length; g< g1;g++){
			g2 += b.call(c,{n:a[g],i:g});	 
 		}
		return g2;
	},
	w:function(a,b,c,d){
		switch (a){
			case 1 : b.insertBefore(c,d);break;
			case 2 : d.insertBefore(c,d.firstChild);break;
			case 3 : d.insertBefore(c,null);break;	
			case 4 : d.nextSibling?b.insertBefore(c,d.nextSibling):b.appendChild(c);break;		
		}
		return c;
	}, 




	i:function(a,b){
		this.c(
			function (w){
				if($.browser.msie){
					w.insertAdjacentHTML(
						b == 1 ? "beforeBegin" :
						b == 2 ? "afterBegin" :
						b == 3 ? "beforeEnd" : 
						b == 4 ? "afterEnd" :"", a);
				}else{
					var r = w.ownerDocument.createRange();r.setStartBefore(w);
					this.w(b,w.parentNode,r.createContextualFragment(a),w);
				}
			}
		);
		return this;
	},
	ready:function(a){
		$(window).bind("load",function(){
			a.call(this);
		})
	},
	element:function (){
		return this.o.length>1 ?  this.o : this.o[0];
	},
	isNull:function(){
		return this.o[0]!=null ?  this.o[0].innerHTML != null  :  this.o.innerHTML != null;
	},
	check:function(a){
		return this.c(
			function (w){
				 if(a!=null) {w.checked = !a};
				 w.checked ? w.checked = false :w.checked = true;
			}
		);
	},
	
	find:function(a){
  		return this.c(
			function(w,x){
				this.t($.getElement(w,a),x);
			}
		);
	},
	join:function(a){
		this.f($(a).o,function(f){
			if(f.n.tagName)
			{this.o.push(f.n);} 
		},this);
		return this;
	},
	last:function(){
		return $($.w(this.element()).lastChild)
	},
	first:function(){
		return $($.w(this.element()).firstChild)
 	},

	eq:function(a){
		return $(this.o[a]);
	},
	focus: function() {
		return this.c(
			function (w){
				setTimeout(function(){
					w.focus();
					if($.browser.msie){
						var g = w.createTextRange();     
						g.moveStart("character",w.value.length);
						g.collapse(true);
						g.select();   
					}
				}, 0); 
			}
		);
    },
	css:function(a){
		return this.c(
			function (w){
				  $.css(w,a);
			}
		);
	},
	change:function(a,b){
		return this.c(
			function (w){			 
				for(var n in a){
					$.style(w,n,b ? $.removePx(w.style[n])+a[n]:a[n]);
				}
			}
		);
	},
	alpha:function(a){
		return this.css({filter:"alpha(opacity="+ a+")",opacity:a/100});
	},
				

	addClass:function (a){
		return this.c(
			function(w){
				if(!$.test(w.className,a)){
					if(w.className.length>0){
						a=" "+a;
					}
					w.className += a;
				} 
			}
		)
	},
	removeClass:function(a){
		return this.c(
			function(w){
				if(!a) {
					$(w).removeAttr("class");
				}else{	
					var g = a.split(" ");
					this.f(g,function(f){
						w.className=$.replace(w.className,f.n,"");
						if(w.className==""){
							$(w).removeAttr("class");
						}
					})	
				}
			}
		)
	},	
	toggleClass:function(a){
		return this.c(
			function(w){
				 if($.test(w.className,a)){
					$(w).removeClass(a);
				 }else{
					$(w).addClass(a);
				 }
			}
		)
	},
	get:function (a,b){
		var g = [];
		var g1 = b.split(".");
		this.f(a,function(f){
			 g.push(g1.length> 1 ? $.removePx(f.n[g1[0]][g1[1]]):f.n[b]);
		});
		if(g.length==1){
			g = g[0];
			if(typeof g == "boolean"){
				g == true ? g = 1 : g = 0;
			}
		}
		return g;
	},
	set:function(a,b,c){
		var g = b.split(".");	 
		if(typeof c == "number"){		 
			c += "px";
		}
		g.length>1 ? a[g[0]][g[1]] = c:a[b] = c;
	},
	attr:function(a,b){
		var g = [];
		return typeof a =="string" && !b ? 
		this.get(this.o,a):
		this.c(
			function(w){
				switch (typeof b)
				{
				case "string":this.set(w,a,b);break;
				case "function":this.set(w,a,b.call(w));break;
				default:
					for (var n in a){
						this.set(w,n,a[n]);
					};break;
				}
			}
		); 
	},
	removeAttr:function(a){
		return this.c(
			function(w){
				this.set(w,a,"");
				w.removeAttribute(a);
			}
		)
	},


		
	bind:function(a,b,c){
		return this.c(
			function (w){ 
				var g = function (y){
					b.call(w,{e:y,t:c});
				};
				try{$.browser.msie ? w.attachEvent("on"+a,g):w.addEventListener(a,g,false);}catch(e){}
 			}
		);
	},
	p:function(a,b){	
		this.f(b,function(f){
			a.push(f.n);
		});
		return a;
	},
	t:function(a,b){
		this.p(this.o=b?this.o:[],a);
	},
 	child:function(a){
		var g = []; 
		a !=null ? g = arguments : g.push(0);
		return this.c(
			function (w,x){
				this.f(g,function(f){					  
					 this.t([w = $.w(w).childNodes[f.n]],x);
				},this)
			}	
		);
	},
	parent:function(a){	
		return this.c(
			function (w,x){
				this.f(a ==null ? 1 :a ,function(){
					this.t([w = $.w(w).parentNode],x);
				},this)
			}	
		);
	},
	parentFind:function(a){
		return this.c(
			function (w,x){
				var g = 0;
				while(typeof $(w).parent(g).find(a).element() != "object"){
					g++;
				}
				this.t([$(w).parent(g).find(a).element()],x);
			}	
		);
	},
 	wrap:function(a){
		return this.c(
			function (w,x){
				var g =  $.d.createElement(a);					
				w.parentNode.insertBefore(g,w).insertBefore(w,null);
				this.t([g],x);
			}
		);
	},
	before:function(a){
		return this.i(a,1);
	},
	prepend:function(a){
		return this.i(a,2);
	},
	append:function(a,b){
		return this.i(a,3);
	},
	after:function(a,b){
        return this.i(a,4);
	},
	val:function(a){
		return this.v("value",a);
	},
	outer:function(a){	 
		return this.v("outerHTML",a);
	},
	text:function(a){
		var g;
		$.browser.mozilla ? g = "textContent": g = "innerText";
		return this.v(g,a);
	},
	html:function(a){
		return this.v("innerHTML",a);
	},	
	b:function(a,b){ 
		switch (a.a){
			case "slow":a.a = 10000;break;
			case "normal":a.a = 1000;break;
			case "fast":a.a = 500;break;
		}
		return this.c( 
			function (w){
				if(b == "block"){$(w).show()};
				w.b = a.b;	
				w.t = 50;
				w.q  =  setInterval((function(){
					this.q = function(){ 
						clearInterval(w.q);
						if(w.b){w.b.apply(w)};
					};
					switch (b){
						case "none" : 
							w.n != null ? w.n : w.n = 100;
							w.n<0 ? this.q() : $(w).alpha(w.n -= 10);break;
						case "block" :  
							w.n != null ? w.n : w.n = 0;
							w.n>100 ? this.q() :$(w).alpha(w.n += 10);break;
						default:
							w.t -=1;
							for(var n in a.c){
								w.g = $(w).attr("style."+n)*1;	
								w.x = (a.c[n]-w.g)/10;
								w.g += w.x > 0 ? Math.ceil(w.x) : w.x ;
 								$.style(w,n,Math.floor(w.g) == a.c[n] ? a.c[n] :w.g);
							}
							if(w.t<0){
								this.q();
							};break;
					}
				}),a.a/100); 
			}
		)
	},

	show:function(a,b){
		var g = "inline";
		return a ? this.b({a:a,b:b},g):this.css({display:g});
	},
	hide:function(a,b){
		var g = "none";
		return a ? this.b({a:a,b:b},g):this.css({display:g});
	},
	toggle:function(){
		return this.c(
			function (w){
				$.css(w,{display:!(w.style.display=="none") ? "none" : "block"});
			}
		)
	},
	animate:function(a,b,c){
		this.b({a:b,b:c,c:a});
	},
	time:function(a,b,c){
		return this.c(
			function (w){
				var q = function(){
					  if(c.apply(w)||!b){
						clearInterval(w.a);
					  }
				};
				w.a = setInterval(q,a);
			}	 
		);
	},
	point:function(){
		var t = $(this.o[0]).offset().top;var l = $(this.o[0]).offset().left;var w = this.o[0].clientWidth;var h = this.o[0].scrollHeight;
		return [l,t,l+w,t,l,t+h,l+w,t+h];
	},
	offset:function(){
		var g = 0;
		var g1 = 0;
		var g2 = this.o[0];
		while (g2!=null) {
			g+=g2.offsetLeft;g1+=g2.offsetTop;
			if($.browser.msie){
				parseInt(g2.currentStyle.borderLeftWidth)>0?g+=parseInt(g2.currentStyle.borderLeftWidth):"";
				parseInt(g2.currentStyle.borderTopWidth)>0?g1+=parseInt(g2.currentStyle.borderTopWidth):"";
			}
			g2 = g2.offsetParent;
		}
		return {top:g1, left:g};
	},

		/*ok*/
	center:function(a){
		return this.c(
			function (w){
				$.css(w,{left:$.g("offsetWidth")/2 -$.removePx(w.style.width)/2,position:"absolute"});
				if(a) $.css(w,{top:screen.height/10+ $.g("scrollTop")})
			}
		);
	},
	insert:function(a,b){
		return this.c(
			function (w,x){		 
				this.t([this.w(b,w.parentNode,$.d.createElement(a),w)],x);
			}
		);
	},
	remove:function(){			 
		return this.c(
			function (w){				 
				$.css(w, { position: "absolute" });
				if(w){
					$.d.body.removeChild(w);
				}
			}
		);
	},
	dialogue:function(a,b){
		return this.c(
			function (w,x){
 				if(a.remove!=0){$.q();}
				var g = $(w).insert("div",3).css({position:"absolute"}).css(a.css);
				if(a.alpha){
					g.alpha(a.alpha);
				}
				var g1 = $.g("scrollHeight");
				var g2 = $.g("clientHeight");
				var g3 = a.listener;
				this.t([g.element()],x);
				switch (a.type){
					case "background":g.css({width:$.g("clientWidth"),height:g1<g2?g2:g1,top:"0px",left:"0px"});break;
					case "dialogue":
						if(a.center){g.center(1)};break;
					case "menu":
						g.css({top:$(g3).offset().top,left:$(g3).offset().left});
						/*$.style (g3,"position","static");*/
						break;
				}
				if(a.change){g.change(a.change,1)};
				if(a.html){g.html(a.html);}	 
				if(a.display==null){$.dialogue.push(g);}
				g.element().style.zIndex=$.p.zIndex;
				if(b){b.apply(g.element());}	
				try{
					$.s();	
				}
				catch (e){
				}
			}	
		);
	},
	zIndex:0,
 	drag:function(a,b){
		return this.c(
			function (w){
				a = a ? a : {} ;
			    var g = w;
				w.s = true;
			    if (a.parent > 0) {g = $(w).parent(a.parent).element();w.s = false}
			    $.css(g, { position: "absolute"});
			    $.css(w, { cursor: "pointer" });
				var g1 = function(e){return {
					l:g.offsetLeft-$.m(e).x,
					t:g.offsetTop- $.m(e).y,
					w:$.removePx(g.style.width),
					h:$.removePx(g.style.height),
					s:6,
					b:null,
					g:null,
					st:$.browser.msie ? $.g("scrollTop"): 0,
					sl:$.browser.msie ? $.g("scrollLeft"): 0,
					x:$.m(e).x,
					y:$.m(e).y
				}};
				if(a.size){
					g.onmousemove = function(e){
						var i = "";
						var j = g1(e);
						if(j.t-j.st>j.s*-1){i="n";};
						if((j.h + j.t-j.st)<j.s){i+="s";};
						if(j.l-j.sl>j.s*-1){i += "w";};
						if((j.w + j.l-j.sl)<j.s){i+="e";};
						i +="-resize";
						if(i =="-resize"){
							i="move";
						}	
						if(a.parent && i == "move"){
							i = "auto"
						}
						$.css(g,{cursor:i});
					}
				};
				w.onmousedown = function(e){
					w.s = true;
					$.css(w,{cursor:"move"});
				};
				g.s	= true;
				g.onmousedown = function(e) {
					this.q = function(c,d){
						if(a.lock==d || !a.lock ){
							c > a.max ? c = a.max : c<a.min ? c = a.min : c;
							return c;
						}	
					};
			        this.m = function(e) {
			            $.call(a.mousemove, g);
						if(g.s && w.s){
							$(g).css({top:g.q($.m(e).y+g.p.t,"x"),left:g.q($.m(e).x+g.p.l,"y")});
						};
						g.h = function(){if(a.fixed){$.css(g,{height:g1(e).w/g.b});}};
						g.w = function(){if(a.fixed){$.css(g,{width:g1(e).h*g.b});}}; 
						if(a.size){	 
							if((g.p.w + g.p.l-g.p.sl)<g.p.s){$.css(g,{width:g.p.w+($.m(e).x-g.p.x)});g.h();g.s=false;};
							if((g.p.h + g.p.t-g.p.st)<g.p.s){$.css(g,{height:g.p.h+($.m(e).y-g.p.y)});g.w();g.s=false;};
							if(g.p.t-g.p.st>g.p.s*-1){$.css(g,{top:$.m(e).y+g.p.t,height:g.p.h+(g.p.y-$.m(e).y)});g.w();g.s=false;};
							if(g.p.l-g.p.sl>g.p.s*-1){$.css(g,{left:$.m(e).x+g.p.l,width:g.p.w+(g.p.x-$.m(e).x)});g.h();g.s=false;};
						}
						return false;
			        };
			        this.d = function(e) {
			            $.call(a.mousedown, g);						 
			            g.p = g1(e);
						g.b = g.p.w/g.p.h;
						g.s = true;
						$.p.zIndex+=1;
						g.style.zIndex=$.p.zIndex;
						return false;
			        };
			        this.u = function(e) {
			            $.call(a.mouseup, g);
			            $.d.onmousemove = null;
			            $.d.onmouseup = null;
						$.d.onmousedown = null;
						if(a.parent>0){
					 		w.s = false;
						};
			        };
			        $.d.onmousemove = g.m;
			        $.d.onmousedown = g.d;
			        $.d.onmouseup = g.u;
			    }
			}
		);
	},

	h:function(a){
		if(!a){
			a = {};
		};
		return a
	}
};
$.f = $.p.f;
/*克隆*/
$.clone =  function(a, b) {
	if(arguments.length > 1 && ( b === null || b == undefined)){
		return a;   
	};
	if( !b ) {   
		b = a;   
		a = this;   
	};
	for (var i in b ){
		a[i] = b[i];
	}
	return a; 
};  
/*继承*/
$.extend=  function(a, b) {
	for (var n in b ){	
		/* || $.test(b[n],"over");*/
		/*如果父类无，将方法增加到父类*/
		if(!a[n]){
			a[n] = b[n];
		}
	};
	function p(){
		for(var n in b){
			this[n] = b[n];
		}
	};
	p.prototype = a;
	return new p();
}; 
})();
 
$($.d.documentElement).bind("click",function(){
	if($.dialogue.length>0) $.q();
});
 
 
