$(document).ready(function() {

	$(".maintable").find(".catrow").hover(function() {
		$(this).addClass("catrowhl");
		},function(){
		$(this).removeClass("catrowhl");
		}).parent().next().hide().end().end().click(function(){
			var curLink = $(this).find('a').attr('href');
			if (curLink)
				window.location = curLink;
		});
			//$(this).parent().next().toggle();});
	//$("#gallery").show();
	//document.getElementById("load").style.display="none";

	var pattern = /thumbnails\.php/gi;
	if (window.location.href.match(pattern)) {
		$(function() {
			$('.thumbnails a').lightBox({fixedNavigation:true});
		});
	}
});

function dlAlbum(id,aid,asize)
{
document.getElementById(id).innerHTML='<span id="ajaxloader" style="background-image: url(\'/images/ajax-loader.gif\'); background-repeat: no-repeat; background-position: center; align: center; width: 200px; color: #FFFFFF;">&nbsp;&nbsp;Processing...&nbsp;&nbsp;</span>';
xmlHttp=GetXmlHttpObject()
if (xmlHttp==null)
  {
  alert ("Your browser does not support AJAX!");
  return;
  } 
var url="../albumdl.php";
url=url+"?album="+aid;
url=url+"&albumsize="+asize;
xmlHttp.onreadystatechange=function(){dlAlbum_SC(id)};
xmlHttp.open("GET",url,true);
xmlHttp.send(null);
//var xmlHttpTimeout=setTimeout("ajaxTimeout('"+id+"');",120000);
}

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 dlAlbum_SC(id) 
{ 
	switch(xmlHttp.readyState) {
	case 4: //clearTimeout(xmlHttpTimeout);
		var filepath="/"+xmlHttp.responseText;
		window.location.pathname=filepath;
		document.getElementById(id).innerHTML="Done";
		var t=setTimeout("document.getElementById('"+id+"').innerHTML='Download full album'", 2000);
		break;
	}
}

function ajaxTimeout(id){
	xmlHttp.abort();
	alert("Request timed out. The album seems to be too big.");
	document.getElementById(id).innerHTML="Done";
	var t=setTimeout("document.getElementById('"+id+"').innerHTML='Download full album'", 2000);
}

