function openChild(file,window,path) {
	childWindow=open(file,window,'width=500,height=400,resizable=yes,menubar=no,location=no,status=yes,scrollbars=yes');
	childWindow.filepath = path;
	if (childWindow.opener == null) childWindow.opener = self;
}

function updateParent() {
    opener.location.replace('download.php?download_file='+window.filepath);
    self.close();
    return false;
}

function formatCurrency(num) {
    num = isNaN(num) || num === '' || num === null ? 0.00 : num;
    return parseFloat(num).toFixed(2);
}

function onServerDataChange(n){
    var discount_id;
    var price_id;
    var price;
    var amount;
    var discount;

    switch (n) {
        case 1:
            discount_id = $('#function1').val();
            price_id = $('#processors1').val();
            price = arrRental[price_id];
            discount = arrDiscounts[discount_id];
            if (!isNaN(price) && !isNaN(discount)) {
                amount = price - price*discount/100;
                $('#calculated_price1').html(formatCurrency(amount));
            }
            else {
                $('#calculated_price1').html('&nbsp;');
            }
            break;
        case 2:
            discount_id = $('#function2').val();
            price_id = $('#processors2').val();
            price = arrRental[price_id];
            discount = arrDiscounts[discount_id];
            if (!isNaN(price) && !isNaN(discount)) {
                amount = price - price*discount/100;
                $('#calculated_price2').html(formatCurrency(amount));
            }
            else {
                $('#calculated_price2').html('&nbsp;');
            }
    }
}
