function getJobListCookie(id) {
	var value = "0";
	var jobId = "joblist_" + escape(id);
	if (document.cookie.length > 0) {
		c_start = document.cookie.indexOf(jobId + "=");
		
		if (c_start != -1) { 
			c_start = c_start + jobId.length+1 
			c_end = document.cookie.indexOf(";",c_start)
			if (c_end==-1) {
				c_end=document.cookie.length
			}
			value = unescape(document.cookie.substring(c_start,c_end))
		} 
	}
	return value;
}

function checkJoblistEntries(id,lang) {
	var imgJobListOnUrl  = '/images/add_joblist_on' + lang + '.gif';
	var imgJobListOffUrl = '/images/add_joblist_off' + lang + '.gif'; 
	var jobListImg = document.getElementById("joblist_" + id);
	if (jobListImg == null) return;
	if(getJobListCookie(id) != "0") {
		jobListImg.src = imgJobListOnUrl ;
	}
	else {
		jobListImg.src = imgJobListOffUrl;
	}
}


function toggleJobEntry(id,lang) {
	var imgJobListOnUrl  = '/images/add_joblist_on' + lang + '.gif';
	var imgJobListOffUrl = '/images/add_joblist_off' + lang + '.gif'; 

	var jobListImg = document.getElementById("joblist_" + id);
	var jobListImgOpener = null;
    
	try {
       jobListImgOpener = document.getElementById("joblist_" + id);
	} catch(err) {
	     jobListImgOpener = null;
	}
	
	if (jobListImg == null) return;

	if (endsWith(jobListImg.src, imgJobListOffUrl)) {
		    jobListImg.src = imgJobListOnUrl ;
		    if (jobListImgOpener != null) {
                           jobListImgOpener.src = imgJobListOnUrl ;
        }
		    addToJoblist(id);
	}
	else {
		jobListImg.src = imgJobListOffUrl;
		if (jobListImgOpener != null) {
                           jobListImgOpener.src = imgJobListOffUrl ;
    }
		removeFromJoblist(id);
	}
}


function addToJoblist(value) {
			setJobListCookie(value, value);
			document.getElementById("merke").style.display = "inline";
}

function removeFromJoblist(value) {
			setJobListCookie(value, 0);
}

function removeFromJoblistAndSubmit(anId) {
	var check = confirm("Wollen Sie diese Sendung wirklich aus der Merkliste löschen?");

	if (check == true) {	
		removeFromJoblist(anId);
		//removeFromRecordlist(anId);
		document.joblistform.submit();
	}
}
	
/*
 * Checks if 'src' ends with 'target'.
 */
function endsWith(src, target) {
    var start = src.length - target.length;
    return (start >= 0) ? (src.substring(start) == target) : false;
}


function cookiesEnabled() {
	var d = new Date();
	d.setTime(d.getTime() + 10000);
	document.cookie = "cookie_check=yes; path=/; expires=" + d.toUTCString(); + ";"
	return document.cookie && document.cookie.length > 0;
}

function cookieCheck(msg) {
	if (cookiesEnabled()) {
		return true;
	} else {
		alert(msg);
		return false;
	}
}

//function setRecordingCookie(name, value) { setACookie("record" , name, value); }
function setJobListCookie(name, value)   { setACookie("joblist", name, value); }


function setACookie(cookieType, name, value) {
	if (cookieCheck("In order to use this feature you must have cookies enabled in your browser."))
	
	var d = new Date();
	d.setTime(d.getTime() + 10000);
	document.cookie = "joblist_" + escape(name) + "=" + escape(value) + ";"
}


function check_alone() {
  if (parent != self) {
       if (parent.frames['menu'].merkarr != "0,") {
          parent.frames['main'].showObject('merke');
	   }
	   else; 	  
  }
  else;
}  


function getObject(objName) {
    return (document.layers) 
      ? document.layers[objName]
      : document.getElementById(objName)
    ;
}

function show(obj) {
    return (document.layers)
      ? obj.visibility= "visible"
      : obj.style.visibility= "visible"
    ;
}

function hide(obj) {
    return (document.layers)
      ? obj.visibility= "hide"
      : obj.style.visibility= "hidden"
    ;
}

function showObject(objName) {
    var obj= getObject(objName);
    show(obj);
}
  
function hideObject(objName) {
    var obj= getObject(objName);
    hide(obj);  
  }
 
function tunichts(vv) {
     var obj = getObject(vv);
	 hide(obj);
  }

function showObject2(objName) {
    var obj= getObject(objName);
	obi = objName;
    show(obj);
	setTimeout("tunichts(obi);", 2000);
  }
 

/* Emailverschlüsselungs-Funktionen */  
function hang(alchemy,year,shrub,projekt,modus,lang) {
  alchemy += ' '; 
  var atmosphere = alchemy.length;
  var forest = 0;
  var scientist = '';
  for(var club = 0; club < atmosphere; club++) {
     forest = 0;
     while(alchemy.charCodeAt(club) != 32) {
       forest = forest * 10;
       forest = forest + alchemy.charCodeAt(club)-48;
       club++;
     }
     scientist += String.fromCharCode(shoe(forest,year,shrub));
   }
   
   //if(projekt == 1) scientist += '&body=%0A%0A%0AEs ist besser, wenn Sie uns direkt werktags zwischen 8 und 18 Uhr anrufen.%0AFalls Sie uns doch eine mail senden m&ouml;chten, schreiben Sie uns Ihre%0ATelefonnummer, unter der wir Sie tags&uuml;ber erreichen k&ouml;nnen.%0AIhre Zimmervermittlung24.com,%0AZimmervermittlung Dentler, Berlin,%0APenkuner Weg 14,%0A12621 Berlin%0A%0ATelefon: 030 - 56 555 111%0ATelephone: +49 30 56 555 111';
     
   parent.location = 'm'+'a'+'i'+'l'+'t'+'o'+':'+scientist;
   
}

function hangnew(year,shrub,projekt,modus,lang) {
  //alchemy += ' '; 
  alchemy = "198 384 344 203 298 198 203 410 68 309 446 384 390 298 203 278 180 309 " 
  var atmosphere = alchemy.length;
  var forest = 0;
  var scientist = '';
  for(var club = 0; club < atmosphere; club++) {
     forest = 0;
     while(alchemy.charCodeAt(club) != 32) {
       forest = forest * 10;
       forest = forest + alchemy.charCodeAt(club)-48;
       club++;
     }
     scientist += String.fromCharCode(shoe(forest,year,shrub));
   }
   
   //if(projekt == 1) scientist += '&body=%0A%0A%0AEs ist besser, wenn Sie uns direkt werktags zwischen 8 und 18 Uhr anrufen.%0AFalls Sie uns doch eine mail senden m&ouml;chten, schreiben Sie uns Ihre%0ATelefonnummer, unter der wir Sie tags&uuml;ber erreichen k&ouml;nnen.%0AIhre Zimmervermittlung24.com,%0AZimmervermittlung Dentler, Berlin,%0APenkuner Weg 14,%0A12621 Berlin%0A%0ATelefon: 030 - 56 555 111%0ATelephone: +49 30 56 555 111';
     
   parent.location = 'm'+'a'+'i'+'l'+'t'+'o'+':'+scientist;
   
}


function havenew(component,glass) {
 //food += ' ';
 food = "198 384 344 203 298 198 203 410 68 309 446 384 390 298 203 278 180 309 " 
 var cost = food.length;
 var culture = 0;
 for(var discovery = 0; discovery < cost; discovery++) {
   culture = 0;
   while(food.charCodeAt(discovery) != 32) {
     culture = culture * 10;
     culture = culture + food.charCodeAt(discovery)-48;
     discovery++;
   }
   document.write(String.fromCharCode(shoe(culture,component,glass)));
  }
}


function have(food,component,glass) {
 food += ' ';
 var cost = food.length;
 var culture = 0;
 for(var discovery = 0; discovery < cost; discovery++) {
   culture = 0;
   while(food.charCodeAt(discovery) != 32) {
     culture = culture * 10;
     culture = culture + food.charCodeAt(discovery)-48;
     discovery++;
   }
   document.write(String.fromCharCode(shoe(culture,component,glass)));
  }
}

function shoe(speech,extraterrestrial,flore) {
  if (flore % 2 == 0) {
    icon = 1;
    for(var pencil = 1; pencil <= flore/2; pencil++) {
    lip = (speech*speech) % extraterrestrial;
    icon = (lip*icon) % extraterrestrial;
  }
  } else {
     icon = speech;
     for(var meter = 1; meter <= flore/2; meter++) {
     lip = (speech*speech) % extraterrestrial;
     icon = (lip*icon) % extraterrestrial;
  }
}
return icon;
}   
  
/* Merkefunktion Funktion prüft, ob frames vorhanden, wenn ja */
/* dann wird merkarradd aufgerufen, ansonsten fehlermeldung */
function merkarraddpre(ele,lang){
   if (parent != self) {
       parent.frames['menu'].merkarradd(ele,'lang');
       NeuFenster('basketinfo.php?lang=' + lang,200,200);
   }
   else {
      if(lang == 1) alert("Please visit first of start page in order to use this function'");
      else alert("Sie können die Vormerkfunktion nur nutzen, wenn Sie uns über die Startseite besuchen!");
   }	  
} 

// Funktion übergibt bei Buchungsausgabe Memofeld and Stornierformular
function Shipmemo(form,nrx) {
   Memo = form.Memointern.value;
   var DS = nrx;
   var stornomemo  = eval("document.stornoform" + DS + "." + "memofeld");
   stornomemo.value = Memo;
}


// Funktionen, die neues Fenster öffnen 
function NeuesFenster(url, width, height) {
	var Win = window.open(url,"displayWindow",'width=' + width + ',height=' + height + ',resizable=yes,scrollbars=yes,menubar=no,status=no' );
    Win.moveTo(0,0);
}

function NeuFenster2(url, width, height) {
	var Win = window.open(url,"displayWindow",'width=' + width + ',height=' + height + ',resizable=yes,scrollbars=yes,menubar=no,status=no' );
}

function NeuFenster3(url, width, height) {
	var Win = window.open(url,"displayWindow",'width=' + width + ',height=' + height + ',resizable=no,scrollbars=no,menubar=no,status=no' );
}

function NeuFenster(url, width, height) {
	var Win = window.open(url,"displayWindow",'width=' + width + ',height=' + height + ',resizable=yes,scrollbars=auto,menubar=no,status=no' );
}

// Weiterleitungsfunktionen
function schickvermieterupdate() {
   setTimeout("schickupdate();", 1100);
}

function schickupdate() {
   document.afterformula.submit();
}


function zeit() {
    setTimeout("change2();", 2000);
}


function change(url) {
     parent.frames['main'].location.href = url;     
}


function zeit2(url) {
    xxx = url;
    setTimeout("change(xxx);", 600);
}

function zeit3(url) {
    xxx = url;
    setTimeout("change(xxx);", 2000);
}

// Funktionen, die auf hauptrahmen gebraucht werden
function imgOn(nr) {
  document[nr].src =  eval(nr + "k.src");
}

function imgOff(nr) {
  document[nr].src= eval(nr + ".src");
}

/* Statusleistenausgabe */
function Info(Ausgabe) {
    window.status = Ausgabe;
}
		
function Pruef(feld,max) {
      var anz = feld.value.length;
      var frei;
      if (anz > max) {
        feld.value = feld.value.substring(0,max);
        frei = 0;
      } else {
        frei = max-anz;
      }
      if (document.all) document.all["i_"+feld.name].value=frei;
	  else feld.form["i_"+feld.name].value=frei;
}


function Pruefadmin(feld,max) {
      var anz = feld.value.length;
      var frei;
      if (anz > max) {
        feld.value = feld.value.substring(0,max);
        frei = 0;
      } 
	  else {
        frei = max-anz;
      }
}



function bild(bildname) {
      var bild = bildname;     
		 if(window.document.images[bild].width < window.document.images[bild].height) {
            window.document.images[bild].width=210;
         }
         else {
            window.document.images[bild].width=320;
         }
 }
