// +------------------------------------------------------------+
// |              Xin Calendar (In-Page Pro) Lite               |
// +------------------------------------------------------------+
// | Last Modified:                  26-Feb-2003                |
// | Web Site:                       http://www.yxScripts.com   |
// | EMail:                          m_yangxin@hotmail.com      |
// +------------------------------------------------------------+
// |      Copyright 2003  Xin Yang    All Rights Reserved.      |
// +------------------------------------------------------------+

// default settings
// ----------------
var yx_calFormat="Mon-dd-yyyy";
var yx_weekDay=0;
var yx_dayDigits=1;
var yx_footBarOn=1;

var yx_headBar=[
1,"solid","#6699cc",
100,1,
"sans-serif",12,"#ffffff","normal",
"#6699cc",2,

1,"inset","#6699cc",
15,1,
"sans-serif",12,"#ffffff","normal",
"#6699cc",3,
0,

"&#171;","&#187;","&#139;","&#155;",

1,"outset","#6699cc",
0,0,
"#6699cc",1
];

var yx_dayCells=[
1,
"solid", "outset",  "solid",  "solid",  "solid",  "solid",
"#6699cc","#6699cc","#6699cc","#6699cc","#6699cc","#ffffff",
24,1,
"sans-serif",12,
"#ffffff","#ffffff","#000000",          "#999999","#ffffff",
"center","normal",
"#6699cc","#6699cc","#ffffff","#f0f0f0","#f0f0f0","#6699cc",
4,        6,        3,        1,        2,        5,
-1
];

var yx_footBar=[
1,"inset","#6699cc",
42,1,
"sans-serif",12,"#ffffff","normal",
"#6699cc",2,
0,

"Clear","Close",

1,"outset","#6699cc",
0,0,
"#6699cc",1
];

var yx_basePad=[
0,"solid","#6699cc",
0,0,
"#ffffff",

1,1,1,
100
];

var yx_monthTitles=["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"];
var yx_dayTitles=["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday"];
// ----------------

// codes
var yx_cal=null, yx_curCal=null, yx_cals=new Array();
var yx_days=new Array(), yx_offsets=new Array(), yx_mTag=null;
var yx_pw=0, yx_ph=0, yx_hw=0, yx_hh=0, yx_fw=0, yx_fh=0, yx_mw=0, yx_mh=0, yx_tw=0, yx_th=0, yx_cw=0, yx_ch=0, yx_lw=0, yx_lh=0, yx_bw=0, yx_bh=0;
var yx_cY, yx_cM, yx_onBC="", yx_outBC="", yx_mx=0, yx_my=0;

var yx_isKon=(navigator.userAgent.indexOf("Konqueror")!=-1);
var yx_isOpera=(navigator.userAgent.indexOf("Opera")!=-1);
var yx_isMac=(navigator.userAgent.indexOf("Mac")!=-1);

var yx_isIE=(typeof(document.all)!="undefined" && !yx_isOpera && !yx_isKon);
var yx_isIE4=(yx_isIE && navigator.appVersion.indexOf("MSIE 4")!=-1);
var yx_isIE5=(yx_isIE && !yx_isIE4);
var yx_isN6=(navigator.userAgent.indexOf("Gecko")!=-1);
var yx_isK3=(yx_isKon && navigator.appVersion.indexOf('Konqueror/3')!=-1);
var yx_isO7=(navigator.userAgent.indexOf("Opera 7")!=-1);
var yx_isO70=(navigator.userAgent.indexOf("Opera 7.0 ")!=-1);

var yx_calSafe=(yx_isK3 || yx_isIE4 && !yx_isMac || yx_isIE5 || yx_isN6 || yx_isO7);
var yx_goDTD=(yx_isN6 || yx_isK3)?true:(yx_isIE5 || yx_isO7)?(((document.doctype)?document.doctype.name.indexOf(".dtd")!=-1:false)||((document.compatMode)?document.compatMode=="CSS1Compat":false)):false;
var yx_ptr=yx_isIE?"hand":"pointer";

function yxLayersIE4(id) { return document.all[id]; }
function yxLayersDOM(id) { return document.getElementById(id); }
var yxLayers=(yx_isIE4)?yxLayersIE4:yxLayersDOM;

function yx_getLeft(l) { return l.offsetLeft+(l.offsetParent?yx_getLeft(l.offsetParent):(yx_isIE && yx_isMac)?parseInt(document.body.leftMargin):0); }
function yx_getTop(l) { return l.offsetTop+(l.offsetParent?yx_getTop(l.offsetParent):(yx_isIE && yx_isMac)?parseInt(document.body.topMargin):0); }

function yx_toHex(num) {
  var hexStr="0123456789ABCDEF", num2=num%16, num1=(num-num2)/16;
  return hexStr.charAt(num1)+hexStr.charAt(num2);
}

function yx_toTen(num) {
  var hexStr="0123456789ABCDEF";
  return hexStr.indexOf(num.toUpperCase());
}

function yx_fromHex(num) {
  var char1=num.charAt(0), char2=num.charAt(1);
  return yx_toTen(char1)*16+yx_toTen(char2);
}

function yx_getColor(color, m) {
  var red=color.substring(1,3), green=color.substring(3,5), blue=color.substring(5,7);
  var num1=yx_fromHex(red)+m*51, num2=yx_fromHex(green)+m*51, num3=yx_fromHex(blue)+m*51;
  if (num1<0) { num1=0; }
  if (num1>255) { num1=255; }
  if (num2<0) { num2=0; }
  if (num2>255) { num2=255; }
  if (num3<0) { num3=0; }
  if (num3>255) { num3=255; }
  return "#"+yx_toHex(num1)+yx_toHex(num2)+yx_toHex(num3);
}

function yx_getBC(bs,bc) {
  var cl=(bs=="outset")?yx_getColor(bc,1):(bs=="inset")?yx_getColor(bc,-1):bc;
  var cd=(bs=="outset")?yx_getColor(bc,-1):(bs=="inset")?yx_getColor(bc,1):bc;
  return (cl+" "+cd+" "+cd+" "+cl);
}

function yx_getID() { return "yxID"+(++yxCount)+""; }; var yxCount=0;
function yx_getDIV() { return document.createElement("DIV"); }
function yx_makeLayerIE4(l,x,y,w,h,bw,bs,bc,pw,ph,ff,fs,fc,fa,fw,bkc,c,vis,idx) {
  var xID=yx_getID(), holder=(l==null)?document.body:l;
  var bstr=(bw>0)?("border-width:"+bw+"px; border-style:solid; border-color:"+yx_getBC(bs,bc)+"; "):"";
  var rh=(h>0)?("height:"+h+"px; "):"";

  holder.insertAdjacentHTML("AfterBegin",('<div id="'+xID+'" style="position:absolute; left:'+x+'px; top:'+y+'px; width:'+w+'px; '+rh+bstr+'padding:'+ph+'px '+pw+'px; font-family:'+ff+'; font-size:'+fs+'px; color:'+fc+'; text-align:'+fa+'; font-weight:'+fw+'; background-color:'+bkc+'; visibility:'+vis+'; z-index:'+idx+';"><nobr>'+c+'</nobr></div>'));

  return document.all[xID];
}
function yx_makeLayerRest(l,x,y,w,h,bw,bs,bc,pw,ph,ff,fs,fc,fa,fw,bkc,c,vis,idx) {
  var xx=yx_getDIV(), holder=(l==null)?document.body:l;
  with (xx.style) { position="absolute"; visibility=vis; left=x+"px"; top=y+"px"; zIndex=idx; }
  if (yx_isIE5) {
    holder.insertBefore(xx,holder.firstChild);
  }
  else {
    holder.appendChild(xx);
  }

  xx.innerHTML=c;
  with (xx.style) {
    if (yx_goDTD) {
      width=(w-(bw+pw)*2)+"px";
      if (h>0) { height=(h-(bw+ph)*2)+"px"; }
    }
    else {
      width=w+"px";
      if (h>0) {
        if (yx_isO70) {
          height=(h-(bw+ph)*2)+"px";
        }
        else {
          height=h+"px";
        }
      }
    }
    if (bw>0) {
      borderWidth=bw+"px"; borderStyle="solid"; borderColor=yx_getBC(bs,bc);
    }
    padding=ph+"px "+pw+"px";
    fontFamily=ff; fontSize=fs+"px"; color=fc; textAlign=fa; fontWeight=fw;
    backgroundColor=bkc;
  }

  return xx;
}
var yx_makeLayer=(yx_isIE4)?yx_makeLayerIE4:yx_makeLayerRest;

function yx_calOBJ(name, field, form, date, id, id2, dx, dy) {
  this.name=name;
  this.field=field; this.formName=form; this.form=null;
  this.date=date;
  this.id=id; this.id2=id2;
  this.dx=dx; this.dy=dy;
}

function yx_findCal(name) {
  for (var i=0; i<yx_cals.length; i++) {
    if (yx_cals[i].name==name) {
      if (yx_cals[i].form==null) {
        if (yx_cals[i].formName=="") {
          if (document.forms[0]) {
            yx_cals[i].form=document.forms[0];
          }
        }
        else if (document.forms[yx_cals[i].formName]) {
          yx_cals[i].form=document.forms[yx_cals[i].formName];
        }
      }

      return yx_cals[i];
    }
  }

  return null;
}

function yx_getDayTitle(y, m, d) { return yx_dayTitles[(new Date(y,m,d)).getDay()].substring(0,3); }

function yx_getMonthFromTitle(m3) {
  for (var i=0; i<yx_monthTitles.length; i++) {
    if (yx_monthTitles[i].toLowerCase().substring(0,3)==m3.toLowerCase()) {
      return i;
    }
  }

  return 0;
}

function yx_getFormat() {
  var re=/\d{4}\/\d{2}\/\d{2}/; // fix for IE4
  return re;
}

function yx_getDateNumbers(date) {
  var y=date.substring(0,4)-0;
  var m=date.substring(5,7)-1;
  var d=date.substring(8)-0;

  return new Array(y,m,d);
}

function yx_hideIt() { yx_hideCal(); }
function yx_hideCal() {
  yx_cal.style.visibility="hidden";
  window.status="";
}

function yx_lastDate(d) {
  var yy=d.getFullYear(), mm=d.getMonth();
  for (var i=31; i>=28; i--) {
    var nd=new Date(yy,mm,i);
    if (mm==nd.getMonth()) {
      return i;
    }
  }
  return 31;
}

function yx_firstDay(d) { return (new Date(d.getFullYear(),d.getMonth(),1)).getDay(); }

function yx_onCell() {
  with (this.style) {
    color=yx_dayCells[21]; backgroundColor=yx_dayCells[29]; zIndex=yx_dayCells[35]; borderColor=yx_onBC;
  }
}

function yx_outCell() {
  with (this.style) {
    color=yx_dayCells[19]; backgroundColor=yx_dayCells[26]; zIndex=yx_dayCells[32]; borderColor=yx_outBC;
  }
}

function yx_prepareCal(d, day) {
  var yy=d.getFullYear(), mm=d.getMonth();
  var dc=1, fd=yx_firstDay(d), ld=yx_lastDate(d);

  if (yx_weekDay>0 && fd==0) { fd=7; }

  yx_mTag.myMonth=mm;
  yx_mTag.innerHTML=yx_monthTitles[mm]+"&nbsp;"+yy;
  yx_mTag.style.height=yx_goDTD||yx_isO70?yx_mh-(yx_headBar[0]+yx_headBar[4])*2:yx_mh; // for IEMac

  var bs, bc, fc, bkc, cl, cd, zidx, theCell, wd;
  for (var i=0; i<6; i++) {
    for (var j=yx_weekDay; j<yx_weekDay+7; j++) {
      if (i*7+j<fd || dc>ld) {
        if (dc<=31) { yx_days[dc].style.zIndex=-1; }
        if (dc>ld) { dc++; }
      }
      else {
        theCell=yx_days[dc]; wd=(new Date(yy,mm,dc)).getDay();
        if (dc==day) {
          bs=yx_dayCells[2]; bc=yx_dayCells[8]; fc=yx_dayCells[18]; bkc=yx_dayCells[25]; zidx=yx_dayCells[31];

          theCell.onmouseover=null; theCell.onmouseout=null;
          theCell.on=true; theCell.style.cursor=yx_ptr;
        }
        else {
          bs=yx_dayCells[3]; bc=yx_dayCells[9]; fc=yx_dayCells[19]; bkc=yx_dayCells[26]; zidx=yx_dayCells[32];

          theCell.onmouseover=yx_onCell; theCell.onmouseout=yx_outCell;
          theCell.on=true; theCell.style.cursor=yx_ptr;
        }

        with (theCell.style) {
          left=yx_offsets[i][j-yx_weekDay][0]+"px";
          top=yx_offsets[i][j-yx_weekDay][1]+"px";

          borderColor=yx_getBC(bs,bc);
          color=fc; backgroundColor=bkc;
          zIndex=zidx;
        }

        dc++;
      }
    }
  }
}

function yx_showCal(name) {
  if (!yx_calSafe) { return; }

  if (yx_cal==null) {
    yx_makeHolder(); yx_initCal();
    yx_cal.style.width=yx_pw+"px"; yx_cal.style.height=yx_ph+"px"; // fix for IE4
  }

  var lastCal=yx_curCal;
  var d=new Date(), dd=0;

  yx_curCal=yx_findCal(name);

  if (yx_curCal!=null && yx_curCal.form!=null && yx_curCal.form[yx_curCal.field]) {
    var calRE=yx_getFormat();

    if (yx_curCal.form[yx_curCal.field].value!="" && calRE.test(yx_curCal.form[yx_curCal.field].value) || yx_curCal.date!="" && calRE.test(yx_curCal.date)) {
      var cd=yx_getDateNumbers((yx_curCal.form[yx_curCal.field].value!="")?yx_curCal.form[yx_curCal.field].value:yx_curCal.date);
      d=new Date(cd[0],cd[1],cd[2]);

      yx_cY=cd[0]; yx_cM=cd[1]; dd=cd[2];
    }
    else {
      yx_cY=d.getFullYear();
      yx_cM=d.getMonth();
      dd=d.getDate();
    }

    yx_prepareCal(d,dd);

    var cx, cy;
    if (yx_curCal.id=="" && yx_curCal.id2=="") {
      cx=yx_mx; cy=yx_my;
    }
    else {
      var l=yxLayers((yx_isK3 && yx_curCal.id2!="")?(yx_curCal.id2):(yx_curCal.id));
      cx=yx_getLeft(l); cy=yx_getTop(l);
    }
    yx_cal.style.left=cx+yx_curCal.dx+"px";
    yx_cal.style.top=cy+yx_curCal.dy+"px";
    yx_cal.style.visibility="visible";
  }
  else {
    if (yx_curCal==null) {
      window.status="Calendar ["+name+"] not found.";
    }
    else if (!yx_curCal.form) {
      window.status="Form ["+yx_curCal.formName+"] not found.";
    }
    else if (!yx_curCal.form[yx_curCal.field]) {
      window.status="Form Field ["+yx_curCal.formName+"."+yx_curCal.field+"] not found.";
    }

    if (lastCal!=null) { yx_curCal=lastCal; }
  }
}; var showCalendar=yx_showCal;

function yx_getDD(n) { return ((n<10)?"0":"")+n; }

function yx_clearDate() {
  yx_curCal.form[yx_curCal.field].value="";
  yx_hideCal();
}

function yx_pickIt() {
  if (this.myDay==0) {
    yx_clearDate();
  }
  else if (this.on) {
    yx_pickDate(this.myDay);
  }
}

function yx_pickDate(d) {
  yx_curCal.form[yx_curCal.field].value=yx_cY+"/"+yx_getDD(yx_cM+1)+"/"+yx_getDD(d);
  yx_hideCal();
}

function yx_clickIt(e) {
  if (yx_isIE || yx_isK3) {
    yx_mx=event.clientX+(yx_isK3?0:window.document.body.scrollLeft);
    yx_my=event.clientY+(yx_isK3?0:window.document.body.scrollTop);
    event.cancelBubble=false;
  }
  else if (yx_isN6) {
    yx_mx=e.pageX; yx_my=e.pageY;
    document.routeEvent(e);
  }
}
// ------

// cal layers
function yx_makeHolder() {
  if (yx_isIE4) {
    document.body.insertAdjacentHTML("AfterBegin",('<div id="yx_cal" style="position:absolute; left:0px; top:0px; visibility:hidden; z-index:'+yx_basePad[9]+'; background-color:#cccccc;"></div>'));
    yx_cal=document.all("yx_cal");
  }
  else {
    yx_cal=document.createElement("DIV");
    with (yx_cal.style) { position="absolute"; visibility="hidden"; left="0px"; top="0px"; zIndex=yx_basePad[9]; backgroundColor="#cccccc"; }
    if (yx_isIE) {
      document.body.insertBefore(yx_cal,document.body.firstChild);
    }
    else {
      document.body.appendChild(yx_cal);
    }
  }
}

function yx_initCal() {
  if (!yx_calSafe) { return; }

  var theCell=null;

  yx_onBC=yx_getBC(yx_dayCells[6],yx_dayCells[12]);
  yx_outBC=yx_getBC(yx_dayCells[3],yx_dayCells[9]);

  yx_bw=yx_basePad[0]+yx_basePad[3]; yx_bh=yx_basePad[0]+yx_basePad[4];
  yx_mw=yx_headBar[3]; yx_tw=yx_headBar[14]; yx_cw=yx_dayCells[13]; yx_lw=yx_footBar[3];
  yx_hw=yx_cw*7+yx_dayCells[36]*6; yx_fw=yx_hw; yx_pw=yx_bw*2+yx_hw;

  // prepare the empty calendar
  // the month title
  yx_mTag=yx_makeLayer(yx_cal,yx_bw+Math.floor((yx_hw-yx_mw)/2),0,yx_mw,0,yx_headBar[0],yx_headBar[1],yx_headBar[2],0,yx_headBar[4],yx_headBar[5],yx_headBar[6],yx_headBar[7],"center",yx_headBar[8],yx_headBar[9],"&nbsp;","inherit",yx_headBar[10]);
  yx_mh=yx_mTag.offsetHeight;
  yx_mTag.style.cursor="default";

  yx_hh=(yx_headBar[27]+yx_headBar[31])*2+((yx_th<yx_mh)?yx_mh:yx_th);

  yx_mTag.style.top=yx_bh+Math.floor((yx_hh-yx_mh)/2)+"px";

  // the head pad
  theCell=yx_makeLayer(yx_cal,yx_bw,yx_bh,yx_hw,yx_hh,yx_headBar[27],yx_headBar[28],yx_headBar[29],0,0,yx_headBar[5],yx_headBar[6],yx_headBar[32],"center",yx_headBar[8],yx_headBar[32],"&nbsp;","inherit",yx_headBar[33]);

  // the week days
  var dx=yx_bw, dy=yx_bh+yx_hh+yx_basePad[6];
  for (var i=yx_weekDay; i<yx_weekDay+7; i++) {
    theCell=yx_makeLayer(yx_cal,dx,dy,yx_cw,0,yx_dayCells[0],yx_dayCells[1],yx_dayCells[7],0,yx_dayCells[14],yx_dayCells[15],yx_dayCells[16],yx_dayCells[17],"center",yx_dayCells[23],yx_dayCells[24],(yx_dayDigits==0?yx_dayTitles[i]:yx_dayTitles[i].substring(0,yx_dayDigits)),"inherit",yx_dayCells[30]);
    if (yx_ch<theCell.offsetHeight) { yx_ch=theCell.offsetHeight; }
    theCell.style.cursor="default";
    dx+=yx_cw+yx_dayCells[36];
  }

  // the days
  dx=yx_bw, dy=yx_bh+yx_hh+yx_basePad[6]+yx_ch+yx_basePad[7];
  for (var i=1; i<=31; i++) {
    theCell=yx_makeLayer(yx_cal,dx,dy,yx_cw,yx_ch,yx_dayCells[0],yx_dayCells[3],yx_dayCells[9],0,yx_dayCells[14],yx_dayCells[15],yx_dayCells[16],yx_dayCells[19],yx_dayCells[22],yx_dayCells[23],yx_dayCells[26],i,"inherit",yx_dayCells[32]);
    if (yx_isIE) {
      theCell.onselectstart=function() { return false; }
    }

    theCell.onclick=yx_pickIt;
    theCell.style.cursor=yx_ptr;
    theCell.myDay=i; theCell.on=true;

    yx_days[i]=theCell;
  }

  for (var r=0; r<6; r++) {
    yx_offsets[r]=new Array();

    for (var c=yx_weekDay; c<yx_weekDay+7; c++) {
      yx_offsets[r][c-yx_weekDay]=new Array(dx,dy);

      if (r==0 || r==4 || r==5) {
        theCell=yx_makeLayer(yx_cal,dx,dy,yx_cw,yx_ch,yx_dayCells[0],yx_dayCells[4],yx_dayCells[10],0,yx_dayCells[14],yx_dayCells[15],yx_dayCells[16],yx_dayCells[27],yx_dayCells[22],yx_dayCells[23],yx_dayCells[27],"&nbsp;","inherit",yx_dayCells[33]);
        if (yx_isIE) {
          theCell.onselectstart=function() { return false; }
        }

        theCell.onclick=yx_pickIt;
        theCell.style.cursor="default";
        theCell.myDay=0;
      }

      dx+=yx_cw+yx_dayCells[36];
    }

    dx=yx_bw;
    dy+=yx_ch+yx_dayCells[36];
  }

  if (yx_footBarOn==1) {
    // the foot links
    var loff=yx_bh+yx_hh+(yx_ch*7+yx_dayCells[36]*5)+(yx_basePad[6]+yx_basePad[7]+yx_basePad[8])+yx_footBar[14]+yx_footBar[18];

    theCell=yx_makeLayer(yx_cal,yx_bw+Math.floor((yx_fw-yx_lw-yx_lw-yx_footBar[11])/2),loff,yx_lw,0,yx_footBar[0],yx_footBar[1],yx_footBar[2],0,yx_footBar[4],yx_footBar[5],yx_footBar[6],yx_footBar[7],"center",yx_footBar[8],yx_footBar[9],yx_footBar[12],"inherit",yx_footBar[10]);
    if (yx_lh < theCell.offsetHeight) { yx_lh=theCell.offsetHeight; }
    theCell.style.cursor=yx_ptr;
    theCell.onclick=yx_clearDate;
    if (yx_isIE) {
      theCell.onselectstart=function() { return false; }
    }

    theCell=yx_makeLayer(yx_cal,yx_bw+Math.floor((yx_fw-yx_lw*2-yx_footBar[11])/2)+yx_lw+yx_footBar[11],loff,yx_lw,0,yx_footBar[0],yx_footBar[1],yx_footBar[2],0,yx_footBar[4],yx_footBar[5],yx_footBar[6],yx_footBar[7],"center",yx_footBar[8],yx_footBar[9],yx_footBar[13],"inherit",yx_footBar[10]);
    if (yx_lh < theCell.offsetHeight) { yx_lh=theCell.offsetHeight; }
    theCell.style.cursor=yx_ptr;
    theCell.onclick=yx_hideIt; // fix for K3
    if (yx_isIE) {
      theCell.onselectstart=function() { return false; }
    }

    yx_fh=(yx_footBar[14]+yx_footBar[18])*2+yx_lh;

    // the foot pad
    theCell=yx_makeLayer(yx_cal,yx_bw,loff-yx_footBar[14]-yx_footBar[18],yx_fw,yx_fh,yx_footBar[14],yx_footBar[15],yx_footBar[16],0,yx_footBar[18],yx_footBar[5],yx_footBar[6],yx_footBar[19],"center",yx_footBar[8],yx_footBar[19],"&nbsp;","inherit",yx_footBar[20]);
  }

  yx_ph=yx_bh*2+yx_hh+(yx_ch*7+yx_dayCells[36]*5)+(yx_basePad[6]+yx_basePad[7])+(yx_basePad[8]+yx_fh)*yx_footBarOn;

  // the base pad  
  theCell=yx_makeLayer(yx_cal,0,0,yx_pw,yx_ph,yx_basePad[0],yx_basePad[1],yx_basePad[2],yx_basePad[3],yx_basePad[4],yx_headBar[5],yx_headBar[6],yx_basePad[5],"center",yx_headBar[8],yx_basePad[5],"&nbsp;","inherit",0);
}
// ----

// user functions
function addCalendar(name, field, form, date, id, id2, dx, dy) {
  yx_cals[yx_cals.length]=new yx_calOBJ(name, field, form, date, id, id2, dx, dy);
}

function setFormat() {}
function setWeekDay(wd) { yx_weekDay=wd; }
function switchLinks(mode) { yx_footBarOn=mode; }
function switchTags() {}
function setCalendarMode() {}
// ------

// capture clicks
if (yx_calSafe) {
  if (yx_isN6) { document.captureEvents(Event.CLICK); }
  document.onclick=yx_clickIt;
}
