link_click = 0;
function goto(t) {
    if(link_click == 0) {
        window.location = '?wohin='+t;
    }

}
function chClass(t, c) {
    t.className = c;
}
function showLogin() {
    if(document.getElementById("login").style.display == 'block') {
        document.getElementById("login").style.display = 'none';
    }
    else {
        document.getElementById("login").style.display = 'block';
        if(document.getElementById("loginname").value == '') {
            document.getElementById("loginname").value = "Benutzername";
        }
        if(document.getElementById("loginpw").value == '') {
            document.getElementById("loginpw").value = "Passwort";
        }
    }
}
function eraseValue(t,w) {
    if(t.value == w) {
        t.value = '';
    }
}
function LogOut() {
    window.location = "?wohin=96&lo=1";
}
function notify(evt) {
	notify_box_org = document.getElementById("notify_box").innerHTML;

	document.getElementById("notify_box").style.left = evt.clientX+document.body.scrollLeft-200;
	document.getElementById("notify_box").style.top = evt.clientY+document.body.scrollTop+10;
    document.getElementById("notify_box").style.display = 'block';
}
function closeNotify() {
    document.getElementById("notify_box").style.display = 'none';
    document.getElementById("notify_box").innerHTML = notify_box_org;
}

function getCaptchaCode() {
	loc = "?main_only=1&getCaptchaCode=1";
	callAHAH(loc, "tmp_div", "", "");
}
function captchaReady(v) {
   captcha_code = v.substr(4,9);

   if(captcha_code.toLowerCase() != captcha.value.toLowerCase()) {
        captcha.style.border = "1px solid red";
        fehler_str += "<li style='color:red;'>Captcha ungültig!</li>";
        is_error = 1;
   }
   else {
   		captcha.style.border = "1px solid #DBDBDB";
   }

    if(is_error == 1) {
    	document.getElementById("notify_error_field").innerHTML = fehler_str;
    }
    else {
    	document.getElementById("notify_error_field").innerHTML = "";
        document.getElementById("notify_box").style.height = '60px';
        document.getElementById("notify_box").innerHTML = '<div style="text-align:center;padding-left:5px;padding-right:5px;"><br><br><img src="images/freischalten.gif"> &nbsp;eMail wird gesendet...</div>';
        //email sende...

	    loc = "?main_only=1&send_notify=1&noify_email="+email1.value+"&noify_subject="+subject.value+"&noify_msg="+message+"&noify_lnk="+lnk.value;
	    callAHAH(loc, "tmp_div", "", "");
    }

}

function sendNotify() {

	email1		= document.getElementById("notify_email");
    subject     = document.getElementById("notify_subject");
	msg         = document.getElementById("notify_message");
    lnk         = document.getElementById("notify_lnk");
    captcha 	= document.getElementById("notify_c_pic");
    message 	= msg.innerHTML.replace(/\n/g,"[z]");
    captcha_code = '';

    is_error = 0;
    fehler_str = "";
    filter=/^(\w+(?:\.\w+)*)@((?:\w+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i

    if(!filter.test(email1.value)) {
        email1.style.border = "1px solid red";
        fehler_str += "<li style='color:red;'>eMail-Adresse ungültig!</li>";
        is_error = 1;
    }
    else {
        email1.style.border = "1px solid #DBDBDB";
    }
    if(subject.value == "") {
        subject.style.border = "1px solid red";
        fehler_str += "<li style='color:red;'>Name ungültig!</li>";
        is_error = 1;
    }
    else {
    	subject.style.border = "1px solid #DBDBDB";
    }

    getCaptchaCode();

}
function sleep(milliseconds) {
  var start = new Date().getTime();
  for (var i = 0; i < 1e7; i++) {
    if ((new Date().getTime() - start) > milliseconds){
      break;
    }
  }
}
function close_notify_box() {
	sleep(1000);
    document.getElementById("notify_box").style.display = 'none';
    document.getElementById("notify_box").style.height = '';
    document.getElementById("notify_box").innerHTML = notify_box_org;

}
function print(evt) {
	lnk         = document.getElementById("notify_lnk").value;
    lnk = lnk.replace(/XAY9/g,"&");
    url = "?"+lnk+"&print=1&main_only=1";
    fenster = window.open(url, "b", "width=1024,height=800,status=yes,scrollbars=yes,resizable=yes");
    fenster.focus();
}
function GetRandom( min, max ) {
    if( min > max ) {
            return( -1 );
    }
    if( min == max ) {
            return( min );
    }

    return( min + parseInt( Math.random() * ( max-min+1 ) ) );
}

function chC_pic() {
	img = document.getElementById('c_pic');
    //img.src = 'images/descbox/trans.gif';
    rand = GetRandom(1000000,9999999);
    img.src = '?main_only=1&create_captcha=1&r='+rand;
    document.getElementById("notify_c_pic").value = '';
}

function showTrainingBox(evt, training_id, training_name) {

	training_box_org = document.getElementById("training_box").innerHTML;

    document.getElementById("training_box").innerHTML = document.getElementById("training_box").innerHTML.replace("[training_id]", training_id).replace("[training_name]", training_name);

    document.getElementById("training_box").style.display = 'block';

    pixLeft = evt.clientX+document.body.scrollLeft+10;
    pixTop  = evt.clientY+document.body.scrollTop+10


    divHeight       = document.getElementById("training_box").offsetHeight;
    screenHeight    = document.body.clientHeight;
    scrollHeight    = document.body.scrollTop;
    eventHeight     = evt.clientY;


    //wenn div hoehe und mausposition > bildschirmhoeh
    if((divHeight + eventHeight) > (screenHeight)) {

        pixTop -= divHeight;
    }

    document.getElementById("training_box").style.left = pixLeft-200;
    document.getElementById("training_box").style.top = pixTop;
}
function closeTrainingBox() {
    document.getElementById("training_box").style.display = 'none';
    document.getElementById("training_box").innerHTML = training_box_org;
}
function training_chC_pic() {
	img = document.getElementById('training_c_pic');
    //img.src = 'images/descbox/trans.gif';
    rand = GetRandom(1000000,9999999);
    img.src = '?main_only=1&create_captcha=1&r='+rand;
    document.getElementById("training_c_pic_text").value = '';
}
function sendTraining() {

    captcha_text 		= document.getElementById("training_c_pic_text");

    t_name		= document.getElementById("training_name");
    t_email		= document.getElementById("training_email");
    t_message	= document.getElementById("training_message").innerHTML.replace(/\n/g,"[z]");
    t_tel 		= document.getElementById("training_tel");

    t_training_next_termin = document.getElementById("training_next_termin");
    if(t_training_next_termin.checked == true) {
    	t_training_next_termin = 'Ja';
    }
    else {
    	t_training_next_termin = 'Nein';
    }
    t_training_inhouse_training = document.getElementById("training_inhouse_training");
    if(t_training_inhouse_training.checked == true) {
    	t_training_inhouse_training = 'Ja';
    }
    else {
    	t_training_inhouse_training = 'Nein';
    }

    captcha_code = '';

    is_error = 0;
    fehler_str = "";
    filter=/^(\w+(?:\.\w+)*)@((?:\w+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i

    if(!filter.test(t_email.value)) {
        t_email.style.border = "1px solid red";
        fehler_str += "<li style='color:red;'>eMail-Adresse ungültig!</li>";
        is_error = 1;
    }
    else {
        t_email.style.border = "1px solid #DBDBDB";
    }

    if(t_name.value == "") {
        t_name.style.border = "1px solid red";
        fehler_str += "<li style='color:red;'>Name ungültig!</li>";
        is_error = 1;
    }
    else {
    	t_name.style.border = "1px solid #DBDBDB";
    }

    getTrainingCaptchaCode();
}
function getTrainingCaptchaCode() {
	loc = "?main_only=1&getTrainingCaptchaCode=1";
	callAHAH(loc, "tmp_div", "", "");
}
function TrainingCaptchaReady(v) {
   captcha_code = v.substr(9,14);


   if(captcha_code.toLowerCase() != captcha_text.value.toLowerCase()) {
        captcha_text.style.border = "1px solid red";
        fehler_str += "<li style='color:red;'>Captcha ungültig!</li>";
        is_error = 1;
   }
   else {
   		captcha_text.style.border = "1px solid #DBDBDB";
   }

    if(is_error == 1) {
    	document.getElementById("training_error_field").innerHTML = fehler_str;
    }
    else {
    	document.getElementById("training_error_field").innerHTML = "";
        document.getElementById("training_box").style.height = '60px';
        document.getElementById("training_box").innerHTML = '<div style="text-align:center;padding-left:5px;padding-right:5px;"><br><br><img src="images/freischalten.gif"> &nbsp;Ihre Anfrage wird gesendet...</div>';
        //email sende...

	    loc = "?main_only=1&send_training=1&training_name="+t_name.value+"&training_email="+t_email.value+"&training_message="+t_message+"&training_next_termin="+t_training_inhouse_training+"&training_inhouse_training="+t_training_inhouse_training+"&training_tel="+t_tel.value;
	    callAHAH(loc, "tmp_div", "", "");
    }

}

// CONTACT BOX

function showContactBox(evt) {

	contact_box_org = document.getElementById("contact_box").innerHTML;
    document.getElementById("contact_box").style.display = 'block';

    pixLeft = evt.clientX+document.body.scrollLeft+10;
    pixTop  = evt.clientY+document.body.scrollTop+10


    divHeight       = document.getElementById("contact_box").offsetHeight;
    screenHeight    = document.body.clientHeight;
    scrollHeight    = document.body.scrollTop;
    eventHeight     = evt.clientY;


    //wenn div hoehe und mausposition > bildschirmhoeh
    if((divHeight + eventHeight) > (screenHeight)) {

        pixTop -= divHeight;
    }

    document.getElementById("contact_box").style.left = pixLeft-200;
    document.getElementById("contact_box").style.top = pixTop;


}
function closeContactBox() {
    document.getElementById("contact_box").style.display = 'none';
    document.getElementById("contact_box").innerHTML = contact_box_org;
}
function contact_chC_pic() {
	img = document.getElementById('contact_c_pic');
    //img.src = 'images/descbox/trans.gif';
    rand = GetRandom(1000000,9999999);
    img.src = '?main_only=1&create_captcha=1&r='+rand;
    document.getElementById("contact_c_pic_text").value = '';
}
function sendContact() {

    captcha_text 		= document.getElementById("contact_c_pic_text");

    t_name		= document.getElementById("contact_name");
    t_email		= document.getElementById("contact_email");
    t_message	= document.getElementById("contact_message").innerHTML.replace(/\n/g,"[z]");
    t_tel 		= document.getElementById("contact_tel");


    captcha_code = '';

    is_error = 0;
    fehler_str = "";
    filter=/^(\w+(?:\.\w+)*)@((?:\w+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i

    if(!filter.test(t_email.value)) {
        t_email.style.border = "1px solid red";
        fehler_str += "<li style='color:red;'>eMail-Adresse ungültig!</li>";
        is_error = 1;
    }
    else {
        t_email.style.border = "1px solid #DBDBDB";
    }

    if(t_name.value == "") {
        t_name.style.border = "1px solid red";
        fehler_str += "<li style='color:red;'>Name ungültig!</li>";
        is_error = 1;
    }
    else {
    	t_name.style.border = "1px solid #DBDBDB";
    }
    if(document.getElementById("contact_message").value == "") {
        document.getElementById("contact_message").style.border = "1px solid red";
        fehler_str += "<li style='color:red;'>Nachricht eingeben!</li>";
        is_error = 1;
    }
    else {
    	document.getElementById("contact_message").style.border = "1px solid #DBDBDB";
    }

    getContactCaptchaCode();
}
function getContactCaptchaCode() {
	loc = "?main_only=1&getContactCaptchaCode=1";
	callAHAH(loc, "tmp_div", "", "");
}
function ContactCaptchaReady(v) {

   captcha_code = v.substr(11,16);


   if(captcha_code.toLowerCase() != captcha_text.value.toLowerCase()) {
        captcha_text.style.border = "1px solid red";
        fehler_str += "<li style='color:red;'>Captcha ungültig!</li>";
        is_error = 1;
   }
   else {
   		captcha_text.style.border = "1px solid #DBDBDB";
   }

    if(is_error == 1) {
    	document.getElementById("contact_error_field").innerHTML = fehler_str;
    }
    else {
    	document.getElementById("contact_error_field").innerHTML = "";
        document.getElementById("contact_box").style.height = '60px';
        document.getElementById("contact_box").innerHTML = '<div style="text-align:center;padding-left:5px;padding-right:5px;"><br><br><img src="images/freischalten.gif"> &nbsp;Ihre Anfrage wird gesendet...</div>';
        //email sende...

	    loc = "?main_only=1&send_contact=1&contact_name="+t_name.value+"&contact_email="+t_email.value+"&contact_message="+t_message+"&contact_tel="+t_tel.value;
	    callAHAH(loc, "tmp_div", "", "");
    }

}
function changeMenuImageIn(t) {
	if(t.className == 'hauptmenuepunkt' && navigator.appName != 'Microsoft Internet Explorer') {
		//t.style.background = 'url(./images/buttons/b1_over.png)';
        t.className = 'hauptmenuepunkt_over'
	}
}
function changeMenuImageOut(t) {
	if(t.className == 'hauptmenuepunkt_over' && navigator.appName != 'Microsoft Internet Explorer') {
    	//t.style.background = 'url(./images/buttons/b1.png)';
    	t.className = 'hauptmenuepunkt'
    }
}
function rawurldecode( str ) {
    // Decodes URL-encodes string
    //
    // version: 905.412
    // discuss at: http://phpjs.org/functions/rawurldecode
    // +   original by: Brett Zamir (http://brettz9.blogspot.com)
    // +      input by: travc
    // +      input by: Brett Zamir (http://brettz9.blogspot.com)
    // +   bugfixed by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
    // *     example 1: rawurldecode('Kevin+van+Zonneveld%21');
    // *     returns 1: 'Kevin+van+Zonneveld!'
    // *     example 2: rawurldecode('http%3A%2F%2Fkevin.vanzonneveld.net%2F');
    // *     returns 2: 'http://kevin.vanzonneveld.net/'
    // *     example 3: rawurldecode('http%3A%2F%2Fwww.google.nl%2Fsearch%3Fq%3Dphp.js%26ie%3Dutf-8%26oe%3Dutf-8%26aq%3Dt%26rls%3Dcom.ubuntu%3Aen-US%3Aunofficial%26client%3Dfirefox-a');
    // *     returns 3: 'http://www.google.nl/search?q=php.js&ie=utf-8&oe=utf-8&aq=t&rls=com.ubuntu:en-US:unofficial&client=firefox-a'
    // *     example 4: rawurldecode('-22%97bc%2Fbc');
    // *     returns 4: '-22—bc/bc'
    var histogram = {}, ret = str.toString(), unicodeStr='', hexEscStr='';

    var replacer = function(search, replace, str) {
        var tmp_arr = [];
        tmp_arr = str.split(search);
        return tmp_arr.join(replace);
    };

    // The histogram is identical to the one in urlencode.
    histogram["'"]   = '%27';
    histogram['(']   = '%28';
    histogram[')']   = '%29';
    histogram['*']   = '%2A';
    histogram['~']   = '%7E';
    histogram['!']   = '%21';


    for (unicodeStr in histogram) {
        hexEscStr = histogram[unicodeStr]; // Switch order when decoding
        ret = replacer(hexEscStr, unicodeStr, ret); // Custom replace. No regexing
    }

    // End with decodeURIComponent, which most resembles PHP's encoding functions
    ret = ret.replace(/%([a-fA-F][0-9a-fA-F])/g, function (all, hex) {return String.fromCharCode('0x'+hex);}); // These Latin-B have the same values in Unicode, so we can convert them like this
    ret = decodeURIComponent(ret);

    return ret;
}
