// Place your application-specific JavaScript functions and classes here
// This file is automatically included by javascript_include_tag :defaults
function openPeopleList() {
	var url = '/tag/show_people';
	window.open(url, 'people_list', 'scrollbars=yes,resizable=yes,width=400,height=450');
}


function add_to_cart(item_id) {
	var url = '/town/store/add_to_cart/' + item_id;
	window.open(url, 'people_list', 'scrollbars=no,resizable=no,width=300,height=250');
}


function conf_file_usage(obj, id) {
	var url = '/admin/uploaded_file/usage?obj=' + obj + '&obj_id=' + id;
	window.open(url, 'people_list', 'scrollbars=no,resizable=yes,width=400,height=450');
}

function openTS() {
	var url = '/page/terms';
	window.open(url, 'people_list', 'scrollbars=yes,resizable=yes,width=550,height=450');
}

function openRegisterTerms() {
	var url = '/page/register_terms';
	window.open(url, 'register_terms', 'scrollbars=yes,resizable=yes,width=550,height=450');
}

function openShipping() {
	var url = '/page/shipping_explanation';
	window.open(url, 'shipping', 'scrollbars=yes,resizable=yes,width=550,height=450');
}

function openPrintableRecipe(recipe_id) {
	var url = '/town/grandma/view_printable_recipe/' + recipe_id;
	window.open(url, 'recipe', 'scrollbars=yes,resizable=yes,menubar=yes,width=650,height=450');
}


function enlargeImage(product_id) {
	var url = '/shop/show_large_image?id=' + product_id;
	window.open(url, 'large_image', 'scrollbars=yes,resizable=yes,width=750,height=550');
}

function enlargeStoreImage(item_id) {
	var url = '/town/store/show_large_image?id=' + item_id;
	window.open(url, 'large_image', 'scrollbars=yes,resizable=yes,width=750,height=550');
}

function enlargeCoursesAndMembershipImage(courses_and_membership_id) {
	var url = '/courses_and_memberships/show_large_image?id=' + courses_and_membership_id;
	window.open(url, 'large_image', 'scrollbars=yes,resizable=yes,width=750,height=550');
}

function openTownIntro() {
	var url = '/page/town_intro';
	window.open(url, 'town_intro', 'scrollbars=yes,resizable=yes,width=750,height=550');
}

function openRegister() {
	var url = '/town/post_office/register';
	window.open(url, 'register', 'scrollbars=yes,resizable=yes,width=800,height=600');
}

function openVideoPopup() {
	var url = '/page/video_popup';
	window.open(url, 'video_popup', 'scrollbars=yes,resizable=yes,width=750,height=570');
}

function showInnerBookImages() {
	var url = '/shop/book_images';
	window.open(url, 'large_image', 'scrollbars=yes,resizable=yes,width=900,height=680');
}

function showJoints() {
	var url = '/shop/doll_joints';
	window.open(url, 'large_image', 'scrollbars=yes,resizable=yes,width=710,height=930');
}

function changeShippingInfo() {
	var checkbox = document.checkoutFrm.same_as_billing;

	if (checkbox.checked == true) {
		// populate the form
		document.checkoutFrm.shipping_name.value = document.checkoutFrm.billing_name.value;
		document.checkoutFrm.shipping_phone.value = document.checkoutFrm.billing_phone.value;
		document.checkoutFrm.shipping_address.value = document.checkoutFrm.billing_address.value;
		document.checkoutFrm.shipping_city.value = document.checkoutFrm.billing_city.value;
		document.checkoutFrm.shipping_state.value = document.checkoutFrm.billing_state.value;
		document.checkoutFrm.shipping_zip.value = document.checkoutFrm.billing_zip.value;
	} else {
		// clear the form
		document.checkoutFrm.shipping_name.value = "";
		document.checkoutFrm.shipping_phone.value = "";
		document.checkoutFrm.shipping_address.value = "";
		document.checkoutFrm.shipping_city.value = "";
		document.checkoutFrm.shipping_state.value = "";
		document.checkoutFrm.shipping_zip.value = "";
	}

}

function fade_in_home_page() {
	Effect.Fade("beginning_image");
	setTimeout('Effect.Appear("home_page_sections");', 1000);
}
