jQuery(function($){
	$("#twitter").tweet({
		join_text: "auto",
		username: "sakurabijou",
		avatar_size: 48,
		count: 8,
		auto_join_text_default: "we said,",
		auto_join_text_ed: "we",
		auto_join_text_ing: "we were",
		auto_join_text_reply: "we replied",
		auto_join_text_url: "we were checking out",
		loading_text: "loading tweets..."
	});
	$('#facebook').fbWall({
//		id:'neosmart.gmbh',
//		accessToken:'206158599425293|7809823973348bcf8cd72f6d.1-100000221135225|BW9n2eoyL7EYvJs7GEmv61NbBFk',
		id:'sakurabijousilverjewellery',
		accessToken:'AAAC7gAoWDQ0BAOUm7as50Cs8ZBHp2dZCqVa9ZB92r1xci9HSrnaGG3UDcZAcQgZB1inMRYtenLZAhGnPGGZCr2bhLAFvZAg79kWmuTvaa90zVwZDZD',
		showGuestEntries:false,
		showComments:false,
		max:4,
		timeConversion:24,
//		avatarAlternative:'',
//		useAvatarAlternative:true
	});
});

dlg_edit_store = function () {
	$.ajax({
		url: '/get_store',
		type: 'GET',
		dataType: 'json',
		error: function(jqXHR, status, error) {
			alert('Error processing get: ' + error + '. Contact support.');
		},
		success: function(store) {
			$('#dlg_edit_store input[name=old_name]').val(store.name);
			$('#dlg_edit_store input[name=name]').val(store.name);
			$('#dlg_edit_store input[name=short_description]').val(store.name);
			$('#dlg_edit_store input[name=address1]').val(store.address1);
			$('#dlg_edit_store input[name=address2]').val(store.address2);
			$('#dlg_edit_store input[name=city]').val(store.city);
			$('#dlg_edit_store input[name=province]').val(store.province);
			$('#dlg_edit_store input[name=postal_code]').val(store.postal_code);
			$('#dlg_edit_store input[name=phone]').val(store.phone);
			$('#dlg_edit_store input[name=email]').val(store.email);
			$('#dlg_edit_store input[name=short_description]').val(store.short_description);
			$('#dlg_edit_store textarea').val(store.description);
			$('#dlg_edit_store').dialog({
				width: 400,
				height: 575,
				resizable: false,
				create: function(event, ui) {
					$('textarea.mceEditor').tinymce({
						script_url: '/static/scripts/tiny_mce/tiny_mce.js',
				    theme : "simple"
					});
				},
				title: 'Edit Store: ' + store.name,
				open: function() {
		      $(this).parents('.ui-dialog-buttonpane button:eq(1)').focus(); 
		    },
				buttons: {
					'Cancel': function() {
						$(this).dialog('close');
					},
					'Submit': function() {
						$.ajax({
							type: 'POST',
							url: '/update_store',
							data: $("#dlg_edit_store").serialize(),
							dataType: 'json',
							error: function(jqXHR, status, error) {
								alert('Error processing update: ' + error + '. Contact support.');
							},
							success: function(data, status, jqHxr) {
								$('#about-company #store_name').html('Welcome to ' + data.name);
								$('#about-company #store_description').html(data.description);
							}
						});
						$(this).dialog('close');
					}
				}
			});			
		}
	});
}


