var Slider;
var Subscriptions;
window.addEvent('domready', function(){
	if($('recurringProduct'))
	{
		Slider = new Slider({
			element	:	$('recurringProduct'),
			content	:	$('transparentRecurringContainer'),
			scrollEle:	$('transparentRecurringContainer'),
			trigger	:	$('notification_toggle'),
			height	:	260,
			duration:	500,
			CFX		:	Fx.Transitions.Sine.easeIn
		});
	}
	if($('subscriptionProduct'))
	{
		Subscriptions = new Slider({
			element	:	$('subscriptionProduct'),
			content	:	$('transparentSubscriptionContainer'),
			scrollEle:	$('transparentSubscriptionContainer'),
			trigger	:	$('subscriptionToggle'),
			height	:	260,
			duration:	500,
			CFX		:	Fx.Transitions.Sine.easeIn
		});
	}
});

function checkForTOS()
{
	var product_id = $('product_id').value;
	var company_id = $('company_id').value;
	var quantity = $('quantity').options[$('quantity').selectedIndex].value;
	var frequency = $('frequency').options[$('frequency').selectedIndex].value;

	if ($('acceptTOS').checked == false)
	{
		alert ('You must read and accept the terms of service\nbefore setting up an automatic order.');
		//$('acceptTOSError').style.display=''; //shows TOS error
		//new Fx.Scroll(window).toElement('reorderProduct');
	}
	else
	{
		window.location='/login.html?page=automaticOrder.html&product_id='+product_id+'&company_id='+company_id+'&quantity='+quantity+'&frequency='+frequency;

		/*new Request({
			url: href+'p_include/ajax_func.html',
			method: 'post',
			evalScripts: true,
			onComplete: function(ret) {
				$$('.largeView')[0].innerHTML = ret;
				window.scrollTo(0,0);
			}
		}).send('func=recurring_checkout&product_id='+product_id+'&company_id='+company_id+'&quantity='+quantity+'&frequency='+frequency);*/
	}
}
function addProductToFavorites(customer_id,product_id,isChecked)
{
	if(!isNaN(product_id) && !isNaN(customer_id) && !isNaN(isChecked))
	{
		new Request({
			url:'/p_include/ajax_func.html',
			method:'post',
			onComplete:function(){
				showPopUp(this.response.text);
			}
		}).send('func=addProductToFavorites&customer_id='+customer_id+'&product_id='+product_id+'&isChecked='+isChecked);
	}
	else{
		showPopUp('Oops. We encountered a problem adding this product to your favorites.');
	}
}

function updatePrice(unit_price)
{
	var qty = $('recurringQty').value;
	$('recurringCost').set('html',(qty*1*unit_price*1).toFixed(2));
}
function showPriceMatching()
{
	var abbrev;
	var company_name;
	if(location.href.match('apothica'))
	{
		abbrev = 'ap';
		company_name = 'Apothica'
	}
	else if(location.href.match('skinbotanica'))
	{
		abbrev = 'sb';
		company_name = 'Skinbotanica';
	}
	else
	{
		abbrev = 'sk';
		company_name = 'SkinCareRx';
	}
	var html = '<div class="lowestPriceShadow"></div><div class="lowestPriceContainer">'+
	    '<div class="lowestPrice">'+
	        '<p style="margin: 0pt; text-align: right;"><a href="javascript:closePopUp();">CLOSE WINDOW</a></p>'+
	        '<p class="boldAndGray">'+company_name+' offers the highest standard in customer service.</p>'+
	        '<p><span class="boldAndGreen">guaranteed</span> <span class="boldAndGray">lowest price</span></p>'+
	        '<p class="baseText">'+company_name+' promises the lowest prices online. In fact, we are so confident in our prices, we offer a <strong>115% Price, Coupon & Cash Back Matching guarantee</strong> to ensure the most positive shopping experience with us.</p>'+
	        '<p class="postBaseTextLink"><a href="http://'+company_name+'.com/price-matching.html">CLICK HERE</a> for our Guaranteed Lowest Price Page</p>'+
	        '<p><span class="boldAndGreen">60-day</span> <span class="boldAndGray">satisfaction guarantee</span></p>'+
	        '<p class="baseText">Although we are very confident in the efficacy of the products we recommend we also recognize that everyone has unique needs and tolerances.  In lieu of these things, we wanted to offer an <strong style="font-style:italic;">industry-best</strong> 60 day return policy on all the products we carry.  We hope this will give you the confidence to try new products as well as choose us for all your beauty needs in the future.</p>'+
	        '<p class="postBaseTextLink"><a href="http://'+company_name+'.com/returnpolicy.html">CLICK HERE</a> for our Return Policy Page</p>'+
	        '<p class="imageContainer"><img border="0" src="/images/'+abbrev+'-logo-bigger.gif"/></p>'+
	   ' </div>'+
	'</div>';
	showPopUp(html,'','','',200);
}

function showPriceMatchingMinusGuarentee()
{
	var abbrev;
	var company_name;
	if(location.href.match('apothica'))
	{
		abbrev = 'ap';
		company_name = 'Apothica'
	}
	else if(location.href.match('skinbotanica'))
	{
		abbrev = 'sb';
		company_name = 'Skinbotanica';
	}
	else if(location.href.match('personalmicroderm'))
	{
		abbrev = 'pmd';
		company_name = 'PersonalMicroderm';
	}
	else
	{
		abbrev = 'sk';
		company_name = 'SkinCareRx';
	}
	var html = '<div class="lowestPriceShadow"></div><div class="lowestPriceContainer">'+
	    '<div class="lowestPrice">'+
	        '<p style="margin: 0pt; text-align: right;"><a href="javascript:closePopUp();">CLOSE WINDOW</a></p>'+
	        '<p class="boldAndGray">'+company_name+' offers the highest standard in customer service.</p>'+
	        '<p><span class="boldAndGreen">guaranteed</span> <span class="boldAndGray">lowest price</span></p>'+
	        '<p class="baseText">'+company_name+' promises the lowest prices online. In fact, we are so confident in our prices, we offer a <strong>115% Price, Coupon & Cash Back Matching guarantee</strong> to ensure the most positive shopping experience with us.</p>'+
	        '<p class="postBaseTextLink"><a href="http://'+company_name+'.com/price-matching.html">CLICK HERE</a> for our Guaranteed Lowest Price Page</p>'+
	   ' </div>'+
	'</div>';
	showPopUp(html,'','','',200);
}