var req;

function seloadXMLDoc(url) {
	    
		 if (window.XMLHttpRequest) {					// branch for native XMLHttpRequest object  

		 	req = new XMLHttpRequest();
		        req.onreadystatechange = seprocessReqChange;
		        req.open("GET", url, true);
		        req.send(null);
		   

		 
		 } else if (window.ActiveXObject) {			 // branch for IE/Windows ActiveX version
		        
		    req = new ActiveXObject("Microsoft.XMLHTTP");
		        if (req) {
		            req.onreadystatechange = seprocessReqChange;
		            req.open("GET", url, true);
		            req.send();
		        }
		    }   
		}		
function seprocessReqChange() {
	  
		    // only if req shows "complete"
		    if (req.readyState == 4) {
		    	
		        // only if "OK"
		       
		        if (req.status == 200) {
		        	
		          // ...processing statements go here...
		          
			      response = req.responseXML.documentElement;
			         
			      method = response.getElementsByTagName('method')[0].firstChild.data;
			      result = response.getElementsByTagName('result')[0].firstChild.data;
			      id = response.getElementsByTagName('id')[0].firstChild.data;
			      eval(method + '(\'\', result, id)');
		      
		        } else {	
		            alert("There was a problem retrieving the XML data:\n" + req.statusText);
		            
		        }
		    }
		}
		
	
function getVolume(input, response, id) {  //subcat #1 processing function


		if (response == ''){ 
		  	//starting over so disable subcat selects and reset values
			
		  	document.getElementById('volsel').style.display = 'none';
		   	document.forms['searchForm'].volumes.value ="";
		    document.getElementById('isssel').style.display  = 'none';
		   	document.forms['searchForm'].issues.value ="";
		   	document.getElementById('allpubbtn').style.display = 'none';
		   	document.getElementById('allvolbtn').style.display = 'none';
		    	
		}
		  if (response != ''){ 
		  //necessary to restate this to keep user from being able to choose a 
		  //category out of turn and there by throwing off ajax responses
		  document.forms['searchForm'].volumes.disabled = true;
		  document.forms['searchForm'].issues.disabled = true;
		   
		    if(response != 0) {
		    	//we have a subcat and so we must reset the selects to remove previous results
	    		document.forms['searchForm'].volumes.options.length = 0;
				document.forms['searchForm'].issues.options.length = 0;
				
		    	var nameArray = response.split(";");  //this is the select options display - *volume prikey
		    	var idArray = id.split(";");  //this is the select values - *volume prikey
		    	var index = 0;
		    	
		    	//necessary to define the index 0 option to avoid a request for no category not to be seen as a request for 
		    	//main level categories - (ie categroies with a parent id of 0)
		    	document.forms['searchForm'].volumes.options[index] = new Option('Select Volume Number...',-1);
		    	
		    	//could have used either array.length here they are always the same
		    	while(index < nameArray.length) {
	 	
				 	document.forms['searchForm'].volumes.options[index+1] = new Option(nameArray[index], idArray[index]);
				 	index ++;	
				 } // end while
				 //turn on subcat1 for selecting
				 document.forms['searchForm'].volumes.disabled = false;
		    	 document.getElementById('volsel').style.display = '';
		    	 document.getElementById('allpubbtn').style.display = '';
		    	
		    	 
		    }
		    
		  } else {
		  
		    // Input mode
		    	
		 	url = '../ajaxgetvolume.php?q=' + input +'&=SID';
		   // alert(url);
		    seloadXMLDoc(url);
		    
		  }
		
		}
//--------------------------------------------------------------------------------------------------------------------------------------------------------------
//  ISSUE AJAX GETTER		
//--------------------------------------------------------------------------------------------------------------------------------------------------------------		
		
		
		
var req2;

function seloadXMLDoc2(url) {
	    
		 if (window.XMLHttpRequest) {					// branch for native XMLHttpRequest object  

		 		req2 = new XMLHttpRequest();
		        req2.onreadystatechange = seprocessReqChange2;
		        req2.open("GET", url, true);
		        req2.send(null);
		   

		 
		 } else if (window.ActiveXObject) {			 // branch for IE/Windows ActiveX version
		        
		    req2 = new ActiveXObject("Microsoft.XMLHTTP");
		        if (req2) {
		            req2.onreadystatechange = seprocessReqChange2;
		            req2.open("GET", url, true);
		            req2.send();
		        }
		    }   
		}		
function seprocessReqChange2() {
	  
		    // only if req shows "complete"
		    if (req2.readyState == 4) {
		    	
		        // only if "OK"
		       
		        if (req2.status == 200) {
		        	
		          // ...processing statements go here...
		          
			      response = req2.responseXML.documentElement;
			     // alert(response);   
			      method = response.getElementsByTagName('method')[0].firstChild.data;
			      result = response.getElementsByTagName('result')[0].firstChild.data  
			      id = response.getElementsByTagName('id')[0].firstChild.data
			      eval(method + '(\'\', result, id)');
		      
		        } else {	
		            alert("There was a problem retrieving the XML data:\n" + req2.statusText);
		            
		        }
		    }
		}
		
	
function getIssue(input, response, id) {  //subcat #1 processing function

//alert(input);
		if (response == ''){ 
		}
		  if (response != ''){ 
		  //necessary to restate this to keep user from being able to choose a 
		  //category out of turn and there by throwing off ajax responses
		  document.forms['searchForm'].issues.disabled = true
		  document.getElementById('allvolbtn').style.display = 'none';
		    if(response != 0) {
		    	//we have a subcat and so we must reset the selects to remove previous results
				document.forms['searchForm'].issues.options.length = 0;
				
		    	var nameArray = response.split(";");  //this is the select options display - *issue number
		    	var idArray =  id.split(";");  //this is the select options value - *issue prikey
		    	var index = 0;
		    	
		    	//necessary to define the index 0 option to avoid a request for no category not to be seen as a request for 
		    	//main level categories - (ie categroies with a parent id of 0)
		    	document.forms['searchForm'].issues.options[index] = new Option('Select Issue Number...',-1);
		    	
		    	//could have used either array.length here they are always the same
		    	while(index < nameArray.length) {
	 	
				 	document.forms['searchForm'].issues.options[index+1] = new Option(nameArray[index], idArray[index]);
				 	index ++;	
				 } // end while
				 //turn on subcat1 for selecting
				 document.forms['searchForm'].issues.disabled = false;
		    	 document.getElementById('isssel').style.display = '';
		       	 document.getElementById('allvolbtn').style.display = '';
		    	 
		    }
		    
		  } else {
		  
		    // Input mode
		    	
		 	url = '../ajaxgetissue.php?q=' + input +'&=SID';
		    //alert(url);
		    seloadXMLDoc2(url);
		    
		  }
		
		}
		
function gotoPub(input){
	window.location="../getpubdata.php?q="+ input +"&=SID";	
}
function gotoVol(input){
	window.location="../getvoldata.php?q="+ input +"&=SID";	
}
function gotoStore(input){
	window.location="../getvolissuedata.php?q="+ input +"&=SID";	
}
function gotoSearch(input){
	window.location="../getsearchresultsdata.php?q="+ input +"&=SID";	
}