// ================================================
// HHF internal functions
// by dta-online.com
// Autor: H.Schau
// ================================================


// Open Calender
function OpenCal(strZiel, strForm, strFeld, intWidth)
{

// If strFeld has a value, the lookup window starts in month of the date
    strZiel = strZiel + strForm +"."+strFeld;

    if ((document.forms[strForm].elements[strFeld].value != "") )
    {
	strZiel = strZiel + "&userdate=" + document.forms[strForm].elements[strFeld].value;
    }


    Test = window.open(strZiel, "HHFCalender", 'width='+intWidth+',height=145,scrollbars=no,resizable');

    if (document.all)
	{
		var ClickX = window.event.x;
		var ClickY = window.event.y;
		if (navigator.appVersion.indexOf("MSIE 5")>0 )
		{
			Test.moveTo(ClickX+window.screenLeft-50, ClickY+window.screenTop+15);
		}
	}

}



  // by dta - check if the dates are valid
  function chkForm()
  {

   error=0;
     date1 = new Date(document.form.drop_a_year.value, document.form.drop_a_month.value -1, document.form.drop_a_day.value);
     if(date1.getMonth() > (document.form.drop_a_month.value -1)) {
             error=1;
     }
     date2 = new Date(document.form.drop_d_year.value, document.form.drop_d_month.value -1, document.form.drop_d_day.value);
     if(date2.getMonth() > (document.form.drop_d_month.value -1)) {
             error=1;
     }
     if(date1 >= date2) {
           error=1;
     }

     if(error) {
        alert("Please check the date! \n(not valid)" );
        document.form.drop_d_month.focus();
        return false;
     }

  }


// Popup window X
function WinOpenX(progurl)
{
	win=window.open('/hhf/www/xpopup.php?'+progurl,'hhfpop','top=10,left=50,width=780,height=540,scrollbars,locationbar=yes');
	win.self.focus();
}


// ask age of children
// id = idname of outer box
function swap_age(id, display) {

if(!display) var display = "block";
        var count = document.form.f_child.value;
        var i1 = id+'1';
        var i2 = id+'2';
        var i3 = id+'3';
        var i4 = id+'4';

document.getElementById(i1).style.display = 'none';
document.getElementById(i2).style.display = 'none';
document.getElementById(i3).style.display = 'none';
document.getElementById(i4).style.display = 'none';

if(1 <= count)
document.getElementById(i1).style.display = display;
if(2 <= count)
document.getElementById(i2).style.display = display;
if(3 <= count)
document.getElementById(i3).style.display = display;
if(4 <= count)
document.getElementById(i4).style.display = display;


        if(count > 0) {
                document.getElementById(id).style.display = display;
        }
        else {
                document.getElementById(id).style.display='none';
                document.form.f_child_age1.value = '';
                document.form.f_child_age2.value = '';
                document.form.f_child_age3.value = '';
                document.form.f_child_age4.value = '';
        }
}

