String.prototype.pad = function(l, s, t){
	return s || (s = " "), (l -= this.length) > 0 ? (s = new Array(Math.ceil(l / s.length)
		+ 1).join(s)).substr(0, t = !t ? l : t == 1 ? 0 : Math.ceil(l / 2))
		+ this + s.substr(0, l - t) : this;
};

function access(item,url){
  window.open("/index.php?page=access&item="+item+"&url="+escape(url)+"&ourl="+escape(document.location.href));
}

function access_partner(item,url){
  window.open("/index.php?page=access&src=partner&item="+item+"&url="+escape(url)+"&ourl="+escape(document.location.href)) ;
}

function access_test(item,url){
  window.open("/index.php?page=access&item="+item+"&url="+escape(url)+"&ourl="+escape(document.location.href));
}

function CharsCount(id,max){
  document.getElementById("c"+id).value=max-document.getElementById(id).value.length;
  if(document.getElementById("c"+id).value<=0){
    document.getElementById(id).value=document.getElementById(id).value.substr(0,max);
    document.getElementById("c"+id).value=0;
  }
}

function getEl (id) {
	return document.getElementById(id);
}

function getAbsX(elt) 
{ 
	return (elt.x) ? elt.x : getAbsPos(elt,"Left"); 
}

function getAbsY(elt) 
{ 
	return (elt.y) ? elt.y : getAbsPos(elt,"Top"); 
}

function getAbsPos(elt,which) 
{
    iPos = 0;
    while (elt != null) 
    {
        iPos += elt["offset" + which];
        elt = elt.offsetParent;
    }
    return iPos;
}

function showInfo(elm,text){
  var infobox = getEl('infobox');
  if(text!=''){
    infobox.innerHTML=text;
    infobox.style.display='block';
    infobox.style.left=getAbsX(elm) - infobox.offsetWidth - 10 + "px";
    var max_bottom = document.body.clientHeight+document.body.scrollTop;
    var posy = getAbsY(elm) + 13;
    if(max_bottom<(posy+infobox.offsetHeight-13))
      infobox.style.top=getAbsY(elm) - infobox.offsetHeight - 13 + "px";
    else
      infobox.style.top=posy + "px";
  }
}

function hideInfo(){
  var infobox = getEl('infobox');
  infobox.style.display='none';
}
    
var agt=navigator.userAgent.toLowerCase();

// *** BROWSER VERSION ***
// Note: On IE5, these return 4, so use is_ie5up to detect IE5.
var is_major = parseInt(navigator.appVersion);
var is_minor = parseFloat(navigator.appVersion);

var is_ie     = ((agt.indexOf("msie") != -1) && (agt.indexOf("opera") == -1));
var is_ie3    = (is_ie && (is_major < 4));
var is_ie4    = (is_ie && (is_major == 4) && (agt.indexOf("msie 4")!=-1) );
var is_ie4up  = (is_ie && (is_major >= 4));
var is_ie5    = (is_ie && (is_major == 4) && (agt.indexOf("msie 5.0")!=-1) );
var is_ie5_5  = (is_ie && (is_major == 4) && (agt.indexOf("msie 5.5") !=-1));
var is_ie5up  = (is_ie && !is_ie3 && !is_ie4);
var is_ie5_5up =(is_ie && !is_ie3 && !is_ie4 && !is_ie5);
var is_ie6    = (is_ie && (is_major == 4) && (agt.indexOf("msie 6.")!=-1) );
