﻿
// InformationsBox infoText => plain || HTML, fireElement => Auslösendes HTML-Element
function infoBox(infoText, fireElement) {

  if (infoText != "") {
    if (infoText.charAt(0) == "#") {
      var newInfoText = infoText.substr(1);
      var infoToken = newInfoText.split("_");
      var clubLogo = "Injoy";

      if(infoToken[0]==5)
        clubLogo = "Inline"
      else
        if(infoToken[0]==6)
            clubLogo = "";
      newInfoText = "<table cellpadding=\"0\" cellspacing=\"0\" border=\"0\" style=\"width:350px;background-image:url(../_Images/bg_box2Grayscale.png);\">";
      newInfoText += "<tr><td style=\"width:170px;padding-left:30px;font-weight:bold;font-size:14px;padding-right:30px;\">" + infoToken[1] + "</td><td style=\"padding-top:20px;padding-right:30px;text-align:right;\"><img alt=\"\" src=\"../_Images/logo" + clubLogo + ".png\" /></td></tr>";
        newInfoText += "<tr><td colspan=\"2\" style=\"padding-left:30px;\">"+infoToken[2]+"</td></tr>";
        newInfoText += "<tr><td colspan=\"2\" style=\"padding-left:30px;padding-bottom:20px;\">" + infoToken[3] + "</td></tr>";
        newInfoText += "<tr><td colspan=\"2\" style=\"padding-left:30px;padding-bottom:20px;\">" + infoToken[4] + "</td></tr>";
        newInfoText+="</table>";
        infoText = newInfoText;
    }
    $(".tableInfoBoxUpText").html(infoText);
    $(".tableInfoBoxUp").css("display", "block");
    $(".tableInfoBoxUp").click(function() { infoBox("", "") });
    var position = $("#" + fireElement).offset();

    if (position.left > ($("body").width() / 2))
      $(".tableInfoBoxUp").css("left", position.left - ($("#" + fireElement).width()));
    else
    $(".tableInfoBoxUp").css("left", position.left + ($("#" + fireElement).width()));
    $(".tableInfoBoxUp").css("top", position.top - 80);

    var options = { to: ".tableInfoBoxUpText", className: 'seachboxTransferClub' };
    $("#" + fireElement).effect('transfer', options, 500);
    
  }
  else {

      $(".tableInfoBoxUpText").html("");
      $(".tableInfoBoxUp").css("display", "none");
    
  }
}

//Linkverwaltung für Assistent 
//  actAssistState:     Aktueller Navigationsstatus des Bewerbungsassistenten
//  btnName:            
function assistLink(actAssistState, btnName) {
  var hRef = "";
  switch(actAssistState) {

    case '-1':
      if (btnName != 'StepNavigation_btnStep1') {
        infoBox("Bitte starten Sie mit Schritt Eins:\"Clubs w&auml;hlen\".", btnName);
        return false;
      }
      hRef = "../Main/Karrierefinder.aspx?City=&Zipcode=&City2=&Distance=0";
      try {
        location.href=hRef + "&lis=" + locationIdstring;
      } catch (e) {
        location.href=hRef;
      }
      break;
    case '0':
      if (btnName == 'StepNavigation_btnStep3') {
        infoBox("Bitte fahren Sie zun&auml;chst mit Schritt Zwei \"Formular ausfüllen\" fort.", btnName);
        return false;
      }
      if (btnName == 'StepNavigation_btnStep2' || btnName == 'btnStartForm') {
        if (locations.length < 1) {
          infoBox("Bitte w&auml;hlen Sie mindestens einen Club aus bevor Sie mit Schritt Zwei fortfahren.", btnName);
          return false;
        }
        hRef = "../Main/Karriereformular.aspx";
        
        try {
          location.href=hRef + "?lis=" + locationIdstring;
          
        } catch (e) {
          location.href=hRef;
         
        }
      }
     if (btnName == 'StepNavigation_btnStep1') {
        hRef = "../Main/Karrierefinder.aspx";
        try {
          location.href=originalAction + "&lis=" + locationIdstring;
        } catch (e) {
          location.href=originalAction;
        }
      }
      break;
    case '1':
      if (btnName == 'StepNavigation_btnStep3') {
 
      }
      if (btnName == 'StepNavigation_btnStep2') {
        /*if (locations.length < 1) {
        infoBox("Bitte w&auml;hlen Sie mindestens einen Club aus bevor Sie mit Schritt Zwei fortfahren.");
        return false;
        }*/
      }
      if (btnName == 'StepNavigation_btnStep1') {
        hRef = "../Main/Karrierefinder.aspx?City=&Zipcode=&City2=&Distance=0";
        try {
          location.href=hRef + "&lis=" + locationIdstring;
        } catch (e) {
          location.href=hRef;
        }
      }
      break;
      case '2':
        infoBox("Bitte haben Sie ein wenig Geduld bis Ihre Bewerbung an die entsprechenden Clubs versand wurde.", btnName);
    
      break;
  }
   
  return false;
}


//SendMailCounter
function count() {
    
  if (waitingLine >= 100)
    location.href = "../Main/ThankYou.aspx";
  else {
    waitingLine += Math.ceil(Math.random() * 10);
    if (waitingLine > 100)
      waitingLine = 100;
      $("#moreInfo").html("Ihre Bewerbung ist im Begriff gesendet zu werden: " + waitingLine +"%");
        setTimeout(count, (Math.random() * 250));
    }
}



