var xmlhttp1;
var xmlhttp2;

function addLoadEvent(func) {
  var oldonload = window.onload;
  if (typeof window.onload != 'function') {
    window.onload = func;
  } else {
    window.onload = function() {
      if (oldonload) {
        oldonload();
      }
      func();
    }
  }
}

function showPicasaGallery(num) {
	
	document.getElementById("jcarouselbox").innerHTML="<div class=\"ajaxgalleryload\"><br \><img src=\"images/galleryload.gif\"></div>";
	
		
	xmlhttp2=GetXmlHttpObject();
	if (xmlhttp2==null)
	  {
	  alert ("Your browser does not support XMLHTTP!");
	  return;
	  }
	var url="picasa.php";
	url=url+"?gal="+num;
	url=url+"&sid="+Math.random();
	xmlhttp2.onreadystatechange=galleryStateChanged;
	xmlhttp2.open("GET",url,true);
	xmlhttp2.send(null);						
}

function showPicasaMenu()
{
xmlhttp1=GetXmlHttpObject();
if (xmlhttp1==null)
  {
  alert ("Your browser does not support XMLHTTP!");
  return;
  }
	var url="picasa_menu.php";
	url=url+"?sid="+Math.random();
	xmlhttp1.onreadystatechange=menuStateChanged;
	xmlhttp1.open("GET",url,true);
	xmlhttp1.send(null);
}

function menuStateChanged()
{
if (xmlhttp1.readyState==4)
  {
  document.getElementById("leftmenucontainer").innerHTML=xmlhttp1.responseText;
  }
}

function galleryStateChanged()
{
if (xmlhttp2.readyState==4)
  {
	document.getElementById("jcarouselbox").innerHTML=xmlhttp2.responseText;
	$j = jQuery.noConflict();

					
					$j(".auto .jCarouselLite").jCarouselLite({
						auto: 800,
						speed: 1000
					});

					
					$j(function() {
						$j(".jcarouselclass").jCarouselLite({
							btnNext: ".next",
							btnPrev: ".prev",
							//auto: 12000,
							speed: 1000
						});
					});
					
					$j(function() {
						// Use this example, or...
						//$('a[@rel*=lightbox]').lightBox(); // Select all links that contains lightbox in the attribute rel
						// This, or...
						$j('#jcarouselbox ul li a').lightBox(); // Select all links in object with gallery ID
						// This, or...
						//$('a.lightbox').lightBox(); // Select all links with lightbox class
						// This, or...
						//$('a').lightBox(); // Select all links in the page
						// ... The possibility are many. Use your creative or choose one in the examples above
					});

  }
}

function GetXmlHttpObject()
{
if (window.XMLHttpRequest)
  {
  // code for IE7+, Firefox, Chrome, Opera, Safari
  return new XMLHttpRequest();
  }
if (window.ActiveXObject)
  {
  // code for IE6, IE5
  return new ActiveXObject("Microsoft.XMLHTTP");
  }
return null;
}
