
/* Merged Plone Javascript file
 * This file is dynamically assembled from separate parts.
 * Some of these parts have 3rd party licenses or copyright information attached
 * Such information is valid for that section,
 * not for the entire composite file
 * originating files are separated by - filename.js -
 */

/* - formUnload.js - */
// http://indy.gr/portal_javascripts/formUnload.js?original=1
if(!window.beforeunload)(function(){var BeforeUnloadHandler=function(){var self=this;this.message=window.form_modified_message||"Discard changes? If you click OK, any changes you have made will be lost.";this.forms=[];this.chkId=[];this.chkType=new this.CheckType();this.handlers=[this.isAnyFormChanged];this.submitting=false;this.execute=function(event){var domforms=jq('form');self.forms=jq.grep(self.forms, function(form){return domforms.index(form)>-1});if(self.submitting) return;var message;jq.each(self.handlers, function(i,fn){message=message||fn.apply(self)});if(message===true) message=self.message;if(message===false) message=undefined;if(event&&message) event.returnValue=message;return message}
this.execute.tool=this}
var Class=BeforeUnloadHandler.prototype;Class.isAnyFormChanged=function(){for(var i=0;form=this.forms[i++];){if(this.isElementChanged(form))
return true}
return false}
Class.addHandler=function(fn){this.handlers.push(fn)}
Class.onsubmit=function(){var tool=window.onbeforeunload&&window.onbeforeunload.tool;tool.submitting=true;plone.UnlockHandler.submitting=true}
Class.addForm=function(form){if(jq.inArray(form,this.forms)>-1) return;this.forms.push(form);jq(form).submit(this.onsubmit);var elements=form.getElementsByTagName('input');jq(form).find('input:hidden').each(function(){var value=this.defaultValue;if(value!==undefined&&value!==null)
jq(this).attr('originalValue',value.replace(/\r\n?/g,'\n'))})}
Class.addForms=function(){var self=this;jq.each(arguments, function(){if(this.tagName.toLowerCase()=='form')
self.addForm(this);else
self.addForms.apply(self,jq(this).find('form').get())})}
Class.removeForms=function(){var self=this;jq.each(arguments, function(){if(this.tagName.toLowerCase()=='form'){var el=this;self.forms=jq.grep(self.forms, function(form){return form!=el});jq(element).unbind('submit',self.onsubmit)} else
self.removeForms.apply(self,jq(this).find('form').get())})}
Class.CheckType=function(){};var c=Class.CheckType.prototype;c.checkbox=c.radio=function(ele){return ele.checked!=ele.defaultChecked}
c.file=c.password=c.textarea=c.text=function(ele){return ele.value!=ele.defaultValue}
c.hidden=function(ele){var orig=jq(ele).attr('originalValue');if(orig===undefined||orig===null) return false;return jq(ele).val().replace(/\r\n?/g,'\n')!=orig}
c['select-one']=function(ele){for(var i=0;opt=ele[i++];){if(opt.selected!=opt.defaultSelected){if(i===1&&opt.selected) continue;return true}}
return false}
c['select-multiple']=function(ele){for(var i=0;opt=ele[i++];){if(opt.selected!=opt.defaultSelected)
return true}
return false}
Class.chk_form=function(form){var elems=jq(form).find('> :input:not(.noUnloadProtection),'+':not(.noUnloadProtection) :input:not(.noUnloadProtection)');for(var i=0;element=elems.get(i++);){if(this.isElementChanged(element))
return true}
return false}
Class.isElementChanged=function(ele){var method=ele.id&&this.chkId[ele.id];if(!method&&ele.type&&ele.name)
method=this.chkType[ele.type];if(!method&&ele.tagName)
method=this['chk_'+ele.tagName.toLowerCase()];return method?method.call(this,ele):false};window.onbeforeunload=new BeforeUnloadHandler().execute;jq(function(){var tool=window.onbeforeunload&&window.onbeforeunload.tool;var content=getContentArea();if(tool&&content)
tool.addForms.apply(tool,jq('form.enableUnloadProtection').get())})})();

/* - formsubmithelpers.js - */
// http://indy.gr/portal_javascripts/formsubmithelpers.js?original=1
function inputSubmitOnClick(event){if(jq(this).hasClass('submitting')&&!jq(this).hasClass('allowMultiSubmit'))
return confirm(window.form_resubmit_message);else
jq(this).addClass('submitting')}
jq(function(){jq(':submit').each(function(){if(!this.onclick)
jq(this).click(inputSubmitOnClick)})});

