// x_libraries.js, X v3.15.2, Cross-Browser.com DHTML Library
// Modified and repacked for simpler use on a DHTML menu by Damon
// Just deleted some function, nothing more =P
// Copyright (c) 2004 Michael Foster, Licensed LGPL (gnu.org)

var xVersion='3.15.2',xFF1,xNN7, xNN4,xOp7,xOp5or6,xIE4Up,xIE4,xIE5,xMac,xUA=navigator.userAgent.toLowerCase();
if (window.opera){
  xOp7=(xUA.indexOf('opera 7')!=-1 || xUA.indexOf('opera/7')!=-1);
  if (!xOp7) xOp5or6=(xUA.indexOf('opera 5')!=-1 || xUA.indexOf('opera/5')!=-1 || xUA.indexOf('opera 6')!=-1 || xUA.indexOf('opera/6')!=-1);
}
else if (document.all && xUA.indexOf('msie')!=-1) {
  xIE4Up=parseInt(navigator.appVersion)>=4;
  xIE4=xUA.indexOf('msie 4')!=-1;
  xIE5=xUA.indexOf('msie 5')!=-1;
}
else if  (xUA.indexOf('netscape') != -1) {xNN7=true;}
else if  (xUA.indexOf('firefox') != -1) {xFF1=true;}
else if (document.layers) {xNN4=true;}
   

xMac=xUA.indexOf('mac')!=-1;

function xGetElementById(e) {
  if(typeof(e)!='string') return e;
  if(document.getElementById) e=document.getElementById(e);
  else if(document.all) e=document.all[e];
  else e=null;
  return e;
}

function xGetElementbyClass(e){ 
  var elem=new Array()
  var inc=0;
  var alltags=document.all? document.all :
document.getElementsByTagName("*") 
  for (i=0; i<alltags.length; i++){
   if (alltags[i].e==e) 
     elem[inc++]=alltags[i] 
   } 
  } 

function xGetElementsByClassName(clsName, parentEle, tagName, fn)
{
  var found = new Array();
  var re = new RegExp('\\b'+clsName+'\\b', 'i');
  var list = xGetElementsByTagName(tagName, parentEle);
  for (var i = 0; i < list.length; ++i) {
    if (list[i].className.search(re) != -1) {
      found[found.length] = list[i];
      if (fn) fn(list[i]);
    }
  }
  return found;
}

function xGetElementsByTagName(tagName, parentEle)
{
  var list = null;
  tagName = tagName || '*';
  parentEle = parentEle || document;
  if (xIE4 || xIE5) {
    if (tagName == '*') list = parentEle.all;
    else list = parentEle.all.tags(tagName);
  }
  else if (parentEle.getElementsByTagName) list = parentEle.getElementsByTagName(tagName);
  return list || new Array();
}

function xParent(e,bNode){
  if (!(e=xGetElementById(e))) return null;
  var p=null;
  if (!bNode && xDef(e.offsetParent)) p=e.offsetParent;
  else if (xDef(e.parentNode)) p=e.parentNode;
  else if (xDef(e.parentElement)) p=e.parentElement;
  return p;
}

function xGetElementsByAttribute(sTag, sAtt, sRE, fn)
{
  var a, list, found = new Array(), re = new RegExp(sRE, 'i');
  list = xGetElementsByTagName(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 xMoveTo(e,iX,iY) {
  var xL,xT;
  xL = xLeft(e,iX);
  xT = xTop(e,iY);
  return (xL + " " + xT);
}
function xLeft(e,iX) {
  
  if(!(e=xGetElementById(e))) return 0;
  
  var css=xDef(e.style);
  
  if (css && xStr(e.style.left)) 
  {
    if(xNum(iX)) 
      e.style.left=iX+'px';
    else 
    {
      iX=parseInt(e.style.left);
      if(isNaN(iX)) iX=0;
    }
  }
  else if(css && xDef(e.style.pixelLeft)) 
  {
    if(xNum(iX)) 
      e.style.pixelLeft=iX;
    else 
      iX=e.style.pixelLeft;
  }
  return iX;
}
function xTop(e,iY) {
  if(!(e=xGetElementById(e))) return 0;
  var css=xDef(e.style);
  if(css && xStr(e.style.top)) {
    if(xNum(iY)) e.style.top=iY+'px';
    else {
      iY=parseInt(e.style.top);
      if(isNaN(iY)) iY=0;
    }
  }
  else if(css && xDef(e.style.pixelTop)) {
    if(xNum(iY)) e.style.pixelTop=iY;
    else iY=e.style.pixelTop;
  }
  return iY;
}

function xShow(e) {
  if(!(e=xGetElementById(e))) return;
  if(e.style && xDef(e.style.display)) e.style.display='block';
}
function xHide(e) {
  if(!(e=xGetElementById(e))) return;
  if(e.style && xDef(e.style.display)) e.style.display='none';
}
function xWidthBig(e) {
  if(!(e=xGetElementById(e))) return;
  if(e.style && xDef(e.style.width)) e.style.width='33%';
}
function xWidthSmall(e) {
  if(!(e=xGetElementById(e))) return;
  if(e.style && xDef(e.style.width)) e.style.width='25%';
}

function xDef() {
  for(var i=0; i<arguments.length; ++i){if(typeof(arguments[i])=='undefined') return false;}
  return true;
}
function xStr(s) {
  for(var i=0; i<arguments.length; ++i){if(typeof(arguments[i])!='string') return false;}
  return true;
}
function xNum(n) {
  for(var i=0; i<arguments.length; ++i){if(typeof(arguments[i])!='number') return false;}
  return true;
}
function xClientWidth() {
  var w=0;
  if(xOp5or6) w=window.innerWidth;
  else if(!window.opera && document.documentElement && document.documentElement.clientWidth)
    w=document.documentElement.clientWidth;
  else if(document.body && document.body.clientWidth)
    w=document.body.clientWidth;
  else if(xDef(window.innerWidth,window.innerHeight,document.height)) {
    w=window.innerWidth;
    if(document.height>window.innerHeight) w-=16;
  }
  return w;
}
function xClientHeight() {
  var h=0;
  if(xOp5or6) h=window.innerHeight;
  else if(!window.opera && document.documentElement && document.documentElement.clientHeight)
    h=document.documentElement.clientHeight;
  else if(document.body && document.body.clientHeight)
    h=document.body.clientHeight;
  else if(xDef(window.innerWidth,window.innerHeight,document.width)) {
    h=window.innerHeight;
    if(document.width>window.innerWidth) h-=16;
  }
  return h;
}

function xResizeEvent() {
  //if (window.xREL) 
  setTimeout('xResizeEvent()', 250);
  var cw = xClientWidth(), ch = xClientHeight();
  if (window.xPCW != cw || window.xPCH != ch) 
  { 
    window.xPCW = cw; 
    window.xPCH = ch; 
    resiza (cw);
  }
}

function xBackground(e,sColor,sImage) {
  if(!(e=xGetElementById(e))) return '';
  var bg='';
  if(e.style) {
    if(xStr(sColor)) {
      if(!xOp5or6) e.style.backgroundColor=sColor;
      else e.style.background=sColor;
    }
    /*if(xStr(sImage)) e.style.backgroundImage=(sImage!='')? 'url('+sImage+')' : null;
    if(!xOp5or6) bg=e.style.backgroundColor;
    else bg=e.style.background;*/
  }
  return bg;
}


function xRemoveWidth(e) {
  /*if(!(e=xGetElementById(e))) return 0;

  var css=xDef(e.style);
  if(css && xDef(e.offsetWidth) && xStr(e.style.width)) 
  {
    e.style.width = e.oldWidth;
  }
  else if(css && xDef(e.style.pixelWidth)) 
  {
    if(uW) e.style.pixelWidth=e.oldWidth;
  }*/
}

function xSetWidth(e,uW,kD) {

  if(!(e=xGetElementById(e))) return 0;

  if (xNum(uW)) {
    if (uW<0) uW = 0;
    else uW=Math.round(uW);
  }
  else uW=0;
  var css=xDef(e.style);
  if(css && xDef(e.offsetWidth) && xStr(e.style.width)) {
    if(uW) 
    {
      //e.oldWidth = e.style.width;
      e.style.width = uW + kD;
    }
    //xSetCW(e, uW);
    uW=e.offsetWidth;
  }
  else if(css && xDef(e.style.pixelWidth)) {
    if(uW) 
    {
      e.style.pixelWidth=uW + kD;
      //e.oldWidth = e.style.pixelWidth;
    }
    uW=e.style.pixelWidth;
  }
  return uW;
}
function xGetWidth(e) {
  if(!(e=xGetElementById(e))) return 0;

  var css=xDef(e.style);
  if(css && xDef(e.offsetWidth) && xStr(e.style.width)) {
    return (e.offsetWidth);
  }
  else if(css && xDef(e.style.pixelWidth)) {
    return (e.style.pixelWidth);
  }
  return uW;
}
function xGetHeight(e) {
  
  var uH = 0;
  if(!(e=xGetElementById(e))) return 0;
  
  /*if (xNum(uH)) {
    if (uH<0) uH = 0;
    else uH=Math.round(uH);
  }
  else uH=0;*/
  
  var css=xDef(e.style);
  if(css && xDef(e.offsetHeight) && xStr(e.style.height)) {
    //if(uH) xSetCH(e, uH);
    uH=e.offsetHeight;
  }
  else if(css && xDef(e.style.pixelHeight)) {
    //if(uH) e.style.pixelHeight=uH;
    uH=e.style.pixelHeight;
  }
  //if (xOp7 || xOp5or6)
  //  uH = uH + 250;
  
  return uH;
}
function xSetHeight(e, uH, kD)
{
  if (e)
  {
    if (xNum(uH)) {
      if (uH<0) uH = 0;
      else uH=Math.round(uH);
    }
    else uH=0;
    
    var css=xDef(e.style);
    if(css && xDef(e.offsetHeight) && xStr(e.style.height)) {
      //if(uH) xSetCH(e, uH);
      e.style.height = uH + kD;
      uH = e.offsetHeight;
    }
    else if(css && xDef(e.style.pixelHeight)) {
      if(uH) e.style.pixelHeight=uH;
      uH = e.style.pixelHeight;
    }
  }
}

function xSetMargin(e, uH, kD)
{
  if (xNum(uH)) {
    if (uH<0) uH = 0;
    else uH=Math.round(uH);
  }
  else uH=0;//marginLeft
  
  var css=xDef(e.style);
  if(css && xStr(e.style.marginLeft)) {
    //if(uH) xSetCH(e, uH);
    e.style.marginLeft = uH + kD;
    uH = e.style.marginLeft;
  }
  /*else if(css && xDef(e.style.pixelHeight)) {
    if(uH) e.style.pixelHeight=uH;
    uH = e.style.pixelHeight;
  }*/
}

function xSetCW(ele,uW){
  var pl=0,pr=0,bl=0,br=0;
  if(xDef(document.defaultView) && xDef(document.defaultView.getComputedStyle)){
    pl=xGetCS(ele,'padding-left');
    pr=xGetCS(ele,'padding-right');
    bl=xGetCS(ele,'border-left-width');
    br=xGetCS(ele,'border-right-width');
  }
  else if(xDef(ele.currentStyle,document.compatMode)){
    if(document.compatMode=='CSS1Compat'){
      pl=parseInt(ele.currentStyle.paddingLeft);
      pr=parseInt(ele.currentStyle.paddingRight);
      bl=parseInt(ele.currentStyle.borderLeftWidth);
      br=parseInt(ele.currentStyle.borderRightWidth);
    }
  }
  else if(xDef(ele.offsetWidth,ele.style.width)){ // ?
    ele.style.width=uW+'px';
    pl=ele.offsetWidth-uW;
  }
  if(isNaN(pl)) pl=0; if(isNaN(pr)) pr=0; if(isNaN(bl)) bl=0; if(isNaN(br)) br=0;
  var cssW=uW-(pl+pr+bl+br);
  if(isNaN(cssW)||cssW<0) return;
  else ele.style.width=cssW+'px';
}
function xSetCollapsible (v)
{
  createCookie("unito_cookie",v,1);
}
function xGetCollapsible (v)
{
  if (readCookie("unito_cookie") != null)
    return (readCookie("unito_cookie"));
  else
    return ("false");
}

function xChangeFontColor (eL)
{
  eL.style.color = "#333333"
}

// cookie functions from scottandrew.com ...
// goood code never dies - 
// it just gets passed from 
// the source of one site to the next.
function createCookie(name,value,days)
{
	if (days)
	{
		var date = new Date();
		date.setTime(date.getTime()+(days*24*60*60*1000));
//		var expires = "; expires="+date.toGMTString();
		var expires = "";
	}
	else expires = "";
	document.cookie = name+"="+value+expires+"; path=/";
}

function readCookie(name)
{
	var nameEQ = name + "=";
	var ca = document.cookie.split(';');
	for(var i=0;i < ca.length;i++)
	{
		var c = ca[i];
		while (c.charAt(0)==' ') c = c.substring(1,c.length);
		if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
	}
	return null;
}

function eraseCookie(name)
{
	createCookie(name,"",-1);
}
