// JavaScript Document

//document.execCommand("BackgroundImageCache", false, true);

var xmlHttp = createXmlhttpRequestobject();


function createXmlhttpRequestobject()
{
	var xmlHttp;	
	try
	{
		xmlHttp = new XMLHttpRequest();
	}
	catch(e)
	{
		var XmlHttpVersions = new Array("MSXML2.XMLHTTP.6.0",
										"MSXML2.XMLHTTP.5.0",
										"MSXML2.XMLHTTP.4.0",
										"MSXML2.XMLHTTP.3.0",
										"MSXML2.XMLHTTP",
										"Microsoft.XMLHTTP");
		for(var i=0; i<XmlHttpVersions.length && !xmlHttp; i++)
		{
			try
			{
				xmlHttp = new ActiveXObject(XmlHttpVersions[i]);
			}
			catch(e){}
		}
	}
	if(!xmlHttp)
	{
		alert("创建XMLHttpRequest对象出错");
	}
	else
	{		
		return xmlHttp;
	}
}

function getmapsrc(url)
{	
	//alert(url);
	url=url.replace("ISAPI","acoo");
	if(xmlHttp)
	{		
		try
		{	
			
			xmlHttp.open("GET","http://www.acoolive.com/getmap/getmapsrc.php?url="+url+ "&" +Math.random(),true);				
			xmlHttp.onreadystatechange = handleRequestStateChange;
			xmlHttp.send(null);
		}
		catch(e)
		{
			alert("不能连接服务器:\n" + e.toString());	
		}		
	}	
}

function handleRequestStateChange()
{

	
		if(xmlHttp.readyState ==4)
		{
			//http状态为OK时继续
			if(xmlHttp.status == 200)
			{
				try
				{	
					timeout=0;
					var xmlResponse = xmlHttp.responseXML;
					
					// catching potential errors with IE and Opera
					if (!xmlResponse || !xmlResponse.documentElement)
						throw("Invalid XML structure:\n" + xmlHttp.responseText);
					// catching potential errors with Firefox
					var rootNodeName = xmlResponse.documentElement.nodeName;
					if (rootNodeName == "parsererror") 
						throw("Invalid XML structure");
					// obtain the XML's document element
					xmlRoot = xmlResponse.documentElement;				
					
					var arry = xmlRoot.getElementsByTagName("mapsrc");				
					var mapsrc = arry.item(0).firstChild.data;
					myA = document.getElementById(nowid + '_img');
					
					//alert(nowid + '_img');
					//alert(mapsrc);
					//
					myA.innerHTML = '<img src="'+mapsrc+'" border="0" /><br>';
					//myA.innerHTML='+mapsrc+';
					nowid ++;
					if(nowid==10)	
						return ;
					
					getmapsrc(m_maparry[nowid]);
				}
				catch(e)
				{
					//alert(e.toString());
				
				}
			}
		}
	
}
