var scroll_speed = 100;

var current_blog_id;

var xmlHttp;

function createXMLHttpRequest() {
	if (window.ActiveXObject) {
		xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
	}
	else if (window.XMLHttpRequest) {
		xmlHttp = new XMLHttpRequest();
	}
}

function get_blog_gallery(blog_id) {
	current_blog_id = blog_id;

	// hide current gallery (if any)
	document.getElementById("arrows").style.display = "none";
	document.getElementById("lyr_more_images").style.display = "none";
	document.getElementById('loading_' + current_blog_id).style.display = '';

	createXMLHttpRequest();
	xmlHttp.onreadystatechange = get_second_gallery;
	xmlHttp.open("GET", "ajax_get_blog_gallery.aspx?blog_id=" + current_blog_id, true);
	xmlHttp.send(null);
}

function get_second_gallery() {
	if(xmlHttp.readyState == 4) {
		if(xmlHttp.status == 200) {

			document.getElementById("lyr_more_images").innerHTML = xmlHttp.responseText;
			wndo2 = new dw_scrollObj('wn_more_images', 'lyr_more_images');

			// retrieve a second time
			createXMLHttpRequest();
			xmlHttp.onreadystatechange = display_gallery;
			//xmlHttp.open("GET", "ajax_get_blog_gallery.aspx?blog_id=" + current_blog_id, true);
			xmlHttp.open("GET", "ajax_get_blog_gallery.aspx", true);
			xmlHttp.send(null);
		}
	}
}

function display_gallery() {
	// check that we've made a valid request
	if(xmlHttp.readyState == 4) {
		if(xmlHttp.status == 200) {
			document.getElementById("arrows").style.display = "";
			document.getElementById("lyr_more_images").style.display = "";
			document.getElementById('loading_' + current_blog_id).style.display = 'none';
			myLightbox.updateImageList();
			wndo2 = new dw_scrollObj('wn_more_images', 'lyr_more_images');
		}
	}
}
