// JavaScript Document
var req;

function fourmonths(month, year, itemCode, printnum, showkey, cols) {
        var url = '/fourmonths.php?id=' + itemCode + '&monthID=' + month + '&yearID='+ year + '&numprint=' + printnum + '&showkey=' + showkey + '&cols=' + cols;
        if(window.XMLHttpRequest) {
                req = new XMLHttpRequest();
        } else if(window.ActiveXObject) {
                req = new ActiveXObject("Microsoft.XMLHTTP");
        }
        req.open("GET", url, true);
        req.onreadystatechange = callback;
        req.send(null);
}

function callback() {        
        var obj = document.getElementById("mydivcell");
        setFade(0);
		if(req.readyState == 4) {
                if(req.status == 200) {
                        response = req.responseText;
                        obj.innerHTML = response;
                        fade(0);
                } else {
                        alert("There was a problem retrieving the data:\n" + req.statusText);
                }
        }
}

function fade(amt) {
	if(amt <= 100) {
		setFade(amt);
		amt += 10;
		setTimeout("fade("+amt+")", 5);
    }
}

function setFade(amt) {
	var obj = getObject("mydivcell");
	amt = (amt == 100)?99.999:amt;
	obj.style.filter = "alpha(opacity:"+amt+")";
	obj.style.KHTMLOpacity = amt/100;
	obj.style.MozOpacity = amt/100;
	obj.style.opacity = amt/100;
}

function getObject(obj) {
	var o;
	if(document.getElementById) o = document.getElementById(obj);
	else if(document.all) o = document.all.obj;	
	return o;	
}


function createRequestObject(){
	var request_;
	var browser = navigator.appName;
	if(browser == "Microsoft Internet Explorer"){
		request_ = new ActiveXObject("Microsoft.XMLHTTP");
	}else{
		request_ = new XMLHttpRequest();
	}
	return request_;
}

var http = createRequestObject();


function getInfo(month, year, itemCode){
	http.open('get', '/data.php?id=' + itemCode + '&monthID=' + month + '&yearID='+year);
	http.onreadystatechange = handleInfo;
	http.send(null);
}

function fourmonths_old(month, year, itemCode, printnum, showkey){
	http.open('get', '/fourmonths.php?id=' + itemCode + '&monthID=' + month + '&yearID='+ year + '&numprint=' + printnum + '&showkey=' + showkey);
	http.onreadystatechange = handleInfo;
	http.send(null);
}


function handleInfo(){
	if(http.readyState == 4){
		var response = http.responseText;
		document.getElementById('mydivcell').innerHTML = response;
	}
}
