var caution = false

function setCookie(name, value, expires, path, domain, secure) {
        var curCookie = name + "=" + escape(value) +
                ((expires) ? "; expires=" + expires.toGMTString() : "") +
                ((path) ? "; path=" + path : "") +
                ((domain) ? "; domain=" + domain : "") +
                ((secure) ? "; secure" : "")
        if (!caution || (name + "=" + escape(value)).length <= 4000)
                document.cookie = curCookie
        else
                if (confirm("Cookie exceeds 4KB and will be cut!"))
                        document.cookie = curCookie
}

function getCookie(name) {
   var prefix = name + "="
   var cookieStartIndex = document.cookie.indexOf(prefix)
   if (cookieStartIndex == -1)
                return null
   var cookieEndIndex = document.cookie.indexOf(";", cookieStartIndex + prefix.length)
   if (cookieEndIndex == -1)
                cookieEndIndex = document.cookie.length
return unescape(document.cookie.substring(cookieStartIndex + prefix.length, cookieEndIndex))
}

function deleteCookie(name, path, domain) {
        if (getCookie(name)) {
                document.cookie = name + "=" + 
                ((path) ? "; path=" + path : "") +
                ((domain) ? "; domain=" + domain : "") +
                "; expires=Thu, 01-Jan-70 00:00:01 GMT"
        }
}

function fixDate(date) {
        var base = new Date(0)
        var skew = base.getTime()
        if (skew > 0)
                date.setTime(date.getTime() - skew)
}

function frame_test() {
 if (window.name == "") {
  if(parent == null || parent == self) {
    window.location.href="index.html";
  }
 }
}

function c_test() {
 if (window.name == "") {
  if(parent == null || parent == self) {
    window.location.href="index.html";
  }
 }
var now = new Date()
fixDate(now)
now.setTime(now.getTime() + 60 * 60 * 1000)

setCookie("c_ok", now, now)

var now2 = getCookie("c_ok")
if (now2 != now){
alert("Diese Seite verwendet Cookies, um die volle Funktion zu gewhrleisten. \nBitte stellen Sie Ihren Browser so ein, dass Cookies akzeptiert werden, da ansonsten diese Seite nicht funktionieren kann.\n\nVielen Dank")
history.back()
}
}

function c_test2() {

var now = new Date()
fixDate(now)
now.setTime(now.getTime() + 60 * 60 * 1000)

setCookie("c_ok", now, now)

var now2 = getCookie("c_ok")
if (now2 != now){
alert("Diese Seite verwendet Cookies, um die volle Funktion zu gewhrleisten. \nBitte stellen Sie Ihren Browser so ein, dass Cookies akzeptiert werden, da ansonsten diese Seite nicht funktionieren kann.\n\nVielen Dank")
history.back()
}
}

function openWindow(ziel,Window) { 
  features = 
    'toolbar=no,location=no,directories=no,status=no,menubar=no,' +
    'scrollbars=yes,resizable=no,width=600,height=350';
 if (Window != "Reise") { 
  ziel = "../../" + Window + "/" + ziel;
 }
 dlg = window.open (ziel,Window,features);
}

function backclose() {
	history.back();
	close();
}

function parseDatum(X) {
  var Month = new Array("","January","February","March","April","May","June","July","August","September","October","November","December");
  var Mon = eval(X.substr(0,2));
  var Monat = Month[Mon];
  var Tag = X.substr(2,2);
  var Jahr = X.substr(4,2);
  var Dat = Monat + " " +Tag+ ", 20"+Jahr+" 00:00:00";
  var Datum = new Date(Dat); 
  return Datum;
 }
function Auswahl(Auswahl) {
  var jetzt = new Date();
  var Zeit = jetzt.getTime() / 1000 /3600 /24;
  for(i=1; i<document.forms[0].elements[Auswahl].length; i++){
   if(document.forms[0].elements[Auswahl].options[i].selected == true)
	var Wert=document.forms[0].elements[Auswahl].options[i].value;
   }

  if(document.Flugdaten.DUSPMI.options[0].selected == true && document.Flugdaten.CGNPMI.options[0].selected == true) {
   document.Flugdaten.PMIDUS.selectedIndex = 0;
   document.Flugdaten.PMICGN.selectedIndex = 0;
   alert("Bitte zuerst einen Hinflugtermin whlen. Danke.");
   }  
  else {  
   if(Auswahl  == 3){
    document.Flugdaten.PMICGN.selectedIndex = 0;
	Abfzeit = document.Flugdaten.TMP.value;
	var Ruflug = new Date(parseDatum(Wert));
    var Rufzeit = Ruflug.getTime() / 1000 /3600 / 24;
    var Diff = Math.floor(Rufzeit - Abfzeit);
	if(Diff<1){
	  document.Flugdaten.PMIDUS.selectedIndex = 0;
      alert("Bitte whlen Sie einen spteren Rckflugtermin. Danke.");
    }
   }
   if(Auswahl  == 4){
    document.Flugdaten.PMIDUS.selectedIndex = 0;
	Abfzeit = document.Flugdaten.TMP.value;
	var Ruflug = new Date(parseDatum(Wert));
    var Rufzeit = Ruflug.getTime() / 1000 /3600 / 24;
    var Diff = Math.floor(Rufzeit - Abfzeit);
    if(Diff<1){
	  document.Flugdaten.PMICGN.selectedIndex = 0;
      alert("Bitte whlen Sie einen spteren Rckflugtermin. Danke.");
    }
   }
  }
   if(Auswahl  == 1){
    document.Flugdaten.CGNPMI.selectedIndex = 0;
    document.Flugdaten.PMIDUS.selectedIndex = 0;
    document.Flugdaten.PMICGN.selectedIndex = 0;
    var Abflug = new Date(parseDatum(Wert));
    Abfzeit = Abflug.getTime() / 1000 /3600 /24;
	var Diff = Math.floor(Abfzeit - Zeit);
	document.Flugdaten.TMP.value = Abfzeit;
	if(Diff<2) {
	   document.Flugdaten.DUSPMI.selectedIndex = 0;
	   alert("Hinflugdatum zu kurzfristig gewhlt. Bitte ndern. Danke.");
	 }  
   }
   if(Auswahl  == 2){
    document.Flugdaten.DUSPMI.selectedIndex = 0;
    document.Flugdaten.PMIDUS.selectedIndex = 0;
    document.Flugdaten.PMICGN.selectedIndex = 0;
    var Abflug = new Date(parseDatum(Wert));
    Abfzeit = Abflug.getTime() / 1000 /3600 /24;
	var Diff = Math.floor(Abfzeit - Zeit);
	document.Flugdaten.TMP.value = Abfzeit;
	if(Diff<2) {
	   document.Flugdaten.CGNPMI.selectedIndex = 0;
	   alert("Hinflugdatum zu kurzfristig gewhlt. Bitte ndern. Danke.");
	 } 
   }  
}

 
function chkFormular()
{
    Flug = new  Array(5);
	Flugh = new Array(3);
	Flugab = new Array("","DUS","CGN","DUS","CGN");
   var l=1;
   for(j=1; j<5; j++){	
     for(i=1; i<document.forms[0].elements[j].length; i++){
       if(document.forms[0].elements[j].options[i].selected == true) {
	    Flug[j]=document.forms[0].elements[j].options[i].value;
		Flugh[l]=j;
		l++;
		}
     }
   }
		document.Flugdaten.Abf1.value = Flugab[Flugh[1]];
		if(Flugh[2]==3 || Flugh[2]==4)
		  document.Flugdaten.Reise.value = "Nur Flug: "+Flugab[Flugh[1]]+" - PMI   /   PMI - "+Flugab[Flugh[2]];
		else
		  document.Flugdaten.Reise.value = "Nur Flug: "+Flugab[Flugh[1]]+" - PMI   /   one Way";
   var l=1;
   for(k=1; k<5; k++){
     if(document.forms[0].elements[k].options[0].selected == false) {
	   Flug[l] = Flug[k].substr(2,2)+Flug[k].substr(0,2)+Flug[k].substr(4,2);
	   l++;
	   }
	 else
	 Flug[k] = "none";
   }
    if(Flug[2] != "none")
    document.Flugdaten.Dat.value =  Flug[1]+"-"+Flug[2];
	else
	document.Flugdaten.Dat.value =  Flug[1]+"-"+Flug[1];
}

function stat()
{
   document.write("<img src=\"http://www.urlaubsreiseservice.de/cgi-bin/logstat/log.pl?ref="+top.document.referrer+"\" width=1 height=1 border=0>");
}
