$(document).ready(function()
{

$("#kundenlogin").submit(function()
{
        //remove all the class add the messagebox classes and start fading
        $("#msgbox").removeClass().addClass('messagebox').text('Prüfe...').fadeIn(1000);
        //check the username exists or not from ajax
        $.post("../../ajax_login.php",{ user_name:$('#usern').val(),password:$('#passw').val(),rand:Math.random() } ,function(data)
        {
          if(data=='yes') //if correct login detail
          {
                $("#msgbox").fadeTo(200,0.1,function()  //start fading the messagebox
                {
                  //add message and change the class of the box and start fading
                  $(this).html('Ok').addClass('messageboxok').fadeTo(900,1,
                  function()
                  {
                     //redirect to secure page
                     document.location='secure.php';
                  });
                });
          }
          else
          {
                $("#msgbox").fadeTo(200,0.1,function() //start fading the messagebox
                {
                  //add message and change the class of the box and start fading
                  $(this).html('Fehler!').addClass('messageboxerror').fadeTo(900,1);
                });
          }
       });
       return false;//not to post the  form physically
});

$("#partnerlogin").submit(function()
{
        //remove all the class add the messagebox classes and start fading
        $("#msgbox2").removeClass().addClass('messagebox2').text('Prüfe...').fadeIn(1000);
        //check the username exists or not from ajax
        $.post("../../ajax_login.php",{ user_name:$('#partner_usern').val(),password:$('#partner_passw').val(),rand:Math.random() } ,function(data)
        {
          if(data=='yes') //if correct login detail
          {
                $("#msgbox2").fadeTo(200,0.1,function()  //start fading the messagebox
                {
                  //add message and change the class of the box and start fading
                  $(this).html('Ok').addClass('messageboxok2').fadeTo(900,1,
                  function()
                  {
                     //redirect to secure page
                     document.location='secure.php';
                  });
                });
          }
          else
          {
                $("#msgbox2").fadeTo(200,0.1,function() //start fading the messagebox
                {
                  //add message and change the class of the box and start fading
                  $(this).html('Fehler!').addClass('messageboxerror2').fadeTo(900,1);
                });
          }
       });
       return false;//not to post the  form physically
});


});

