
function openSenda() {
window.open('http://www.ellos.is/verslun/senda/senda.asp?strURL=' + escape(document.URL),'Send','height=400,width=400,resizable=no,location=no,menubar=no,scrollbars=no,status=no,titlebar=yes');
}
            // Indicates whether the user is on
            // the public site or not.
            var onPublic = true;

            function openPopups() {
        
            }
   
        function popup(url,x,y) {
            window.open(url, 'popupWindow', 'directories=no,location=no,menubar=no,resizable=yes,titlebar=yes,toolbar=no,scrollbars=yes,height=' + y + ',width=' + x ).focus();
    }
    
	//  Setja vöru í körfu

function addItem(newItem, newPrice, newQuantity,  newNumber, newOption, newOption2) {
		if (newQuantity >= 1000) {
					rc = alert('Óleyfilegur fjöldi');
				} else {
                if (newQuantity >= 1) {
				window.alert(''+newQuantity+' x '+newItem+' sett í körfu!');						
		                        index = document.cookie.indexOf("TheBasket");
		                        countbegin = (document.cookie.indexOf("=", index) + 1);
		                        countend = document.cookie.indexOf(";", index);
		                        if (countend == -1) {
		                        countend = document.cookie.length;
                        }
		                document.cookie="TheBasket="+document.cookie.substring(countbegin, countend)+"["+newItem+"|"+newPrice+"|"+newNumber+"|"+newOption+"|"+newOption2+"|"+newQuantity+"]";
			}
		}
	}


	function resetShoppingBasket() {
		index = document.cookie.indexOf("TheBasket");
		document.cookie="TheBasket=.";
	}

// showItems() - birtir vörur í töflu
	function showItems() {
		index = document.cookie.indexOf("TheBasket");
		countbegin = (document.cookie.indexOf("=", index) + 1);
        	countend = document.cookie.indexOf(";", index);
        	if (countend == -1) {
            		countend = document.cookie.length;
        	}
		fulllist = document.cookie.substring(countbegin, countend);
		subtotal = 0;
		itemlist = 0;
		for (var i = 0; i <= fulllist.length; i++) {
			if (fulllist.substring(i,i+1) == '[') {
				itemstart = i+1;
				thisitem = 1;
			} else if (fulllist.substring(i,i+1) == ']') {
				itemend = i;
				thequantity = fulllist.substring(itemstart, itemend);
				itemtotal = 0;
				itemtotal = (eval(theprice*thequantity));
				temptotal = itemtotal * 100;
				subtotal = subtotal + itemtotal;
				itemlist=itemlist+1;

			} else if (fulllist.substring(i,i+1) == '|') {
				if (thisitem==1) theitem = fulllist.substring(itemstart, i);
				if (thisitem==2) theprice = fulllist.substring(itemstart, i);
				if (thisitem==3) theoption = fulllist.substring(itemstart, i);
				thisitem++;
				itemstart=i+1;
			}
		}

		document.writeln('</select><FONT SIZE="2" FACE="Verdana, Arial, Helvetica, sans-serif">. <B>'+alterError(subtotal)+'</B></FONT></TD></TR></TABLE>');

	}

	function amendItem(itemno, newquant) {
		newItemList = null;
		itemlist = 0;
		for (var i = 0; i <= fulllist.length; i++) {
			if (fulllist.substring(i,i+1) == '[') {
				thisitem = 1;
				itemstart = i+1;
				fullstart = i+1;
			} else if (fulllist.substring(i,i+1) == ']') {
				itemend = i;
				itemlist=itemlist+1;
				if (itemlist != itemno) {
					newItemList = newItemList+'['+fulllist.substring(fullstart, itemend)+']';
				} else {
					newItemList = newItemList + '['+theitem+'|'+theprice+'|'+theoption+'|'+theoption2+'|'+thenumber+'|'+newquant+']';
				}
			} else if (fulllist.substring(i,i+1) == '|') {
				if (thisitem==1) theitem = fulllist.substring(itemstart, i);
				if (thisitem==2) theprice = fulllist.substring(itemstart, i);
				if (thisitem==3) theoption = fulllist.substring(itemstart, i);
				if (thisitem==4) theoption2 = fulllist.substring(itemstart, i);
				if (thisitem==5) thenumber = fulllist.substring(itemstart, i);
				thisitem++;
				itemstart=i+1;
			}
		}
		index = document.cookie.indexOf("TheBasket");
		document.cookie="TheBasket="+newItemList;
		self.location = "karfa.asp";

	}

	function removeItem(itemno) {
		newItemList = null;
		itemlist = 0;
		for (var i = 0; i <= fulllist.length; i++) {
			if (fulllist.substring(i,i+1) == '[') {
				itemstart = i+1;
			} else if (fulllist.substring(i,i+1) == ']') {
				itemend = i;
				theitem = fulllist.substring(itemstart, itemend);
				itemlist=itemlist+1;
				if (itemlist != itemno) {
					newItemList = newItemList+'['+fulllist.substring(itemstart, itemend)+']';
				}
			}
		}

	}
 
 
 	function clearBasket() {
 		if (confirm('Tæma körfu?')) {
 			index = document.cookie.indexOf("TheBasket");
 			document.cookie="TheBasket=.";
 			self.location = "tom_karfa.asp";
 			top.frames[2].location = "leit.asp";
 		}
	}
