var current_element;

function setCurrElement(element){
  current_element=element;
}

function swap_color(nav_elem_to, id, cid){
  if(current_element != null){
    document.getElementById(current_element).style.backgroundColor='rgb(155,205,230)';
    current_element=nav_elem_to;
    document.getElementById(nav_elem_to).style.backgroundColor='rgb(0,111,179)';
    showPics(nav_elem_to, id, cid);
  }
  else{
    current_element=nav_elem_to;
    document.getElementById(nav_elem_to).style.backgroundColor='rgb(0,111,179)';
    showPics(nav_elem_to, id, cid);
  }
}

var xmlHttp

function showPics(str, id, cid){
  xmlHttp=GetXmlHttpObject();
  if (xmlHttp==null)
    {
    alert ("Your browser does not support AJAX!");
    return;
    } 
  var url="getPictures.php";
  url=url+"?cat="+str;
  url=url+"&id="+id;
  url=url+"&cid="+cid;
  xmlHttp.onreadystatechange=stateChanged;
  xmlHttp.open("GET",url,true);
  xmlHttp.send(null);
} 

function stateChanged() { 
if (xmlHttp.readyState==4)
{ 

document.getElementById("pictures").innerHTML=xmlHttp.responseText;
location.reload();
}
}

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;
}
