﻿/*000001*/

$ = function (s){
	var o = {o:[],e:[]}
	o.push= function (a){
		for (n =0;n<a.length;n++ ){
				o.o.push(a[n]);
		}
	}

	o.b  = function (){
		var g = typeof(s)
		switch (g){
				case "string" :  
					 	var h = s.substring(0,1)
						var i = replace(s,h,"")
						switch (h){
							case "#" : o.o.push(document.getElementById(i));break;	
							case "@" : o.push(document.getElementsByTagName(i));break;
							case "*" : o.push(document.getElementsByName(i));break;
							case "~" : i = i.split('>');o.push(document.getElementById(i[0]).getElementsByTagName(i[1]));break;
						}
						break;
				case "object" :  
						o.o.push(s);
						break;	
 		}
	}
	o.b();
  

	var h;
	o.child =function (){
 	    var g = arguments;
	    h = $(o.u())
	    h.o.shift()
		f = function(m) {
 			for(n= 0;n<g.length;n++){
				 cleanBlankNode(o.o[m])
				if(n==0){
						h.o[m]  = o.o[m].childNodes[g[n]]
				}else{
						h.o[m]  = h.o[m].childNodes[g[n]]
				}
			}
 		}	
			  
		return  o.f(f);
  	}

	o.parent =function (a){

		if(a==null){a =1}
		h = $(o.u())
		h.o.shift()
		f = function(m) {
			for(n= 0;n<a;n++){	 
				if(n ==0){
					h.o[m]  = o.o[m].parentNode
				}else{
					h.o[m]  = h.o[m].parentNode
				}
			}
		}
		return o.f(f);
 	}

	o.f = function (a){ 
		for (m in o.o){
			 o.l!=null ?  o.l == o.o[m] ? a(m) : null :   a(m)
		};
		if(h!=null){
			return h
		}else{
			return this;
		}
	}

	o.html = function (a){		
		return  o.f(f = function(m) {if(a) {o.o[m].innerHTML = a}});
	}
	
	o.outer = function (a){		
		return  o.f(f = function(m) {if(a) {o.o[m].outerHTML = a}});
	}

	o.value = function (a){		
		
		return  o.f(f = function(m) {if(a) {o.o[m].value = a}});
	}

	o.points = function (a,b,c){		
		return o.f(
			 function(m) {
					o.o[m].style.position= "absolute";
				 
					var w = function (t){
						return eval("o.o[m].offset"+t) 

					}
					var x = function (){
						var g = mt(w("Left"),w("Top"),b,a)	
						o.o[m].style.left = px(g.x);
						o.o[m].style.top = px(g.y);	 
						if(g.x== w("Left") && g.y == w("Top")){
							clearInterval(i)
						}
							
							
					}
				    var i= setInterval(x,c)
					 
			}	
		); 
	}


	o.after =function (a,b){
		return o.f(
			 function(m) {
				  var g = document.createElement(a);
				  var h = o.o[m].parentNode ;
				  switch (b){
								case 1 : h.insertBefore(g,o.o[m]) ; break;
								case 2 : o.o[m].insertBefore(g,o.o[m].firstChild) ; break;
								case 3 : o.o[m].insertBefore(g,null) ; break;	
								case 4 : o.o[m].nextSibling ? h.insertBefore(g,o.o[m].nextSibling) :  h.appendChild(g) ; break;
				   }
				  o.o[m] =g
			}	
		);
 	}

	o.alpha =function (a){
		return o.f(
			 function(m) {
					if(a){alpha(o.o[m],a)}
			}	
		);
 	}

	o.show  = function (a,b,c){
		return o.f(
			f = function(m) {
				var h = cq(o.o[m].style.display,"none")
				h  ? 	o.e[m] = [0,10,110]  : o.e[m] = [100,-10,-10];

				w = function (){
					alpha(o.o[m], o.e[m][0])
					if(h){ x(m,"block") }
					o.e[m][0]+=o.e[m][1];
					if(o.e[m][0] ==o.e[m][2]){
							clearInterval(o.e[m][3]);if(o.e[m][2]<0) {x(m,"none")}
					 }
				}
				x = function (a,b){
					o.o[a].style.display = b;
					eval(ck(c));
				}
				a == "slow" ? o.e[m][3] = setInterval(w,b) :  h ? x(m,"block") :  x(m,"none")
 			}
		);
	}

	o.style = function (a){			 
		return o.f(
			f = function(m) {
				if(a){style(o.o[m],a)}
			}	
		);
	}
	
	o.add = function (a,b){			 
		return o.f(
			 function(m) {
				var g = eval("o.o[m].style."+a)
				if(g){ g = px(g)}
				style(o.o[m],a+":"+px(b+g))
			}	
		);
	}

	o.cssText = function (a){			 
		return o.f( function(i) {o.o[m].style.cssText=a;});
	}

	o.cssName = function (a,b,c){		
		return o.f( function(m) {
			o.o[m].className=a
			 if(m==b){o.o[m].className =c}
		});
	}
	
	//执行外部命令	
	o.command = function (a){		
		return  o.f( 
			function(m) {
				a
			}
		);
	}

	o.remove = function (){			 
		return o.f(
			 function(m) {
				document.body.removeChild(o.o[m])
			}
		);
	}
	
	
	o.check = function (a){			 
		return o.f(
			 function(m) {
				 o.o[m].checked =a
			}
		);
	}

	o.center  = function (s){
		return o.f(
			function(m) {
				 style(o.o[m],"left:"+px(ge("offsetWidth")/2 -px(o.o[m].style.width)/2))
			}
		);
	}
	o.middle  = function (s){
		return o.f(
			function(m) {
				 style(o.o[m],"left:"+px(ge("offsetWidth")/2 -px(o.o[m].style.width)/2))
				 style(o.o[m],"top:"+px(ge("offsetHeight")/2 -px(o.o[m].style.height)/2))
			}
		);
	}


	o.cssChange  = function (a,b){
		return o.f(
			function(m) {
				  cq(o.o[m].className,a) ? o.o[m].className= b :	 o.o[m].className= a
			}
		);
	}
	o.imgChange  = function (a){
		return o.f(
			function(m) {
			     var g = getStyle(o.o[m],"backgroundImage");
			     var h = g.replace(".","_s.")
				 $(o.o[m]).event("mouseover",'$(this).style("background:'+h+'")').event("mouseout",'$(this).style("background:'+g+'")')
			}
		);
	}

	o.event = function (a,b){
		return o.f(
			function(m) {
				  w= function (){		 		
							b= replace(b,"$(this)","$(o.o[m])")
							if(b.substring(0,1)!="$" ){
								o.l = o.o[m]
								eval("o."+b)
							}else{
								eval(b)
							}
				   }	
				  if(ie()){o.o[m].attachEvent("on"+a,w)}else{o.o[m].addEventListener(a,w,false)}
				 
			}	
		);
		
	};
	
	//===============
	o.u = function (){
		if(o.o.length == 1){
			return o.o[0];
		} else {
			return o.o;
		}
 	}

	o.s = function (a){
		return eval("o.u().style."+a); // []
	}

	o.k =function (a){
		return eval("o.u()."+a); // []
	}
	
	o.t =function (a){
		return o.u().getElementsByTagName(a);
 	}
	
	o.tagName  = function(a){
		var g = o.u().getElementsByTagName(a);
		var h = $(o.u())
		for (n =0;n<g.length;n++ ){
				h.o[n] = g[n];
		}
		return h;	
	}

	o.childNodes = function (a){
		var g = o.u().childNodes;
		var h = $(o.u())
		for (n =0;n<g.length;n++ ){
				h.o[n] = g[n];
		}
		return h;	
	}
  
  	return o ;
}


//同时兼容ie和ff的写法
getEvent	= function () 
    {  
        if(document.all)   return window.event;    
        func=getEvent.caller;        
        while(func!=null){  
            var arg0=func.arguments[0];
            if(arg0)
            {
              if((arg0.constructor==Event || arg0.constructor ==MouseEvent) || (typeof(arg0)=="object" && arg0.preventDefault && arg0.stopPropagation))
              {  
              return arg0;
              }
            }
            func=func.caller;
        }
        return null;
}

//停止IE冒泡事件
stopEvent = function (){
	  ie() ?	getEvent().cancelBubble=true : getEvent().stopPropagation();  
}
 
setCookie = function (a, b, c){
  var g = "";
  if(c != null)
  {
    g = new Date((new Date()).getTime() + c * 3600000);
    g = "; expires=" + g.toGMTString();
  }
  document.cookie = a + "=" + escape(b) + g;
}

function getCookie(a)
{
  var g = "";
  var h = a + "=";
  if(document.cookie.length > 0)
  { 
    offset = document.cookie.indexOf(h);
    if (offset != -1)
    { 
      offset += h.length;
      end = document.cookie.indexOf(";", offset);
      if (end == -1) end = document.cookie.length;
      g = unescape(document.cookie.substring(offset, end))
    }
  }
  return g;
}
 
js = function(a){
	document.write("<script src="+path+"Scripts/"+a+".js></script>")
}

ie  =  function (){
	var g=navigator.userAgent.toLowerCase(); 
	return  indexof (g,"msie") && (document.all&&! indexof (g,"opera")); 	
}

ms = function (a){
		var g = document.body;	
		var h  = a || window.event;
 		if(h.pageX){return {x:h.pageX, y:h.pageY}}return{x:h.clientX + g.scrollLeft - g.clientLeft,y:h.clientY + g.scrollTop - g.clientTop}
}

mt = function(a,b,c,d)    
{           
	var g = Math.abs(a-c);    
	var h = Math.abs(b-d);    
	var i = 10 * (g/Math.sqrt(g*g+h*h));    
	var j = 10 * (h/Math.sqrt(g*g+h*h));    
	a<c ? a += i : a -= i;    
	b<d ? b += j : b -= j;    
   
	if(g<i)    
		a = c;    
	if(h<j)    
		b = d;   
	return {x:a,y:b}
}

style  = function (a,b){
		var g =  b.split(';')
		var h;
		for (n in g){
			h =g[n].split(':')	
			eval('a.style.'+h[0]+'="'+replace(g[n],h[0]+":","")+'"') 
		}
}

ge = function (s){
		return	eval("document.documentElement."+s);
}

indexof = function (a,b) {
	a += "";
	return eval("a.indexOf(b)>=0")
} 
replace = function (a,b,c){		
 	while (indexof(a,b)){a = a.replace(b,c)	} 
	return a;
}

px = function (a){
	var g="px";
	!indexof(a,g) ? a +=g : a = replace (a,g,"")*1 
	//a ? !indexof(a,g) ? a +=g : a = replace (a,g,"")*1 : a = ""
	return a 
}

ck = function (a){if(a == null){ return "" }else{ return a}}
ce = function (a,b){if(a ==null ){ return b }else{return a}}
cq = function(a,b){return a == b;}
cw = function (a){document.write(a)}
 
alpha = function (a,b){
		a.style.filter = "alpha(opacity="+ b+")";
		a.style.opacity = b/100;
}

getStyle = function(a,b){
		 return  ie() ?  replace(eval("a.currentStyle."+b),'"','') : eval("document.defaultView.getComputedStyle(a,null)."+b);
}	 

cleanBlankNode =  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]);
					}
        }
}	
 

dispose	 = function ()	  {	 
	while(od.length>0){od.shift().remove()}
}

var od = [] ;
var ot  = [] ;
var zi  = 0

dialogue = function (a){
		zi++
		var g = $(document.body).after("div",2).style("zIndex :"+ zi+";position:absolute;"+a.style).html(a.html).alpha(a.alpha);
		stopEvent();

		var h = ge("scrollHeight");

		if(h<ge("clientHeight")){
			h = ge("clientHeight")
		}
	
		switch (a.type){
			case "background" : g.style("zIndex:1;width:"+px(ge("clientWidth"))+";height:"+px(h)); break;
			case "dialogue" :dispose();if(a.center){g.center();};if(a.middle){g.middle();};ot.push(g) ; break;
			case "menu" :dispose();var h = $(a.listener).style("position:absolute");g.style("top:"+px(h.k("offsetTop"))+";left:"+px(h.k("offsetLeft"))); h.style("position:static");	break;			 
		}
		g.add("top",ck(a.top)).add("left",ck(a.left))
	 
		if(a.type == "menu"){
			var i = g.k("offsetLeft")+g.k("offsetWidth")
			var j =ge("clientWidth")
			if(i>j){
				g.add("left",-g.k("offsetWidth"))
			}
		}

		eval(ck(a.callback))
		if(a.display==null){
			od.push(g)
		}
		return g
}

drag = function (a) {
		zi++

		var d = a.drag;
		var m =ce(a.move,d)
		var c = a.call
		var lock = a.lock
		var mo  = $(m).style("position:absolute")
		var alpha = a.alpha;
		var cursor= a.cursor;
		var l ;
		var t ;
		var mx;
		var my;
		var mw;
		var mh;
		var ds = 10;
		var db = false;

		gl = function (a){return m.offsetLeft-ms(a).x}
			    gt = function (a){return m.offsetTop- ms(a).y}
		gw = function(){ return mo.k("width")}
		gh = function(){	return mo.k("height")}

		if(cursor!=null){
			$(d).style("cursor:"+cursor)
		}else{
			$(d).style("cursor:move")
		}
		
		if(a.size){
		d.onmousemove = function(e){
				var sa =""
				if(gt(e)>ds*-1){sa="n"}
				if((gh() + gt(e))<ds){sa+="s"}
				if(gl(e)>ds*-1){sa += "w"} 
				if((gw() + gl(e))<ds){sa+="e"}
				sa +="-resize"
				if(sa =="-resize"){
					sa="move"
				}	
				mo.style("cursor:"+sa)
			
			}
		}
		d.onmousedown = function(e){
				move  =  function (e) {
					if(a.size){
				if(t>ds*-1){	mo.style("top:"+ px(ms(e).y+t)+";height:"+ px(mh+(my - ms(e).y)));db= true;}
				if(l>ds*-1){mo.style("left:"+ px(ms(e).x+l)+";width:"+  px(mw+(mx - ms(e).x)));db= true;}	
				if((mw + l)<ds){mo.style("width:"+px(mw+(ms(e).x-mx)));db= true;}
				if((mh + t)<ds){mo.style("height:"+ px(mh+(ms(e).y-my)));db= true;}
					}
					if(!db){
					var top="";var left=""
					if(lock!="y"){
						 top = ";top:"+ px(ms(e).y+t)
					}
					 if(lock!="x"){
						 left = ";left:"+ px(ms(e).x+l)
					}
					mo.style("zIndex :"+zi+top+left).alpha(alpha)
					}
					eval(c)

				
					return false;

				}
				down  =  function (e) {
					l =	gl(e);t =	gt(e);mw = gw();mh =  gh();mx = ms(e).x;my = ms(e).y;
					if(mw>0){
				mo.style("width:"+px(mw)+";height:"+px(mh))
					}
					return false;
				}
				up=  function (e) {db= false;mo.alpha(100) ; document.onmousemove = null;}

 			    document.onmousemove = move;
				document.onmousedown = down;
				document.onmouseup = up;		
		}
}

ajax = function (a){
	var ae;
	try { ae=new XMLHttpRequest; }
		catch(e) {
			try { ae=new ActiveXObject("MSXML2.XMLHTTP"); }
			catch(e) {
				try { ae=new ActiveXObject("Microsoft.XMLHTTP"); }
					catch(e) { ae=false; }
		}
	} 
	ac = function (){
		 if(ae.readyState==4){
			// if(ae.status == 200) {
				if(a.id.length>0){
					$("#"+a.id).html(ae.responseText);
				}
			// }
		 }
	}
	var g = "?timeStamp=" + new Date().getTime();
	var h = cq(a.type,"POST")
	if(h){
		a.url+=g
	}else{
		a.url+=g+"&"+a.query;
	}
   ae.open(a.type,a.url, true); 
   ae.onreadystatechange=eval(a.callback);

   if(h){
		ae.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
	    ae.send(a.query)
   }
   else{
	    ae.send(null)
   }
}

if(window.HTMLElement) {
	HTMLElement.prototype.__defineSetter__("outerHTML",function(a){
		var g=this.ownerDocument.createRange();
		g.setStartBefore(this);
		this.parentNode.replaceChild(g.createContextualFragment(a),this);
		return a;
	});
}

$(document.documentElement).event("click",'command(dispose())') 
//$(window).event("resize",'command(resize())') //resize = function (){	for(n in ot){	ot[n].center()}}
