// Place your application-specific JavaScript functions and classes here
// This file is automatically included by javascript_include_tag :defaults

function refreshNewUserForm() {
	$.ajax({
		type: 'GET',
		dataType: 'html',
		url: '/curator_area/users/new',
		success: function(data,textStatus) {
			$('#user_new').html(data);
		}
	});
};

function checkForEverywhere() {
	if($("[everywhere_else='true']").length > 0){
		$('#shipping_destination_item_nowhere').hide();
	} else {
		$('#shipping_destination_item_nowhere').show();
	}
}
function clickRefreshImageLink(id){
	$('#refresh_images_link').attr('href',$('#refresh_images_link').attr('href') + '/' + id);
	$('#refresh_images_link').click();
	$('#post_element_new').empty();
	$('#post_element_new_links').show();
}
function clickRefreshCommentImageLink(id){
	bare_link = $('#refresh_images_link').attr('href');
	$('#refresh_images_link').attr('href',bare_link + '/' + id + '?preview=true');
	$('#refresh_images_link').click();
	$('#refresh_images_link').attr('href',bare_link);
	$('#post_image_uploading').hide();
	$('#post_comment_image').val('');
}
function clickRefreshAssetImageLink(id){
	bare_link = $('#refresh_images_link').attr('href');
	$('#refresh_images_link').attr('href',bare_link + '/' + id + '?preview=true');
	$('#refresh_images_link').click();
	$('#refresh_images_link').attr('href',bare_link);
	$('#message_image_uploading').hide();
	$('#message_asset_image').val('');
}
function clickRefreshAvatarLink(){
	$('#refresh_images_link').click();
}
function bindCloseDialog(){
	$("[ui_binding='close_dialog']").click(closeDialog);
}
function bindRoundCorners(){
	$("[data-styling='round_corners']").each(function(i){
		if($(this).attr('data-styling_options')){
			$(this).corner($(this).attr('data-styling_options'));
		} else {
			$(this).corner("12px");
		}
	});
}
function closeDialog(){
	$('#dialog').hide();
	$('#modal_mask').hide();
	$('#widget_form_container').empty();
}
function handlePreviewButton(){
	if(($("[data-binding='active_form']").length > 0) || ($("[data-binding='widget_item']").length < 1)){
		$("[ui_binding='widget_preview_link']").hide();
	} else {
		$("[ui_binding='widget_preview_link']").show();
	}
}

function bindActivityWidgetQuantitySelect(){
	$('#quantity_select').html($('#quantity_select_' + $('#content_type_select').val()).html());
	$('#content_type_select').change(function(e){
		$('#quantity_select').html($('#quantity_select_' + $(e.target).val()).html());
	});
}
$(document).ready(function(){
	bindRoundCorners();
});