// JavaScript Document

function get_gallery(lang)
{
  var id = document.getElementById('reference_id').value;
  document.getElementById('add_reference_id').value = id;
  var url = "/ajax/admin_gallery_select.php?id="+id+"&lang="+lang;
  sendRequest_admin_gallery_select(url);
}

function gallery_priority(id, priority, new_priority,direction,lang,reference_id)
{
  //alert(id+" "+priority+" "+new_priority);
  var url = "/ajax/admin_gallery_ajax.php?reference_id="+reference_id+"&id="+id+"&priority="+priority+"&new_priority="+new_priority+"&direction="+direction+"&lang="+lang;
  sendRequest_admin_gallery_priority(url);
}

function stateChanged_admin_gallery_priority()
{ 
  if (xmlHttp.readyState==4)
  { 
    document.getElementById('admin_gallery_list').innerHTML=xmlHttp.responseText;
  }
}

function sendRequest_admin_gallery_priority(url)
{
	xmlHttp = createXMLHttpRequest();

	if (xmlHttp)
	{
	  xmlHttp.onreadystatechange=stateChanged_admin_gallery_priority;
		xmlHttp.open("GET", url, true);
		xmlHttp.send("");
	}
}

function stateChanged_admin_gallery_select()
{ 
  if (xmlHttp.readyState==4)
  { 
    document.getElementById('admin_gallery_list').innerHTML=xmlHttp.responseText;
    document.getElementById('admin_gallery_add_form').style.display = "block";
  }
}

function sendRequest_admin_gallery_select(url)
{
	xmlHttp = createXMLHttpRequest();

	if (xmlHttp)
	{
	  xmlHttp.onreadystatechange=stateChanged_admin_gallery_select;
		xmlHttp.open("GET", url, true);
		xmlHttp.send("");
	}
}

/*AJAX function*/

var xmlHttp;

function createXMLHttpRequest()
{
	try 
  { 
    return new XMLHttpRequest();     
  } 
  catch (e) 
  {
    try 
    { 
      return new ActiveXObject("Microsoft.XMLHTTP"); 
    } 
    catch (e) 
    {
      try 
      { 
        return new ActiveXObject("Msxml2.XMLHTTP");
      } 
      catch(e) 
      {
      	alert("Your browser does not support AJAX!");
	      return null;
      }
    }
  }
}
