// JavaScript Document
var xmlHttp = null;


//this populates my drop down box with a list of choices fed from my database table
function loadXMLDoc( url ) {
xmlHttp=GetXmlHttpObject()

 if (xmlHttp==null){
		alert ("Your browser does not support xml HTTP requests.")
	return
  }
    xmlHttp.onreadystatechange = parseFeedList
    xmlHttp.open("GET", url, true);
    xmlHttp.send(null);
}


//define a custom function
function showRSS(str) { 
xmlHttp=GetXmlHttpObject()
 if (xmlHttp==null)
  {  alert ("Your browser does not support xml HTTP requests.")
  return
  }
var url="http://www.precisionresources.net/10103prc!/include/getrss.php"
url=url+"?q="+str
url=url+"&sid="+Math.random()
xmlHttp.onreadystatechange=stateChanged 
xmlHttp.open("GET",url,true)
xmlHttp.send(null)
}


//do something when data gets returned to me
function stateChanged() 
 { 
 if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete") {
	  document.getElementById("attache_loading").innerHTML=" ";
	 document.getElementById("rssOutput").innerHTML=xmlHttp.responseText;
	 }  
	 else{
		 document.getElementById("attache_loading").innerHTML="loading...";
	 }
 }






//check which browser user has
 function GetXmlHttpObject()
{
var xmlHttp=null;
try
 {
 // Firefox, Opera 8.0+, Safari
 xmlHttp=new XMLHttpRequest();
}
//if that failed or returned an error (e), then try something else
catch (e)
 {
 // Internet Explorer
 try
  {
  xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
  }
  ////if that failed or returned an error (e), then try something else
 catch (e)
  {
  xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
  }
 }
return xmlHttp;//return the value to the function that called this function
}



////////////////from the db_d file collection

function parseFeedList( dom ) {
  var elfw = document.getElementById( 'elFeedList' );
  elfw.innerHTML = '';

  var nl = xmlHttp.responseXML.getElementsByTagName( 'link' );
  var firstId = null;
  for( var i = 0; i < nl.length; i++ ) {
    var nli = nl.item( i );
    var id = nli.getAttribute( 'id' );
    var mylink = nli.getAttribute( 'address' );
    var name = nli.getAttribute( 'name' );

    var elOption = document.createElement( 'option' );
    elOption.value = mylink;
	elOption.innerHTML = name;
	elfw.appendChild( elOption );

    if ( firstId == null ) firstId = id;
  }

}

////////////


//first load up my feed list of options
function getFeedList() {
	loadXMLDoc('http://www.precisionresources.net/10103prc!/include/populate_list.php'); 
	}