function updatePodcasts(str) {
    var httpRequest;

    if (window.XMLHttpRequest) { // Mozilla, Safari, ...
        httpRequest = new XMLHttpRequest();
        if (httpRequest.overrideMimeType) {
            httpRequest.overrideMimeType('text/xml');
            // See note below about this line
        }
    } 
    else if (window.ActiveXObject) { // IE
        try {
            httpRequest = new ActiveXObject("Msxml2.XMLHTTP");
        } 
        catch (e) {
            try {
                httpRequest = new ActiveXObject("Microsoft.XMLHTTP");
            } 
            catch (e) {}
        }
    }

    if (!httpRequest) {
        alert('Giving up :( Cannot create an XMLHTTP instance');
        return false;
    }
    httpRequest.onreadystatechange = function() { alertContents(httpRequest,str); };
    var urlnew = "/development/MidirsPodcast.nsf/podcasts.xml";
    httpRequest.open('GET', urlnew, true);
    httpRequest.send('');

}

function alertContents(httpRequest,src) {
    if (httpRequest.readyState == 4) {
        if (httpRequest.status == 200) {
        	
        	if(window.ActiveXObject){ // If IE Windows
        		var xmldoc = new ActiveXObject("Microsoft.XMLDOM");
        		xmldoc.loadXML(httpRequest.responseText);
        		} else {
        		var xmldoc = httpRequest.responseXML;
        		}
        	
        	//var xmldoc = httpRequest.responseXML;
        	var podcastHTML = "";
        	var firstNames = xmldoc.getElementsByTagName("PODCAST");
        	var z = 0;
        	
        	for (var i=0; i < firstNames.length; i++) {  
        	
        	if (firstNames[i].getElementsByTagName("CATEGORY")[0].childNodes[0].nodeValue == src) {
        		 	if(z < 10) {
        				podcastHTML = podcastHTML + '<div class="podcast_list_result"><p><span class="right">Date: '+ firstNames[i].getElementsByTagName("DATEADDED")[0].childNodes[0].nodeValue + '</span><span class="left"><a href="/development/MidirsPodcast.nsf/cmspod/' + firstNames[i].getElementsByTagName("DOCID")[0].childNodes[0].nodeValue + '?OpenDocument" class="white"><b>' + firstNames[i].getElementsByTagName("PODNAME")[0].childNodes[0].nodeValue + '</b></a></span></p><br/><p><i>' +  firstNames[i].getElementsByTagName("AUTHOR")[0].childNodes[0].nodeValue + '</i></p><br/><p>' + firstNames[i].getElementsByTagName("DESCRIPTION")[0].childNodes[0].nodeValue + '</p></div>';
        		 	}
        			z = z + 1;
        		} else if (src == "*"){
        			if(z < 10) {
        				podcastHTML = podcastHTML + '<div class="podcast_list_result"><p><span class="right">Date: '+ firstNames[i].getElementsByTagName("DATEADDED")[0].childNodes[0].nodeValue + '</span><span class="left"><a href="/development/MidirsPodcast.nsf/cmspod/' + firstNames[i].getElementsByTagName("DOCID")[0].childNodes[0].nodeValue + '?OpenDocument" class="white"><b>' + firstNames[i].getElementsByTagName("PODNAME")[0].childNodes[0].nodeValue + '</b></a></span></p><br/><p><i>' +  firstNames[i].getElementsByTagName("AUTHOR")[0].childNodes[0].nodeValue + '</i></p><br/><p>' + firstNames[i].getElementsByTagName("DESCRIPTION")[0].childNodes[0].nodeValue + '</p></div>';
        			}
        			z = z + 1;
        		}   
        	}
        	
        	   var names = document.getElementById('ajaxResultHolder');
        	   var getCategoriesLink = document.getElementById('categoriesLink');
        	   if (podcastHTML.length > 0) {
        		   names.innerHTML = podcastHTML;
        		   if(src == "*"){
        			   getCategoriesLink.innerHTML = "&gt; <a href='/development/MidirsPodcast.nsf/search?openform' class='white'>Click here to view all podcasts</a>";
        		   } else {
        			   getCategoriesLink.innerHTML = "&gt; <a href='/development/MidirsPodcast.nsf/PodcastSearch/Search?SearchView&Query=field category=" + src + "' class='white'>Click here to view all " + src + " podcasts</a>";
        		   }
        	   } else {
        		   names.innerHTML = "<br/><p><b>Sorry, there are currently no podcasts in that category</b></p>";
        		   getCategoriesLink.innerHTML = "";
        		}
        	
        	
        	
        	
        	
        	
        	

        	//var root_node = xmldoc.getElementsByTagName("PODCAST");
        	//alert(root_node);

        } else {
            alert('There was a problem with the request.');
        }
    }

}

function clicked(type){

	if (type == "expand"){
	document.getElementById('restOfArchive').style.display = 'block';
	document.getElementById('expandSpan').style.visibility = 'hidden';
	document.getElementById('collapseSpan').style.visibility = 'visible';
	} else {
	document.getElementById('restOfArchive').style.display = 'none';
	document.getElementById('expandSpan').style.visibility = 'visible';
	document.getElementById('collapseSpan').style.visibility = 'hidden';
	}
	}


function IFPO(page) {
OpenWin = window.open(page,'CtrlWindow','toolbar=no,menubar=no,location=no,scrollbars=no,resizable=no,height=330,width=250,left=50,top=50');
}


function Start(page) {
OpenWin = window.open(page, "CtrlWindow", "toolbar=no,menubar=no,location=no,scrollbars=Yes,resizable=no,height=330,width=550,left=10,top=10");
}


