var rc={};

document.write('<style type="text/css">.png {behavior: url("/js/rc_win/pngbehavior.htc");}</style>');

function rc_preload(in_src)
{
	var _object = new Image();
	_object.src = in_src;
}

function rc_image(in_src,in_width,in_height,in_alt)
{
	var _object = document.createElement("img");
	_object.src				= '/js/rc_win/images/'+in_src;
	_object.width			= in_width;
	_object.height			= in_height;
	_object.border			= 0;
	_object.alt				= in_alt;

	return _object;
}
function rc_image_png(in_src,in_width,in_height,in_alt)
{
	var _object = rc_image(in_src,in_width,in_height,in_alt);
	_object.className		= 'png';

	return _object;
}

/* XLib */
function rc_Def()
{
  for(var i=0; i<arguments.length; ++i){if(typeof(arguments[i])=='undefined') return false;}
  return true;
}

function rc_Num()
{
  for(var i=0; i<arguments.length; ++i){if(isNaN(arguments[i]) || typeof(arguments[i])!='number') return false;}
  return true;
}

function rc_Str(s)
{
  for(var i=0; i<arguments.length; ++i){if(typeof(arguments[i])!='string') return false;}
  return true;
}

function rc_GetElementById(e)
{
  if(typeof(e)=='string') {
    if(document.getElementById) e=document.getElementById(e);
    else if(document.all) e=document.all[e];
    else e=null;
  }
  return e;
}

function rc_GetElementsByTagName(t,p)
{
  var list = null;
  t = t || '*';
  p = p || document;
  if (p.getElementsByTagName) { // DOM1
    list = p.getElementsByTagName(t);
    if (t=='*' && (!list || !list.length)) list = p.all; // IE5 '*' bug
  }
  else { // IE4 object model
    if (t=='*') list = p.all;
    else if (p.all && p.all.tags) list = p.all.tags(t);
  }
  return list || new Array();
}

function rc_GetElementsByAttribute(sTag, sAtt, sRE, fn)
{
  var a, list, found = new Array(), re = new RegExp(sRE, 'i');
  list = rc_GetElementsByTagName(sTag);
  for (var i = 0; i < list.length; ++i) {
    a = list[i].getAttribute(sAtt);
    if (!a) {a = list[i][sAtt];}
    if (typeof(a)=='string' && a.search(re) != -1) {
      found[found.length] = list[i];
      if (fn) fn(list[i]);
    }
  }
  return found;
}

function rc_GetElementsByClassName(c,p,t,f)
{
  var found = new Array();
  var re = new RegExp('\\b'+c+'\\b', 'i');
//  var list = p.getElementsByTagName(t);
  var list = rc_GetElementsByTagName(t, p); // See xml comments.
  for (var i = 0; i < list.length; ++i) {
    if (list[i].className && list[i].className.search(re) != -1) {
      found[found.length] = list[i];
      if (f) f(list[i]);
    }
  }
  return found;
}

function rc_GetComputedStyle(oEle, sProp, bInt)
{
  var s, p = 'undefined';
  var dv = document.defaultView;
  if(dv && dv.getComputedStyle){
    s = dv.getComputedStyle(oEle,'');
    if (s) p = s.getPropertyValue(sProp);
  }
  else if(oEle.currentStyle) {
    // convert css property name to object property name for IE
    var i, c, a = sProp.split('-');
    sProp = a[0];
    for (i=1; i<a.length; ++i) {
      c = a[i].charAt(0);
      sProp += a[i].replace(c, c.toUpperCase());
    }
    p = oEle.currentStyle[sProp];
  }
  else return null;
  return bInt ? (parseInt(p) || 0) : p;
}

function rc_ClientHeight()
{
  var v=0,d=document,w=window;
  if(d.compatMode == 'CSS1Compat' && !w.opera && d.documentElement && d.documentElement.clientHeight)
    {v=d.documentElement.clientHeight;}
  else if(d.body && d.body.clientHeight)
    {v=d.body.clientHeight;}
  else if(rc_Def(w.innerWidth,w.innerHeight,d.width)) {
    v=w.innerHeight;
    if(d.width>w.innerWidth) v-=16;
  }
  return v;
}

function rc_ClientWidth()
{
  var v=0,d=document,w=window;
  if(d.compatMode == 'CSS1Compat' && !w.opera && d.documentElement && d.documentElement.clientWidth)
    {v=d.documentElement.clientWidth;}
  else if(d.body && d.body.clientWidth)
    {v=d.body.clientWidth;}
  else if(rc_Def(w.innerWidth,w.innerHeight,d.height)) {
    v=w.innerWidth;
    if(d.height>w.innerHeight) v-=16;
  }
  return v;
}


function rc_ScrollLeft(e, bWin)
{
  var offset=0;
  if (!rc_Def(e) || bWin || e == document || e.tagName.toLowerCase() == 'html' || e.tagName.toLowerCase() == 'body') {
    var w = window;
    if (bWin && e) w = e;
    if(w.document.documentElement && w.document.documentElement.scrollLeft) offset=w.document.documentElement.scrollLeft;
    else if(w.document.body && rc_Def(w.document.body.scrollLeft)) offset=w.document.body.scrollLeft;
  }
  else {
    e = rc_GetElementById(e);
    if (e && rc_Num(e.scrollLeft)) offset = e.scrollLeft;
  }
  return offset;
}

function rc_ScrollTop(e, bWin)
{
  var offset=0;
  if (!rc_Def(e) || bWin || e == document || e.tagName.toLowerCase() == 'html' || e.tagName.toLowerCase() == 'body') {
    var w = window;
    if (bWin && e) w = e;
    if(w.document.documentElement && w.document.documentElement.scrollTop) offset=w.document.documentElement.scrollTop;
    else if(w.document.body && rc_Def(w.document.body.scrollTop)) offset=w.document.body.scrollTop;
  }
  else {
    e = rc_GetElementById(e);
    if (e && rc_Num(e.scrollTop)) offset = e.scrollTop;
  }
  return offset;
}

function rc_ResizeEvent()
{
  if (window.xREL) setTimeout('rc_ResizeEvent()', 250);
  var w=window, cw=rc_ClientWidth(), ch=rc_ClientHeight();
  if (w.xPCW != cw || w.xPCH != ch) { w.xPCW = cw; w.xPCH = ch; if (w.xREL) w.xREL(); }
}

function rc_ScrollEvent()
{
  if (window.xSEL) setTimeout('rc_ScrollEvent()', 250);
  var w=window, sl=rc_ScrollLeft(), st=rc_ScrollTop();
  if (w.xPSL != sl || w.xPST != st) { w.xPSL = sl; w.xPST = st; if (w.xSEL) w.xSEL(); }
}

function rc_Height(e,h)
{
  if(typeof(e)!='object')
	  if(!(e=rc_GetElementById(e)))
		return 0;

  if (rc_Num(h)) {
    if (h<0) h = 0;
    else h=Math.round(h);
  }
  else h=-1;
  var css=rc_Def(e.style);
  if (e == document || e.tagName.toLowerCase() == 'html' || e.tagName.toLowerCase() == 'body') {
    h = rc_ClientHeight();
  }
  else if(css && rc_Def(e.offsetHeight) && rc_Str(e.style.height)) {
    if(h>=0) {
      var pt=0,pb=0,bt=0,bb=0;
      if (document.compatMode=='CSS1Compat') {
        var gcs = rc_GetComputedStyle;
        pt=gcs(e,'padding-top',1);
        if (pt !== null) {
          pb=gcs(e,'padding-bottom',1);
          bt=gcs(e,'border-top-width',1);
          bb=gcs(e,'border-bottom-width',1);
        }
        // Should we try this as a last resort?
        // At this point getComputedStyle and currentStyle do not exist.
        else if(rc_Def(e.offsetHeight,e.style.height)){
          e.style.height=h+'px';
          pt=e.offsetHeight-h;
        }
      }
      h-=(pt+pb+bt+bb);
      if(isNaN(h)||h<0) return;
      else e.style.height=h+'px';
    }
    h=e.offsetHeight;
  }
  else if(css && rc_Def(e.style.pixelHeight)) {
    if(h>=0) e.style.pixelHeight=h;
    h=e.style.pixelHeight;
  }
  return h;
}

function rc_Width(e,w)
{
  if(typeof(e)!='object')
	  if(!(e=rc_GetElementById(e)))
		return 0;

  if (rc_Num(w)) {
    if (w<0) w = 0;
    else w=Math.round(w);
  }
  else w=-1;
  var css=rc_Def(e.style);
  if (e == document || e.tagName.toLowerCase() == 'html' || e.tagName.toLowerCase() == 'body') {
    w = rc_ClientWidth();
  }
  else if(css && rc_Def(e.offsetWidth) && rc_Str(e.style.width)) {
    if(w>=0) {
      var pl=0,pr=0,bl=0,br=0;
      if (document.compatMode=='CSS1Compat') {
        var gcs = rc_GetComputedStyle;
        pl=gcs(e,'padding-left',1);
        if (pl !== null) {
          pr=gcs(e,'padding-right',1);
          bl=gcs(e,'border-left-width',1);
          br=gcs(e,'border-right-width',1);
        }
        // Should we try this as a last resort?
        // At this point getComputedStyle and currentStyle do not exist.
        else if(rc_Def(e.offsetWidth,e.style.width)){
          e.style.width=w+'px';
          pl=e.offsetWidth-w;
        }
      }
      w-=(pl+pr+bl+br);
      if(isNaN(w)||w<0) return;
      else e.style.width=w+'px';
    }
    w=e.offsetWidth;
  }
  else if(css && rc_Def(e.style.pixelWidth)) {
    if(w>=0) e.style.pixelWidth=w;
    w=e.style.pixelWidth;
  }
  return w;
}

function rc_Left(e, iX)
{
  if(!(e=rc_GetElementById(e))) return 0;
  var css=rc_Def(e.style);
  if (css && rc_Str(e.style.left)) {
    if(rc_Num(iX)) e.style.left=iX+'px';
    else {
      iX=parseInt(e.style.left);
      if(isNaN(iX)) iX=rc_GetComputedStyle(e,'left',1);
      if(isNaN(iX)) iX=0;
    }
  }
  else if(css && rc_Def(e.style.pixelLeft)) {
    if(rc_Num(iX)) e.style.pixelLeft=iX;
    else iX=e.style.pixelLeft;
  }
  return iX;
}

function rc_Right(e, iX)
{
	var parent = xParent(e, true);
	var max_width = rc_Width(parent);

	if(rc_Num(iX))
		iX = rc_Left(e,max_width-iX-rc_Width(e))+rc_Width(e);
	else
		iX = max_width-rc_Left(e)+rc_Width(e);

	return iX;
}

function rc_Top(e, iY)
{
  if(!(e=rc_GetElementById(e))) return 0;
  var css=rc_Def(e.style);
  if(css && rc_Str(e.style.top)) {
    if(rc_Num(iY)) e.style.top=iY+'px';
    else {
      iY=parseInt(e.style.top);
      if(isNaN(iY)) iY=rc_GetComputedStyle(e,'top',1);
      if(isNaN(iY)) iY=0;
    }
  }
  else if(css && rc_Def(e.style.pixelTop)) {
    if(rc_Num(iY)) e.style.pixelTop=iY;
    else iY=e.style.pixelTop;
  }
  return iY;
}

function rc_Bottom(e, iY)
{
	var parent = xParent(e, true);
	var max_height = rc_Height(parent);

	if(rc_Num(iY))
		iY = rc_Top(e,max_height-iY-rc_Height(e))+rc_Height(e);
	else
		iY = max_height-rc_Top(e)+rc_Height(e);

	return iY;
}

function rc_AddEventListener(e,eT,eL,cap)
{
  if(!(e=rc_GetElementById(e))) return;
  eT=eT.toLowerCase();
  if (e==window && !e.opera && !document.all) { // simulate resize and scroll events for all except Opera and IE // this is not a good sniff but I want to remove the sims before long
    if(eT=='resize') { e.xPCW=rc_ClientWidth(); e.xPCH=rc_ClientHeight(); e.xREL=eL; rc_ResizeEvent(); return; }
    if(eT=='scroll') { e.xPSL=rc_ScrollLeft(); e.xPST=rc_ScrollTop(); e.xSEL=eL; rc_ScrollEvent(); return; }
  }
  if(e.addEventListener) e.addEventListener(eT,eL,cap);
  else if(e.attachEvent) e.attachEvent('on'+eT,eL);
  else e['on'+eT]=eL;
}

function rc_RemoveEventListener(e,eT,eL,cap)
{
  if(!(e=rc_GetElementById(e))) return;
  eT=eT.toLowerCase();
  if(e==window) {
    if(eT=='resize' && e.xREL) {e.xREL=null; return;}
    if(eT=='scroll' && e.xSEL) {e.xSEL=null; return;}
  }
  if(e.removeEventListener) e.removeEventListener(eT,eL,cap);
  else if(e.detachEvent) e.detachEvent('on'+eT,eL);
  else e['on'+eT]=null;
}
