function toggle_box_display(id) { id2 = id+'_plus'; if (document.getElementById(id).style.display == 'none') { document.getElementById(id).style.display = 'block'; document.getElementById(id+'_plus').src = 'templates/erosnap/images/box_minus.gif' } else { document.getElementById(id).style.display = 'none'; document.getElementById(id+'_plus').src = 'templates/erosnap/images/box_plus.gif' } } function checkUniqueEmail(email) { var result; new Ajax.Request('/xml.php', //Needs the prototypeclass { method: 'post', asynchronous: false, parameters: { type: 'checkRegisterEmail', email: email }, onSuccess: function(transport) { var xml = transport.responseXML; var checker = xml.getElementsByTagName("check_flag")[0].firstChild.data; result = true; if (checker=="NOK") result = false; } } ); return result; } function saveRating(info,uid,id,object_name,comment) { var html; new Ajax.Request('/xml.php', { method: 'post', asynchronous: false, parameters: { type: 'saveRating', rating: info.rated, uid: uid, id: id, object_name: object_name, comment: comment }, onSuccess: function(transport) { var xml = transport.responseXML; html = xml.getElementsByTagName("htmlReturn")[0].firstChild.data; } } ); document.getElementById('rating').innerHTML = html; } function checkEmail(email,id) { /* checks an email, also that is unique in the system */ if (email.length>0) { var res = false; reg = new RegExp('^([a-zA-Z0-9\\-\\.\\_]+)'+ '(\\@)([a-zA-Z0-9\\-\\.]+)'+ '(\\.)([a-zA-Z]{2,4})$'); res = reg.test(email); if (!res) error_msg='Bitte geben Sie eine gültige E-Mail-Adresse an.'; /* if (res) { //do the ajax checks res=checkUniqueEmail(email); if (!res) error_msg='Diese E-Mailadresse existiert schon. Falls Sie Ihr Passwort vergessen haben lassen Sie es sich über den "Passwort vergessen" Link zuschicken.'; } */ if (!res) input_error(id,true,error_msg); else input_error(id,false); } else showLamp(); } function checkANYTHING(value,id) { /* not used yet */ if (!checker) input_error(id,true); else input_error(id,false); } function input_error(id,flag,error_msg) { /* Changes classes and styles for the input errors */ var error_class="error"; oldclass = document.getElementById(id).className; oldclass = oldclass.replace(new RegExp(error_class,"g"),''); showLamp(0,id); if (flag) { //put the error class oldclass = oldclass + " " + error_class; //show the red light showLamp(1,id,error_msg); } document.getElementById(id).className=oldclass; } function showLamp(status,id,error_msg) { /* turns on/off the lamp next to an input */ lamp = document.getElementById("lamp_"+id); if (status==0) { lamp.src="images/lamp_green.gif"; lamp.alt="Ok"; lamp.title="Ok"; } else if (status==1) { lamp.src="images/lamp_red.gif"; lamp.alt=error_msg; lamp.title=error_msg; } else { lamp.src="images/lamp_empty.gif"; lamp.alt=""; lamp.title=""; } }