﻿var ShowNearby, input, map, cluster, pois, markers, icons, cross, loading, context, pixel, isRgc, cat, autodetect;

$(document).ready(function() {
	if (GBrowserIsCompatible()) {
		$(window).unload(function() {GUnload()});
		map = new GMap2(document.getElementById("map"));
		map.addControl(new ShowNearbyMapLogo());
		map.addControl(new GLargeMapControl3D());
		map.addControl(new GMenuMapTypeControl());
		map.enableScrollWheelZoom();
		map.enableContinuousZoom();
  		map.setCenter(new GLatLng(1.352083,103.819836),map.getCurrentMapType().getMaximumResolution()-6);
		
		icons = []; createIcons();
		cross = new GMarker(new GLatLng(1.352083,103.819836),{icon:icons['redmarker'],title:'Drag me!',draggable:true});
		cross.point = cross.getLatLng();
		GEvent.addListener(cross,"dragend",function() {setTimeout("moveCross()",500)});
		map.addOverlay(cross);
		
		cluster = new MarkerClusterer(map,{gridSize:30});
		
		loading = document.createElement('div');
		loading .id = 'loading';
		loading .innerHTML = '<img src="http://api.shownearby.com/images/loading.gif" alt="" style="float:left;" />Loading...';
		map.getContainer().appendChild(loading);
		var pos = new GControlPosition(G_ANCHOR_TOP_LEFT, new GSize(map.getSize().width/2-50,map.getSize().height-28));  
		pos.apply(loading);
		
		context = document.createElement('div');
		context.id = 'context';
		context.innerHTML='<a onclick="changeLoc()">ShowNearby</a>';
		map.getContainer().appendChild(context);
		
		GEvent.addListener(map,"singlerightclick",function(px) {
			pixel = px;
			if (px.x > map.getSize().width - context.clientWidth - 10) {px.x = map.getSize().width - context.clientWidth - 10}
			if (px.y > map.getSize().height - context.clientHeight - 10) {px.y = map.getSize().height - context.clientHeight - 10}
			var pos = new GControlPosition(G_ANCHOR_TOP_LEFT, new GSize(px.x,px.y));  
			pos.apply(context);
			context.style.visibility = "visible";
		});
		
		GEvent.addListener(map,"click",function() {
			context.style.visibility = "hidden";
		});
	}
	ShowNearby = new ShowNearby();
	input = new ShowNearby.autocomplete('input', document.getElementById('search'), document.getElementById('results'));
	cat = 'atm';
	var x = location.href.split(base_url);
	if (x[1]) var y = x[1].split('-near-');
	if (y) { 
		if (y.length == 1) {
			input.populate(decodeURIComponent(y[0]).replace(/-/g, ' '));
		}
		else if (y.length == 2) {
			cat = decodeURIComponent(y[0]).replace(/-/g, ' ');
			input.populate(decodeURIComponent(y[1]).replace(/-/g, ' '));
		}
		else { detectlocation() }
	} else { detectlocation() }
	$('#search').focus();
	$('#map').scrollFollow({offset:10});
});

function detectlocation() {
	var gl = null;
	if (google.gears) gl = google.gears.factory.create('beta.geolocation'); 
	else if (navigator.geolocation) gl = navigator.geolocation;
	gl?gl.getCurrentPosition(
		function(position) { rgc2(new GLatLng(position.coords.latitude,position.coords.longitude)) }, 
		function(err) { alert(err.message) }
	):null;
}

function onselectcallback(acDiv) {
	loading.style.visibility = "visible";
	if (!isRgc) {
		moveCross(new GLatLng(acDiv.results[acDiv.selected].latitude, acDiv.results[acDiv.selected].longitude));
		ShowNearby.loadPOIs('?q='+acDiv.results[acDiv.selected].latitude+','+acDiv.results[acDiv.selected].longitude+'&o=1&t='+cat+'&callback=shownearby');
	}
	else {
		ShowNearby.loadPOIs('?q='+cross.getLatLng().lat()+','+cross.getLatLng().lng()+'&o=1&t='+cat+'&callback=shownearby');
	}
	isRgc = false;
}

// Reverse Geocode
function rgc2(point) {
	loading.style.visibility = "visible";
	ShowNearby.loadPOIs('?q='+point.lat()+','+point.lng()+'&callback=rgccb2');
}
function rgccb2(response) {
	data = JSON.parse(response);
	if (!response||data.status != 200) {alert("SnbSearchStatusCode: "+data.status)} else {
		input.populate(data.pois[0].name);
	}
}

// Reverse Geocode
function rgc(point) {
	loading.style.visibility = "visible";
	ShowNearby.loadPOIs('?q='+point.lat()+','+point.lng()+'&callback=rgccb');
}
function rgccb(response) {
	data = JSON.parse(response);
	if (!response||data.status != 200) {alert("SnbSearchStatusCode: "+data.status)} else {
		isRgc = true;
		input.populate(data.pois[0].name);
	}
}

function setcat(c) {
	cat = c; 
	if (input.acDiv.results) {
		loading.style.visibility = "visible"; 
		ShowNearby.loadPOIs('?q='+cross.getLatLng().lat()+','+cross.getLatLng().lng()+'&o=1&t='+cat+'&callback=shownearby');
	}
}

// ShowNearby POIs
function shownearby(response) {
	data = JSON.parse(response); 
	if (!response||data.status != 200) {alert("SnbSearchStatusCode: "+data.status)} else { 
		pois = []; 
		markers = []; 
		var bounds = new GLatLngBounds();
		bounds.extend(cross.getLatLng());
		for (var i=0; i<data.pois.length; i++) {
			pois[i] = data.pois[i];
			if (i>0 && pois[i].latitude == pois[i-1].latitude && pois[i].longitude == pois[i-1].longitude) {
				pois[i].mi = pois[i-1].mi;
				markers[pois[i].mi] = createMarker(i,1); // multipleIcon
			}
			else {
				pois[i].mi = markers.length;
				markers[pois[i].mi] = createMarker(i,0);
				bounds.extend(markers[pois[i].mi].getLatLng()); // singleIcon
			}
		} 
		map.setCenter(cross.getLatLng()); 
		map.savePosition();
		cluster.clearMarkers(); 
		cluster.addMarkers(markers);
		map.showBounds(bounds,{top:30,right:10,bottom:10,left:50});
		loading.style.visibility = "hidden";
		updateList();
	}
}

function createMarker(i,j) { // j ? multipleIcon : singleIcon;
	var marker = new GMarker(new GLatLng(pois[i].latitude,pois[i].longitude),{icon:icons[cat],title:(j?'Click to see all':pois[i].name)});
	pois[i].html = '<div style="font-weight:bold;">'+pois[i].name+'</div>';
	if (pois[i].address) {
		pois[i].html += pois[i].address+'<br />';
	}
	else {
		var address = '';
		pois[i].country ? address += pois[i].country+', ':'';
		pois[i].postal ? address += pois[i].postal+'<br />':'';
		pois[i].state ? address += pois[i].state+', ':'';
		pois[i].city ? address += pois[i].city+', ':'';
		pois[i].locality ? address += pois[i].locality+', ':'';
		pois[i].road ? address += pois[i].road+', ':'';
		pois[i].block ? address += pois[i].block+', ':'';
		pois[i].building ? address += pois[i].building+', ':'';
		pois[i].floor ? address += pois[i].floor+', ':'';
		pois[i].unit ? address += pois[i].unit+', ':'';
		if (address.substr(address.length-2, 2) == ', ')
			address = address.substr(0, address.length-2);
		pois[i].html += address+'<br />';
	}
	if (pois[i].website) pois[i].html += '<small>Website:</small> <a href="'+(pois[i].website.substr(0,7)!='http://'?'http://':'')+pois[i].website+'" target="_blank">'+pois[i].website+'</a><br />';
	if (pois[i].email) pois[i].html += '<small>Email:</small> <a href="mailto:'+pois[i].email+'">'+pois[i].email+'</a><br />';
	if (pois[i].phone) pois[i].html += '<small>Phone:</small> '+pois[i].phone+'<br />';
	if ('attributes' in pois[i]) {
		pois[i].attributes = pois[i].attributes.replace(/&#34;/g,'"');
		var xml = ShowNearby.loadXMLString(pois[i].attributes);
		$(xml).find('item').each(function(){
			var attr = $(this)[0].attributes;
			for (var j=0; j<attr.length; j++) {
				pois[i].html += (attr[j].name=='key'?'<small>':'')+attr[j].value+(attr[j].name=='key'?':</small> ':'<br />');
			}
		});
	}
	var result = input.acDiv.results[input.acDiv.selected];
	pois[i].html += '<small><a href="http://directions.shownearby.com/from-'+
		ShowNearby.strToSlug(result.name+(result.address?', '+result.address:'')+'-to-'+pois[i].name+(pois[i].address?', '+pois[i].address:''))+
			'" target="_blank">Get Directions</a></small><br />';
	marker.count = j?markers[pois[i].mi].count+1:1; // num of pois in this marker
	marker.html = (j?markers[pois[i].mi].html+'<br />':'')+pois[i].html; // html of all pois in this marker
	GEvent.addListener(marker,"click",function() {myOpenInfoWindowHtml(i,pois[i].mi,1)});
	return marker;
}

function myOpenInfoWindowHtml(i,mi,j) {
	j?map.setCenter(markers[mi].getLatLng()):map.setCenter(markers[mi].getLatLng(),map.getCurrentMapType().getMaximumResolution());
	markers[mi].openInfoWindowHtml('<div style="width:300px;'+(markers[mi].count>5&&j?' height:250px; overflow-y:auto;':'')+' background-color:#fff;">'+(j?markers[mi].html:pois[i].html)+'</div>');
}

function updateList() {
	var row = 1;
	var list = '<ol>';
	for (var i=0; i<pois.length; i++) {
		list += '<li>'+row+'. <span class="heading"><a href="" onclick="myOpenInfoWindowHtml('+i+','+pois[i].mi+',0); return false;">'+pois[i].name+'</a></span>&nbsp;<span class="subheading">('+(new Number(pois[i].distance).toFixed(2))+' km away)</span><br /><small>'+(pois[i].address?pois[i].address:'')+'</small></li>';
		row++;
	}
	list += '</ol>';
	document.getElementById('list').innerHTML = list;
}

function changeLoc() {
	var point = map.fromContainerPixelToLatLng(pixel);
	moveCross(point);
	rgc(point);
	context.style.visibility = "hidden";
}

function moveCross(point) {
	if (point) {
		map.setCenter(point);
		cross.point = point;
		cross.setLatLng(point);
	}
	else {
		if (confirm("ShowNearby?")) {
			cross.point = cross.getLatLng();
			rgc(cross.getLatLng());
		}
		else {
			cross.setLatLng(cross.point);
		}
	}
}

function createIcons() {
	icons['redmarker'] = new GIcon();
	icons['redmarker'].image = 'http://api.shownearby.com/images/redmarker-image.png';
	icons['redmarker'].shadow = 'http://api.shownearby.com/images/redmarker-shadow.png';
	icons['redmarker'].iconSize = new GSize(26,50);
	icons['redmarker'].shadowSize = new GSize(51,50);
	icons['redmarker'].iconAnchor = new GPoint(13,50);
	icons['redmarker'].infoWindowAnchor = new GPoint(13,0);
	icons['redmarker'].printImage = 'http://api.shownearby.com/images/redmarker-printImage.gif';
	icons['redmarker'].mozPrintImage = 'http://api.shownearby.com/images/redmarker-mozPrintImage.gif';
	icons['redmarker'].printShadow = 'http://api.shownearby.com/images/redmarker-printShadow.gif';
	icons['redmarker'].transparent = 'http://api.shownearby.com/images/redmarker-transparent.png';
	icons['redmarker'].imageMap = [14,0,16,1,19,2,21,3,23,4,25,5,25,6,25,7,25,8,25,9,24,10,24,11,24,12,24,13,23,14,23,15,23,16,23,17,22,18,22,19,22,20,21,21,21,22,21,23,21,24,20,25,20,26,20,27,20,28,19,29,19,30,19,31,19,32,18,33,18,34,18,35,18,36,17,37,17,38,17,39,17,40,16,41,16,42,16,43,16,44,15,45,15,46,15,47,15,48,14,49,14,49,14,48,13,47,13,46,13,45,12,44,12,43,12,42,11,41,11,40,11,39,10,38,10,37,10,36,9,35,9,34,9,33,8,32,8,31,8,30,7,29,7,28,7,27,6,26,6,25,6,24,5,23,5,22,5,21,4,20,4,19,4,18,3,17,3,16,3,15,2,14,2,13,2,12,1,11,1,10,0,9,0,8,0,7,0,6,1,5,2,4,4,3,6,2,8,1,10,0];
	
	icons['atm'] = new GIcon();
	icons['atm'].image = 'images/icons/atm-image.png';
	icons['atm'].shadow = 'images/icons/atm-shadow.png';
	icons['atm'].iconSize = new GSize(32,37);
	icons['atm'].shadowSize = new GSize(51,37);
	icons['atm'].iconAnchor = new GPoint(16,37);
	icons['atm'].infoWindowAnchor = new GPoint(16,0);
	icons['atm'].printImage = 'images/icons/atm-printImage.gif';
	icons['atm'].mozPrintImage = 'images/icons/atm-mozPrintImage.gif';
	icons['atm'].printShadow = 'images/icons/atm-printShadow.gif';
	icons['atm'].transparent = 'images/icons/atm-transparent.png';
	icons['atm'].imageMap = [29,0,30,1,31,2,31,3,31,4,31,5,31,6,31,7,31,8,31,9,31,10,31,11,31,12,31,13,31,14,31,15,31,16,31,17,31,18,31,19,31,20,31,21,31,22,31,23,31,24,31,25,31,26,31,27,31,28,31,29,30,30,29,31,23,32,22,33,21,34,20,35,19,36,12,36,11,35,10,34,9,33,8,32,2,31,1,30,0,29,0,28,0,27,0,26,0,25,0,24,0,23,0,22,0,21,0,20,0,19,0,18,0,17,0,16,0,15,0,14,0,13,0,12,0,11,0,10,0,9,0,8,0,7,0,6,0,5,0,4,0,3,0,2,1,1,2,0];	
	
	icons['bus stop'] = new GIcon();
	icons['bus stop'].image = 'images/icons/bus-image.png';
	icons['bus stop'].shadow = 'images/icons/bus-shadow.png';
	icons['bus stop'].iconSize = new GSize(32,37);
	icons['bus stop'].shadowSize = new GSize(51,37);
	icons['bus stop'].iconAnchor = new GPoint(16,37);
	icons['bus stop'].infoWindowAnchor = new GPoint(16,0);
	icons['bus stop'].printImage = 'images/icons/bus-printImage.gif';
	icons['bus stop'].mozPrintImage = 'images/icons/bus-mozPrintImage.gif';
	icons['bus stop'].printShadow = 'images/icons/bus-printShadow.gif';
	icons['bus stop'].transparent = 'images/icons/bus-transparent.png';
	icons['bus stop'].imageMap = [29,0,30,1,31,2,31,3,31,4,31,5,31,6,31,7,31,8,31,9,31,10,31,11,31,12,31,13,31,14,31,15,31,16,31,17,31,18,31,19,31,20,31,21,31,22,31,23,31,24,31,25,31,26,31,27,31,28,31,29,30,30,29,31,23,32,22,33,21,34,20,35,19,36,12,36,11,35,10,34,9,33,8,32,2,31,1,30,0,29,0,28,0,27,0,26,0,25,0,24,0,23,0,22,0,21,0,20,0,19,0,18,0,17,0,16,0,15,0,14,0,13,0,12,0,11,0,10,0,9,0,8,0,7,0,6,0,5,0,4,0,3,0,2,1,1,2,0];	
	
	icons['carpark'] = new GIcon();
	icons['carpark'].image = 'images/icons/parking-image.png';
	icons['carpark'].shadow = 'images/icons/parking-shadow.png';
	icons['carpark'].iconSize = new GSize(32,37);
	icons['carpark'].shadowSize = new GSize(51,37);
	icons['carpark'].iconAnchor = new GPoint(16,37);
	icons['carpark'].infoWindowAnchor = new GPoint(16,0);
	icons['carpark'].printImage = 'images/icons/parking-printImage.gif';
	icons['carpark'].mozPrintImage = 'images/icons/parking-mozPrintImage.gif';
	icons['carpark'].printShadow = 'images/icons/parking-printShadow.gif';
	icons['carpark'].transparent = 'images/icons/parking-transparent.png';
	icons['carpark'].imageMap = [29,0,30,1,31,2,31,3,31,4,31,5,31,6,31,7,31,8,31,9,31,10,31,11,31,12,31,13,31,14,31,15,31,16,31,17,31,18,31,19,31,20,31,21,31,22,31,23,31,24,31,25,31,26,31,27,31,28,31,29,30,30,29,31,23,32,22,33,21,34,20,35,19,36,12,36,11,35,10,34,9,33,8,32,2,31,1,30,0,29,0,28,0,27,0,26,0,25,0,24,0,23,0,22,0,21,0,20,0,19,0,18,0,17,0,16,0,15,0,14,0,13,0,12,0,11,0,10,0,9,0,8,0,7,0,6,0,5,0,4,0,3,0,2,1,1,2,0];	
	
	icons['erp'] = new GIcon();
	icons['erp'].image = 'images/icons/erp-image.png';
	icons['erp'].shadow = 'images/icons/erp-shadow.png';
	icons['erp'].iconSize = new GSize(32,37);
	icons['erp'].shadowSize = new GSize(51,37);
	icons['erp'].iconAnchor = new GPoint(16,37);
	icons['erp'].infoWindowAnchor = new GPoint(16,0);
	icons['erp'].printImage = 'images/icons/erp-printImage.gif';
	icons['erp'].mozPrintImage = 'images/icons/erp-mozPrintImage.gif';
	icons['erp'].printShadow = 'images/icons/erp-printShadow.gif';
	icons['erp'].transparent = 'images/icons/erp-transparent.png';
	icons['erp'].imageMap = [29,0,30,1,31,2,31,3,31,4,31,5,31,6,31,7,31,8,31,9,31,10,31,11,31,12,31,13,31,14,31,15,31,16,31,17,31,18,31,19,31,20,31,21,31,22,31,23,31,24,31,25,31,26,31,27,31,28,31,29,30,30,29,31,23,32,22,33,21,34,20,35,19,36,12,36,11,35,10,34,9,33,8,32,2,31,1,30,0,29,0,28,0,27,0,26,0,25,0,24,0,23,0,22,0,21,0,20,0,19,0,18,0,17,0,16,0,15,0,14,0,13,0,12,0,11,0,10,0,9,0,8,0,7,0,6,0,5,0,4,0,3,0,2,1,1,2,0];	
	
	icons['fast food'] = new GIcon();
	icons['fast food'].image = 'images/icons/fastfood-image.png';
	icons['fast food'].shadow = 'images/icons/fastfood-shadow.png';
	icons['fast food'].iconSize = new GSize(32,37);
	icons['fast food'].shadowSize = new GSize(51,37);
	icons['fast food'].iconAnchor = new GPoint(16,37);
	icons['fast food'].infoWindowAnchor = new GPoint(16,0);
	icons['fast food'].printImage = 'images/icons/fastfood-printImage.gif';
	icons['fast food'].mozPrintImage = 'images/icons/fastfood-mozPrintImage.gif';
	icons['fast food'].printShadow = 'images/icons/fastfood-printShadow.gif';
	icons['fast food'].transparent = 'images/icons/fastfood-transparent.png';
	icons['fast food'].imageMap = [29,0,30,1,31,2,31,3,31,4,31,5,31,6,31,7,31,8,31,9,31,10,31,11,31,12,31,13,31,14,31,15,31,16,31,17,31,18,31,19,31,20,31,21,31,22,31,23,31,24,31,25,31,26,31,27,31,28,31,29,30,30,29,31,23,32,22,33,21,34,20,35,19,36,12,36,11,35,10,34,9,33,8,32,2,31,1,30,0,29,0,28,0,27,0,26,0,25,0,24,0,23,0,22,0,21,0,20,0,19,0,18,0,17,0,16,0,15,0,14,0,13,0,12,0,11,0,10,0,9,0,8,0,7,0,6,0,5,0,4,0,3,0,2,1,1,2,0];	
	
	icons['hotel'] = new GIcon();
	icons['hotel'].image = 'images/icons/hotel-image.png';
	icons['hotel'].shadow = 'images/icons/hotel-shadow.png';
	icons['hotel'].iconSize = new GSize(32,37);
	icons['hotel'].shadowSize = new GSize(51,37);
	icons['hotel'].iconAnchor = new GPoint(16,37);
	icons['hotel'].infoWindowAnchor = new GPoint(16,0);
	icons['hotel'].printImage = 'images/icons/hotel-printImage.gif';
	icons['hotel'].mozPrintImage = 'images/icons/hotel-mozPrintImage.gif';
	icons['hotel'].printShadow = 'images/icons/hotel-printShadow.gif';
	icons['hotel'].transparent = 'images/icons/hotel-transparent.png';
	icons['hotel'].imageMap = [29,0,30,1,31,2,31,3,31,4,31,5,31,6,31,7,31,8,31,9,31,10,31,11,31,12,31,13,31,14,31,15,31,16,31,17,31,18,31,19,31,20,31,21,31,22,31,23,31,24,31,25,31,26,31,27,31,28,31,29,30,30,29,31,23,32,22,33,21,34,20,35,19,36,12,36,11,35,10,34,9,33,8,32,2,31,1,30,0,29,0,28,0,27,0,26,0,25,0,24,0,23,0,22,0,21,0,20,0,19,0,18,0,17,0,16,0,15,0,14,0,13,0,12,0,11,0,10,0,9,0,8,0,7,0,6,0,5,0,4,0,3,0,2,1,1,2,0];	
	
	icons['petrol station'] = new GIcon();
	icons['petrol station'].image = 'images/icons/gazstation-image.png';
	icons['petrol station'].shadow = 'images/icons/gazstation-shadow.png';
	icons['petrol station'].iconSize = new GSize(32,37);
	icons['petrol station'].shadowSize = new GSize(51,37);
	icons['petrol station'].iconAnchor = new GPoint(16,37);
	icons['petrol station'].infoWindowAnchor = new GPoint(16,0);
	icons['petrol station'].printImage = 'images/icons/gazstation-printImage.gif';
	icons['petrol station'].mozPrintImage = 'images/icons/gazstation-mozPrintImage.gif';
	icons['petrol station'].printShadow = 'images/icons/gazstation-printShadow.gif';
	icons['petrol station'].transparent = 'images/icons/gazstation-transparent.png';
	icons['petrol station'].imageMap = [29,0,30,1,31,2,31,3,31,4,31,5,31,6,31,7,31,8,31,9,31,10,31,11,31,12,31,13,31,14,31,15,31,16,31,17,31,18,31,19,31,20,31,21,31,22,31,23,31,24,31,25,31,26,31,27,31,28,31,29,30,30,29,31,23,32,22,33,21,34,20,35,19,36,12,36,11,35,10,34,9,33,8,32,2,31,1,30,0,29,0,28,0,27,0,26,0,25,0,24,0,23,0,22,0,21,0,20,0,19,0,18,0,17,0,16,0,15,0,14,0,13,0,12,0,11,0,10,0,9,0,8,0,7,0,6,0,5,0,4,0,3,0,2,1,1,2,0];	
	
	icons['restaurant'] = new GIcon();
	icons['restaurant'].image = 'images/icons/restaurant-image.png';
	icons['restaurant'].shadow = 'images/icons/restaurant-shadow.png';
	icons['restaurant'].iconSize = new GSize(32,37);
	icons['restaurant'].shadowSize = new GSize(51,37);
	icons['restaurant'].iconAnchor = new GPoint(16,37);
	icons['restaurant'].infoWindowAnchor = new GPoint(16,0);
	icons['restaurant'].printImage = 'images/icons/restaurant-printImage.gif';
	icons['restaurant'].mozPrintImage = 'images/icons/restaurant-mozPrintImage.gif';
	icons['restaurant'].printShadow = 'images/icons/restaurant-printShadow.gif';
	icons['restaurant'].transparent = 'images/icons/restaurant-transparent.png';
	icons['restaurant'].imageMap = [29,0,30,1,31,2,31,3,31,4,31,5,31,6,31,7,31,8,31,9,31,10,31,11,31,12,31,13,31,14,31,15,31,16,31,17,31,18,31,19,31,20,31,21,31,22,31,23,31,24,31,25,31,26,31,27,31,28,31,29,30,30,29,31,23,32,22,33,21,34,20,35,19,36,12,36,11,35,10,34,9,33,8,32,2,31,1,30,0,29,0,28,0,27,0,26,0,25,0,24,0,23,0,22,0,21,0,20,0,19,0,18,0,17,0,16,0,15,0,14,0,13,0,12,0,11,0,10,0,9,0,8,0,7,0,6,0,5,0,4,0,3,0,2,1,1,2,0];	

}
