$(function(){
	$.form("system/systems", "", "", "", "");

	$("#color_picker").ColorPicker({
		color: "#7ce4e2",
		onChange: function (hsb, hex, rgb) {
			$("#color_picker div").css({"background-color": "#"+hex});
			$("#brand_color").val(hex);
		}
	}).find("div").css({"background-color": "#7ce4e2"});
	$("#brand_color").keyup(function(){
		$("#color_picker").ColorPickerSetColor($(this).val());
		$("#color_picker div").css({"background-color": "#"+$(this).val()});
	});
	
	$("#restore_default").click(function(){
		$("#color_picker").ColorPickerSetColor("#7ce4e2");
		$("#color_picker div").css({"background-color": "#7ce4e2"});
		$("#brand_color").val("7ce4e2");
		return false;
	});
	
	$("#custom_brand_image a").click(function(){
		$("#custom_brand_image div").append("<input type='hidden' value='' name='brand_image' />");
		$("#custom_brand_image").hide();
		return false;
	});
	
	swfu = new SWFUpload({
		upload_url : "http://demo.firerift.com/api/system/systems/",
		flash_url : "http://demo.firerift.com/app/core/shared/swfs/swfupload.swf",
		file_post_name : "userfile",
		file_size_limit : "5 MB",
		file_types : "*.jpg;*.gif;*.png",
		file_types_description : "All Files",
		file_upload_limit : 0,
		file_queue_limit : 0,

		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 : uploadSuccess,
		upload_complete_handler : uploadComplete,
		queue_complete_handler : queueComplete,
		
		button_image_url : "http://demo.firerift.com/app/core/images/btn-upload-rpt.png",	// Relative to the SWF file
		button_placeholder_id : "spanButtonPlaceholder",
		button_width: 96,
		button_disabled: true,
		button_height: 24,
		button_cursor: SWFUpload.CURSOR.HAND,
		button_action : SWFUpload.BUTTON_ACTION.SELECT_FILE,
		button_window_mode : SWFUpload.WINDOW_MODE.TRANSPARENT
 	});
});

