var RegisterForm = new Object();

RegisterForm.initFileUploader = function(sid){
	if ($('#spanButtonPlaceholder').length == 1){
		swfu = new SWFUpload({
			flash_url: '/repository/layout/swfupload.swf',
			upload_url: "/getContent.php",
			post_params: {
				PHPSESSID : sid,
				plugin: 'PrbPanelBiblioteki',
				content: 'upload'
			},
			file_size_limit : "10 MB",
			file_types : "*.jpg;*.gif;*.png;*.bmp;*.jpeg",
			file_types_description : "Zdjęcia",
			file_upload_limit :1 ,
			file_queue_limit : 0,
			custom_settings : {
				progressTarget : "fsUploadProgress",
				cancelButtonId : "btnCancel"
			},
			debug: false,

			button_window_mode : SWFUpload.WINDOW_MODE.TRANSPARENT, 
			button_cursor : SWFUpload.CURSOR.HAND, 
			
			
			// Button settings
			button_width: "73",
			button_height: "24",
			button_placeholder_id: "spanButtonPlaceholder",
			button_text: '',
			button_text_style: "",
			button_text_left_padding: 0,
			button_text_top_padding: 0,
			button_image_url: '/repository/layout/panel_biblioteki/form_przegladaj.gif',
			
			// The event handler functions are defined in handlers.js
			file_queued_handler : fileQueued,
			file_queue_error_handler : fileQueueError,
			file_dialog_complete_handler : fileDialogComplete,
			upload_start_handler : uploadStart,
			upload_progress_handler : uploadProgress,
			upload_error_handler : uploadError,
			upload_success_handler : uploadSuccessZdjecie,
			upload_complete_handler : uploadComplete,
			queue_complete_handler : queueComplete	// Queue plugin event
		});
		}
}

RegisterForm.otherPhonesInit = function(){
	if ($('div#otherPhones input[value!=""]').length > 0){
		$('div#otherPhones').show();
		$('#otherPhoneCh').attr('checked', 'checked');
	}
	else	
		$('div#otherPhones').hide();
	
	$('#otherPhoneCh').click(function(){
		if ($(this).attr('checked')) $('div#otherPhones').show();
		else $('div#otherPhones').hide();
	}
	);
}

RegisterForm.init = function(){
	$('.tooltip').tooltip({track: true});
	$('.tooltip_ico').tooltip({track: true});
	

	jQuery.validator.addMethod("kod_pocztowy", 
		function(value, element) {
			if (value.match(/^\d{2}-\d{3}$/)) return true;
			return false;
		}, jQuery.format("Wpisz poprawny kod pocztowy.")
	);
};
