// here we define global variable
var ajaxdestination="";
var ajaxdestination2="";
var xmlhttp="";
var xmlhttp2="";

function getdata(what,cat,where) { // get data from source (what)
 try {
   xmlhttp = window.XMLHttpRequest?new XMLHttpRequest():
  		new ActiveXObject("Microsoft.XMLHTTP");
 }
 catch (e) { /* do nothing */ }

// we are defining the destination DIV id, must be stored in global variable (ajaxdestination)
 ajaxdestination=where;
 xmlhttp.onreadystatechange = triggered; // when request finished, call the function to put result to destination DIV
 page=what.concat('_submenu.php?'.concat(cat));
 xmlhttp.open("GET", page);
 xmlhttp.send(null);
 getdata2(what,cat,'content2');
return false;
}
function getdata2(what2,cat2,where2,listid) { // get data from source (what)

try {
   xmlhttp2 = window.XMLHttpRequest?new XMLHttpRequest():
  		new ActiveXObject("Msxml2.XMLHTTP");
 }
 catch (e) { /* do nothing */ }

// we are defining the destination DIV id, must be stored in global variable (ajaxdestination)
 ajaxdestination2=where2;
 xmlhttp2.onreadystatechange = triggered2; // when request finished, call the function to put result to destination DIV
 var hlink='_gallery.php?cat='.concat(cat2)
 if (listid != undefined) {
	 hlink=hlink.concat('&id='.concat(listid))
 }
  page2=what2.concat(hlink);

 xmlhttp2.open("GET", page2);
 xmlhttp2.send(null);
  return false;
}

function triggered() { // put data returned by requested URL to selected DIV
  if (xmlhttp.readyState == 4) if (xmlhttp.status == 200) {
    document.getElementById(ajaxdestination).innerHTML =xmlhttp.responseText;
	  startScroll();
  }
}
function triggered2() { // put data returned by requested URL to selected DIV
	if (xmlhttp2.readyState == 4 && (xmlhttp2.status==200 || window.location.href.indexOf("http")==-1)){
    document.getElementById(ajaxdestination2).innerHTML =xmlhttp2.responseText;
	startGallery();
	}
}



