var enableCache = false;
var param_products_id;
var param_disk_surface_id, param_add_ons_id, param_poly_wrap_id;

function disc_type(products_id) {
agent.call('cdquote.php','disc_type','disc_type',products_id);
waiting();
setTimeout("agent.call('cdquote.php','case_option','case_option')",100);
setTimeout("agent.call('cdquote.php','insert_option','insert_option')",100);
setTimeout("agent.call('cdquote.php','misc_option','misc_option')",200);
setTimeout("agent.call('cdquote.php','calculate_price','product_price')",300);
}

function case_option_change(products_id) {
param_products_id = products_id;
agent.call('cdquote.php','check_disk_type_selection','case_option_confirm');
}

function case_option_confirm(str){
if(str > 0) {
	case_option(param_products_id);
	} else {
	alert('Please select "DISC TYPE"');
	}
}

function case_option(products_id) {
agent.call('cdquote.php','case_option','case_option',products_id);
waiting();
setTimeout("agent.call('cdquote.php','insert_option','insert_option')",100);
setTimeout("agent.call('cdquote.php','calculate_price','product_price')",100);
}

function insert_option_change(products_id) {
param_products_id = products_id;
agent.call('cdquote.php','check_case_option_selection','insert_option_confirm');
}

function insert_option_confirm(str) {
if(str > 0) {
        insert_option(param_products_id);
        } else {
        alert('Please select "CASE OPTION"');
        }
}

function insert_option(products_id) {
agent.call('cdquote.php','insert_option','insert_option',products_id);
waiting();
setTimeout("agent.call('cdquote.php','calculate_price','product_price')",100);
}

function misc_option_change(disk_surface_id, add_ons_id, poly_wrap_id) {
param_disk_surface_id = disk_surface_id;
param_add_ons_id = add_ons_id;
param_poly_wrap_id = poly_wrap_id;
agent.call('cdquote.php','check_disk_type_selection','misc_option_confirm');
}

function misc_option_confirm(str) {
if(str > 0) {
	misc_option(param_disk_surface_id, param_add_ons_id, param_poly_wrap_id);
	} else {
	alert('Please select "DISC TYPE"');
	}
}

function misc_option(disk_surface_id, add_ons_id, poly_wrap_id) {
agent.call('cdquote.php','misc_option','misc_option',disk_surface_id,add_ons_id,poly_wrap_id);
waiting();
setTimeout("agent.call('cdquote.php','calculate_price','product_price')",100);
}

function change_price() {
var time = document.cdquote.time.value;
var quantity = document.cdquote.quantity.value;
agent.call('cdquote.php','change_price','change_price_confirm',time, quantity);
}

function change_price_confirm(str) {
waiting();
calculate_price();
}

function calculate_price() {
agent.call('cdquote.php','calculate_price','product_price');
}

function upload_artwork() {
window.open ("upload_artwork.php", "mywindow","menubar=0,resizable=0,width=300,height=250");
}

function checkout() {
agent.call('cdquote.php','checkout','checkout_confirm');
}

function checkout_confirm(str) {
if(str == 0) {
	var answer = confirm("You have not yet uploaded artwork."+"\n\n"+"If you wish to do so now then please click Cancel followed by the Upload Artwork button."+"\n\n"+"If you would like to continue and send the artwork later then please click OK.");	


	if(answer) {
		window.location = 'checkout_shipping.php';
		} else {
		
		}
	} else {
	window.location = str;
	}
}

function waiting() {
if(document.getElementById('product_price')) {
	document.getElementById('product_price').innerHTML = '<center><img src="/images/loading.gif"></center><br><hr>';
	}
}


