

function popupWin(page) {
	var w = 735;
	var h = 500;

	var x = Math.max(1, (screen.availWidth - w)/2);
	var y = Math.max(1, (screen.availHeight - h)/2);

	
	var win = window.open(page, "", "toolbar=no,location=no,directories=no,status=no,menubar=no,copyhistory=no,scrollbars=yes,left="+x+",top="+y+",width="+w+",height="+h);
	win.focus();
	
	return false;
}


function confirmDel(ProdTitle, qty) {
	if ((isNaN(qty) || qty<1) && !confirm('This will DELETE "' + unescape(ProdTitle) + '" from your basket. Continue?')) return false;
}

function reset_option($id_csv) {
	$id_arr = $id_csv.split(',');
	for($i=0; $i<$id_arr.length; $i++) {
		if(document.getElementById($id_arr[$i])) {
			document.getElementById($id_arr[$i]).options.length = 1; // Clear all entries except first (empty) one
		}
	}
}

function disable_button(id) {
	document.getElementById(id).value = 'please wait ...';
	document.getElementById(id).disabled = true;
	document.getElementById(id).className = 'btn dead';
}

function setOptions(URL) {
	var $ck = new Date().getTime();
	URL += (URL.indexOf('?') > -1)? '&cK='+$ck : '?cK='+$ck;
	
	// Get list entries
	Http.get({
		url: URL,
		callback: fillLists,
		cache: Http.Cache.Get
	});
}

function fillLists(xmlreply) {
	if (xmlreply.status != Http.Status.OK) {
		alert('ERROR: Could not generate list(s). Please try again!');
		return;
	}
	
	if (!xmlreply.responseText) return;
	
	var main_arrays = xmlreply.responseText.split('::');
	
	for (i=0; i<main_arrays.length; i++) {
	
		// Next get all elements in current array
		curr_array = main_arrays[i].split('|');
		curr_id = document.getElementById(curr_array[0]);
		if(!curr_id) continue;

		// Clear all entries except first (empty) one
		curr_id.options.length = 1;
		
		// Loop through array and build options list (NOTE: First entry is Options ID so is skipped here)
		for(j=1; j<curr_array.length; j++) {
			row = curr_array[j].split(';'); // Get current row
			curr_id.options[j] = new Option(unescape(row[1]), row[0]); // Add to options list (text, value)
			if (row[2] != '1') curr_id.options[j].className='inactive'; // Red text if list item not active
		}
		
	}
	
}