// JavaScript Document
//Create a boolean variable to check for a valid IE instance.
var xmlhttp = false;
//Check if we are using IE.
try {
//If the javascript version is greater than 5.
xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
} catch (e) {
//If not, then use the older active x object.
try {
//If we are using IE.
xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
} catch (E) {
//Else we must be using a non-IE browser.
xmlhttp = false;
}
}
//If we are using a non-IE browser, create a JavaScript instance of the object.
if (!xmlhttp && typeof XMLHttpRequest != 'undefined') {
	xmlhttp = new XMLHttpRequest();
}

function previousPic(code){
	
	var page = "includes/xmlhttp_loadpic.php";
	var el = document.getElementById('picindex');
	var picindex = el.innerHTML;
	picindex--;
	
	xmlhttp.open("POST", page, true);
	xmlhttp.setRequestHeader("Content-Type","application/x-www-form-urlencoded; charset=UTF-8");
	xmlhttp.onreadystatechange = function() {
		if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
			el = document.getElementById('picindex');
			el.innerHTML = picindex;
			el = document.getElementById('pic');
			el.innerHTML = xmlhttp.responseText;			
		}
	}
	xmlhttp.send("picindex="+picindex+"&code="+code+"&dir=prev");
}

function nextPic(code){
	
	var page = "includes/xmlhttp_loadpic.php";
	var el = document.getElementById('picindex');
	var picindex = el.innerHTML;
	picindex++;
	
	xmlhttp.open("POST", page, true);
	xmlhttp.setRequestHeader("Content-Type","application/x-www-form-urlencoded; charset=UTF-8");
	xmlhttp.onreadystatechange = function() {
		if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
			el = document.getElementById('picindex');
			el.innerHTML = picindex;
			el = document.getElementById('pic');
			el.innerHTML = xmlhttp.responseText;	
		}
	}
	xmlhttp.send("picindex="+picindex+"&code="+code+"&dir=next");
}

function initialPic(code){
	
	var page = "includes/xmlhttp_loadpic.php";
	var el = document.getElementById('picindex');
	var picindex = el.innerHTML;
	xmlhttp.open("POST", page, true);
	xmlhttp.setRequestHeader("Content-Type","application/x-www-form-urlencoded; charset=UTF-8");
	xmlhttp.onreadystatechange = function() {
		if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
			el = document.getElementById('pic');
			el.innerHTML = xmlhttp.responseText;
		}
	}
	xmlhttp.send("picindex="+picindex+"&code="+code);
}
