var gAutoPrint = true; // Flag for whether or not to automatically call the print function
function printSpecial()
{
 if (document.getElementById != null)
 {
  var html = '<HTML>\n<HEAD><!-- PageID 245 - published by RedDot 6.1 - 6.1.2.19 - 15669 -->\n';
  if (document.getElementsByTagName != null)
  {
   var headTags = document.getElementsByTagName("head");
   if (headTags.length > 0)
    html += headTags[0].innerHTML;
  }
  html += '\n</HE' + 'AD>\n<BODY>\n';
  var printReadyElem = document.getElementById("printReady");
  if (printReadyElem != null)
  {
    html += printReadyElem.innerHTML;
  }
  else
  {
   alert("Could not find the printReady section in the HTML");
   return;
  }
  html += '\n</BO' + 'DY>\n</HT' + 'ML>';
  var printWin = window.open("","printSpecial");
  printWin.document.open();
  printWin.document.write(html);
  printWin.document.close();
  if (gAutoPrint)
   printWin.print();
 }
 else
 {
  alert("Sorry, the print ready feature is only available in modern browsers.");
 }
}
function setBackExtraAmount(extra, id)
{
 if(extra.checked)
 {
  eval("document.getElementById('extraAmount"+id+"').value=1");
  extra.checked=true;
 }
 else
 {
  eval("document.getElementById('extraAmount"+id+"').value=''");
  extra.checked=false;
 }
}
function setDropOffStation(id){
 var s_options = document.main.carDropOffStationId.options;
 var index = document.main.carDropOffStationId.selectedIndex;
 var val = document.main.carDropOffStationId.options[index].value;
 if(val=="-1")
 {
  for(i=0; i<s_options.length; i++)
  {
   var myvalue = s_options[i].value;
   if(myvalue==id)
   {
    document.main.carDropOffStationId.selectedIndex=i;
    break;
   }
  }
 }
}
function setPickUpsBack()
{
 var s_pickups  = document.main.carPickUpStationId;
 var pickups  = document.main.carPickUpStationId.options;
 var selectedValue = "";
 // Pickups zurücksetzen
 for (i = 0; i<pickups.length; i++)
 {
  selectedValue = pickups[i].value;
  if(selectedValue=="-1")
  {
   s_pickups.selectedIndex=i;
   break;
  }
 }
}
function setDropOffsBack()
{
 var s_dropoffs  = document.main.carDropOffStationId;
 var dropoffs  = document.main.carDropOffStationId.options;
 var selectedValue = "";
 for (i = 0; i<dropoffs.length; i++)
 {
  selectedValue = dropoffs[i].value;
  if(selectedValue=="-1")
  {
   s_dropoffs.selectedIndex=i;
   break;
  }
 }
}
function changeStation()
{
 document.main.exec.value='GetStatInfo';
 document.main.action='CarDelMarServlet';
 document.main.submit();
}
  //change[START]igr#0xx:2005-12-30
function changePickUpStation(list,sessionId)
{
 if(list.selectedIndex > 0)
 {
  document.main.exec.value='CheckCarPriceGetStatInfo';
  document.main.action='CarDelMarServlet;jsessionid='+sessionId;
  document.main.submit();
 }
}
function changeDropOffStation(list,sessionId)
{
 if(list.selectedIndex > 0)
 {
  document.main.exec.value='GetStatInfo';
  document.main.action='CarDelMarServlet;jsessionid='+sessionId;
  document.main.submit();
 }
}
  //change[END]igr#0xx:2005-12-30
//add:140806 - booking3 cant choose dropoff station before pickup station
function checkDropStation() {
var pick = document.getElementById("origStation");
var drop = document.getElementById("destStation");
/* if (pick.value == -1) {
   drop.disabled = "disabled";
    }*/
}

function setPickUpCitiesBack()
{
 var s_pickups  = document.main.carPickUpCity;
 var pickups  = document.main.carPickUpCity.options;
 var selectedValue = "";
 // Pickups zurücksetzen
 for (i = 0; i<pickups.length; i++)
 {
  selectedValue = pickups[i].value;
  if(selectedValue=="-1")
  {
   s_pickups.selectedIndex=i;
   break;
  }
 }
}
function setDropOffCitiesBack()
{
 var s_dropoffs  = document.main.carDropOffCity;
 var dropoffs  = document.main.carDropOffCity.options;
 var selectedValue = "";
 for (i = 0; i<dropoffs.length; i++)
 {
  selectedValue = dropoffs[i].value;
  if(selectedValue=="-1")
  {
   s_dropoffs.selectedIndex=i;
   break;
  }
 }
}
function checkDropOff(def){
 var s_dropoff  = document.main.carDropOffStationId;
 var dropoff  = document.main.carDropOffStationId.options;
 var selectedValue = dropoff[s_dropoff.selectedIndex].value;
 // Dropoffs zurücksetzen
 if(selectedValue == "-1" )
 {
  for (i = 0; i<dropoff.length; i++)
  {
   selectedValue = dropoff[i].value;
   if(selectedValue == def)
   {
    s_dropoff.selectedIndex=i;
    break;
   }
  }
 }
 else
  document.main.submit();
}
function setAreasBack()
{
 var s_areas = document.main.carArea;
 var areas = document.main.carArea.options;
 
 // areas zurücksetzen
 for (i = 0; i<areas.length; i++)
 {
  selectedValue = areas[i].value;
  if(selectedValue == "-1")
  {
   s_areas.selectedIndex=i;
   break;
  }
 }
}
function setCitiesBack()
{
 var s_cities  = document.main.carCity;
 var cities = document.main.carCity.options;
 // cities zurücksetzen
 for (i = 0; i<cities.length; i++)
 {
  selectedValue = cities[i].value;
  if(selectedValue=="-1")
  {
   s_cities.selectedIndex=i;
   break;
  }
 }
}
function changePage(newPage,lastPage,tab,subtab)
{
 document.main.p.value=newPage;
 document.main.submit();
 return false;
}
function getExtras(sessionId,carId,scId)
{
  document.main.exec.value='GetCarExtras';
  document.main.action='CarDelMarServlet;jsessionid='+sessionId+'?iid=' + carId + '&scId=' + scId;
  document.main.submit();
  return false;
}
function stripSpaces(element)
{
 textIn  = element.value;
 textOut = '';
 for (i=0;i<textIn.length;i++)
 {
  c = textIn.charAt(i);
  if(c != ' ')
  textOut += c;
 }
 element.value=textOut;
}
function getTimeFromValue (date, hour, min)
{
 var reg =  /^([0-9]{1,2})[\.\,]([0-9]{1,2})[\.\,]([0-9]{2,4})$/;
 
 if(reg.exec(date))
 {
  var datArr  =  reg.exec(date);
  datArr[3] =  (datArr[3].length == 2)? "20" + datArr[3] : datArr[3];
  datArr[2] =  (datArr[2] > 0 )? datArr[2] - 1 : 11;
  aktDate     =  new Date(datArr[3], datArr[2], datArr[1], hour, min, 0);
  return aktDate.getTime();
 }
 else 
  return false;
}