//javascript to handle the display of transactions

// Changes the cursor to an hourglass
function cursor_hand() {
document.body.style.cursor = 'hand';
}

// Returns the cursor to the default pointer
function cursor_clear() {
document.body.style.cursor = 'default';
}

function arrowShow(inID1,inID2) {
	document.getElementById(inID1).style.display = 'block';
    document.getElementById(inID2).style.display = 'none';
}

function darkenButtons(inID, inName){
	document.getElementById('cat_browse1').style.display = 'none';
	document.getElementById('cat_add1').style.display = 'none';
	document.getElementById('cat_item1').style.display = 'none';
	document.getElementById('cat_change1').style.display = 'none';
	document.getElementById(inID+'1').style.display = 'block';
	document.getElementById('cat_browse').style.backgroundColor = "#666666";
	document.getElementById('cat_add').style.backgroundColor = "#666666";
	document.getElementById('cat_item').style.backgroundColor = "#666666";	
	document.getElementById('cat_change').style.backgroundColor = "#666666";
	document.getElementById(inID).style.backgroundColor = "#CCCCCC";
	document.getElementById('cat_title').innerHTML = inName;
}

function createRequestObject(){
	var request_o; //declare the variable to hold the object.
	var browser = navigator.appName; //find the browser name
	if(browser == "Microsoft Internet Explorer"){
		/* Create the object using MSIE's method */
		request_o = new ActiveXObject("Microsoft.XMLHTTP");
	}else{
		/* Create the object using other browser's method */
		request_o = new XMLHttpRequest();
	}
	return request_o; //return the object
}

// Create an instance of the XML HTTP Request object
var http8 = createRequestObject();
var curlim = 0;
var curmax = 0;
var curmode = "new";

function getItems3(cat, limno, ss, limmax, tmode) {
	document.getElementById('item_text').innerHTML = "Loading, Please Wait.....2";
	if (limno != 0) {limno = limno + curlim; curlim = limno;}
	if (limno == 0) {curlim = 0; arrowShow('arrow_left_off', 'arrow_left_on'); }
	else { arrowShow('arrow_left_on', 'arrow_left_off'); }
	if (limmax == 0) {limmax = curmax;} else {curmax = limmax;}
	if (limmax > (limno +5)) {arrowShow('arrow_right_on', 'arrow_right_off'); }
	else { arrowShow('arrow_right_off', 'arrow_right_on'); }
	if (tmode == "") {tmode = curmode;} else {curmode = tmode;}
	var params = "cat="+cat+"&limno="+limno+"&tmode="+tmode+"&ss="+ss;
	// Prepare the XMLHTTP object for a HTTP POST to our validation ASP page
	http8.open('post', 'cat_xml.php', true);
	http8.onreadystatechange = handleTrans;
	// Execute the request
	http8.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
	http8.setRequestHeader("Content-length", params.length);
	http8.setRequestHeader("Connection", "close");
	http8.send(params);
}

function handleTrans(){
	if (http8.responseText != "")
	{ document.getElementById('item_text').innerHTML = http8.responseText;	
	}
}
