//**********************************************************************************************************************
/**
* DOCUMENT: /core/plugins/store/front/content.front.js
* DEVELOPED BY: Ryan Stemkoski
* COMPANY: Zipline Interactive
* EMAIL: ryan@gozipline.com
* PHONE: 509-321-2849
* DATE: 4/28/2010
* DESCRIPTION: This document has all of the javascript functions required for the front-end store plugin.
*/
//***********************************************************************************************************************


function same_as() {
		
	$('.cc_first_name').val($('.ship_first_name').val());	
	$('.cc_last_name').val($('.ship_last_name').val());
/*
	$('.cc_title').val($('.ship_title').val());
	$('.cc_company').val($('.ship_company').val());
*/
	$('.cc_phone').val($('.ship_phone').val());
	$('.cc_email').val($('.ship_email').val());
	$('.cc_address').val($('.ship_address').val());
	$('.cc_city').val($('.ship_city').val());
	$('.cc_state').val($('.ship_state').val());
	$('.cc_zip').val($('.ship_zip').val());
		
}

function validate(item) {
	$(item).attr('value',$(item).val().replace(' ', ''));
	$(item).attr('value',$(item).val().replace('-', ''));
	$(item).attr('value',$(item).val().replace('+', ''));
	
	if(isNaN($(item).val()) || $(item).val() == '' || $(item).val() == ' ') {
		$(item).attr('value','0');
	}
}

//***********************************************************************************************************************
//ON DOCUMENT READY FUNCTIONS
//***********************************************************************************************************************
$(function() {
	
	$('#same_as').click(function () {
		if($(this).attr('checked')) {
			same_as();
		}
	});
	
	$('.qty-box').click(function () {
		$(this).attr('value','');
	});
	
	$('.qty-box').blur(function () {
		validate($(this));
	});
	
	$('.qty-box').change(function () {
		validate($(this));
	});

	
});
