var ie = false;

if(navigator.appName.indexOf("Microsoft") > -1) ie = true;

function showDetail(i)
{
	w = document.documentElement.clientWidth;
	h = document.documentElement.clientHeight;
	
	if(ie)
	{
		document.getElementById('ML_Loading').style.width = w + 'px';
		document.getElementById('ML_Loading').style.height = h + document.documentElement.scrollTop + 'px';
	
		document.getElementById('ImageInfo').style.left = parseInt((w - 640) / 2) + "px";
		document.getElementById('ImageInfo').style.top = parseInt((h - 640) / 2) + document.documentElement.scrollTop + "px";
	}
	else
	{
		document.getElementById('ML_Loading').style.width = w + 'px';
		document.getElementById('ML_Loading').style.height = h + window.pageYOffset + 'px';
	
		document.getElementById('ImageInfo').style.left = parseInt((w - 640) / 2) + "px";
		document.getElementById('ImageInfo').style.top = parseInt((h - 640) / 2) + window.pageYOffset + "px";
	}
	
	show('ML_Loading');
	document.getElementById('imgarea').innerHTML = '<a href="javascript:void(0);" onclick="hide(\'ML_Loading\'); hide(\'ImageInfo\');"><img src="' + i + '" style="border: 1px solid #ff0000;" /></a>';
	show('ImageInfo');
	document.getElementById('ML_Loading').style.height = document.body.clientHeight + 'px';
}

function showDetail2(id)
{
	xmlHttp = GetXmlHttpObject();
	if (xmlHttp == null) { alert ("Your browser does not support AJAX!"); return; }

	var url = "calendar_eventinfo.php?id=" + id;
	xmlHttp.onreadystatechange = function() {
		if(xmlHttp.readyState >= 0 && xmlHttp.readyState <= 3) show('ML_Loading');
		else if(xmlHttp.readyState == 4)
		{
			//hide('ML_Loading');
			document.getElementById('EventInfo').innerHTML = xmlHttp.responseText;
			show('EventInfo');
			//alert(xmlHttp.responseText);
		}
	};
	xmlHttp.open("GET",url,true);
	xmlHttp.send(null);
}

function GetXmlHttpObject()
{
	// Firefox, Opera 8.0+, Safari
	try { xmlHttp=new XMLHttpRequest(); }
	catch (e)
	{
		// Internet Explorer 6.0+
		try { xmlHttp=new ActiveXObject("Msxml2.XMLHTTP"); }
		catch (e)
		{
			//Internet Explorer 5.5+
			try { xmlHttp=new ActiveXObject("Microsoft.XMLHTTP"); }
			catch (e) { alert("Your browser does not support AJAX!"); return false; }
		}
	}
	return xmlHttp;
}

function show(i) { document.getElementById(i).style.display = "block"; }
function hide(i) { document.getElementById(i).style.display = "none"; }
function url(i) { location.href = i; }

function wheelReaction(delta)
{
	w = document.documentElement.clientWidth;
	h = document.documentElement.clientHeight;

	if (delta < 0)	//scroll down
	{

	}
	else			//scroll up
	{
		
	}
	
	document.getElementById('ML_Loading').style.height = document.body.clientHeight + 'px';
}

function wheel(evt)
{
	var delta = 0;

	evt = (evt) ? evt : (window.event) ? window.event : "";

	if (evt.wheelDelta)	/* IE/Opera. */
	{
		delta = evt.wheelDelta/120;

		/** In Opera 9, delta differs in sign as compared to IE. */
		if (window.opera) delta = -delta;
	}
	else if (evt.detail)	/** Mozilla */
	{
		/** In Mozilla, sign of delta is different than in IE. Also, delta is multiple of 3.*/
		delta = -evt.detail/3;
	}

	if (delta) wheelReaction(delta);

	/** Prevent default actions caused by mouse wheel.
	* That might be ugly, but we handle scrolls somehow
	* anyway, so don't bother here..
	*/

	//if (evt.preventDefault) evt.preventDefault();
	
	//evt.returnValue = false;
}

function init()
{
	w = document.documentElement.clientWidth;
	h = document.documentElement.clientHeight;
	
	if(document.getElementById('ML_Loading'))
	{
		document.getElementById('ML_Loading').style.width = w + 'px';
		document.getElementById('ML_Loading').style.height = h + 'px';
	}
	
	if(document.getElementById('ImageInfo'))
	{
		document.getElementById('ImageInfo').style.left = parseInt((w - 640) / 2) + "px";
		document.getElementById('ImageInfo').style.top = parseInt((h - 640) / 2) + "px";
	}
}

if (window.addEventListener) window.addEventListener('DOMMouseScroll', wheel, false);	/** DOMMouseScroll is for mozilla. */
else window.onmousewheel = document.onmousewheel = wheel;	/** IE/Opera. */
