function number_format (number, decimals, dec_point, thousands_sep) {
    // http://kevin.vanzonneveld.net
    // +   original by: Jonas Raoni Soares Silva (http://www.jsfromhell.com)
    // +   improved by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
    // +     bugfix by: Michael White (http://crestidg.com)
    // +     bugfix by: Benjamin Lupton
    // +     bugfix by: Allan Jensen (http://www.winternet.no)    
    // *     example 1: number_format(1234.5678, 2, '.', '');
    // *     returns 1: 1234.57     
 
    var i, j, kw, kd, km, neg = "";
 
    // input sanitation & defaults
    if( isNaN(decimals = Math.abs(decimals)) ){
        decimals = 2;
    }
    if( dec_point == undefined ){
        dec_point = ".";
    }
    if( thousands_sep == undefined ){
        thousands_sep = ",";
    }
 
    i = parseInt(number = (+number || 0).toFixed(decimals)) + "";
    if (i.substr(0,1) == "-") {
        number = Math.abs(number);
        neg = "-";
        i = i.substr(1);
    }
    
    if ((j = i.length) > 3 ) {
        j = j % 3;
    } else {
        j = 0;
    }
    
    km = (j ? i.substr(0, j) + thousands_sep : "");
    kw = i.substr(j).replace(/(\d{3})(?=\d)/g, "$1" + thousands_sep);
    //kd = (decimals ? dec_point + Math.abs(number - i).toFixed(decimals).slice(2) : "");
    kd = (decimals ? dec_point + Math.abs(number - i).toFixed(decimals).replace(/-/, 0).slice(2) : "");
    return neg + km + kw + kd;
}

function RecalculatePrice () {
	var form_name = document.getElementById('item_form');
	var item_price = parseFloat (document.getElementById('original_item_price').innerHTML);
	var reg_price = parseFloat (document.getElementById('original_item_regprice').innerHTML);
	var input_tags = form_name.getElementsByTagName('input');
	for (i = 0; i < input_tags.length; i++) {
		if ((input_tags[i].checked == true) && (input_tags[i].value != '')) {
			var tmp_value = input_tags[i].value;
			var check_bracket_1 = tmp_value.indexOf ('(');
			var check_bracket_2 = tmp_value.indexOf (')');
			if ((check_bracket_1 > 0) && (check_bracket_2 > 0)) {
				var tmp_price = tmp_value.substring (check_bracket_1 + 1, check_bracket_2);
				tmp_price = tmp_price.replace ('+', '');
				tmp_price = tmp_price.replace ('$', '');
				tmp_price = parseFloat (tmp_price);
				
				item_price = item_price + tmp_price;
				reg_price = reg_price + tmp_price;
			}
		}
	}

	item_price = number_format (item_price, 2, '.', '');
	reg_price = number_format (reg_price, 2, '.', '');
	
	document.getElementById('item_price').innerHTML = '$' + item_price;
	document.getElementById('reg_price').innerHTML = '$' + reg_price;
}

function enlarge(imsrc, ww, wh) {
ww=ww+25; wh=wh+50;
w1=window.open('','w1','width='+ww+',height='+wh+',status=no,toolbar=no,menubar=no,location=no,resizable=yes,scrollbars=yes');
w1.document.open();
w1.document.write("<html><head><title>Large Image<\/title><META HTTP-EQUIV=\"Pragma\" CONTENT=\"no-cache\"><META HTTP-EQUIV=\"Expires\" CONTENT=\"-1\"><\/head>");
w1.document.write("<body bgcolor='#FFFFFF' text='#000000' leftmargin=2 topmargin=10><p align=center>");
w1.document.write("<img name=theimg src=" + imsrc + "><br>");
w1.document.write("<a href=\"javascript:window.close();\"><font size=1 face=tahoma color=#000000>close window<\/font><\/a><\/body><\/html>");
w1.document.focus();
}

function EmailFriend (id, store, product) {
	window.open ('http://www.kingwebtools.com/blanketsnmore/email_to_friend/email_to_friend.php?id='+id+'&store='+store+'&prod_name='+product, '', 'width=570, height=532');
}
