// redirectare

function formHandlerParteneri() {
var URL = document.view_parteneri.select_parteneri.options[document.view_parteneri.select_parteneri.selectedIndex].value;
  if (URL != "")
    window.location.href = URL;
}

function formHandlerStatiuni() {
var URL = document.view_statiuni.show_statiune.options[document.view_statiuni.show_statiune.selectedIndex].value;
  if (URL != "")
    window.location.href = URL;
}

function formHandlerRezervari() {
var URL = document.view_rezervari.select_rezervare.options[document.view_rezervari.select_rezervare.selectedIndex].value;
  if (URL != "")
    window.location.href = URL;
}

function formHandlerHoteluri() {
var URL = document.view_hoteluri.show_hotel.options[document.view_hoteluri.show_hotel.selectedIndex].value;
  if (URL != "")
    window.location.href = URL;
}

// fereastra noua
function fereastra(url,lungime,latime,denumire){
    if (window.screen){
      var w = screen.width;
      var h = screen.height;
      var center_x = w / 2;
      var center_y = h / 2;
      var new_left;
      var new_top;
      new_left   = center_x - (lungime / 2);
      new_top    = center_y - (latime / 2);
      var new_Window = window.open(url, denumire, "menubar=no, location=no, status=no, toolbar=no, scrollbars=no, resizable=no , width=" + lungime + ", height=" + latime + ", top=" + new_top + ", left=" + new_left + "");
      new_Window.focus();
    }
}

function fereastra1(url,lungime,latime,denumire){
    if (window.screen){
      var w = screen.width;
      var h = screen.height;
      var center_x = w / 2;
      var center_y = h / 2;
      var new_left;
      var new_top;
      new_left   = center_x - (lungime / 2);
      new_top    = center_y - (latime / 2);
      var new_Window = window.open(url, denumire, "menubar=no, location=no, status=no, toolbar=no, scrollbars=yes, resizable=no , width=" + lungime + ", height=" + latime + ", top=" + new_top + ", left=" + new_left + "");
      new_Window.focus();
    }
}

function formHandlerStatistica1() {
var URL = document.form1.hotel.options[document.form1.hotel.selectedIndex].value;
  if (URL != "")
    window.location.href = URL;
}

function formHandlerStatistica2() {
var URL = document.form2.bot.options[document.form2.bot.selectedIndex].value;
  if (URL != "")
    window.location.href = URL;
}

function formHandlerStatistica3() {
var URL = document.form3.inregistrari.options[document.form3.inregistrari.selectedIndex].value;
  if (URL != "")
    window.location.href = URL;
}
//verifica daca este gol
function isEmpty(elem, helperMsg){
	if(elem.value.length == 0){
		alert(helperMsg);
		elem.focus();
		return true;
	}
	return false;
}


//verifica daca este gol fara mesaj
function isEmptyTest(elem){
	if(elem.value.length == 0){
		return true;
	}
	return false;
}

//verifica daca este numar sau litera
function isAlphanumeric(elem, helperMsg){
	var alphaExp = /^[0-9a-zA-Z]+$/;
	if(elem.value.match(alphaExp)){
		return true;
	}else{
		alert(helperMsg);
		elem.focus();
		return false;
	}
}

// verifica daca este numar
function isNumeric(elem, helperMsg){
	var numericExpression = /^[0-9]+$/;
	if(elem.value.match(numericExpression)){
		return true;
	}else{
		alert(helperMsg);
		elem.focus();
		return false;
	}
}

// verifica daca este litera
function isAlphabet(elem, helperMsg){
	var alphaExp = /^[a-zA-Z]+$/;
	if(elem.value.match(alphaExp)){
		return true;
	}else{
		alert(helperMsg);
		elem.focus();
		return false;
	}
}

// verifica lungimea unui sir
function lengthRestriction(elem, min, max){
	var uInput = elem.value;
	if(uInput.length >= min && uInput.length <= max){
		return true;
	}else{
		alert("Introduceti un sir de minim " +min+ " si maxim " +max+ " caractere");
		elem.focus();
		return false;
	}
}
// verifica daca este e-mail
function emailValidator(elem, helperMsg){
	var emailExp = /^[\w\-\.\+]+\@[a-zA-Z0-9\.\-]+\.[a-zA-z0-9]{2,4}$/;
	if(elem.value.match(emailExp)){
		return true;
	}else{
		alert(helperMsg);
		elem.focus();
		return false;
	}
}

function Compare2Date(date1,date2){
     var arrDate1 = date1.split("-");
     if (arrDate1.length!=3){
         alert("Data invalida!");
         return;
     }

     var arrDate2 = date2.split("-");
     if (arrDate2.length!=3){
         alert("Data invalida!");
         return;
     }

     var newdate1 = new Date(arrDate1[0], arrDate1[1]-1, arrDate1[2]);
     if (isNaN(newdate1)){
          alert("Invalid date!");
          return;
      }

      var newdate2 = new Date(arrDate2[0], arrDate2[1]-1, arrDate2[2]);
      if (isNaN(newdate2)){
          alert("Invalid date!");
          return;
      }

      if(newdate2 > newdate1){
          return true;
      } else {
          return false;
      }
}

