var xmlHttp;


// basic functions for the divs

function hideDiv(indiv){
   indivx= document.getElementById('crwdiv');
   indivx.style.visibility="hidden";
   indivx= document.getElementById('crewnodiv');
   indivx.style.visibility="hidden";
   indivx= document.getElementById('dddiv');
   indivx.style.visibility="hidden";
}

function matchAcSerial(matches) {
   var AcName = document.getElementById("share_acserial");
   AcName.value = matches;
   document.getElementById("dddiv").style.visibility="hidden";
   //GetAlbumByArtist(artistName.value);
}
function matchAcName(matches) {
   var AcName = document.getElementById("share_acperson");
   AcName.value = matches;
   document.getElementById("crwdiv").style.visibility="hidden";
//GetAlbumByArtist(artistName.value);
}

function matchCrewNo(matches) {
   var AcName = document.getElementById("share_accrew");
   AcName.value = matches;
   document.getElementById("crewnodiv").style.visibility="hidden";
   //GetAlbumByArtist(artistName.value);
}

function showshareac(inobj,inel){
var AcName = document.getElementById(inel);
if (inobj.checked){
      AcName.style.visibility ="visible";
      AcName.style.height="100px";
    }
else {
      AcName.style.visibility ="hidden";
      AcName.style.height="1px";
     }
}


// Validate Photo Fields **************************
function checkPhotoParms()
{
  //vpResult = 'x';
  var g =document.forms['xphotos'];
  rx = validatePhoto();

   if (!(rx =="1"))
   {
     vp = document.getElementById("vphoto") ;
     vp.innerHTML=rx;
     vp.style.visibility = "visible";
     g.action = "javascript:alert(rx);";
     //return false;
   }
   else
   {
    g.action = 'photosave2.php';
   }


}

function validatePhoto()
{ 
xmlHttp=GetXmlHttpObject()
if (xmlHttp==null)
 {
 alert ("Browser does not support HTTP Request");
 return;
 }
var Acs = document.getElementById('share_acserial').value;
var Acn = document.getElementById('share_acperson').value;
var Acc = document.getElementById('share_accrew').value;
var url="vphotojax.php";
url=url+"?serial="+Acs;
url=url+"&crew="+Acc;
url=url+"&pers="+Acn;
url=url+"&sid="+Math.random();
//xmlHttp.onreadystatechange=vPhoto 
xmlHttp.open("GET",url,false);
xmlHttp.send(null);
return xmlHttp.responseText; 

}






// acserial **************************
function getAcSerial()
{ 
xmlHttp=GetXmlHttpObject()
if (xmlHttp==null)
 {
 alert ("Browser does not support HTTP Request");
 return;
 }
var AcName = document.getElementById('share_acserial').value;
var url="acserialjax.php";
url=url+"?serial="+AcName;
url=url+"&sid="+Math.random();
xmlHttp.onreadystatechange=acChanged ;
xmlHttp.open("GET",url,true);
xmlHttp.send(null);

}

function acChanged() 
{ 
if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
 { 
matchList = document.getElementById("acserialmatches") ;
matchListdiv = document.getElementById("dddiv") ;
//matchList.size = 10; //reset the states dropdown
//matchList.size = document.getElementById("acserial").length; 
matchList.innerHTML=xmlHttp.responseText; 
matchListdiv.style.width= "100px";
matchListdiv.style.visibility = "visible";
 } 
}

// crewname ***********************************
function getCrewName()
{ 
xmlHttp=GetXmlHttpObject()
if (xmlHttp==null)
 {
 alert ("Browser does not support HTTP Request")
 return
 }
var AcName = document.getElementById('share_acperson').value;
var url="crewnamejax.php";
url=url+"?name="+AcName;
url=url+"&sid="+Math.random();
xmlHttp.onreadystatechange=crwChanged ;
xmlHttp.open("GET",url,true);
xmlHttp.send(null);

}

function crwChanged() 
{ 
if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
 { 
matchList = document.getElementById("crwnamematches") ;
matchList2 = document.getElementById("increwname") ;
matchListdiv = document.getElementById("crwdiv") ;
 //matchListdiv.left = matchList2.left;
matchListdiv.style.width= "220px";
//matchList2.style.width;

matchList.innerHTML=xmlHttp.responseText; 
matchListdiv.style.visibility = 'visible';


 } 
}

// ** crew no
function getCrewNo()
{ 
xmlHttp=GetXmlHttpObject();
if (xmlHttp==null)
 {
 alert ("Browser does not support HTTP Request")
 return
 }
var AcName = document.getElementById('share_accrew').value;
var url="crewnamejax.php";
url=url+"?crew="+AcName;
url=url+"&sid="+Math.random();
xmlHttp.onreadystatechange=crewNoChanged ;
xmlHttp.open("GET",url,true);
xmlHttp.send(null);
}

function crewNoChanged() 
{ 
if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
 { 
matchList = document.getElementById("crewnomatches") ;
matchList2 = document.getElementById("increwno") ;
matchListdiv = document.getElementById("crewnodiv") ;
 //matchListdiv.left = matchList2.left;
matchListdiv.style.width= "100px";
//matchList2.style.width;

matchList.innerHTML=xmlHttp.responseText; 
matchListdiv.style.visibility = 'visible';

 } 
}



// Shared

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;
}
