
var richtig_idx = '';
var gewahlt_idx = '';


// *****************
function absenden()
// *****************
{
    if (check_form())
    {
    	if (richtig_idx==gewahlt_idx) { document.forms.frm1.richtig.value='1'; }
    	else                          { document.forms.frm1.richtig.value='0'; }
        alert('Vielen Dank für Ihre Teilnahme in dieser Woche.\nDas Popup schliesst sich automatisch.');
        document.forms.frm1.submit();
        return true;
    }
    else
    {
        return false;
    }
}

// ****************************
function checkEmail(inputvalue)
// ****************************
{
    var pattern=/^([a-zA-Z0-9_.-])+@([a-zA-Z0-9_.-])+\.([a-zA-Z])+([a-zA-Z])+/;

    if(pattern.test(inputvalue))
    {
        return true;
    }

    return false;
}


// *******************
function isok(myInput)
// *******************
{
    eval('wert = document.forms.frm1.' + myInput + '.value;');

    if (wert!='') { return true;  }
    else          { return false; }
}


// *******************
function check_form()
// *******************
{
    if ( (isok('firma')) && (isok('name')) && (isok('telefon')) && (gewahlt_idx!='') )
    {
        if (checkEmail(document.forms.frm1.email.value)) { return true; }
    }

    alert('Bitte prüfen Sie Ihre Antwort, Ihre Daten und die Korrektheit Ihrer E-Mail Adresse.');
    return false;
}



function popup_win(name,theUrl,xsize,ysize)
{
    xsize = xsize + 10;  // inner - height correction
    ysize = ysize + 25;

    var abstand_links = ((window.screen.width)  - xsize) / 2;
    var abstand_oben  = ((window.screen.height) - ysize) / 2;
    return window.open(theUrl,name,'toolbar=no,scrollbars=yes,location=no,directories=no,status=no,menubar=no,resizable=yes,width=' + xsize +',height=' + ysize + ',top='+ abstand_oben +',left='+ abstand_links);
}

