/*
***************************************************************
*  Copyright
*
*  (c) 2009 websedit AG
***************************************************************
**
 * Javascript-Funktionen Preisberechnung
 *
 * $Id: preisberechnung.js 0001 2009-01-08 websedit AG, http://www.websedit.de $
 *
 * @author  Daniel Knubben <daniel.knubben (at) websedit.de>
 *

**
 * [CLASS/FUNCTION INDEX of SCRIPT]
 *
 *
 *
*/
function goToURL(url) {
    opener.parent.location.href = url;
    opener.parent.focus();
}

function submitter() {
  document.formtarife.submit();
}

function Reset() {
  flag_abfrage = 0;
  document.formtarife.start_ort.value = "";
  document.formtarife.ziel_ort.value = "";
  var y, x;
  x = 322;
  y = 0;
  var xx = x + "px";
  var yy = y + "px";

  document.getElementById("startflag").style.left = xx;
  document.getElementById("startflag").style.top = yy;
  document.getElementById("startflag").style.left = xx;
  document.getElementById("targetflag").style.top = yy;
  document.getElementById("startflag").style.visibility="hidden";
  document.getElementById("targetflag").style.visibility="hidden";

}

// Hole Auswahlwert aus Selection, z.B. Tarifrechner
function setBOB(ziel, val, source) {
  setCoords();

  // Auswahl über Grafik
  if (source == 1) {
    if (!document.getElementById("start_ort").value) {
      var ziel = "start";
    }
    else if (!document.getElementById("ziel_ort").value) {
       var ziel = "target";
    }
    else {
      var ziel = "target";
    }
  }

  for (i = 1; i < cities.length; ++i) {
    document.getElementById(ziel + "_" + cities[i]).style.visibility = "hidden";
  }

  if (!val || val == 0) {
    return false;
  }


  var temp = val.split(",");
  var cityid = temp[1];
  var obj = ziel + "_" + cities[cityid];

  var x, y, xx, yy, korrektur_x, korrektur_y, tempCoords;

// nur bei absoluter Positionierung
// korrektur_x = 559;
// korrektur_y = 261;

  if (cityid != 1 && cityid != 3) {
    korrektur_x = 1;
  }
  else {
    korrektur_x = 0;
  }
  korrektur_y = 0;

  tempCoords = flagCoords[cityid].split(",");
  x = tempCoords[0];
  y = tempCoords[1];

  xx = parseInt(x) + korrektur_x + "px";
  yy = parseInt(y) + korrektur_y + "px";

  document.getElementById(obj).style.left = xx;
  document.getElementById(obj).style.top = yy;

  document.getElementById(obj).style.visibility = "visible";
  
  if (source == 1) {
    document.getElementById(ziel + "_" + cityid).selected = true;
  }
}

// Koordinatendefinitionen
function setCoords() {
  flagCoords = new Array();
  flagCoords[1] = "0,0";
  flagCoords[2] = "57,0";
  flagCoords[3] = "85,0";
  flagCoords[4] = "110,0";
  flagCoords[5] = "137,0";
  flagCoords[6] = "180,0";
  flagCoords[7] = "263,0";
  flagCoords[8] = "295,0";
  flagCoords[9] = "337,0";
  flagCoords[10] = "407,0";
  flagCoords[11] = "435,0";
  flagCoords[12] = "526,0";
  flagCoords[13] = "703,0";
}

var flag_abfrage; // Flag, ob schon ein Wert gesetzt ist

function chkFormular(theForm) {
  if (theForm.start_ort.value == "") {
    alert("Geben Sie bitte einen Wert in das Feld \"Abfahrt\" ein.");
    theForm.start_ort.focus();
    return (false);
  }
  if (theForm.ziel_ort.value == "") {
    alert("Geben Sie bitte einen Wert in das Feld \"Ziel\" ein.");
    theForm.ziel_ort.focus();
    return (false);
  }
 
   if (theForm.start_ort.value == theForm.ziel_ort.value) {
    alert("Geben Sie bitte unterschiedliche Orte an.");
    theForm.ziel_ort.focus();
    return (false);
  }
  return (true);
}
