var g_arrObjectReferences = new Array();

function getE(id){if(!g_arrObjectReferences[id])g_arrObjectReferences[id]=document.getElementById(id);return g_arrObjectReferences[id];}

function showE(e){e.style.visibility='visible';}

function hideE(e){e.style.visibility='hidden';}

function displayE(e){e.style.display="";}

function unDisplayE(e){e.style.display="none";}

function setZ(e,z){e.style.zIndex=z;}

function getZ(e){return e.style.zIndex;}

function setX(e,x){e.style.left=x;}

function getX(e){return(parseInt(e.style.left));}

function setY(e,y){e.style.top=y;}

function getY(e){return(parseInt(e.style.top));}

function setW(e,w){e.style.width=w;}

function getW(e){if(e.style.width)return(parseInt(e.style.width));return(e.offsetWidth);}

function setH(e,h){e.style.height=h;}

function getH(e){if (e.style.height)return(parseInt(e.style.height));return(e.offsetHeight);}

function IsNotSelected(o){return(o.options.selectedIndex<0)}

function IsNotOr1stSelected(o){return(o.options.selectedIndex<1)}

function IsChecked(o){return(o.checked)}

function IsEmpty(s){return(s.length==0)}

function IsNum(n){return/^-?\d*\.?\d*$/.test(n)}

function IsDec(n){return/^-?\d{0,18}(\.\d{0,10})?$/.test(n)}

function IsInt(n){return/^-?\d+$/.test(n)}

function IsMilli(n){return/^\d+$/.test(n)&&n<1000}

function IsDate(d,m,y){return(IsInt(d)&&IsInt(m)&&IsInt(y))&&!((d<1||d>31||m<1||m>12)||(d==31&&(m==2||m==4||m==6||m==9||m==11))||(d==30&&m==2)||(d==29&&m==2&&(y%4!=0||(y%100==0&&y%400!=0))))}

function IsEmail(s){return/^[\w\.-]+\@[\w\.-]+\.\w+$/.test(s)}

function HasLength(s,m,M){return(s.length>=m&&s.length<=M)}

function FirstIsLetter(s){return/^[a-zA-Z]/.test(s)}

function IsAlphaNum(s){return/^\w+$/.test(s)}

function IsUID(s){return/^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$/.test(s)}

function IsSafePwd(s){return s.length>=8&&/\d+.*\d+/.test(s)&&/[a-zA-Z]+.*[a-zA-Z]+/.test(s)}

function Warn(o,m){alert(m);o.focus();return false;}

function IsRadioSelected(o){var b=false,i=0;while(o[i]){b=b||o[i].checked;i++}return b}

function getValue(o){var i=0;if(o.value)return o.value;if(typeof o.selectedIndex!='undefined')return o[o.selectedIndex].value;while(o[i]){if(o[i].checked) return o[i].value;i++}}

function getPageX(e) {
  var x=0; var obj=e;
  while(obj.offsetParent){
    x+=obj.offsetLeft;obj=obj.offsetParent;
  }
  return x+obj.offsetLeft;
}
function getPageY(e) {
  var y=0; var obj=e;
  while(obj.offsetParent){
    y+=obj.offsetTop;obj=obj.offsetParent;
  }
  return y+obj.offsetTop;
}

function getI(id){
 if (lay)return findI(id, doc);
 if (ie4)return document.all[id];
 if(dom)return doc.getElementById(id);}
function findI(id, d){
 var i,img;
 for(i=0;i<d.images.length;i++)if(d.images[i].name==id)return d.images[i];
 for (i=0;i<d.layers.length;i++)if((img=findI(id,d.layers[i].document))!= null){img.container = d.layers[i];return img;}}
function getIPageX(im){
 var x,obj;
 if(lay)return (im.container)?(im.container.pageX+im.x):im.x;
 if(ie4||dom){x=0;obj=im;
  while(obj.offsetParent){x+=obj.offsetLeft;obj=obj.offsetParent;}
  return x+obj.offsetLeft;}}
function getIPageY(im){
 var y, obj;
 if(lay)return (im.container)?(im.container.pageY+im.y):im.y;
 if(ie4||dom){y=0;obj=im;
  while(obj.offsetParent){y+=obj.offsetTop;obj=obj.offsetParent;}
  return y+obj.offsetTop;}}

function isString(a) {
	return typeof a == 'string';
}

function isInt(x) { 
	var y=parseInt(x); 
	if (isNaN(y)) return false; 
	return x==y && x.toString()==y.toString(); 
}
 
function dosearch() {
	var search = document.getElementById("inputSearch");
	if(search.value!='') searchRedirector(search.value);
	else return false;
}

function dosearchwithkeyboard(e) { 
	var keycode;
	if (window.event) keycode = window.event.keyCode;
	else if (e) keycode = e.which;
	if(keycode==13) dosearch();
	return;
}

function searchRedirector(stringDatas) {
	window.location.replace("/search/index.lbl?search="+encodeURIComponent(stringDatas));
}

function setEffectOpacity(elementToChange,newval) {
	if(!newval)
		var newval = 65;
 	elementToChange.style.MozOpacity = '0.'+newval;
 	elementToChange.style.opacity = '0.'+newval;
 	elementToChange.style.KhtmlOpacity = '0.'+newval;
	elementToChange.style.filter = "alpha(opacity='"+newval+"');";
}

function removeEffectOpacity(elementToChange) {
 	elementToChange.style.MozOpacity = '';
 	elementToChange.style.opacity = '';
 	elementToChange.style.KhtmlOpacity = '';
	elementToChange.style.filter = '';
}

function effIMG(eleidIMG,opac){
	if(isString(eleidIMG)) var ele = document.getElementById(eleidIMG);
 	else var ele = eleidIMG;
 	if(!ele) return;
 	if(opac>=1){
	 	ele.style.MozOpacity = '';
	 	ele.style.opacity = '';
	 	ele.style.KhtmlOpacity = '';	
	 	ele.style.filter = '';}
 	else{
	 	ele.style.MozOpacity = opac;
	 	ele.style.opacity = opac;
	 	ele.style.KhtmlOpacity = opac;	
	 	ele.style.filter = "alpha(opacity='"+parseInt(opac*100)+"');";}
}

function animateRollOver(strID){
	effIMG(strID,1);
	document.getElementById(strID).style.display = '';
}

function rvoid(event) {
  event = event?event:window.event;
  if (event.stopPropagation) 
  	event.stopPropagation();
  event.cancelBubble = true;
}

function getXHR(){
  var xhr = null; 
  if(window.XMLHttpRequest) // Firefox et autres
    xhr = new XMLHttpRequest(); 
    if (xhr.overrideMimeType) {
			xhr.overrideMimeType('text/xml');
		}
  else if(window.ActiveXObject){ // Internet Explorer 
    try {
      xhr = new ActiveXObject("Msxml2.XMLHTTP");
    } catch (e) {
      xhr = new ActiveXObject("Microsoft.XMLHTTP");
    }
  }
  else { // XMLHttpRequest non supporté par le navigateur 
    alert("Votre navigateur ne supporte pas les objets XMLHTTPRequest..."); 
    xhr = false; 
  }
  return xhr;
}

function getXHRHTTP(){
  var xhr = null; 
  if(window.XMLHttpRequest) // Firefox et autres
    xhr = new XMLHttpRequest(); 
  else if(window.ActiveXObject){ // Internet Explorer 
    try {
      xhr = new ActiveXObject("Msxml2.XMLHTTP");
    } catch (e) {
      xhr = new ActiveXObject("Microsoft.XMLHTTP");
    }
  }
  else { // XMLHttpRequest non supporté par le navigateur 
    alert("Votre navigateur ne supporte pas les objets XMLHTTPRequest..."); 
    xhr = false; 
  }
  return xhr;
}

var arVersion = navigator.appVersion.split("MSIE");
var version = parseFloat(arVersion[1]);
function fixIE6PNGS(){
	if(navigator.appName!='Microsoft Internet Explorer'&&navigator.appVersion!='6') return false;
	if ((version >= 5.5) && (document.body.filters)) {
	   for(var i=0; i<document.images.length; i++){
	      var img = document.images[i];
	      var imgName = img.src.toUpperCase();
	      if (imgName.substring(imgName.length-3, imgName.length) == "PNG"){
	         var imgID = (img.id) ? "id='" + img.id + "' " : "";
	         var imgClass = (img.className) ? "class='" + img.className + "' " : "";
	         var imgTitle = (img.title) ? "title='" + img.title + "' " : "title='" + img.alt + "' ";
	         var imgStyle = "display:inline-block;" + img.style.cssText;
	         if (img.align == "left") imgStyle = "float:left;" + imgStyle;
	         if (img.align == "right") imgStyle = "float:right;" + imgStyle;
	         if (img.parentElement.href) imgStyle = "cursor:hand;" + imgStyle;
	         var strNewHTML = "<span class=\"pngfixspan\" " + imgID + imgClass + imgTitle+ " style=\"" + "width:" + img.width + "px; height:" + img.height + "px;" + imgStyle + ";"+ "filter:progid:DXImageTransform.Microsoft.AlphaImageLoader"+ "(src=\'" + img.src + "\', sizingMethod='scale');\"></span>" ;
	         img.outerHTML = strNewHTML;
	         i = i-1;
	}}}
}

/*
 Automatic, anti-aliased rounded corners.
 
 By Steven Wittens
 Based on http://pro.html.it/esempio/nifty/
 
 Thanks to Jacob from Oddlabs.com for fixing two nasty bugs.
*/

function NiftyCheck() {
  if(!document.getElementById || !document.createElement) {
    return false;
  }
  var b = navigator.userAgent.toLowerCase();
  if (b.indexOf("msie 5") > 0 && b.indexOf("opera") == -1) {
    return false;
  }
  return true;
}

function Rounded(selector, bk, color, sizex, sizey) {
  var i;
  var v = getElementsBySelector(selector);
  var l = v.length;
  for (i = 0; i < l; i++) {
    AddTop(v[i], bk, color, sizex, sizey);
    AddBottom(v[i], bk, color, sizex, sizey);
  }
}

Math.sqr = function (x) {
  return x*x;
};

function Blend(a, b, alpha) {
  var ca = Array(
    parseInt('0x' + a.substring(1, 3)), 
    parseInt('0x' + a.substring(3, 5)), 
    parseInt('0x' + a.substring(5, 7))
  );
  var cb = Array(
    parseInt('0x' + b.substring(1, 3)), 
    parseInt('0x' + b.substring(3, 5)), 
    parseInt('0x' + b.substring(5, 7))
  );
  r = '0' + Math.round(ca[0] + (cb[0] - ca[0])*alpha).toString(16);
  g = '0' + Math.round(ca[1] + (cb[1] - ca[1])*alpha).toString(16);
  b = '0' + Math.round(ca[2] + (cb[2] - ca[2])*alpha).toString(16);
  return '#'
    + r.substring(r.length - 2)
    + g.substring(g.length - 2)
    + b.substring(b.length - 2);
}

function AddTop(el, bk, color, sizex, sizey) {
  var i, j;
  var d = document.createElement("div");
  d.style.backgroundColor = bk;
  d.className = "rounded";
  var lastarc = 0;
  for (i = 1; i <= sizey; i++) {
    var coverage, arc2, arc3;
    // Find intersection of arc with bottom of pixel row
    arc = Math.sqrt(1.0 - Math.sqr(1.0 - i / sizey)) * sizex;
    // Calculate how many pixels are bg, fg and blended.
    var n_bg = sizex - Math.ceil(arc);
    var n_fg = Math.floor(lastarc);
    var n_aa = sizex - n_bg - n_fg;
    // Create pixel row wrapper
    var x = document.createElement("div");
    var y = d;
    x.style.margin = "0px " + n_bg +"px";
    // Make a wrapper per anti-aliased pixel (at least one)
    for (j = 1; j <= n_aa; j++) {
      // Calculate coverage per pixel
      // (approximates circle by a line within the pixel)
      if (j == 1) {
        if (j == n_aa) {
          // Single pixel
          coverage = ((arc + lastarc) * .5) - n_fg;
        }
        else {
          // First in a run
          arc2 = Math.sqrt(1.0 - Math.sqr(1.0 - (n_bg + 1) / sizex)) * sizey;
          coverage = (arc2 - (sizey - i)) * (arc - n_fg - n_aa + 1) * .5;
        }
      }
      else if (j == n_aa) {
        // Last in a run
        arc2 = Math.sqrt(1.0 - Math.sqr((sizex - n_bg - j + 1) / sizex)) * sizey;
        coverage = 1.0 - (1.0 - (arc2 - (sizey - i))) * (1.0 - (lastarc - n_fg)) * .5;
      }
      else {
        // Middle of a run
        arc3 = Math.sqrt(1.0 - Math.sqr((sizex - n_bg - j) / sizex)) * sizey;
        arc2 = Math.sqrt(1.0 - Math.sqr((sizex - n_bg - j + 1) / sizex)) * sizey;
        coverage = ((arc2 + arc3) * .5) - (sizey - i);
      }
      
      x.style.backgroundColor = Blend(bk, color, coverage);
      y.appendChild(x);
      y = x;
      var x = document.createElement("div");
      x.style.margin = "0px 1px";
    }
    x.style.backgroundColor = color;
    y.appendChild(x);
    lastarc = arc;
  }
  el.insertBefore(d, el.firstChild);
}

function AddBottom(el, bk, color, sizex, sizey) {
  var i, j;
  var d = document.createElement("div");
  d.className = "rounded";
  d.style.backgroundColor = bk;
  var lastarc = 0;
  for (i = 1; i <= sizey; i++) {
    var coverage, arc2, arc3;
    // Find intersection of arc with bottom of pixel row
    arc = Math.sqrt(1.0 - Math.sqr(1.0 - i / sizey)) * sizex;
    // Calculate how many pixels are bg, fg and blended.
    var n_bg = sizex - Math.ceil(arc);
    var n_fg = Math.floor(lastarc);
    var n_aa = sizex - n_bg - n_fg;
    // Create pixel row wrapper
    var x = document.createElement("div");
    var y = d;
    x.style.margin = "0px " + n_bg + "px";
    // Make a wrapper per anti-aliased pixel (at least one)
    for (j = 1; j <= n_aa; j++) {
      // Calculate coverage per pixel
      // (approximates circle by a line within the pixel)
      if (j == 1) {
        if (j == n_aa) {
          // Single pixel
          coverage = ((arc + lastarc) * .5) - n_fg;
        }
        else {
          // First in a run
          arc2 = Math.sqrt(1.0 - Math.sqr(1.0 - (n_bg + 1) / sizex)) * sizey;
          coverage = (arc2 - (sizey - i)) * (arc - n_fg - n_aa + 1) * .5;
        }
      }
      else if (j == n_aa) {
        // Last in a run
        arc2 = Math.sqrt(1.0 - Math.sqr((sizex - n_bg - j + 1) / sizex)) * sizey;
        coverage = 1.0 - (1.0 - (arc2 - (sizey - i))) * (1.0 - (lastarc - n_fg)) * .5;
      }
      else {
        // Middle of a run
        arc3 = Math.sqrt(1.0 - Math.sqr((sizex - n_bg - j) / sizex)) * sizey;
        arc2 = Math.sqrt(1.0 - Math.sqr((sizex - n_bg - j + 1) / sizex)) * sizey;
        coverage = ((arc2 + arc3) * .5) - (sizey - i);
      }
      
      x.style.backgroundColor = Blend(bk, color, coverage);
      y.insertBefore(x, y.firstChild);
      y = x;
      var x = document.createElement("div");
      x.style.margin = "0px 1px";
    }
    x.style.backgroundColor = color;
    y.insertBefore(x, y.firstChild);
    lastarc = arc;
  }
  el.appendChild(d);
}

function getElementsBySelector(selector) {
  var i;
  var s = [];
  var selid = "";
  var selclass = "";
  var tag = selector;
  var objlist = [];
  if (selector.indexOf(" ") > 0) {  //descendant selector like "tag#id tag"
    s = selector.split(" ");
    var fs = s[0].split("#");
    if (fs.length == 1) {
      return objlist;
    }
    return document.getElementById(fs[1]).getElementsByTagName(s[1]);
  }
  if (selector.indexOf("#") > 0) { //id selector like "tag#id"
    s = selector.split("#");
    tag = s[0];
    selid = s[1];
  }
  if (selid != "") {
    objlist.push(document.getElementById(selid));
    return objlist;
  }
  if (selector.indexOf(".") > 0) {  //class selector like "tag.class"
    s = selector.split(".");
    tag = s[0];
    selclass = s[1];
  }
  var v = document.getElementsByTagName(tag);  // tag selector like "tag"
  if (selclass == "") {
    return v;
  }
  for (i = 0; i < v.length; i++) {
    if (v[i].className == selclass) {
      objlist.push(v[i]);
    }
  }
  return objlist;
}

function isArray(obj) {
   if (obj.constructor.toString().indexOf("Array") == -1) return false;
   return true;
}


if (!window.console) {window.console = {debug: function(o) { return false;}}}
