// JavaScript Document



var xmlHttp;
var current_ID = 1;
var last_ID = 19
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 moveToNextEmployee(execFile) {
	if(!isLastElement()) {
		current_ID = current_ID + 1 
	} else {
		current_ID = 1 
	}
	//alert(current_ID);
	show_employee(execFile, current_ID);
	
}

function moveToPreviousEmployee(execFile) {
	if(!isFirstElement()) {
		current_ID = current_ID - 1 ;
	} else {
		current_ID = last_ID;
	}
	//alert(current_ID);
	show_employee(execFile, current_ID);	
}

function show_employee_ini(page_item, employee) {
	getEmployeeData("../media/DB_emps/update_employee_3.php" ,  employee,page_item);	
}

function show_employee(execFile, employee) {
	getEmployeeData("../media/DB_emps/update_employee_"+execFile+".php" ,  employee);	
}

function employeeStateChanged() { 
	if (xmlHttp.readyState==4) { 
		document.getElementById("employeeData").innerHTML=xmlHttp.responseText;
	}
}


function getEmployeeData(url, employee) { 
	xmlHttp=GetXmlHttpObject();
	if (xmlHttp==null) {
		alert ("Your browser does not support AJAX!");
		return;
	} 
	
	//alert(url);
	url=url+"?current="+employee;
	//alert(url);
	xmlHttp.onreadystatechange=employeeStateChanged;
	xmlHttp.open("GET",url,true);
	xmlHttp.send(null);
}