// JavaScript Document
/* Number of thumbnail pages*/

var thumbpages=9;
function inIE() {
	return navigator.appName == "Microsoft Internet Explorer";
}

var freevar = 0;
var scrollduration = 1;
var actualpage=1;

function load(){
	document.getElementById('thumbnails').style.position='relative';
	showLinks();
}

window.onload=load;
function pageDown(page){
	hideLinks();
	//doAjax('gallery0'+(++actualpage)+'.htm',function (text){
	doAjax('list_gallery.php?page='+(++actualpage)+'',function (text){
		var pager = document.getElementById('thumbnails');
		var newdiv = document.createElement('div');
		var olddiv = pager.firstChild;
		/*pager.appendChild(newdiv);
		newdiv.style.width='580px';
		newdiv.style.padding='7px';*/

		//newdiv.innerHTML=
		   /*'<table border="0" cellspacing="0" cellpadding="7" width="580">'+
            '<tbody>'+
            '<tr>'+
              '<td width="100%" height="290" valign="top">'+*/
                //text
              /*+'</td>'+
             '</tr>'+
             '</tbody>'+
           '</table>';*/
		   
		if (inIE()){
			newdiv.style.width='580px';
			newdiv.style.padding='7px';
			newdiv.innerHTML=text;
		} else {
		newdiv.innerHTML=
		   '<table border="0" cellspacing="0" cellpadding="7" width="580">'+
            '<tbody>'+
            '<tr>'+
              '<td width="100%" height="290" valign="top">'+
                text
              +'</td>'+
             '</tr>'+
             '</tbody>'+
           '</table>';
          }
		newdiv.id='page_'+(++freevar);   
		   
		   
		   
		//newdiv.id='page_'+(++freevar);
		pager.appendChild(newdiv);
		//alert(newdiv.id);
		new Effect.SlideUp(olddiv.id,{duration:scrollduration});
		//new Effect.Fade(olddiv.id,{duration:scrollduration});
		setTimeout(function (){olddiv.style.display='none';pager.removeChild(olddiv);showLinks();},scrollduration*900);
	});
}

function pageUp(page){
	hideLinks();
	//doAjax('gallery0'+(--actualpage)+'.htm',function(text){
	doAjax('list_gallery.php?page='+(--actualpage)+'',function (text){
		var pager = document.getElementById('thumbnails');
		var olddiv = pager.firstChild;
		var newdiv = document.createElement('div');
		
		newdiv.style.display='none';
		if (inIE()){
			newdiv.style.width='580px';
			newdiv.style.padding='7px';
			newdiv.innerHTML=text;
		} else {
		newdiv.innerHTML=
		   '<table border="0" cellspacing="0" cellpadding="7" width="580">'+
            '<tbody>'+
            '<tr>'+
              '<td width="100%" height="290" valign="top">'+
                text
              +'</td>'+
             '</tr>'+
             '</tbody>'+
           '</table>';
          }
		newdiv.id='page_'+(++freevar);
		
		/*newdiv.style.display='none';
		newdiv.style.width='580px';
		newdiv.style.padding='7px';
		newdiv.innerHTML=*/
		   /*'<table border="0" cellspacing="0" cellpadding="7" width="580">'+
		   '<tbody>'+
            '<tr>'+
              '<td width="100%" height="290" valign="top">'+*/
                //text
              /* +'</td>'+
             '</tr>'+
             '</tbody>'+
           '</table>';*/
		//newdiv.id='page_'+(++freevar);
		
		
		
		pager.insertBefore(newdiv,olddiv);
		new Effect.SlideDown(newdiv.id,{duration:scrollduration});
		//new Effect.Appear(newdiv.id,{duration:scrollduration});
		setTimeout(function (){pager.removeChild(olddiv);showLinks();},scrollduration*1100);
	});
}
function showLinks(){
	thumbpages=document.getElementById('thumbpages').value;
	if (actualpage==1) {
		document.getElementById('pageUp').style.display='none';
	} else {
		document.getElementById('pageUp').style.display='inline';
	}
	if (actualpage==thumbpages) {
		document.getElementById('pageDown').style.display='none';
	} else {
		document.getElementById('pageDown').style.display='inline';
	}
}
function hideLinks(){
	document.getElementById('pageUp').style.display='none';
	document.getElementById('pageDown').style.display='none';
}
function getHTTPObject() {
  var xmlhttp; /** Special IE only code ... */
  /*@cc_on @if (@_jscript_version >= 5) try
    { xmlhttp = new ActiveXObject("Msxml2.XMLHTTP"); }
    catch (e) { try { xmlhttp = new ActiveXObject("Microsoft.XMLHTTP"); }
     catch (E) { xmlhttp = false; } } @else
    xmlhttp = false; @end @*/
    /** Every other browser on the planet */
    if (!xmlhttp && typeof XMLHttpRequest != "undefined")
    { try { xmlhttp = new XMLHttpRequest(); }
    catch (e)
    { xmlhttp = false; }
    }
    return xmlhttp;
}

function doAjax(url, func)
{
	var xmlDoc =getHTTPObject();
    xmlDoc.abort();
	try {
       xmlDoc.open("GET", url, true);
       xmlDoc.setRequestHeader("Connection", "close");
    } catch (e) {
       alert("Error:"+e);
    }
	xmlDoc.onreadystatechange = function () {
		if (xmlDoc.readyState == 4) func(xmlDoc.responseText);
	};
    try {
	   xmlDoc.send(null);
    } catch (e) {
	   alert("Error:"+e);
    }
}

