/******************************************************************************
 * Class PictureGalery inherits AjaxList which is derived from AjaxModule
 *
 ******************************************************************************/
function PictureGalery(){
	AjaxList.apply(this, arguments); // superclass constructor
	this.emitters.imgID = new CallbackList();
	this.emitters.srcID = new CallbackList();
	this.uploadHandler = '/mod/v3/pict/pictUplo.asp';
}

function PictureGalery_load() {
	AjaxList.prototype.load.apply(this, arguments);
}
function PictureGalery_doOnRequestsComplete(request) {
	AjaxList.prototype.doOnRequestsComplete.apply(this, arguments);
}
function PictureGalery_formSubmit(form) {
	
	var formValues = Form.serialize(form, true);
	var errEl;
	var errorOccured = false;

	errEl = Selector.findChildElements(form, $A(['.user_name .error']))[0]
	if (formValues['user_name'].match(/^\W*$/)) {
		if (errEl) errEl.style.display = '';
		errorOccured = true;
	}
	else if (errEl) errEl.style.display = 'none';

	errEl = Selector.findChildElements(form, $A(['.user_country .error']))[0]
	if (formValues['user_country'].match(/^\W*$/)) {
		if (errEl) errEl.style.display = '';
		errorOccured = true;
	}
	else if (errEl) errEl.style.display = 'none';
	
	errEl = Selector.findChildElements(form, $A(['.user_picture_title .error']))[0]
	if (formValues['user_picture_title'].match(/^\W*$/)) {
		if (errEl) errEl.style.display = '';
		errorOccured = true;
	}
	else if (errEl) errEl.style.display = 'none';
	
	errEl = Selector.findChildElements(form, $A(['.user_picture_file .error']))[0]
	if (formValues['user_picture_file'].match(/^\W*$/)) {
		if (errEl) errEl.style.display = '';
		errorOccured = true;
	}
	else if (errEl) errEl.style.display = 'none';
	
	if (errorOccured) return false;
	else return true;
	
}
function PictureGalery_changeSelectedPicture(selImgId) {
	this.xsltParams["selImgID"] = selImgId
	this.load(false,false);
}
Object.extend(PictureGalery.prototype, AjaxList.prototype);
PictureGalery.prototype.load = PictureGalery_load;
PictureGalery.prototype.doOnRequestsComplete = PictureGalery_doOnRequestsComplete;
PictureGalery.prototype.formSubmit = PictureGalery_formSubmit;


function PictureGaleryStatic() {
	PictureGalery.apply(this, arguments); // superclass constructor
	AjaxListStatic.apply(this, arguments); // superclass constructor
	if (!this.emitters.ItemsPerPage) this.emitters.ItemsPerPage = new CallbackList();
	if (!this.emitters.itemCount) this.emitters.itemCount = new CallbackList();
}
function PictureGaleryStatic_doOnRequestsComplete() {
	AjaxListStatic.prototype.doOnRequestsComplete.apply(this, arguments);

}
function PictureGaleryStatic_doOnPageChange() {
	this.emitters.ItemsPerPage.invoke(this.pager.getItemsPerPage(), this);
	this.emitters.itemCount.invoke(this.pager.getItemCount(), this);
	AjaxListStatic.prototype.doOnPageChange.apply(this, arguments);
}

function PictureGaleryStatic_processStaticContent() {
	AjaxListStatic.prototype.processStaticContent.apply(this, arguments);

}
function PictureGaleryStatic_load() {
	if (this.pager) this.params['rpp'] = this.pager.getItemsPerPage();
	if (this.pager) this.params['itemCount'] = this.pager.getItemCount();
	AjaxListStatic.prototype.load.apply(this, arguments);
}
Object.extend(PictureGaleryStatic.prototype, PictureGalery.prototype);
Object.extend(PictureGaleryStatic.prototype, AjaxListStatic.prototype);
PictureGaleryStatic.prototype.doOnRequestsComplete = PictureGaleryStatic_doOnRequestsComplete
PictureGaleryStatic.prototype.processStaticContent = PictureGaleryStatic_processStaticContent;
PictureGaleryStatic.prototype.doOnPageChange = PictureGaleryStatic_doOnPageChange;
PictureGaleryStatic.prototype.load = PictureGaleryStatic_load;
