// JavaScript Document

function fullscreen(year,month){
window.open('calendarfull.php?y='+year+'&m='+month,'','fullscreen=yes,top=0,left=0,menubar=no,toolbar=no,location=no,directories=no,scrollbars=yes,status=yes,resizable=yes');
void(0);
}

var lastElem = '';

function toggleactive(elem){
	//elem.style.display='none';
	
}


function aloaderToggle(aswitch){
	if (aswitch=='on'){
		document.getElementById('aloader').style.display='block';
	}else{
		document.getElementById('aloader').style.display='none';
	}
}

function event_preview( p_year , p_month , p_day , p_id )
{
	window.location="#preview";
	window.location="#y="+ p_year + "&m=" + p_month+ "&d=" + p_day + "&id=" + p_id;
}


function acal(functionId,year,month,day,elem,id){
var ajaxRequest;  // The variable that makes Ajax possible!
	
	try{
		// Opera 8.0+, Firefox, Safari
		ajaxRequest = new XMLHttpRequest();
	} catch (e){
		// Internet Explorer Browsers
		try{
			ajaxRequest = new ActiveXObject("Msxml2.XMLHTTP");
		} catch (e) {
			try{
				ajaxRequest = new ActiveXObject("Microsoft.XMLHTTP");
			} catch (e){
				// Something went wrong
				alert("Your browser broke!");
				return false;
			}
		}
	}

toggleactive(elem);


if (functionId == 'load'){
	ajaxRequest.onreadystatechange = function(){
		if(ajaxRequest.readyState == 4){
			document.getElementById('calendar').innerHTML = ajaxRequest.responseText;
			setupLabels();
			aloaderToggle('off');
			window.location="#y="+ year + "&m=" + month;
		}
	}
	aloaderToggle('on');
	ajaxRequest.open("GET", "includes/ajaxcalendar.php?y="+ year + "&m=" + month + "&ajax=1" , true);
	ajaxRequest.send(null);
}

if (functionId == 'preview'){
	ajaxRequest.onreadystatechange = function(){
		if(ajaxRequest.readyState == 4){
			document.getElementById('preview').innerHTML = ajaxRequest.responseText;
			aloaderToggle('off');
			if(day != '' || id != ''){
				new SmoothScroll({ duration:700 }, window); 
				var preview_scroll = new Fx.Scroll(window, { wait: false, duration: 500, transition: Fx.Transitions.Quad.easeInOut });  
				preview_scroll.toElement('preview');
				setTimeout("event_preview('"+ year + "','" + month+ "','" + day + "','" + id + "');",600);
			}
		}
	}
	aloaderToggle('on');
	if(id == '' || id == null){
		ajaxRequest.open("GET", "includes/ajaxpreview.php?y="+ year + "&m=" + month + "&d=" + day + "&ajax=1" , true);
	}else{
		ajaxRequest.open("GET", "includes/ajaxpreview.php?y="+ year + "&m=" + month + "&id="+ id +"&ajax=1" , true);
	}
	ajaxRequest.send(null);
}


}