// 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) 
{
 var width  = 870;
 var height = 600;
 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 +'.gif" width="825"></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
		s = $('#sellers').val();
		i = $('#items').val();
		t = s*i
		if(t<=350){
		p = 6.00
		} else if (t>=351 && t<=749) {
		p = 6.75
		} else if (t>=750) {
		p = 7.50
		}
		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');
		});
});

$().ready(function() {
    var counter = 0,
        divs = $('#panel-one, #panel-two');
    function showDiv () {
        divs.hide() // hide all divs
        .filter(function (index) { return index == counter % 2; }) // figure out correct div to show
        .fadeIn('slow'); // and show it
        counter++;
    }; // function to loop through divs and show correct div
    showDiv(); // show first div    
    setInterval(function () {
        showDiv(); // show next div
    }, 6 * 1000); // do this every 10 seconds    
});