function compara_date(d1,d2)
{
var entry = d1.split('-');
y=entry[0]*1;
m=entry[1]*1-1;
d=entry[2]*1;
var data1 = new Date(y,m,d);

var entry = d2.split('-');
y=entry[0]*1;
m=entry[1]*1-1;
d=entry[2]*1;
var data2 = new Date(y,m,d);

if(data1>data2) return true;
else return false;



}


function is_float_minus(char, mozChar) {

if(mozChar != null) { // Look for a Mozilla-compatible browser
if((mozChar >= 48 && mozChar <= 57 && mozChar != 13) ||(mozChar==46) ||(mozChar==45) ||(mozChar==8)||(mozChar==0)) RetVal = true;
else {
RetVal = false;
alert('Tastati doar cifre!');

}
}
else { // Must be an IE-compatible Browser


if((char >= 48 && char <= 57 && char != 13)  ||(char==46)||(char==45) ||(char==8)||(char==0) ) RetVal = true;
else {
RetVal = false;
alert('Tastati doar cifre!');
}
}
return RetVal;
}


function is_float(char, mozChar) {

if(mozChar != null) { // Look for a Mozilla-compatible browser
if((mozChar >= 48 && mozChar <= 57 && mozChar != 13) ||(mozChar==46) ||(mozChar==8)||(mozChar==0)) RetVal = true;
else {
RetVal = false;
alert('Tastati doar cifre!');

}
}
else { // Must be an IE-compatible Browser


if((char >= 48 && char <= 57 && char != 13)  ||(char==46)||(char==8)||(char==0) ) RetVal = true;
else {
RetVal = false;
alert('Tastati doar cifre!');
}
}
return RetVal;
}

function is_integer(char, mozChar) {

if(mozChar != null) { // Look for a Mozilla-compatible browser
if((mozChar >= 48 && mozChar <= 57 && mozChar != 13)  ||(mozChar==8)||(mozChar==0)) RetVal = true;
else {
RetVal = false;
alert('Tastati doar cifre!');

}
}
else { // Must be an IE-compatible Browser

if((char >= 48 && char <= 57 && char != 13) ||(char==8)||(char==0) ) RetVal = true;
else {
RetVal = false;
alert('Tastati doar cifre!');
}
}
return RetVal;
}

function openCentered(url,name,w,h)
{
  var winl = (screen.width-w)/2;
  var wint = (screen.height-h)/2;
  var settings  ='height='+h+',';
      settings +='width='+w+',';
      settings +='top='+wint+',';
      settings +='left='+winl+',';
      settings +='scrollbars=1,toolbar=no,menubar=no,resizable=yes';
  win=window.open(url,name,settings);
  //if(parseInt(navigator.appVersion) >= 4){win.window.focus();}
}

function openTopLeft(url,name,w,h)
{
  var winl = (screen.width-w)/2;
  var wint = (screen.height-h)/2;
  var settings  ='height='+h+',';
      settings +='width='+w+',';
      settings +='top='+0+',';
      settings +='left='+0+',';
      settings +='scrollbars=1,toolbar=no,menubar=no,resizable=yes';
  win=window.open(url,name,settings);
  //if(parseInt(navigator.appVersion) >= 4){win.window.focus();}
}



function resizeCentered(w,h)
{
  var winl = (screen.width-w)/2;
  var wint = (screen.height-h)/2;
  window.resizeTo(w,h);
  window.moveTo(winl,wint);
  window.focus();
}
function resizeFullScreen()
{
  window.moveTo(0,0);
  window.resizeTo(screen.width,screen.height);
  window.focus();
}
function isInt (str)
{
    var i = str;
    if (isNaN (i))
        return false;
    if (i == "")
      return false;
    i = i . toString ();
    if (i != str)
        return false;
    return true;
}

function adaugaOptiune(theText, theValue, idselect)
{
  var theSel = document.getElementById(idselect);
  var newOpt = new Option(theText, theValue);
  var selLength = theSel.length;
  theSel.options[selLength] = newOpt;
}

function modificaOptiune(theText, idselect,idoption)
{
  var theSel = document.getElementById(idselect);
  var i=0;
  while(idoption!=theSel.options[i].value)
  i++;
  theSel.options[i].text=theText;
}


String.prototype.isValidDate = function() {
  var IsoDateRe = new RegExp('^([0-9]{4})-([0-9]{2})-([0-9]{2})$');

  var matches = IsoDateRe.exec(this);
  if (!matches) return false;


  var composedDate = new Date(matches[1], (matches[2] - 1), matches[3]);

  return ((composedDate.getMonth() == (matches[2] - 1)) &&
          (composedDate.getDate() == matches[3]) &&
          (composedDate.getFullYear() == matches[1]));

}


function diferenta(data2,data1)
{
ydata2=data2.replace(/-0/g,'-');
var vector=ydata2.split('-');
var xdata2=new Date(vector[0],vector[1]-1,vector[2]);

ydata1=data1.replace(/-0/g,'-');
var vector=ydata1.replace(/-0/g,'-').split('-');
var xdata1=new Date(vector[0],vector[1]-1,vector[2]);

return xdata2-xdata1;

}