﻿

var PhotoUploadForm = {
	initialize:function(container)
	{

		//embed themself to window to make iframe accesible
		window.photoUploadForm = this;		
	    this.loadMembers({el:$(container),exitBtn:$("photoExitButton"),saveBtn:$("photoSaveBtn"),cancelBtn:$("photoCancelBtn")});
		 Event.observe( window,"load", this.appendToBody.bindAsEventListener(this));    
        this.categoryController = categoryController;
		
	},
	appendToBody:function()
	{
	    appendElementToAnother(this.el,document.body);
	},
	
	getCurrentCategoryId:function()
	{	  
	  return this.categoryController.categoryId;
	},
	setOnsubmit:function(handler)
	{
		this.saveBtn.onclick = handler;		
	}
	
}


var PhotoUploadForm =Class.extend(CustomForm,PhotoUploadForm);


var UploadIframe = Class.create();

UploadIframe.prototype={
	initialize:function()
	{

		this.photoUploadForm = window.parent.photoUploadForm;
		this.frmUploadPhotos = $("frmUploadPhotos");
		this.categoryField =$("categoryId"); 
		this.photoUploadForm.setOnsubmit(this.submitForm.bindAsEventListener(this));
		
		if(shouldRefreshPhotos) window.parent.photoListingController.refreshListing();
		
		
	},
	submitForm:function()
	{
	   this.categoryField.value =this.photoUploadForm.getCurrentCategoryId();
	   this.frmUploadPhotos.submit();
	}	
	
}
