var req;

function navigate_from(month,year,apartman_id) {
        var url = "ajax_calendar_from/calendar.php?month="+month+"&year="+year+"&id="+apartman_id;
        if(window.XMLHttpRequest) {
                req = new XMLHttpRequest();
        } else if(window.ActiveXObject) {
                req = new ActiveXObject("Microsoft.XMLHTTP");
        }
        req.open("GET", url, true);
        req.onreadystatechange = callback_from;
        req.send(null);
}

function callback_from() {        
        obj = document.getElementById("calendar_from");
        setFade_from(0);
        
		if(req.readyState == 4) {
                if(req.status == 200) {
                        response = req.responseText;
                        obj.innerHTML = response;
                        fade_from(0);
                } else {
                        alert("There was a problem retrieving the data:\n" + req.statusText);
                }
        }
}

function fade_from(amt) {
	if(amt <= 100) {
		setFade_from(amt);
		amt += 10;
		setTimeout("fade_from("+amt+")", 5);
    }
}

function setFade_from(amt) {
	obj = document.getElementById("calendar_from");
	
	amt = (amt == 100)?99.999:amt;
  
	// IE
	obj.style.filter = "alpha(opacity:"+amt+")";
  
	// Safari<1.2, Konqueror
	obj.style.KHTMLOpacity = amt/100;
  
	// Mozilla and Firefox
	obj.style.MozOpacity = amt/100;
  
	// Safari 1.2, newer Firefox and Mozilla, CSS3
	obj.style.opacity = amt/100;
}



// part for price

var req_price;

function navigate_price(id) {
	    navigate_from("","",id);
		
        var url = "ajax_calendar_from/getdata.php?id="+id;
        if(window.XMLHttpRequest) {
                req_price = new XMLHttpRequest();
        } else if(window.ActiveXObject) {
                req_price = new ActiveXObject("Microsoft.XMLHTTP");
        }
		
        req_price.open("GET", url, true);
        req_price.onreadystatechange = callback_price;
        req_price.send(null);
}

function callback_price() {        
        obj = document.getElementById("dayprice");
        setFade_price(0);
        
		if(req_price.readyState == 4) {
                if(req_price.status == 200) {
                        response = req_price.responseText;
                        obj.innerHTML = response;
                        fade_price(0);
                } else {
                        alert("There was a problem retrieving the data:\n" + req_price.statusText);
                }
        }
}

function fade_price(amt) {
	if(amt <= 100) {
		setFade_price(amt);
		amt += 10;
		setTimeout("fade_price("+amt+")", 5);
    }
}

function setFade_price(amt) {
	obj = document.getElementById("dayprice");
	
	amt = (amt == 100)?99.999:amt;
  
	// IE
	obj.style.filter = "alpha(opacity:"+amt+")";
  
	// Safari<1.2, Konqueror
	obj.style.KHTMLOpacity = amt/100;
  
	// Mozilla and Firefox
	obj.style.MozOpacity = amt/100;
  
	// Safari 1.2, newer Firefox and Mozilla, CSS3
	obj.style.opacity = amt/100;
}
