function swap_div( div )
{
	document.getElementById( 'div1' ).style.display = "none";
	document.getElementById( 'div2' ).style.display = "none";
	document.getElementById( 'div3' ).style.display = "none";
	document.getElementById( 'div4' ).style.display = "none";
	document.getElementById( 'div5' ).style.display = "none";
	
	document.getElementById( div ).style.display = "block";
}

function close_share()
{
	$('share').set('tween',{
		duration: 0,
		link: 'chain'
	});

	$('share').tween('width', 0).tween('height', 0);
}

function open_share()
{
	$('share').set('tween',{
		duration: 500,
		transition: Fx.Transitions.Bounce.easeOut,
		link: 'chain'
	});
	$('share').tween('width', 500).tween('height', 400);

}

function validate_customer()
{
	var error = new Array();
	var html = '';
	
	billing_name = document.getElementById( 'billing_name' ).value;
	billing_company = document.getElementById( 'billing_company' ).value;
	billing_address = document.getElementById( 'billing_address' ).value;
	billing_address2 = document.getElementById( 'billing_address2' ).value;
	billing_city = document.getElementById( 'billing_city' ).value;
	billing_state = document.getElementById( 'billing_state' ).value;
	billing_zip = document.getElementById( 'billing_zip' ).value;
	billing_phone = document.getElementById( 'billing_phone' ).value;
	billing_country = document.getElementById( 'billing_country' ).value;
	shipping_name = document.getElementById( 'shipping_name' ).value;
	shipping_company = document.getElementById( 'shipping_company' ).value;
	shipping_address = document.getElementById( 'shipping_address' ).value;
	shipping_address2 = document.getElementById( 'shipping_address2' ).value;
	shipping_city = document.getElementById( 'shipping_city' ).value;
	shipping_zip = document.getElementById( 'shipping_zip' ).value;
	shipping_state = document.getElementById( 'shipping_state' ).value;
	shipping_phone = document.getElementById( 'shipping_phone' ).value;
	shipping_country = document.getElementById( 'shipping_country' ).value;
	referrer = document.getElementById( 'referrer' ).value;

	if( shipping_name.length == 0 )
	{
		error[error.length] = 'Please enter the shipping name.';
	}

	if( shipping_address.length == 0 )
	{
		error[error.length] = 'Please enter the shipping address.';
	}

	if( shipping_city.length == 0 )
	{
		error[error.length] = 'Please enter the shipping city.';
	}

	if( shipping_state == 'Please Select' )
	{
		error[error.length] = 'Please select the shipping state.';
	}

	if( shipping_zip.length == 0 )
	{
		error[error.length] = 'Please enter the shipping zip.';
	}

	if( shipping_country == 'Please Select' )
	{
		error[error.length] = 'Please select the shipping country.';
	}
	
	if( shipping_phone.length == 0 )
	{
		error[error.length] = 'Please enter the shipping phone.';
	}
	
	if( billing_name.length == 0 )
	{
		error[error.length] = 'Please enter the billing name.';
	}

	if( billing_address.length == 0 )
	{
		error[error.length] = 'Please enter the billing address.';
	}

	if( billing_city.length == 0 )
	{
		error[error.length] = 'Please enter the billing city.';
	}

	if( billing_state == 'Please Select' )
	{
		error[error.length] = 'Please select the billing state.';
	}

	if( billing_zip.length == 0 )
	{
		error[error.length] = 'Please enter the billing zip.';
	}

	if( billing_country == 'Please Select' )
	{
		error[error.length] = 'Please select the billing country.';
	}
	
	if( billing_phone.length == 0 )
	{
		error[error.length] = 'Please enter the billing phone.';
	}
	
	if( referrer.length == "Please Select" )
	{
		error[error.length] = "Please select how you heard of our products.";
	}

	if( error.length == 0 )
	{
		document.getElementById( 'error' ).style.visibility = 'hidden';
		document.customer.submit();
	}
	else
	{	
		for( i = 0; i < error.length; i++ )
		{
			html = html + "<li>" + error[i] + "</li>";
		}
		
		document.getElementById( 'error' ).innerHTML = "<ul>" + html + "</ul>";
		document.getElementById( 'error' ).style.visibility = 'visible';	
	}
}

function validate_payment()
{
	var error = new Array();
	var html = '';
	name = document.getElementById( 'payment_name' ).value;
	card = document.getElementById( 'card' ).value;
	card_number = document.getElementById( 'card_number' ).value;
	card_expiration = document.getElementById( 'card_expiration' ).value;
	cvv = document.getElementById( 'cvv' ).value;
	
	if( name.length == 0 )
	{
		error[error.length] = 'Please enter the name on the credit card';
	}

	if( card == 'Please Select' )
	{
		error[error.length] = 'Please select the payment method';
	}

	if( card_number.length != 16 )
	{
		error[error.length] = "You have entered an incorrect credit card number";
	}
	
	if( card_expiration.length != 4 )
	{
		error[error.length] = 'Please enter the expiration date month and year with no dashes. ( MMDD )';
	}
	
	if( cvv.length != 3 )
	{
		error[error.length] = 'Please enter the credit card security code';
	}
	
	if( error.length == 0 )
	{
		document.getElementById( 'error' ).style.visibility = 'hidden';
		document.payment.submit();
	}
	else
	{	
		for( i = 0; i < error.length; i++ )
		{
			html = html + "<li>" + error[i] + "</li>";
		}
		
		document.getElementById( 'error' ).innerHTML = "<ul>" + html + "</ul>";
		document.getElementById( 'error' ).style.visibility = 'visible';	
	}
}