// JavaScript Document
$(document).ready(function() {
// toggles the box on clicking the link  
$('a#droppaymenttoggle').click(function() {
$('#droppayment').slideToggle(500);
return false;
});
// toggles the box on clicking the link 
$('a#dropebidaccounttoggle').click(function() {
$('#dropaccount').slideToggle(500);
return false;
});
// toggles the box on clicking the link 		
$('a#advanceddrop').click(function() {
$('#onetest').slideToggle(500);
return false;
});
// toggles the box on clicking the link 		
$('a#instructme').click(function() {
$('#instruct').slideToggle(500);
return false;
});
});
function Calculate() 
{
// start var
var StartPrice = parseFloat(document.getElementById('startprice').value);

var EbidAccountType = document.getElementById('ebidaccounttype').value;

// ebid account vars
var EbidAccountSeller = document.getElementById('ebidaccountseller').value;
var EbidAccountSellerPlusGallery = document.getElementById('ebidaccountsellerplusgallery').value;
var EbidAccountSellerPlusFree = document.getElementById('ebidaccountsellerplusfree').value;
var EbidAccountCustom1 = document.getElementById('ebidaccountcustom1').value;

var PaymentProcessor = document.getElementById('paymentprocessor').value;

var PayPal1 = document.getElementById('paypal1').value;
var PayPal2 = parseFloat(document.getElementById('paypal2').value);
var GoogleCheckout1 = document.getElementById('googlecheckout1').value;
var GoogleCheckout2 = parseFloat(document.getElementById('googlecheckout2').value);
var Custom1 = document.getElementById('custom1').value;
var Custom2 = parseFloat(document.getElementById('custom2').value);

var NumberOfItems = document.getElementById('numberofitems').value;

//shipping
var ShippingCost = parseFloat(document.getElementById('shipping').value);

var OriginalItemCost = parseFloat(document.getElementById('originalitemcost').value);

var UP1 = parseFloat(document.getElementById('up1').value);
var UP2 = parseFloat(document.getElementById('up2').value);
var UP3 = parseFloat(document.getElementById('up3').value);
var UP4 = parseFloat(document.getElementById('up4').value);
var UP5 = parseFloat(document.getElementById('up5').value);

var TotalEbidFees = document.getElementById('totalebidfees').value;

var TotalPaymentFees = document.getElementById('totalpaymentfees').value;

var TotalProfit = document.getElementById('totalprofit').value;


var Blank1 = "0"; //%
var Blank2 = parseFloat("0.00");

//Check what ebid account was selected
//none
 if (document.getElementById('ebidaccounttype').options[0].selected) {
var EbidAccountType1  = Blank1;}
//seller
 else if (document.getElementById('ebidaccounttype').options[1].selected) {
var EbidAccountType1 = EbidAccountSeller;} 
//sell+gall
 else if (document.getElementById('ebidaccounttype').options[2].selected) {
var EbidAccountType1 = EbidAccountSellerPlusGallery;} 
//sell+free
 else if (document.getElementById('ebidaccounttype').options[3].selected) {
var EbidAccountType1 = EbidAccountSellerPlusFree;} 
//blank
 else if (document.getElementById('ebidaccounttype').options[4].selected) {
var EbidAccountType1  = Blank1;}
//custom
 else if (document.getElementById('ebidaccounttype').options[5].selected) {
var EbidAccountType1 = EbidAccountCustom1;} 


//Get price and calc ebid fee then post to ebid fees
var EbidAccountType2 = EbidAccountType1 / 100;
var EbidAccountType3 = EbidAccountType2 * StartPrice;

// check and add to ebid fees any listingupgrades selected
if (document.getElementById('up1').checked) {
var BoldExtra = UP1;}
else {var BoldExtra = Blank2;}

if (document.getElementById('up2').checked) {
var HighLightExtra = UP2;}
else {var HighLightExtra = Blank2;}

if (document.getElementById('up3').checked) {
var SubtitleExtra = UP3;}
else {var SubtitleExtra = Blank2;}

if (document.getElementById('up4').checked) {
var PictureExtra = UP4;}
else {var PictureExtra = Blank2;}

if (document.getElementById('up5').checked) {
var CategoryExtra = UP5;} 
else {var CategoryExtra = Blank2;}

var EbidAccountType4 = EbidAccountType3 + CategoryExtra + PictureExtra + SubtitleExtra + HighLightExtra + BoldExtra;
document.getElementById('totalebidfees').value = EbidAccountType4.toFixed(2);

//Check what payment type was selected
//none
 if (document.getElementById('paymentprocessor').options[0].selected) {
var PayMent1 = Blank1;
var AddEx = Blank2;}
//paypal
 else if (document.getElementById('paymentprocessor').options[1].selected) {
var PayMent1 = PayPal1;
var AddEx = PayPal2;} 
//google
 else if (document.getElementById('paymentprocessor').options[2].selected) {
var PayMent1 = GoogleCheckout1;
var AddEx = GoogleCheckout2;} 
//blank
 else if (document.getElementById('paymentprocessor').options[3].selected) {
var PayMent1 = Blank1;
var AddEx = Blank2;}
//custom
 else if (document.getElementById('paymentprocessor').options[4].selected) {
var PayMent1 = Custom1;
var AddEx = Custom2;}  



var StartPriceAndShipping = StartPrice + ShippingCost;
//Get price and calc paypal google fees etc then post to total payment fees
var PayMent2 = PayMent1 / 100;
var PayMent3 = PayMent2 * StartPriceAndShipping;
var PayMent4 = PayMent3 + AddEx;

document.getElementById('totalpaymentfees').value = PayMent4.toFixed(2);

var Total1 = StartPriceAndShipping - EbidAccountType4;
var Total2 = Total1 - PayMent4;
var Total3 = Total2 - OriginalItemCost;
var Total4 = Total3 - ShippingCost;
document.getElementById('totalprofit').value = Total4.toFixed(2);


// read total ebid fee box and times by item number and post back
var EbidFeeOne = document.getElementById('totalebidfees').value;
var EbidFeeTwo = NumberOfItems * EbidFeeOne;
document.getElementById('totalebidfees').value = EbidFeeTwo.toFixed(2);

// read total pay fee box and times by item number and post back
var PayFeeOne = document.getElementById('totalpaymentfees').value;
var PayFeeTwo = NumberOfItems * PayFeeOne;
document.getElementById('totalpaymentfees').value = PayFeeTwo.toFixed(2);

// read total fee box and times by item number and post back
var TotFeeOne = document.getElementById('totalprofit').value;
var TotFeeTwo = NumberOfItems * TotFeeOne;
document.getElementById('totalprofit').value = TotFeeTwo.toFixed(2);

}