// JavaScript Document

function processGetbrand(){
	var myajax=ajaxpack.ajaxobj
	formname = ajaxpack.formname;
	var myfiletype=ajaxpack.filetype
	if (myajax.readyState == 4){ //if request of file completed
	if (myajax.status==200 || window.location.href.indexOf("http")==-1){ //if request was successful or running script locally
		if (myfiletype=="txt")
		{
		//alert(myajax.responseText)
		//formname = myajax.formname;
		doc = getxml(myajax.responseText);
		//alert(myajax.responseText);
		//alert(doc.childNodes[0].nodeName);
		result = doc.childNodes[0];
		
		
		search = result.childNodes[2].childNodes[0].nodeValue;
		//alert(search);
		document.getElementById(formname).innerHTML=search;
		
		//featured = result.childNodes[1].childNodes[0].nodeValue;
		//document.getElementById("featuredtd").innerHTML=featured;
		
		address = result.childNodes[4].childNodes[0].nodeValue;
		//alert(address);
		zoom = result.childNodes[3].childNodes[0].nodeValue;
		 //zoom = map.getZoom();
		map.clearOverlays();
		if(zoom==100){zoom=2;}else{zoom = map.getZoom();}
		Getlatitude(address,zoom);
		//loadmap(lat,lng,zoom);
		//loadmap(centerlat,centerlon,zoom);
		cluster._removeClusterMarkers();
		cluster.removeMarkers();
		
		markers = result.childNodes[0];
		markersArray=[];
		
		//alert(markers.childNodes.length)
		
		for(i=0;i<markers.childNodes.length;i++)
		{
			details = markers.childNodes[i];
			title = details.childNodes[0].childNodes[0].nodeValue;
			thumb = details.childNodes[1].childNodes[0].nodeValue;
			lat = details.childNodes[2].childNodes[0].nodeValue;
			lon = details.childNodes[3].childNodes[0].nodeValue;
			url = details.childNodes[4].childNodes[0].nodeValue;
			rating = details.childNodes[5].childNodes[0].nodeValue;
			cdate = details.childNodes[6].childNodes[0].nodeValue;
			category = details.childNodes[7].childNodes[0].nodeValue;
			totalvotes = details.childNodes[8].childNodes[0].nodeValue;
			//alert(title);
			marker=newmarker(lat,lon,title,thumb,url,rating,cdate,category,totalvotes);
			markersArray.push(marker);
			 
		}
		
		
		cluster=new ClusterMarker(map, { markers:markersArray, clusterMarkerClick:newClusterMarkerClick } );
		cluster.fitMapToMarkers();
		
		map.savePosition();
	
		hide();
		
		
		
		}
		else
		{
		
		}
		}
		}
} 

function postback(url,formid)
{

var poststr=getPostParameters(formid);
ajaxpack.formname = formid;
geth();
//alert(url+poststr);
ajaxpack.postAjaxRequest(url, poststr, processGetbrand, "txt");
return false;
} 