// Enews Sign-up Window
function signup() 
{
 var width  = 480;
 var height = 200;
 var left   = (screen.width  - width)/2;
 var top    = (screen.height - height)/2;
 var params = 'width='+width+', height='+height;
 params += ', top='+top+', left='+left;
 params += ', directories=no';
 params += ', location=no';
 params += ', menubar=no';
 params += ', resizable=no';
 params += ', scrollbars=no';
 params += ', status=no';
 params += ', toolbar=no';
 newwin=window.open('forms/enews-signup.php','enews', params);
 if (window.focus) {newwin.focus()}
 return false;
}

// Nutritional Info Pop-up
function view_nutrition(product,option) 
{
 var width  = 870;
 var height = 600;
 var ext = '.gif';
 if(option=='pie'){	
	 width  = 350;
	 height = 890;
	 ext = '.jpg';
 }
 var left   = (screen.width  - width)/2;
 var top    = (screen.height - height)/2;
 var params = 'width='+width+', height='+height;
 params += ', top='+top+', left='+left;
 params += ', directories=no';
 params += ', location=no';
 params += ', menubar=no';
 params += ', resizable=no';
 params += ', scrollbars=1';
 params += ', status=no';
 params += ', toolbar=no';
 nutrition_window=window.open('','nutritional_info', params);
	nutrition_window.document.write('<html><head><title>Nutritional Information</title>');
	//nutrition_window.document.write('<link rel="stylesheet" href="style.css">');
	nutrition_window.document.write('</head><body>');
	nutrition_window.document.write('<p align="center"><img src="/img/nutrition/'+ product + ext +'"></p>');
	nutrition_window.document.write('<p align="center"><a href="javascript:self.close()">Close This Window</a></p>');
	nutrition_window.document.write('</body></html>');
	nutrition_window.document.close();
 if (window.focus) {nutrition_window.focus()}
 	return false;
}

// Profit Calculator
$().ready(function() {
	$("#buttoncalculate a").click(function(){
		var s,i,t,p,totalprofit,totalsold,totalperseller,itemPrice
		itemPrice = 15.0;
		s = $('#sellers').val();
		i = $('#items').val();
		t = s*i
		
		if(t<=44){
			p = itemPrice * .25;
		} else if (t <=99) {
			p = itemPrice * .3
		} else if (t<=149) {
			p = itemPrice * .35
		} else if (t<=349) {
			p = itemPrice * .40
		} else if (t<=749) {
			p = itemPrice * .45
		} else {
			p = itemPrice * .5
		}
		totalsold = s*i
		totalprofit = totalsold*p
		totalperseller = totalprofit/s
		$('#totalprofit').html(totalprofit);
		if(isNaN(totalsold)){
			$('#totalsold').html('0');
		} else {
			$('#totalsold').html(totalsold);
		}
		$('#totalperseller').html(totalperseller);
		$('#totalprofit').formatCurrency();
		$('#totalperseller').formatCurrency();
		return false;
	});
	$("#buttonreset a").click(function(){
		$('#sellers').val('0');
		$('#items').val('10');
		$('#totalprofit').html('$0.00');
		$('#totalsold').html('0');
		$('#totalperseller').html('$0.00');
		});
});
// Home Page Panel Rotator
$().ready(function() {
    var counter = 0,
        divs = $('#panel-one, #panel-two');
    function showDiv () {
        divs.hide() 
        .filter(function (index) { return index == counter % 2; }) 
        .fadeIn('slow');
        counter++;
    }; 
    showDiv();
    setInterval(function () {
        showDiv();
    }, 6 * 1000); 
});