//var isIE = navigator.userAgent.indexOf("MSIE") != -1;
function browse(url)
{
	
	ajaxxml(url,'browseresult');
}
function browseresult(xml)
{
	alert(xml);
	//document.write("Praise the Lord");
	var xmlRes = ffLoadXMLBrowser(xml);//xml.getElementsByTagName('movies');//
	alert(xmlRes.childNodes[0].getElementsByTagName( 'node').length)
	//var node = vtag(xml,'node');
	//alert(node);
	//alert(ntag(node,'child'));
}
function vtag(xml,tag)
{
	
	return xml.childNodes[0].getElementsByTagName(tag).text;
}
function ntag(xml,tag)
{
	//alert(xml+":"+tag);
	return xml.getElementsByTagName(tag).text;
}
function ffLoadXMLBrowser(strXML)
{
	if(document.implementation && document.implementation.createDocument) 
	{
		//alert('Hello')
		//alert(strXML);
		// MOZILLA
		//xmlSerializer = new XMLSerializer();
		xmlParser = new DOMParser();
		xmlDocum = xmlParser.parseFromString( strXML, 'text/xml');
		xmlSerializer = new XMLSerializer();
		//xmlDocum = xmlSerializer.serializeToString(xmlDocum1);
		
		//alert( xmlSerializer.serializeToString(xmlDocum));
	}
	else if(window.ActiveXObject) {
	//alert('test');
		// IE
		xmlDocum = new ActiveXObject("Microsoft.XMLDOM");
		xmlDocum.async=false;
		xmlDocum.loadXML( strXML);
	}
	//alert(xmlDocum.xml);
	return xmlDocum;
}

function ajaxxml(url,callback_fun,param)
{
	var xmlhttp = '';
	/*if(isIE)
		var xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
	else
		var xmlhttp = new XMLHttpRequest();*/
	if(window.XMLHttpRequest)//For Firefox
	{
		xmlhttp = new XMLHttpRequest();
		if(xmlhttp.overrideMimeType)
			xmlhttp.overrideMimeType("text/xml");
	}
	else if(window.ActiveXObject)//For IE
	{
		try
		{
			 xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
		}
		catch(e)
		{
			 xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
		}
	}
	
	
	xmlhttp.onreadystatechange = function() 
	{
		if (xmlhttp.readyState == 4)
		{
		 	if(xmlhttp.status == 200)
		 	{
				//ret_val = xmlhttp.responseText;
				//alert('test'+xmlhttp.responseXML)
				eval(callback_fun+'(xmlhttp.responseText,param)');
				//else
				//	eval(callback_fun+"("+xmlhttp.responseXML+")");
			}
			else
				alert('The request code is not valid as '+xmlhttp.status);
		}
	}
	
	xmlhttp.open( 'GET', url,true);

	xmlhttp.send(null);
}


