<!--
var book = new Array()
var totalPrice = 0
var totalItems = 0
var books_in_basket = 0 //books.length

function price(){
totalPrice = 0
totalItems = 0
	for(i=0 ; i<books_in_basket ; i++){
		tempAmount = parseInt(book[i].amount)
		tempPrice = parseInt(book[i].price)
		tempTotal = tempAmount * tempPrice	
		totalPrice = totalPrice + tempTotal	
		totalItems += parseInt(book[i].amount)
	}
}

function add_book_to_basket(ISBN,title,amount,price){

if(amount>0){

		if(books_in_basket ==0){//sista
			book[books_in_basket] = new Book(ISBN,title,amount,price)//sista
			books_in_basket += 1
	//		alert(book[0].title + '\n' + book[0].amount + '\n '+ book[0].price + '\n' + book[0].ISBN + '\n')
		}else{
			for(i=0 ; i<books_in_basket ; i++){
				if(book[i].ISBN == ISBN){
	//			alert('adding amount of items')
					amountTemp1 = parseInt(book[i].amount)
					amountTemp2 = parseInt(amount)
					book[i].amount = amountTemp1 + amountTemp2;
					return;
				}else{
					if((i==(books_in_basket-1))&&(book[i].ISBN != ISBN)){
	//					alert('ny bok')
						book[books_in_basket] = new Book(ISBN,title,amount,price)
						books_in_basket += 1
						return;
					}
				}
			}
		}
	}
}
function remove_book_from_basket(object_to_delete){
	for(i=object_to_delete ; i<books_in_basket ; i++){
		book[i] = book[i+1]
	}
	books_in_basket -= 1
}
							  
function Book(ISBN,title,amount,price){
this.title = title
this.amount = amount
this.price = price
this.ISBN = ISBN

}


function openWin(winName,features) {
price()//to get the totalPrice variable
newWindow = window.open('',winName,features);
makeContent()
newWindow.focus()
}
function makeContent(){
content = '<HTML><HEAD><TITLE>Varukorg</TITLE>\n'
content += '<style type=\"text/css\">\n'
content += 'td {  font-family: Arial, Helvetica, sans-serif; font-size: 10pt; text-align: left; padding-left: 5px}\n'
content += 'th {  font-family: Arial, Helvetica, sans-serif; font-size: 10pt; font-weight: bold; text-align: left; background-color: #CCCCCC; padding-left: 5px}\n'
content += '</style>\n'
content += '</HEAD>\n'
content += '<BODY bgcolor=FFFFFF>\n'
content += '<FORM name=basket>\n'

content += '<table width=\"100%\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\">\n'
content += '  <tr> \n'
content += '    <th>Produkt</th>\n'
content += '    <th>Artikelnr</th>\n'
content += '    <th>Antal</th>\n'
content += '    <th>&agrave; pris</th>\n'
content += '    <th>summa</th>\n'
content += '    <th>&nbsp;</th>\n'
content += '  </tr>\n'

for(i=0 ; i<books_in_basket ; i++){
content += '  <tr>\n'
content += '    <td>'+book[i].title+'</td>\n'
content += '    <td>'+book[i].ISBN+'</td>\n'
content += '    <td>\n'
content += '      <input type=\"text\" name=\"v'+book[i].ISBN+'\" value=\"'+book[i].amount+'\" size=\"3\">\n'
content += '    </td>\n'
content += '    <td>'+book[i].price+'</td>\n'
content += '    <td>'+book[i].price*book[i].amount+' SEK</td>\n'
content += '    <td>\n'
content += '      <input type=\"button\" value=\" Ändra \" onClick=\"opener.book[' + i + '].amount = document.forms[0].v'+ book[i].ISBN +'.value,opener.price(),opener.makeContent()\">\n'
content += '      <input type=\"button\" value=\" Ta bort \" onClick=\"opener.remove_book_from_basket(' + i +'),opener.price(),opener.makeContent()\">\n'
content += '    </td>\n'
content += '  </tr>\n'
}
content += '  <tr> \n'
content += '    <th>Summa</th>\n'
content += '    <th>&nbsp;</th>\n'
content += '    <th>&nbsp;</th>\n'
content += '    <th>&nbsp;</th>\n'
content += '    <th>'+ totalPrice+' SEK</th>\n'
content += '    <th>&nbsp;</th>\n'
content += '  </tr>\n'
content += '</table>\n'

content += '</FORM>\n'
content += '</BODY>\n'
content += '</HTML>\n'
content += '<a href=\"javascript:window.close(),opener.makeContentMenu()\">Stäng</A>\n'
newWindow.document.write(content) 
newWindow.document.close()
}

function makeContentMenu(){
	contentM = ''
var order = ''
	for(i=0 ; i<books_in_basket ; i++){
		order += book[i].amount + ' st, ' + book[i].ISBN + ', ' + escape(book[i].title) + ', ' + book[i].price + ' SEK/st+'
	}
	contentM = '<html><head><title>Jure AB - Juridisk N&auml;tbokhandel</title>\n'
	contentM += '<meta http-equiv=\"Content-Type\" content=\"text/html; charset=iso-8859-1\">\n'
	contentM += '<Link rel=\"stylesheet\" type=\"text/css\" href=\"include/jurestyle.css\" title=\"jureStyle\">\n'
	contentM += '</head><body background=\"/media/images/cart_bg.gif\" topmargin=\"0\" leftmargin=\"0\" marginwidth=\"0\" marginheight=\"0\">\n'
	contentM += '<table width=\"643\" cellspacing=\"0\" cellpadding=\"0\" border=\"0\">\n'
	contentM += '<tr><form method=\"post\" name=\"cart\" action=\"order.asp\" target=\"main\">\n'
	contentM += '<td colspan=\"2\">\n'
	contentM += '<img src=\"/media/images/cart_space.gif\" width=\"640\" height=\"5\" border=\"0\"></td></tr><tr><td width=\"160\">\n'
	contentM += '<input type=\"hidden\" name=\"order\" value=\"' + order + '\"><input type=\"hidden\" name=\"summa\" value=\"'+ totalPrice +'\">\n'
	contentM +=	'&nbsp;<input type=\"image\" src=\"/media/images/button_order.gif\" width=\"54\" height=\"15\" border=\"0\" name=\"cart\">\n'
	contentM +=	'&nbsp;<a href=\"javascript:top.menu.openWin(\'basket\',\'location=yes,status=yes,menubar=yes,scrollbars=yes,resizable=yes,width=520,height=400\')\">\n'
	contentM +=	'<img src=\"/media/images/button_cart.gif\" width=\"82\" height=\"15\" border=\"0\"></a></td><td width=\"483\">\n'

	

singular = (totalItems > 1 || totalItems==0)?'böcker':'bok'

	contentM += '  <select style=\"width:240\" id=select1 name=select1> \n'
	contentM += '  <option value=\"\">Du har ' + totalItems + ' ' + singular + ' i din varukorg</option>\n'
	contentM += '  <option value=\"\">-----------------------------------------</option>\n'

	for(i=0 ; i<top.menu.books_in_basket ; i++){

	contentM += '  <option value=\"\">' + book[i].amount + ' st  \"' +book[i].title + '\" ā ' + book[i].price + ' SEK</option>\n'
	}
	contentM += '  <option value=\"\">-----------------------------------------</option>\n'
	contentM += '  <option value=\"\">Totalt___________' + totalPrice + ' SEK</option>\n'
	contentM += '  </select> \n'


contentM +=	'</td></form></tr></table></body></html>\n'

	top.cart.document.write(contentM) 
	top.cart.document.close()
}
// -->