﻿function debug(o){a=[];for(k in o)a.push(k+":"+o[k]);alert(a.join("\n"))}

//Array.prototype.each=function(f){for(var i=0,l=this.length;i<l;i++)f.call(this[i])}
//function $A(o){var a=[];o=getById(o).childNodes;for(var i=0;i<o.length;i++){var e=o[i];if(e.tagName)a.push(e)}return a}
Array.prototype.remove=function(o){for(var i=0;i<this.length;i++){if(o==this[i])this.splice(i,1)}return this}
Array.prototype.repush=function(a){if(!a.length)a=[a];for(var i=0;i<a.length;i++){var e=a[i];var b=1;for(var j=0;j<this.length;j++){if(e==this[j]){b=0;break;}}if(b)this.push(e)}return this}

function getById(o){return typeof(o)=="string"?document.getElementById(o):o}
function $$(f,t){var a=document.getElementsByTagName(t?t:"*");for(var i=0;i<a.length;i++){f.apply(a[i])}}
function ae(o,e,f){if(!e){f=o;o=window;e="load"}try{o.attachEvent("on"+e,f)}catch(s){o.addEventListener(e,f,false)}}
function fe(e){e=e||event;return{x:e.clientX,y:e.clientY}}
function fo(o){l=o.offsetLeft;t=o.offsetTop;w=o.offsetWidth;h=o.offsetHeight;while(o=o.offsetParent){l+=o.offsetLeft;t+=o.offsetTop}return {x:l,y:t,w:w,h:h}}
function json(s){try{return eval("("+s+")")}catch(e){return null}}
function ajax(fun,url,str,xml){
  var o=function(){try{o=new ActiveXObject("Msxml2.XMLHTTP")}catch(e){try{o=new ActiveXObject("Microsoft.XMLHTTP")}catch(e){try{o=new XMLHttpRequest()}catch(e){}}}return o}();
  if(!o)return;url+="&"+Math.random();o.open(str?"POST":"GET",url,true);if(str)o.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
  o.onreadystatechange=function(){if(o.readyState==4)if(o.status==200)fun(xml?o.responseXML:o.responseText)};o.send(str);
}
function getCookie(name){var arr=document.cookie.match(new RegExp("(^| )"+name+"=([^;]*)(;|$)"));if(arr!=null)return unescape(arr[2]);return ""}
function setCookie(name,value){var exp =new Date();exp.setTime(exp.getTime()+30*24*60*60*1000);document.cookie=name+"="+escape(value)+";expires="+ exp.toGMTString()}

function fcheck(o,s){
  //<a href="" onclick="fcheck(this,'chk');return false">全选</a>
  var b=o.innerHTML=='全选';
  $$(function(){
    if(this.type=='checkbox'&&this.id.indexOf(s)!=-1)
      this.checked=b;
  },"input");
  o.innerHTML=b?'不选':'全选';
}
function falter(s,c){
  var o=document.getElementsByTagName("tr");
  for(var i=0;i<o.length;i++){
    var e=o[i];
    if(s&&e.className.indexOf(s)==-1)continue;
    e.onmouseover=function(){tempColor=this.style.backgroundColor;this.style.backgroundColor=c?c:'#ffc'};
    e.onmouseout=function(){this.style.backgroundColor=tempColor};
  }
}
function fmove(o1,o2){
  if(o2.length==1&&!o2[0].value)o2.length=0;
  for(var i=o1.length-1;i>=0;i--){
    var o=o1[i];
    if(o.selected){
      o1.remove(i);
      var b=0;
      for(var j=0;j<o2.length;j++){
        if(o2[j].value==o.value){b=1;break;}
      }
      if(!b)o2.options[o2.length]=new Option(o.text,o.value);
    }
  }
}










