function axp(formi,divi) {
  var params = $(formi).serialize('',true);
  var params = params+"&formi="+formi+"&sid="+Math.random() 
  var url="index.php";
  new Ajax.Updater(divi, url, { method: 'post', parameters: params });
}

function ag(bl,divi,qr,extr) {
  var url="index.php";
  var pars = "port="+bl+"&qr="+qr+"&extra="+extr
  var pars = pars+"&sid="+Math.random();
  new Ajax.Updater(divi, url, { method: 'get', parameters: pars });
}

function az(bl,divi,qr,extr) {
  var url="index.php";
  var pars = "port="+bl+"&qr="+qr+"&extra="+extr
  var pars = pars+"&sid="+Math.random();
  new Ajax.Updater(divi, url, { method: 'get', parameters: pars, onLoading: myLoading  });
}

function myLoading() {
  //  alert(wd);  
  // wd = 500;
  // document.getElementById("zoom").style.backgroundColor = 'white';  
  document.getElementById("a1").innerHTML = "<h1>wait...</h1>";
  // document.getElementById("zoom").style.width = "100%";
  // document.getElementById("zoom").style.height = "100%";
  
}

function myMouseOver(mdiv,color) {
  mdiv.style.backgroundColor = color;
}

function highlight(mdiv) {
  var koko;
  var x = mdiv.parentNode
  koko = mdiv.parentNode.childNodes.length
  for ( j=0;j<x.childNodes.length;j++) {
    x.childNodes[j].style.background = 'white';
  }
  mdiv.style.backgroundColor = 'MediumSpringGreen';
}

function chta(str,rws,cols){
    ml = rws * cols;
    var lineBreaks =  lineBreakCount(str.value) ;
    if (lineBreaks > rws){
        trim(str);
    }
    if ( str.value.length > ml ) {
        str.value = str.value.substr(0,ml);
    }
}

function ScrollToElement(theElement){
  var selectedPosX = 0;
  var selectedPosY = 0;
              
  while(theElement != null){
    selectedPosX += theElement.offsetLeft;
    selectedPosY += theElement.offsetTop;
    theElement = theElement.offsetParent;
  }                        		      
 window.scrollTo(selectedPosX,selectedPosY);
}

function LeftTrim(str) {
    var re = /\s*((\S+\s*)*)/;
    return str.replace(re, "$1");

}

function RightTrim(str) {
    var re = /((\s*\S+)*)\s*/;
    return str.replace(re, "$1");

}

function trim(str) {
    str.value = LeftTrim(RightTrim(str.value));
}

function lineBreakCount(str){
    try {
        return((str.match(/[^\n]*\n[^\n]*/gi).length));
    } catch(e) {
        return 0;
    }
}



function hbg(hide,raise) {
  /* document.getElementById(hide).style.opacity="0.1"
     document.getElementById(hide).style.filter="alpha(opacity = 10)"
  */
  document.getElementById(raise).style.display="block"
  
  if( typeof( window.innerWidth ) == 'number' ) {
    myw = window.innerWidth;
    myh = window.innerHeight;
  } else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
    myw = document.documentElement.clientWidth;
    myh = document.documentElement.clientHeight;
  } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
    myw = document.body.clientWidth;
    myh = document.body.clientHeight;
  }
  var tp=document.getElementById(raise).offsetTop;
  var ng= myh - tp - 60 ;
  document.getElementById(raise).style.height=ng+"px";
}

