function getCommentList(div, option)
{
	var xmlHttp;
	try
	{ // Firefox, Opera 8.0+, Safari
		xmlHttp=new XMLHttpRequest();
	}
	catch (e)
	{ // Internet Explorer
		try
		{ xmlHttp=new ActiveXObject("Msxml2.XMLHTTP"); }
		catch (e)
		{
			try
			{ xmlHttp=new ActiveXObject("Microsoft.XMLHTTP"); }
			catch (e)
			{ alert("Your browser does not support AJAX!"); return false; }
		}
	}
	
	xmlHttp.onreadystatechange=function() {
		if(xmlHttp.readyState==4)
		{
			document.getElementById(div).innerHTML = xmlHttp.responseText;
		}
	}
	xmlHttp.open("GET", "daomahalai/getCommentList.php?option="+option, true);
	//document.getElementById(div).innerHTML = "<table width='100%' bgcolor='#FFFFFF'><tr><td align='center'><img src='images/loader.gif'></td></tr></table>";
	xmlHttp.send(null);
}


var http_request = false;
function makePOSTRequest(url, parameters)
{
	http_request = false;
	if (window.XMLHttpRequest) { // Mozilla, Safari,...
		http_request = new XMLHttpRequest();
		if (http_request.overrideMimeType) {
			// set type accordingly to anticipated content type
            //http_request.overrideMimeType('text/xml');
            http_request.overrideMimeType('text/html');
		}
	}else if (window.ActiveXObject) { // IE
		try {
			http_request = new ActiveXObject("Msxml2.XMLHTTP");
		} catch (e) {
			try {
				http_request = new ActiveXObject("Microsoft.XMLHTTP");
			} catch (e) {}
		}
	}
	if (!http_request) {
		alert('Cannot create XMLHTTP instance');
		return false;
	}
	
	http_request.onreadystatechange = alertContents;
    http_request.open('POST', url, true);
    http_request.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
    http_request.setRequestHeader("Content-length", parameters.length);
    http_request.setRequestHeader("Connection", "close");
    http_request.send(parameters);
}

function alertContents()
{
	if (http_request.readyState == 4) {
		if (http_request.status == 200) {
			//alert(http_request.responseText);
            result = http_request.responseText;
            document.getElementById('myspan').innerHTML = result;
		} else {
			alert('There was a problem with the request.');
		}
	}
}
   
function PostComment(obj)
{
	var poststr = "mytextarea1=" + encodeURI( document.getElementById("mytextarea1").value ) +
						"&mytextarea2=" + encodeURI( document.getElementById("mytextarea2").value );
	makePOSTRequest('post.php', poststr);
}

function getImageData(image_file, DivID) {
	
	//------------------------------------------------------
	var xmlHttp = null;
	try { // Firefox, Opera 8.0+, Safari
		xmlHttp=new XMLHttpRequest();
	}
	catch (e) { // Internet Explorer
		try {
			xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
		}
		catch (e) {
			xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
		}
	}	
	if (xmlHttp==null) {
		alert ("Your browser does not support AJAX!");
		return;
	}
	//------------------------------------------------------	
	document.getElementById('waitMessage').style.display='block';	
	document.getElementById('displayImg').style.display='none';	
	//------------------------------------------------------
	var url="service/getImageGallery.php?"+image_file;
	xmlHttp.onreadystatechange = function() {
		if (xmlHttp.readyState==4) {
			//document.getElementById(DivID).innerHTML=xmlHttp.responseText;
			showPreview(xmlHttp.responseText, DivID);
		}
	};
	//------------------------------------------------------
	xmlHttp.open("GET",url,true);
	xmlHttp.send(null);
	//------------------------------------------------------
}

function showPreview(imagePath, DivID)
{
	var img = document.getElementById('displayImg');	
	img.style.dispaly = "none";
	img.onload = function() { 
		hideWaitMessageAndShowCaption();
	};
	img.style.dispaly = "none";
	img.src = imagePath;
}

function hideWaitMessageAndShowCaption()
{
	document.getElementById('waitMessage').style.display='none';	
	document.getElementById('displayImg').style.display='block';	
	//document.getElementById('largeImageCaption').innerHTML = imageGalleryCaptions[imageIndex];
	//document.getElementById('largeImageCaption').style.display='block';	
}
