function product_photo_swap(thumb_url, large_url) {
	$('product_photo').src = thumb_url;
	$('product_photo_link').href = large_url;    
}

function product_email_friend_popup(url) {
	day = new Date();
	id = day.getTime();
	eval('page' + id + ' = window.open(url, "' + id + '", "toolbar=0,scrollbars=yes,location=0,statusbar=0,menubar=0,resizable=0,width=500,height=500");');
	return false;
}

function shipping_as_billing(cbox) {
	$w('firstname lastname address city state postal_code address2').each(function(f) {
		$('order_shipping_' + f).value = cbox.checked ? $('order_billing_' + f).value : "";
	});
}

function weekend_photo_swap(product_photo_id, variant_id, variation_thumb_url, variation_large_url, default_thumb_url, default_large_url) {
	variant_id = variant_id.split('-')
	var photo_swap_type = variant_id[1]
	var variant_photo_id = variant_id[2]

	
	if ($('product_photo') != null) { 
		switch(photo_swap_type) {
			case 'variant':
			$('product_photo').src = variation_thumb_url.replace('swap', variant_photo_id);
			break;
			case 'default':
			$('product_photo').src = default_thumb_url.replace('swap', product_photo_id);
			break;
		}
	}

	new Ajax.Request('/product/alternate_views/' + variant_id, {
		method: 'get',
		onLoading: function() {
			$('alternate_views').innerHTML = 'Loading..';
		}
	});		
}

var slides= new Array('slide0', 'slide1', 'slide2', 'slide3','slide4', 'slide5'); 
var i = 0; var wait = 4800;

function SlideShow() {
	Effect.Fade(slides[i], { duration:1, from:1.0, to:0.0 }); 
	i++;
	if (i == 6) i = 0; 
	Effect.Appear(slides[i], { duration:1, from:0.0, to:1.0 });
} 

// the onload event handler that starts the fading. 
function start_slideshow() { setInterval('SlideShow()',wait); }

//Page slideshow for branding
var pageslides= new Array('slide0', 'slide1', 'slide2'); 
var i = 0; var wait = 4800;

function PageSlideShow() {
	Effect.Fade(pageslides[i], { duration:1, from:1.0, to:0.0 }); 
	i++;
	if (i == 3) i = 0; 
	Effect.Appear(pageslides[i], { duration:1, from:0.0, to:1.0 });
} 

// the onload event handler that starts the fading. 
function start_pageslideshow() { setInterval('PageSlideShow()',wait); }
