var ajax_call = { myConn: false, // the XMLHttpRequest body: false, // the body element form: false, // the form element target: false, // the target container loader: false, // the loader init: function(controlId, targetId){ // test for methods & elements if(!document.getElementById || !document.getElementsByTagName || !document.getElementById(controlId) || !document.getElementById(targetId)) { return; } // set and test XHConn, quitting silently if it fails ajax_call.myConn = new XHConn(); if(!ajax_call.myConn) return; // get the body ajax_call.body = document.getElementsByTagName('body')[0]; // get the form ajax_call.form = document.getElementsByTagName('form')[0]; // get the controller ajax_call.control = document.getElementById(controlId); // get the target ajax_call.target = document.getElementById(targetId); ajax_call.part2 = document.getElementById('part2'); if (semid = ajax_call.checkCondition()) { ajax_call.getConn(semid); } // add the onchange event to the controller, ajax_call.addEvent(ajax_call.control, 'change', function(){ ajax_call.part2.style.display = 'none'; if ( semid = ajax_call.checkCondition() ){ ajax_call.getConn(semid); } else { ajax_call.target.innerHTML = '
Fehler: Sie haben eine Kategorie ausgewält.
Bitte wählen Sie ein Seminar aus!
'; } }); }, checkCondition: function() { index = ajax_call.form.seminar_select.selectedIndex; if (ajax_call.form.seminar_select.options[index].value != 0) { return ajax_call.form.seminar_select.options[index].value; } return false; }, terminSelect: function(){ obj = document.getElementById('termin_select'); val = obj.options[obj.selectedIndex].value; //alert(ajax_call.part2.style.display); if (val != 0) { ajax_call.part2.style.display = 'block'; } else { ajax_call.part2.style.display = 'none'; } }, getConn: function(semid, termin_id){ // the Ajax call // let's let the user know something is happening (see below) ajax_call.buildLoader(); /* this is the function that is run once the Ajax call completes */ var fnWhenDone = function(oXML) { // get rid of the loader ajax_call.killLoader(); // insert the returned address information into the target ajax_call.target.innerHTML = oXML.responseText; }; // use XHConn's connect method if (termin_id != 'undefined' && termin_id > 0) { ajax_call.part2.style.display = 'block'; } ajax_call.myConn.connect('seminaranmeldung_ajax.php', 'POST', 'semid='+semid+'&termin_id='+termin_id, fnWhenDone); }, buildLoader: function(){ // builds a loader // create a new div ajax_call.loader = document.createElement('div'); // give it some style ajax_call.loader.style.position = 'absolute'; ajax_call.loader.style.top = '0'; ajax_call.loader.style.left = '0'; ajax_call.loader.style.width = '100px'; ajax_call.loader.style.lineHeight = '20px'; ajax_call.loader.style.margin = '0'; ajax_call.loader.style.textAlign = 'center'; ajax_call.loader.style.border = '1px solid #870108'; ajax_call.loader.style.background = '#990033'; ajax_call.loader.style.color = '#FFFFFF'; ajax_call.loader.style.fontFamily = 'Arial, Helvetica, sans-serif'; ajax_call.loader.style.fontWeight = 'bold'; // give it some text ajax_call.loader.appendChild( document.createTextNode( 'Lade\u2026')); // append it to the body ajax_call.body.appendChild(ajax_call.loader); }, killLoader: function(){ // kills the loader // remove the loader form the body ajax_call.body.removeChild(ajax_call.loader); }, addEvent: function(obj, type, fn){ // the add event function if (obj.addEventListener) obj.addEventListener(type, fn, false); else if (obj.attachEvent) { obj["e"+type+fn] = fn; obj[type+fn] = function() { obj["e"+type+fn](window.event); }; obj.attachEvent("on"+type, obj[type+fn]); } } }; /* run the init() method on page load, passing it the required arguments */ ajax_call.addEvent(window, 'load', function() { ajax_call.init('seminar_select', 'termin_select_div'); });