function calcPrice(oForm,width,addons){
   var price = 0;
   var subtotal = 0;
   var subtotal1 = 0;
       if(oForm[width]){
           var num = oForm[width].length;
               if(num > 0){
                 for(var i=0; i<num; i++){
                    if(oForm[width][i].checked){
                       var value = (oForm[width][i].value).split('_');
                       subtotal = subtotal+document.getElementById('square_feet').value*(parseFloat(value[1]));
                    }
                 }
               }
       }
       if(oForm[addons]){
           var num = oForm[addons].length;
               if(num > 0){
                 for(var i=0; i<num; i++){
                    if(oForm[addons][i].checked){
                        var value = (oForm[addons][i].value).split('_');
                    	subtotal1 = subtotal1+document.getElementById('square_feet').value*(parseFloat(value[1]));
                    }
                 }
               }
       }
    var delivery = parseFloat(150 + 0.60*document.getElementById('square_feet').value);
    price = subtotal + subtotal1 + delivery +'$';   
    document.getElementById('total_price').innerHTML = price;
}

function changeDisabled(){
	var square = document.getElementById('square_feet').value;

	var f = document.forms[0];
	if(isNaN(square) == false){
		for(var i=0; i<f.elements.length;i++){
			if(f.elements[i].disabled){
				f.elements[i].disabled=false; 
			}
		}
		changeWidthFirst();
		changeWidth();
		changeRandomWidth();
	}else{
		for(var i=1; i<f.elements.length;i++){
				f.elements[i].disabled=true; 
		}
		alert("Square feet must be a number!!!");
	}
}

function changeWidth(){
	var random = document.getElementById('random_width');
	var width  = document.getElementById('width');
	
    var len_widt = document.instant_quote.get_width.length;
    var len_random_wid = document.instant_quote.get_random_width.length;
	
	
	if(width.checked == true){
		if(len_random_wid > 0){
			for(var i=0; i<len_random_wid; i++){
				document.instant_quote.get_random_width[i].checked = false;
				document.instant_quote.get_random_width[i].disabled = true;
				random.checked = false;
			}
		}else{
			document.instant_quote.get_random_width.checked = false;
			document.instant_quote.get_random_width.disabled = true;
			random.checked = false;
		}
		
		if(len_widt > 0){
			for(var i=0; i<len_widt; i++){
				document.instant_quote.get_width[i].disabled = false;
			}
		}else{
			document.instant_quote.get_width.disabled = false;
		}
	}
}

function changeRandomWidth(){
	var random = document.getElementById('random_width');
	var width  = document.getElementById('width');
	
    var len_widt = document.instant_quote.get_width.length;
    var len_random_wid = document.instant_quote.get_random_width.length;
    
    if(random.checked == true){
    	if(len_widt > 0){
    		for(var i=0; i<len_widt; i++){
	    		document.instant_quote.get_width[i].checked = false;
	    		document.instant_quote.get_width[i].disabled = true;
	    		width.checked = false;
	    	}
    	}else{
    		document.instant_quote.get_width.checked = false;
    		document.instant_quote.get_width.disabled = true;
    		width.checked = false;
    	}
    	if(len_random_wid > 0){
    		for(var i=0; i<len_random_wid; i++){
    			document.instant_quote.get_random_width[i].disabled = false;
    		}
    	}else{
    		document.instant_quote.get_random_width.disabled = false;
    	}
	}
}

function changeWidthFirst(){
	var random = document.getElementById('random_width');
	var width  = document.getElementById('width');
	
    var len_widt = document.instant_quote.get_width.length;
    var len_random_wid = document.instant_quote.get_random_width.length;

	if((random.checked == false) && (width.checked == false)){
		if(len_widt > 0){
			for(var i=0; i<len_widt; i++){
				document.instant_quote.get_width[i].disabled = true;
			}
		}else{
			document.instant_quote.get_width.disabled = true;
		}
		if(len_random_wid > 0){
			for(var i=0; i<len_random_wid; i++){
				document.instant_quote.get_random_width[i].disabled = true;
			}
		}else{
			document.instant_quote.get_random_width.disabled = true;
		}	
	}
}
