// JavaScript Document

var xmlHttp;

function isLastElement() {
	var res = false;
	if(current_ID == last_ID)
		res = true;
	return res;
}

function isFirstElement() {
	var res = false;
	if(current_ID == 1)
		res = true;
	return res;
}

function GetXmlHttpObject() {
	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");
		}
	}
	return xmlHttp;
}

function resetImage(omit_doc){
	if(current_doc != "" && current_doc != omit_doc){
		document.getElementById(current_doc + "_data").innerHTML = "<img class='publication_pic' src='../media/publications/"+ docFile[current_doc]  +".gif' width='225' height='100' />" 
		current_doc = ""
	}
	
}

function showDocDetails(doc) {
	current_doc = doc;
	getDocData("../media/DB_docs/getDocLinks.php", doc);	
}

function docStateChanged(doc) { 
	var div = current_doc+"_data";
	//alert(div);
	
	if (xmlHttp.readyState==4) { 
		document.getElementById(div).innerHTML=xmlHttp.responseText;
	}
}

function getDocData(url,doc) { 
	xmlHttp=GetXmlHttpObject();
	if (xmlHttp==null) {
		alert ("Your browser does not support AJAX!");
		return;
	} 	
	//alert(url);
	url=url+"?current="+doc;
	//alert(url);
	xmlHttp.onreadystatechange=docStateChanged;
	xmlHttp.open("GET",url,true);
	xmlHttp.send(null);
}