/* ==========================================================
Steel Site Javascript

This file deals with basket page script

author:    Matheu Niblett
website:   http://www.parkersteel.co.uk
============================================================ */

// Global variables. 
var origQty;

/* Show or hide basket line detail */ 
function showHideDetail( x ) {
    window.location = '/Basket?showDtl=' + x;
}


/* Validate basket shotblasting and painting options. */
function validBasketProcess( sht, pnt, pck ) {
	
	
	var shot = false;
	var sel;
	var paint = "   ";
	var sel2;
	var pack = false;
	
	if (document.getElementById(sht)) {
		shot  = document.getElementById(sht).checked;
	}
	if (sel   = document.getElementById(pnt)) {
		paint = sel.options[sel.selectedIndex].value;
	}
	if (sel2  = document.getElementById(pck)) {
		pack  = sel2.options[sel2.selectedIndex].value;
	}
	
    if ( shot == false && paint != "   " ) {
        alert("You cannot paint without shotblasting"); 
        sel.selectedIndex = 0;
    }
    disableProceed();
}


/* Disable proceed with order button */
function disableProceed() {

	$('button#procOrd').attr('disabled', 'disabled');
	$('div.procOrd').addClass('disabled');

	/*
	if(document.getElementById('procOrd')) {
		document.getElementById('procOrd').disabled = true;
	}
	*/
}


/* Check basket numeric entry */ 
function checkBasketNumeric(id) {
   var val = document.getElementById(id).value;
   if(isNaN(val)) {
	   alert("Please enter only numeric values");
	   document.getElementById(id).value = "";
	   document.getElementById(id).focus();
   } else {
	   if( val != origVal ) {
	       disableProceed();   
	   }
   }
}


/* Save basket line quantity */
function saveQuantity(id) {
	origVal = document.getElementById(id).value;
}

