Now = new Date();
NowDay = Now.getDate();
NowMonth = Now.getMonth();
NowYear = Now.getYear();
bolCanSave = false;




function SaveData(){
		    return bolCanSave;				  
		  };


function DaysInMonth(intMonth, intYear)
{
  var DaysInMonth = 31;
  if (intMonth == 4 || intMonth == 6 || intMonth == 9 || intMonth == 11) DaysInMonth = 30;
  if (intMonth == 2 && (intYear/4) != Math.floor(intYear/4))	DaysInMonth = 28;
  if (intMonth == 2 && (intYear/4) == Math.floor(intYear/4))	DaysInMonth = 29;
  return DaysInMonth;
}

//function to change the available days in a months

function ChangeOptionDays(strDateObject)
{
  YearObject = document.getElementById(strDateObject+"_year");
  MonthObject = document.getElementById(strDateObject+"_month");
  DayObject = document.getElementById(strDateObject+"_day");

  intMonth = MonthObject[MonthObject.selectedIndex].value;
  intYear = YearObject[YearObject.selectedIndex].value;

  DaysForThisSelection = DaysInMonth(intMonth, intYear)+1;

  CurrentDaysInSelection = DayObject.length;

  if (CurrentDaysInSelection > DaysForThisSelection)
  {
    for (i=0; i<(CurrentDaysInSelection-DaysForThisSelection); i++)
    {
      DayObject.options[DayObject.options.length - 1] = null
    }
  }

  if (DaysForThisSelection > CurrentDaysInSelection)
  {
    for (i=0; i<(DaysForThisSelection-CurrentDaysInSelection); i++)
    {
      NewOption = new Option(DayObject.options.length);
      DayObject.add(NewOption);
    }
  }
    if (DayObject.selectedIndex < 0) DayObject.selectedIndex == 0;
}


function SetToToday(strDateObject)
{

  YearObject = document.getElementById(strDateObject+"_year");
  MonthObject = document.getElementById(strDateObject+"_month");
  DayObject = document.getElementById(strDateObject+"_day");

  for (intCounter = 0; intCounter < YearObject.options.length; intCounter++){

    if (YearObject[intCounter].value == NowYear) YearObject[intCounter].selected = true;

  };


  MonthObject[NowMonth+1].selected = true;

  ChangeOptionDays(strDateObject);

  DayObject[NowDay].selected = true;
}


function WriteDateToControl(strDateObject)
{

  YearObject = document.getElementById(strDateObject+"_year");
  MonthObject = document.getElementById(strDateObject+"_month");
  DayObject = document.getElementById(strDateObject+"_day");

  if ((YearObject.selectedIndex > 0)&&(MonthObject.selectedIndex > 0)&&(DayObject.selectedIndex > 0)) {

   document.getElementById(strDateObject).value = YearObject[YearObject.selectedIndex].text+"."+MonthObject[MonthObject.selectedIndex].text+"."+DayObject[DayObject.selectedIndex].text;

  } else {

   document.getElementById(strDateObject).value = '';

  };


}


//function to write option years plus x
function WriteYearOptions(intYearFrom,intYearTo)
{
  line = "";
  for (i=0+intYearFrom; i<intYearTo; i++)
  {
    line += '<OPTION value='+i+'>';
    line += i;
    line += "</OPTION>";
  }
  return line;
}

function SetSelected(conControl,strValue){

  for (intCounter = 0; intCounter < conControl.options.length; intCounter++){

    if (conControl[intCounter].value == strValue) conControl[intCounter].selected = true;

  };

};


function SelectorWindow(strLink,conControl,conControl2){
  window.open(strLink, "Választás", "width=265,height=350,status=no,resizable=yes,scrollbars=yes");
  conSelectTarget  = conControl;
  conSelectTarget2 = conControl2;
};

function CreateSearch(frmForm){
  var strSearch = '';
  for(intCount=0;intCount<frmForm.elements.length;intCount++){ 
   if ((frmForm.elements[intCount].type != 'button')){

    if (frmForm.elements[intCount].value != '')
    strSearch = strSearch + frmForm.elements[intCount].name + '=' + frmForm.elements[intCount].value + '^';
    };
  };
return strSearch;
};

function check(input) {
  var ok = true;

  for (var i = 0; i < input.length; i++) {
    var chr = input.charAt(i);
    var found = false;
    for (var j = 1; j < check.length; j++) {
      if (chr == check[j]) found = true;
    }
    if (!found) ok = false;
  }
  return ok;
}

function test(input) {
  var ok = true;
  if (!check(input, "1", "2", "3", "4", "5", "6", "7", "8", "9", "0")) {
    return true;
  }
  else {
    return false;
  }
}


function CheckRequiredField(frmForm){
  var strSearch = '';
  var bolFlag = true;
  for(intCount=0;intCount<frmForm.elements.length;intCount++){ 
   if ((frmForm.elements[intCount].type != 'button') && (frmForm.elements[intCount].type != 'hidden')){

    if((frmForm.elements[intCount].type == 'select-one') && (frmForm.elements[intCount].selectedIndex == 0) && (frmForm.elements[intCount].className == 'KOTELEZO')){
      alert('A(z) '+frmForm.elements[intCount].title+' mező kitöltése kötelező!');
      bolFlag = false;
      break;
     };

    if ((frmForm.elements[intCount].value == '') && (frmForm.elements[intCount].className == 'KOTELEZO')){
      alert('A(z) '+frmForm.elements[intCount].title+' mező kitöltése kötelező!');
      bolFlag = false;
      break;
     };

   if (frmForm.elements[intCount].title == "kamarai szám")  {
      var GoodChars = "0123456789";
      for (a =0; a <= frmForm.elements[intCount].value.length -1; a++) {
	if (GoodChars.indexOf(frmForm.elements[intCount].value.charAt(a)) == -1) {
       	    alert('A kamarai szám csak számokból állhat!');
        	    bolFlag = false;
        	    break;
	  }
	}
      }

   };

  };
  return bolFlag;
};


function fajonchange(frmForm) {

  alert(frmForm.allat_faj.value);

  if (frmForm.allat_faj.value != 'kutya'){

    frmForm.allat_fajta.readonly = true;
    frmForm.allat_szin.readonly = true;
    frmForm.allat_szorzet.readonly = true;
    frmForm.allat_mintazat.readonly = true;

   } else {

    frmForm.allat_fajta.readonly = false;
    frmForm.allat_szin.readonly = false;
    frmForm.allat_szorzet.readonly = false;
    frmForm.allat_mintazat.readonly = false;

  };

}

function irszamAdd(strText,selIrszam) { 
  selIrszam.options[selIrszam.length] = new Option('       ');  
  selIrszam.options[selIrszam.length-2].text = strText;
 };

function irszamDel(selIrszam) { 
	for ( intCount = selIrszam.length-2; intCount > -1   ; intCount-- ) {

		if (selIrszam.options[intCount].selected) {

	          selIrszam.options.remove(intCount); 

		};

        };
 };


function irszamClear(selIrszam) { 
	for ( intCount = selIrszam.length-1; intCount > -1   ; intCount-- ) {


	          selIrszam.options.remove(intCount); 
        };
 };


function irszamTypeInit(selType,intLevel) { 

  if (intLevel >= 3){ selType.options[selType.length] = new Option('Terület'); selType.options[selType.length-1].value = 2;};
  if (intLevel >= 4){ selType.options[selType.length] = new Option('Város');   selType.options[selType.length-1].value = 3;};
  if (intLevel >= 5){ selType.options[selType.length] = new Option('Régió');   selType.options[selType.length-1].value = 4;};
  if (intLevel >= 6){ selType.options[selType.length] = new Option('Megye');   selType.options[selType.length-1].value = 5;};

 };

function irszamListInit(selList,strString) { 

var tempString=strString;

while (tempString.indexOf(';')>0) { 

  selList.options[selList.length] = new Option('       ');
  selList.options[selList.length-2].text = tempString.substr(0,tempString.indexOf(';'));
  tempString=tempString.substr(tempString.indexOf(';')+1,tempString.length-tempString.indexOf(';')+1); 

} 

};


function irszamListGet(selList) { 
        
        strTemp = '';

	for ( intCount = 0;  intCount <= selList.length-2;  intCount++ ) {

		strTemp = strTemp + selList.options[intCount].text + ';';
        };

        return strTemp;
};

