var shopping_cart_page="shoppingcart.htm"
var Personal_Details="PersonalDetails.htm"
var Check_Out="checkout.htm"


function add_to_cart(number,n,price,Discountfor2,Discountfor3,Desc)
{
for(var counter=0;counter<database_records.length;counter++)
{
if(database_records[counter].number==number)
{
database_records[counter].quantity=n
database_records[counter].price=price
database_records[counter].Discountfor2=Discountfor2
database_records[counter].Discountfor3=Discountfor3
database_records[counter].description=Desc

var current_quantity=database_records[counter].quantity
var current_price=database_records[counter].price
var current_discount2=database_records[counter].Discountfor2
var current_discount3=database_records[counter].Discountfor3
var current_desc=database_records[counter].description

if(current_quantity==0)
{
update_record_quantity(counter,1,current_price,current_discount2,current_discount3,current_desc)
}
var current_price=database_records[counter].price
if(current_price=='')
{
update_record_quantity(counter,current_quantity,current_price,current_discount2,current_discount3,current_desc)
}
//update_record_quantity(counter,current_quantity,current_price,current_discount2,current_discount3)

}

save_orders()
save_orders1()
save_orders2()
save_orders3()
save_orders4()
//location=shopping_cart_page
}
}


function remove_from_cart(record_index)
{
update_record_quantity(record_index,0)
save_orders()
//save_orders1()

location.reload()
}

function update_record_quantity(record_index,record_quantity,record_price,record_discount2,record_discount3,record_desc)
{
database_records[record_index].quantity=record_quantity
database_records[record_index].price=record_price
database_records[record_index].Discountfor2=record_discount2
database_records[record_index].Discountfor3=record_discount3
database_records[record_index].description=record_desc
if(record_quantity==0)
{
total_ordered--
}
if(record_price=='')
{
total_ordered--
}

}

function recalculate_order()
{
for(var counter=0;counter<document.shopping_cart.length;counter++)
{
if(document.shopping_cart[counter].type=="text")
{
current_quantity=document.shopping_cart[counter].value
var current_index=document.shopping_cart[counter].record_index
update_record_quantity(current_index,current_quantity)
}
save_orders()
//save_orders1()

location.reload()
}
}


