function ajaxFunction(){
	var ajaxRequest;
	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){
				//browsers all not support, rare case
				alert("Your browser broke!");
				return false;
			}
		}
	}
	return ajaxRequest;
}


function setAnnotation(mode) {

	htmlRequest = ajaxFunction();
	if (htmlRequest==null){ // If it cannot create a new Xmlhttp object.
		alert ("Browser does not support HTTP Request");
		return;
	}

	htmlRequest.open('POST', '/files/js/show_hide_annotations.php');
	if(mode == 'hide') {
		$('annotation_show').hide();
		$('annotation_hide').show();
		$('annotation').hide();
	} else {
       		$('annotation_show').show();
		$('annotation_hide').hide();
		$('annotation').show();
	}

	htmlRequest.onreadystatechange = function(){
		if(htmlRequest.readyState == 4){
                }
	}
	htmlRequest.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
	htmlRequest.send('set_annotation=' + mode);
}

