Prototype.Browser.IE6 = Prototype.Browser.IE && parseInt(navigator.userAgent.substring(navigator.userAgent.indexOf("MSIE") + 5)) == 6
document.observe('dom:loaded', function() {
// Fix ie6 support for alpha png
if (Prototype.Browser.IE6) {
$$('img, input[type=image]').each(function(fix){
fixsrc = fix.readAttribute('src');
if (fixsrc.indexOf('png') != -1) {
fix.style.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='" + fixsrc + "', sizingMethod='scale')";
fix.writeAttribute({
'src': '/layout/alpha.gif'
});
}
});
}
// Auto empty form fields	
getFieldsAllFields();
validateReminderForm();
$$('table.cake-sql-log').each(function(dbg) { dbg.hide(); })
});
/**
* Create auto empty formfields for all forms with class autoclean
*/
function getFieldsAllFields() {
$$('input.autoclean').each(function(f) {
new emptyFormField(f);
});
}
/**
* Class to autoempty form fields
* @param String elm The element to use autoempty on
*/
var emptyFormField = Class.create({
initialize: function(elm) {
this.elm = $(elm);
this.oldValue = this.elm.value;
this.elm.observe('click', function(e) {
val = Event.element(e);
if(val.value == this.oldValue) val.value='';
}.bindAsEventListener(this));
elm.observe('blur', function(e) {
val = Event.element(e);
if(val.value.length == 0) val.value=this.oldValue;
}.bindAsEventListener(this));
}
});
/**
* Show the cake debug
*/
function showDebug() {
elm = $$('table.cake-sql-log').first();
if (elm) {
var isVisible = $$('table.cake-sql-log').first().visible();
$$('table.cake-sql-log').each(function(dbg){
if (isVisible) 
dbg.hide();
else 
dbg.show();
});
}
}
/**
* Validate the reminder form email address
*/
function validateReminderForm() {
elm = $('UserRemindMeForm');
if(elm) {
elm.observe('submit', function(e) {
Event.stop(e);
val = $('UserEmail').value;
var emailRegEx = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
if (val.match(emailRegEx)) elm.submit();
else alert("Bitte geben Sie eine gültige E-Mail Adresse ein!");
});
}
}

