function Username(was, inhalt) {
if(was.value=='Username'){was.value=''; was.style.color = '#000'; was.style.textAlign = 'left'; }
else if(was.value=='Username Falsch') { was.value=''; was.style.color = '#000'; was.style.textAlign = 'left';}
else if(was.value==inhalt){ was.value=''; was.style.color = '#000'; was.style.textAlign = 'left'; $("#CookieKoeschen").load('php/deletecookie.php'); }

$('#LoginSavs').css('display','block');


}

function outUsername(was, inhalt) {

if(was.value==''){was.value='Username'; was.style.color = '#888'; was.style.textAlign = 'center'; $('#LoginSavs').css('display','none'); }
if(inhalt != null) {
if(was.value==inhalt){was.value=inhalt; was.style.color = '#888'; was.style.textAlign = 'center';}
}
}

function Password(was, inhalt) {
if(was.value==inhalt){was.value=''; was.style.color = '#000'; was.style.textAlign = 'left'; was.type = 'password';}
}
function outPassword(was, inhalt) {
if(was.value==''){was.value=inhalt; was.style.color = '#888'; was.style.textAlign = 'center'; was.type = 'text';}
}

function Laden(PhPSeite, prefixs) {


$('.Ad_Werbung').remove();
$('.hbg_reg').css('display', 'none');
$('.hbg_img').css('display', 'none');
$('.fbg').html('<br><br><br><center style="color: #fff;"><img src="images/loading.gif"> <br>Seite wird geladen...</center><br><br><br><br>');

$('#NavRegistieren').removeClass('active');
$('#NavStartseite').removeClass('active');
$('#NavWebSuche').removeClass('active');
if('regist' == PhPSeite) {
$('#NavRegistieren').addClass('active');
}
if('index/suche' == PhPSeite) {
$('#NavWebSuche').addClass('active');
}


if(prefixs == null) {
$(".fbg").load('php/'+PhPSeite+'.php');
}
else {
$(".fbg").load('php/'+PhPSeite+'.php?'+prefixs);
}

if(PhPSeite == 'index/suche') {

$(".footer").css('position', 'absolute');
$(".footer").css('bottom', '0px');
$(".footer").css('left', '50%');
$(".footer").css('margin-left', '-500px');


}
}

function hashcheck() {
if(window.location.hash == "#Registieren") {
Laden('regist');
}
else if(window.location.hash == "#Registieren/Code") {
Laden('regist', 'code=false');

}
else if(window.location.hash == "#Registieren/Fertig") {
Laden('regist', 'fertig=true');

}
else if(window.location.hash == "#logout") {
//error, success, notice, warning
   showToast('Erfolgreich ausgeloggt!<br> Danke f&uuml;r deinen Besuch, bis bald!', true, 'success');

}
else if(window.location.hash == "#Suche") {
Laden('index/suche');

}
else if(window.location.hash == "#Impressum") {
Laden('index/impressum-DE');
}
else if(window.location.hash == "#AGB") {
Laden('index/agb-DE');
}
else if(window.location.hash == "#Datenschutz") {
Laden('index/datenschutz-DE');
}
else if(window.location.hash == "#Jugendschutz") {
Laden('index/kinderschutz-DE');
}
else if(window.location.hash == "#Jugendschutz") {
Laden('index/kinderschutz-DE');
}
else if(window.location.hash.split("#")[1] != null) {

  Verfallsdatum = new Date;
  Verfallsdatum.setMonth(Verfallsdatum.getMonth()+2);
   document.cookie="EinladeUser="+window.location.hash.split("#")[1]+";expires="+Verfallsdatum.toGMTString();
}

}

function check(was) {

var wert = $('#'+was).val();


if(wert == '') {
document.getElementById('res'+was).style.background = "url(images/loading.gif)";
document.getElementById('res'+was).style.background = "url(images/startseite/no.png)";
document.getElementById('ok_'+was).checked = false; agreesubmit();
}
else {
if(was == "vorname" || was == "nachname") {
document.getElementById('resvollname').style.background = "url(images/loading.gif)";
if($('#vorname').val() == "" || $('#nachname').val() == "") {

document.getElementById('resvollname').style.background = "url(images/startseite/no.png)";
document.getElementById('ok_vollname').checked = false; agreesubmit();
}
else {
document.getElementById('resvollname').style.background = "url(images/startseite/ya.png)";
document.getElementById('ok_vollname').checked = true; agreesubmit();
}


}else {
document.getElementById('res'+was).style.background = "url(images/loading.gif)";
$.get('php/ort.php?'+was+'='+wert, function(data){
if(data == 'true') {
document.getElementById('res'+was).style.background = "url(images/startseite/ya.png)";
document.getElementById('ok_'+was).checked = true; agreesubmit();

}
else {
document.getElementById('res'+was).style.background = "url(images/startseite/no.png)";
document.getElementById('ok_'+was).checked = false; agreesubmit();
}
})

}
}


}

function ortplz(was) {
var plz = $('#PLZRest').val();
document.getElementById('resPLZ').style.background = "url(images/loading.gif)";
if(plz > 10000 || typeof(plz)=='number') {
$.get('php/ort.php?plz='+plz, function(data){
if(data == 'false') {
document.getElementById('resPLZ').style.background = "url(images/startseite/ya.png)";
document.getElementById('ok_plz').checked = true; agreesubmit();
document.getElementById("WohnortRest").removeAttribute("readonly");
}
else {
$('#WohnortRest').val(data);
document.getElementById('resPLZ').style.background = "url(images/startseite/ya.png)";
document.getElementById('resWohnort').style.background = "url(images/startseite/ya.png)";
document.getElementById('ok_plz').checked = true; agreesubmit();
}
})
}
else {
$('#PLZRest').val('Richtige PLZ angeben!');
document.getElementById('resPLZ').style.background = "url(images/startseite/no.png)";
document.getElementById('ok_plz').checked = false; agreesubmit();
}
}

function passwort() {
document.getElementById('respwd2').style.background = "url(images/loading.gif)";
if($('#pwd1').val() == $('#pwd2').val() && $('#pwd1').val() != "" && $('#pwd1').val().length > 5) {
document.getElementById('respwd2').style.background = "url(images/startseite/ya.png)";
document.getElementById('respwd1').style.background = "url(images/startseite/ya.png)";
document.getElementById('ok_pwd').checked = true; agreesubmit();
agreesubmit();
}
else  {
document.getElementById('respwd2').style.background = "url(images/startseite/no.png)";
document.getElementById('ok_pwd').checked = false; agreesubmit();
agreesubmit();
}
}



function char_count(){
   //Über die DOM-Methode document.getElementById wird der Wert aus dem Eingabefeld geholt
   //und der Variablen val zugewiesen.
   var val = document.getElementById('pwd1').value;

   //Anschließend wird über die selbe DOM-Methode ein Referenzpunkt für das Feedback erzeugt 
   //und in der Variablen call gespeichert.
   var call = document.getElementById('feedback');
            
   //Ab hier beginnt die Prüfung.
   //Das Passwort ist entweder zu kurz, unsicher, sicher oder sehr sicher
   
   //Ist das Passwort wenigstens 6 Zeichen lang?
   if (val.length > 5)  
   {    
        
      //Wenn das Passwort neben Buchstaben zusätzlich wenigstens eine Zahl 
      //und ein Sonderzeichen enthält, ist es "sehr sicher".    
      if (val.match(/\d{1,}/) && val.match(/[a-zA-ZäöüÄÖÜ]{1,}/) && val.match(/\W/)) 
        {   
      call.style.color="#428c0d";               
      call.innerHTML = "<div id='sicher' style='width: 100px; height: 16px; background: #6fda20;'></div>";
        }
        
        //Wenn das Passwort nur eine Zahl oder ein Sonderzeichen enthält, ist es "sicher"?           
        else if (val.match(/\d{1,}/) && val.match(/[a-zA-ZäöüÄÖÜ]{1,}/) || val.match(/\W/) && val.match(/[a-zA-ZäöüÄÖÜ]{1,}/)) 
        {   
    call.style.color="#56a40c"; 
    call.innerHTML = "<div id='sicher' style='width: 100px; height: 16px; background: #eee;'><div style='width: 75px; height: 16px; background: #c3d12d;'></div></div>";
        }
        else //Hier enthält das Passwort weder Ziffern noch Sonderzeichen und ist somit "unsicher".
        {   
         
    call.style.color="#ff9410"; 
    call.innerHTML = "<div id='sicher' style='width: 100px; height: 16px; background: #eee;'><div style='width: 50px; height: 16px; background: #e06909;'></div></div>";}
    } 
    else //Hier enthält das Passwort nicht mal die erforderlichen 6 Zeichen und ist daher "zu kurz"
    { //b70c0c
    call.style.color="#ff352c"; 
    call.innerHTML = "<div id='sicher' style='width: 100px; height: 16px; background: #eee;'><div style='width: 25px; height: 16px; background: #b70c0c;'></div></div>";}          
    };      
	
	
	



var checkobj

function agreesubmit(){
/*
checkobj=el
if (document.all||document.getElementById){
for (i=0;i<checkobj.form.length;i++){  //hunt down submit button
var tempobj=checkobj.form.elements[i]
if(tempobj.type.toLowerCase()=="submit")
tempobj.disabled=!checkobj.checked
}
}
*/
if(document.getElementById('ok_pwd').checked == true && 
document.getElementById('ok_email').checked == true && 
document.getElementById('ok_vollname').checked == true && 
document.getElementById('ok_plz').checked == true && 
document.getElementById('ok_name').checked == true && 
document.getElementById('inputchack').checked == true && 
document.getElementById('code').value != '') {
document.getElementById('submit').disabled = false;
}
else {
document.getElementById('submit').disabled = true;
}




}

function defaultagree(el){
if (!document.all&&!document.getElementById){
if (window.checkobj&&checkobj.checked)
return true
else{
alert("Please read/accept terms to submit form")
return false
}

}




}


function checkhoehe() {
document.getElementById('suchinhalt').height = document.getElementById('suchinhalt').contentWindow.document.body.scrollHeight+35;


}

//error, success, notice, warning
    function showToast(Ctext, Csticky, Ctype) {
        $().toastmessage('showToast', {
            text     : Ctext,
            sticky   : Csticky,
            position : 'middle-center',
            type     : Ctype,
            closeText: '',
            close    : function () {
                console.log("toast is closed ...");
            }
        });

    }
