// Place your application-specific JavaScript functions and classes here
// This file is automatically included by javascript_include_tag :defaults
function apply_form_helpers() {
  jQuery.bt.options.fill = "#000";
  jQuery.bt.options.positions = "top";
  jQuery.bt.options.shadow = true;
  jQuery.bt.options.shadowColor = "#666";
  jQuery.bt.options.color = "#fff";
  $('input.email').attr('title', 'emails should be of the format name@example.com and be no greater than 100 characters');
  $('input.email').bt();
  $('input.email').example('name@example.com');

  $('input.login').attr('title', 'login must be between 3 and 40 characters');
  $('input.login').bt();

  $('.line-item-description').bt();

  $('input.password').attr('title', 'password must be between 4 and 40 characters');
  $('input.password').bt();

  $('input.title').example("title");

  $('input.phone-number').example("+61 3 9123 4567");
  $('input.phone-number').attr('title', 'use a country code prefix if you want to reach an international audience');
  $('input.phone-number').bt();
  $('input.street').example("123 example st");
  $('input.locality').example("suburb/town");
  $('input.postal-code').example("zip/postcode");
  $('input.region').example("state/region");
  $('input.country').example("country");

  $('input.first-name').example('first name');
  $('input.middle-name').example('middle name');
  $('input.last-name').example('last name');

  $('input.web-property-id').example('UA-9999999-1');

  $('input.url').attr('title', 'urls should be of the format http://www.example.com');
  $('input.relative-url').example('/pageurl');
  $('input.redirect').example('http://example.com or /pageurl');
  $('input.redirect').attr('title', 'urls should be of the format http://www.example.com to redirect to another website or /pageurl if it\'s another page within this website');
  $('input.url').example('http://www.example.com');
  $('input.url').bt();

  $('input.paid').attr('title', 'this item has been paid for, click to move to unpaid');
  $('input.paid').bt();
  $('input.unpaid').attr('title', 'this item has NOT been paid for, click to mark as paid');
  $('input.unpaid').bt();
  $('input.processed').attr('title', 'this item has already been processed, click to move to unprocessed');
  $('input.processed').bt();
  $('input.unprocessed').attr('title', 'this item has NOT been processed, click to mark as processed');
  $('input.unprocessed').bt();


  $('input.tags').example('tag1, tag2');
  $('.page.published').bt();
  $('.property.published').bt();
  $('.property.view').bt();
  
  $('.login-email').example('enter your email address');
  $('.login-password').example('********');

  $('.tooltipped').bt();
}

function calculatePrice() {
	var price = 0.0;
	var selected = 0;
	selected = $('#card_ids_ :selected').length;
	var price = 0.0;
	$('#templates-list .item:checked').each(function() {
		price += parseFloat($(this).attr('price'));
	});
	price = price * selected;
	$('#cost').html('$' + price.toFixed(2))
	$('#cart-items .line-item').each(function() {
		price += parseFloat($(this).attr('price'));
	});
	$('#subtotal').html('$' + price.toFixed(2))
	$('#tax').html('$' + (price * 0.1).toFixed(2))
	$('#total-cost').html('$' + (price + (price * 0.1)).toFixed(2))
}