var suggDivCount=0;
var lmStore,lmType="";
var offStore;
var serviceArray=new Array();
var serCount=0;
var editformDiv=0;
var officeDeptStore=new dojo.data.ItemFileReadStore({url:"/igsg/office_dep"});
var officeCatStore=new dojo.data.ItemFileReadStore({url:"/igsg/office_cat"});
var buildcatStore=new dojo.data.ItemFileReadStore({url:"/igsg/buildcats/"});
var rankStore=new dojo.data.ItemFileReadStore({url:"/igsg/officerranks/"});
var buildStore;
var  deleteId;
function getUserSuggestion()
{
	serCount=0;
	map.events.unregister('mousedown',map,getLandMark);
	suggDivCount++;
	showSidebar();
	var parentDiv=document.getElementById("sidebarContent");
	parentDiv.innerHTML="";
	var usersuggDiv=document.createElement("div");
	usersuggDiv.setAttribute('id','usersugg');
	usersuggDiv.className="searchOptionDiv";	
	usersuggDiv.innerHTML="<div id=suggDivContainer"+suggDivCount+" style='height: 100%; overflow: hidden;'><div id=suggPane_1"+suggDivCount+" style='height:auto;overflow:hidden;visibility:hidden;padding-left:5%;'><div id=listTabContainer"+suggDivCount+"  style='height:380px;'><div id=officeListContainer"+suggDivCount+"><div id=officeList class=advresult></div></div><div id=placeListContainer"+suggDivCount+"><div id=listSugg class=advresult></div></div></div></div><div id=suggPane_2"+suggDivCount+" style='height:auto;overflow:hidden;visibility:hidden;padding-left:7%;background-color:#f3fcfd;'><center><div ><br><table width=100% ><tr><td id=placeLmark1></td><td id=placeLmark2></td></tr><tr><td id=lmName1></td><td id=lmName></td></tr><tr><td id=urName1></td><td id=urName></td></tr><tr><td id=eAddress1></td><td id=eAddress></td></tr><tr><td id=desc1></td><td id=desc></td></tr><tr><td><input type=hidden id=landx /></td><td><input type=hidden id=landy /></td></tr><tr><td colspan=2 ><center><span id=addmsg style=color:green></span></center></td></tr><tr><td colspan=2 id=validationTd></td></tr><tr><td colspan=2><center><span id=addsuggbtn></span><span id=clearsuggbtn></span><span id=addMoreBtn1></span></center></td></tr></table></div></center></div><div id=suggPane_4"+suggDivCount+" style='height:auto;overflow:hidden;visibility:hidden;padding-left:7%;background-color:#f3fcfd;'><div id=buildingDiv></div><center><div id=newOfficeDiv></div><div><table><tr><td colspan=2 ><center><span id=addmsg2 style=color:green></span></center></td></tr><tr><td colspan=2 id=validationTd2></td></tr><tr><td colspan=2><center>	<span id=addsuggbtn2></span><span id=clearsuggbtn2></span><span id=proceedButton></span><span id=addMoreBtn2></span></center></td></tr></table></div></center></div></div>";
	
	parentDiv.appendChild(usersuggDiv);
	adjustCenter();	
	
	showlist();	
	
	var clearsuggnButtonTd=document.getElementById("clearsuggbtn");
	clearsuggnButtonTd.innerHTML="";
	var  clearsuggnButton= new dijit.form.Button(
	{ 
		id:"clearPlace"+suggDivCount,
		label: "Cancel",
		alt: "clear",
		title: "clear",
		onClick:clearSuuggestion
	}, document.createElement('div'));
        clearsuggnButtonTd.appendChild(clearsuggnButton.domNode);
	clearsuggnButton.startup();
	
	var clearsuggnButtonTd=document.getElementById("clearsuggbtn2");
	clearsuggnButtonTd.innerHTML="";
	var  clearsuggnButton= new dijit.form.Button(
	{ 
		id:"clearOffice"+suggDivCount,
		label: "Cancel",
		alt: "clear",
		title: "clear",
		onClick:clearSuuggestion
	}, document.createElement('div'));
        clearsuggnButtonTd.appendChild(clearsuggnButton.domNode);
	clearsuggnButton.startup();
	
	
	var tc1=new dijit.layout.AccordionPane(
	{
		title:'Places/Land Mark',
		id:"placesList"+suggDivCount				
	}, document.getElementById("placeListContainer"+suggDivCount));
	tc1.startup();
	
	
	if(document.getElementById("log").value==1)
	{	
		var tc2=new dijit.layout.AccordionPane(
		{
			title:'Offices',
			id:"officesList"+suggDivCount			
		}, document.getElementById("officeListContainer"+suggDivCount));
		tc2.startup();
		showOfficeList();
	}
	
	var tc=new dijit.layout.AccordionContainer(
	{
		id:"tcmain"+suggDivCount
				
	}, document.getElementById("listTabContainer"+suggDivCount));
	tc.startup();
	
	
	var acp1=new dijit.layout.AccordionPane(
	{
		title:'Recent suggestions from Users',
		id:"suggFields"+suggDivCount,
		onSelected:selectList
		
	}, document.getElementById("suggPane_1"+suggDivCount));
	acp1.startup();
	
	var acp2=new dijit.layout.AccordionPane(
	{
		title:'Add Place/ Land Mark',
		id:"addPlace"+suggDivCount,
		selected:true,
		onSelected:selectPlace			
	}, document.getElementById("suggPane_2"+suggDivCount));
	acp2.startup();
	
	if(document.getElementById("log").value==1)
	{
		var acp4=new dijit.layout.AccordionPane(
		{
			title:'Add Office',
			id:"addOffice"+suggDivCount,
			onSelected:selectOffice					
		}, document.getElementById("suggPane_4"+suggDivCount));
		acp4.startup();
	}
		
	var ac=new dijit.layout.AccordionContainer(
	{
		duration:200,
		id:"suggPane"+suggDivCount
				
	}, document.getElementById("suggDivContainer"+suggDivCount));
	ac.startup();
	
	//map.events.register('mousedown',map,getLandMark);
	
}
function selectList()
{
	if(lmPoint!=undefined) 
	{
		lmpointMarker.removeMarker(lmPoint);
		lmPoint.destroy();
		lmPoint=null;
	}
	map.events.unregister('mousedown',map,getLandMark);
}
function selectPlace()
{

	lmType='Place';
	document.getElementById("addmsg").innerHTML="<span style=color:green;text-align:center;> <b>Right-Click on the map to select your place/ Landmark</b></span>";
	if(lmPoint!=undefined) 
	{
		lmpointMarker.removeMarker(lmPoint);
		lmPoint.destroy();
		lmPoint=null;
	}
	map.events.register('mousedown',map,getLandMark);
}
function selectOffice()
{
	
	if(document.getElementById("log").value==1)
	{
		lmType='Office';
		document.getElementById("addmsg2").innerHTML="<span style=color:green;text-align:center;> <b>Right-Click on the map to select your Office</b></span>";
		if(lmPoint!=undefined) 
		{
			lmpointMarker.removeMarker(lmPoint);
			lmPoint.destroy();
			lmPoint=null;
		}
		map.events.register('mousedown',map,getLandMark);
	}
	else
	{
		map.events.unregister('mousedown',map,getLandMark);
		document.getElementById("addmsg2").innerHTML="<span style=color:red;text-align:center;> <b>Sorry !!!<br>You are not a valid user</b></span>";
	}
}



function clearSuuggestion()
{
	map.events.unregister('mousedown',map,getLandMark);
	if(lmPoint!=undefined) 
	{
		lmpointMarker.removeMarker(lmPoint);
		lmPoint.destroy();
		lmPoint=null;
	}		
	if(document.getElementById("usersugg")!=null)
		removeElement("usersugg");
	getHelp();
	adjustCenter();
}
function showlist()
{
	var content="";
	var name1 = new Array();
	var type = new Array();
	var x = new Array();
	var y = new Array();
	var id = new Array();
	lmStore=new dojo.data.ItemFileReadStore({url: "/igsg/ListLandMark/"});
	var divid=document.getElementById("listSugg");
	divid.style.cursor="pointer";			
	divid.innerHTML="";
	divid.innerHTML="<div class=serchloading ><center>searching...<br><img src='/giskerala/images/loading1.gif' /></center></div>";
	var request = lmStore.fetch({onComplete:function(items, request)
	{
		if(items.length<1)
		{
			divid.innerHTML="<div class=serchloading style='color:red;font-weight:bold'><center><b>You dont have any suggestion yet now !!!</b></center></div>";
		}
		else
		{
			for(var i=0;i<items.length;i++)
			{				
				type[i]=lmStore.getValue(items[i],"type");
				name1[i]=lmStore.getValue(items[i],"name");				
				id[i]=lmStore.getValue(items[i],"id");
				content+="<ul ><li><b><a hre=# onclick=getListCloud("+id[i]+") >"+name1[i]+"</a> </b>  (" +type[i]+")</li></ul>";
			}
			divid.innerHTML=content;
		}
	
	},onError:showSuggError});
}
function showOfficeList()
{
	var content="";
	var name1 = new Array();
	var type = new Array();
	var x = new Array();
	var y = new Array();
	var id = new Array();
	offStore=new dojo.data.ItemFileReadStore({url: "/igsg/ListOffice/"});
	var divid=document.getElementById("officeList");
	divid.style.cursor="pointer";			
	divid.innerHTML="";
	divid.innerHTML="<div class=serchloading ><center>searching...<br><img src='/giskerala/images/loading1.gif' /></center></div>";
	var request = offStore.fetch({onComplete:function(items, request)
	{
		if(items.length<1)
		{
			divid.innerHTML="<div class=serchloading style='color:red;font-weight:bold'><center><b>You dont have any suggestion yet now !!!</b></center></div>";
		}
		else
		{
			for(var i=0;i<items.length;i++)
			{				
				name1[i]=offStore.getValue(items[i],"name");				
				id[i]=offStore.getValue(items[i],"id");
				content+="<tr><td><b><a hre=# onclick=getOffListCloud("+id[i]+") >"+name1[i]+"</a> </b></td><td> <a hre=# onClick=editOffices("+id[i]+"); ><img src='/giskerala/images/edit.png' width=15 height=15 />Edit</a> </td><td> <a hre=# onClick=deleteConfirmation("+id[i]+"); ><img src='/giskerala/images/delete.png' width=15 height=15 title=delete /></a> </td></tr>";
			}
			//alert(content);
			divid.innerHTML="<table width=100% >"+content+"</table>";
		}
	
	},onError:showSuggError});
}
function deleteConfirmation(id)
{
	deleteId=id;
	dijit.byId('delOfficeDiv').show();
	//dijit.byId('delOfficeDiv')._underlay.hide();
	/**/
}
function deleteOffice()
{
	
	var delRequest=new createObject();
	delRequest.open('GET',"/igsg/DeleteOffice/?id="+deleteId,true);
	delRequest.onreadystatechange=function()
	{
		
		if(delRequest.readyState==4)
		{
			if(delRequest.responseText=='yes')
			{
				getHelp();
				getUserSuggestion();
				getEditOffice();
			}
			else if(delRequest.responseText=='no')
			{
				alert("Can't delete");
			}
		}
	}
	delRequest.send(null);
	dijit.byId('delOfficeDiv').hide();
}
function showSuggError(err)
{
	//alert(err);
	var divid=document.getElementById("listSugg");			
	divid.innerHTML="";
	divid.innerHTML="<div id=advserchloading class=advserchloading style=color:red;><center>Unable to load the result !!!<br>Please try after some time...</center></div>";
}
function getListCloud(id)
{
	
	var id1,x,y,name1,email,user,desc,type;
	var request = lmStore.fetch({onComplete:function(items, request)
	{
		for(var i=0;i<items.length;i++)
		{
			id1=lmStore.getValue(items[i],"id");
			if(id1==id)
			{
				//alert(id);
				name1=lmStore.getValue(items[i],"name");
				x=lmStore.getValue(items[i],"long");
				y=lmStore.getValue(items[i],"lat");
				//email=lmStore.getValue(items[i],"email");
				user=lmStore.getValue(items[i],"user");
				desc=lmStore.getValue(items[i],"desc");
				type=lmStore.getValue(items[i],"type");
			}
			
		}
		var coords=new OpenLayers.LonLat(x,y);
		showOfficeindicator(coords);
		content="<br><div class=popTable ><table width=250px><tr><th colspan=2><b>"+name1+"</b></th></tr><tr><td >Type: </td><td>"+type+"</td></tr><tr><td >User: </td><td>"+user+"</td></tr><tr><td colspan=2>"+desc+"</td></tr><tr><td></td><td></td></tr></table></div>";
		if (searchCloud)
		{	
			map.removePopup(searchCloud);
			searchCloud.destroy();
			searchCloud=null;
		}
			
		searchCloud = new OpenLayers.Popup.FramedCloud("Searching",coords,null,content,null,true,deletePlaceOfficePoint);
       		coords.popup = searchCloud;
        	map.addPopup(searchCloud);
	}});
}
function getOffListCloud(id)
{
	
	var id1,x,y,name1,department,address,pin,build;
	var request = offStore.fetch({onComplete:function(items, request)
	{
		for(var i=0;i<items.length;i++)
		{
			id1=offStore.getValue(items[i],"id");
			
			if(id1==id)
			{
				name1=offStore.getValue(items[i],"name");
				build=offStore.getValue(items[i],"build");
				y=offStore.getValue(items[i],"long");
				x=offStore.getValue(items[i],"lat");
				department=offStore.getValue(items[i],"department");
				address=offStore.getValue(items[i],"address");
				//pin=offStore.getValue(items[i],"pin");
			}
			
		}
		map.setCenter(new OpenLayers.LonLat(y,x),7);
		var coords=new OpenLayers.LonLat(y,x);
		showOfficeindicator(coords);
		content="<br><div class=popTable ><table width=250px><tr><th colspan=2><b>"+name1+"</b></th></tr><tr><td >Building Name: </td><td>"+build+"</td></tr><tr><td >Department: </td><td>"+department+"</td></tr><tr><td>Address: </td><td>"+address+"</td></tr></table></div>";
		if (searchCloud)
		{	
			map.removePopup(searchCloud);
			searchCloud.destroy();
			searchCloud=null;
		}
			
		searchCloud = new OpenLayers.Popup.FramedCloud("Searching",coords,null,content,null,true,deletePlaceOfficePoint);
       		coords.popup = searchCloud;
        	map.addPopup(searchCloud);
	}});
}
function getLandMark(e)
{
	var ieClick=0,mozClick=0,landxy;
	if (navigator.appName == 'Microsoft Internet Explorer')
		ieClick=e.button;
	else
		mozClick=e.which;
	if(ieClick==2 || mozClick==3)
	{
		var landxy=map.getLonLatFromViewPortPx(e.xy);
		if(lmPoint!=undefined) 
		{
			lmpointMarker.removeMarker(lmPoint);
			lmPoint.destroy();
			lmPoint=null;
		}	
		var size = new OpenLayers.Size(10,15);
		var offset = new OpenLayers.Pixel(-(size.w/2), -size.h);
		var icon = new OpenLayers.Icon("/giskerala/images/marker.png",size,offset);
		lmPoint=new OpenLayers.Marker(landxy,icon);
		lmpointMarker.addMarker(lmPoint);
		if(lmType=='Place')
		{
			//document.getElementById("addsuggbtn2").innerHTML="";
			confirmButton('addsuggbtn');
		}
		else if(lmType=='Office')
		{
			//document.getElementById("addsuggbtn").innerHTML="";
			confirmButton('addsuggbtn2');
		}
		document.getElementById("landx").value=landxy.lat;
		document.getElementById("landy").value=landxy.lon;
		
	}
	

}
var confmBtn=0;
function confirmButton(type)
{
	confmBtn++;
	var addsuggnButtonTd=document.getElementById(type);
	//alert(type);
	addsuggnButtonTd.innerHTML="";
	var  addsuggnButton= new dijit.form.Button(
	{ 
		id:"confirmbtn"+confmBtn,
		label: "Confirm Point",
		alt: "Confirm",
		title: "Confirm",
		onClick:createaddForm
	}, document.createElement('div'));
        addsuggnButtonTd.appendChild(addsuggnButton.domNode);
	addsuggnButton.startup();
}

var createformDiv=0;
var LmtypeStore = new dojo.data.ItemFileWriteStore({data: {identifier: 'option', items:[{"option": "Place"}, {"option": "Landmark"}]}});
function createaddForm()
{
	map.events.unregister('mousedown',map,getLandMark);
	document.getElementById("addmsg").innerHTML="";
	document.getElementById("addmsg2").innerHTML="";
	//document.getElementById("addmsg3").innerHTML="";
	createformDiv++;
	
	if(lmType=='Place')
	{
		document.getElementById("placeLmark1").innerHTML="Type";
		var typeTd=document.getElementById("placeLmark2");
		typeTd.innerHTML="";
		var typeCombobox= new dijit.form.ComboBox(
		{
			id:"placeLmarkType"+createformDiv,
			value: '--Select Type --',
			store: LmtypeStore,
			searchAttr:"option",
			onChange:getplaceLm		
		},  document.createElement('div'));	
		typeTd.appendChild(typeCombobox.domNode);
		typeCombobox.startup();
		
		
		var lmNameTd=document.getElementById("lmName");
		lmNameTd.innerHTML="";
		var lmNameTextbox= new dijit.form.TextBox(
		{
			id:"lmNames"+createformDiv		
		},  document.createElement('div'));	
		lmNameTd.appendChild(lmNameTextbox.domNode);
		lmNameTextbox.startup();
	
		document.getElementById("urName1").innerHTML="Your Name";
		var urNameTd=document.getElementById("urName");
		urNameTd.innerHTML="";
		var urNameTextbox= new dijit.form.TextBox(
		{
			id:"urNames"+createformDiv		
		},  document.createElement('div'));	
		urNameTd.appendChild(urNameTextbox.domNode);
		urNameTextbox.startup();
	
		document.getElementById("eAddress1").innerHTML="Email Address";
		var eAddressTd=document.getElementById("eAddress");
		eAddressTd.innerHTML="";
		var eAddressTextbox= new dijit.form.TextBox(
		{
			id:"eAddress"+createformDiv		
		},  document.createElement('div'));	
		eAddressTd.appendChild(eAddressTextbox.domNode);
		eAddressTextbox.startup();
	
		document.getElementById("desc1").innerHTML="Description";
		var descTd=document.getElementById("desc");
		descTd.innerHTML="";
		var descTextarea= new dijit.form.Textarea(
		{
			id:"desc"+createformDiv		
		},  document.createElement('div'));	
		descTd.appendChild(descTextarea.domNode);
		descTextarea.startup();
	
		var addsuggnButtonTd=document.getElementById("addsuggbtn");
		addsuggnButtonTd.innerHTML="";
		var  addsuggnButton= new dijit.form.Button(
		{ 
			id:"add"+createformDiv,
			label: "Add",
			alt: "add",
			title: "add",
			onClick:addPlaceLmark
		}, document.createElement('div'));
		addsuggnButtonTd.appendChild(addsuggnButton.domNode);
		addsuggnButton.startup();
	}
	var x,y;
	var na=new Array();
	var id=new Array();
	if(lmType=='Office')
	{
		document.getElementById("buildingDiv").innerHTML="<ul ><li  ><span id=buildList1 ></span><ul id=buildList2 ></ul></li></ul><div id=buildTable><table><tr><td id=buildName1></td><td id=buildName2></td></tr><tr><td id=buildCat1></td><td id=buildCat2></td></tr><tr><td id=buildDesc1></td><td id=buildDesc2></td></tr><tr><td colspan=2 ><center><span id=bAddMsg style='color:green;'></span></center></td></tr></table></div>";
		//<li id=newBuilding1><a href=# onClick=createNewBuildingForm(); >New Building</a></li>
		var NewButton=document.getElementById("proceedButton");
		//alert(type);
		NewButton.innerHTML="";
		var  New= new dijit.form.Button(
		{ 
			label: "New Building",
			alt: "New",
			title: "New",
			onClick:createNewBuildingForm
		}, document.createElement('div'));
		NewButton.appendChild(New.domNode);
		New.startup();
		
		
		document.getElementById("addsuggbtn2").innerHTML="";
		map.events.unregister('mousedown',map,getLandMark);
		x=document.getElementById("landx").value;
		y=document.getElementById("landy").value;
		//buildStore=new dojo.data.ItemFileReadStore({url: "/igsg/BuildConfirm/?long=723337.66425661&lat=932809.52169668"});
		buildStore=new dojo.data.ItemFileReadStore({url: "/igsg/BuildConfirm/?long="+x+"&lat="+y});
		var divid=document.getElementById("buildList2");
		divid.style.cursor="pointer";			
		divid.innerHTML="";
		var content="";
		divid.innerHTML="<div class=serchloading ><center>Loading...<br><img src='/giskerala/images/loading1.gif' /></center></div>";
		var request = buildStore.fetch({onComplete:function(items, request)
		{
			if(items.length<1)
			{
				document.getElementById("buildList1").innerHTML="";
				divid.innerHTML="";
			}
			else
			{
				document.getElementById("buildList1").innerHTML="Following Buildinds are in the selected Location. If your office is in any of these building Click on the Building Name";
				for(var i=0;i<items.length;i++)
				{				
					na[i]=buildStore.getValue(items[i],"name");
					id[i]=buildStore.getValue(items[i],"id");
					content+="<li><b><a hre=# onClick=getSelectedBuilding("+id[i]+") >"+na[i]+"</a></li>";
				}
				divid.innerHTML=content;
			}
	
		},onError:showSuggError});
		
	}
	
	
}
var newBuildingFlag=0;
var selectedBuilding="";
var selectedBuildingId="";
function getSelectedBuilding(id)
{
	//alert(id);
	newBuildingFlag=0;
	var id1;
	var request = buildStore.fetch({onComplete:function(items, request)
	{
		for(var i=0;i<items.length;i++)
		{				
			id1=buildStore.getValue(items[i],"id");
			if(id1==id)
			{
				selectedBuilding=buildStore.getValue(items[i],"name");
				selectedBuildingId=id1;
			}				
		}				

	},onError:showSuggError});
	createAddOfficeForm();
}

var buildingFormDiv=0;
function createNewBuildingForm()
{
	buildingFormDiv++;
	newBuildingFlag=1;
	document.getElementById("buildList1").innerHTML="";
	document.getElementById("buildList2").innerHTML="";
	document.getElementById("proceedButton").innerHTML="";
	
	
	document.getElementById("buildName1").innerHTML="Building name";
	document.getElementById("buildCat1").innerHTML="Building Category";
	document.getElementById("buildDesc1").innerHTML="Description";
	
	document.getElementById("buildName2").innerHTML="";
	document.getElementById("buildCat2").innerHTML="";
	document.getElementById("buildDesc2").innerHTML="";
	
	var buildName= new dijit.form.TextBox(
	{
		id:"buildName"+buildingFormDiv		
	},  document.createElement('div'));	
	document.getElementById("buildName2").appendChild(buildName.domNode);
	buildName.startup();
	
	var buildcat= new dijit.form.ComboBox(
	{
		id:"buildcat"+buildingFormDiv,
		value:"--Select Category--",
		store: buildcatStore,
		searchAttr:"name"		
	},  document.createElement('div'));	
	document.getElementById("buildCat2").appendChild(buildcat.domNode);
	buildcat.startup();
	
	var buildDesc= new dijit.form.Textarea(
	{
		id:"buildDesc"+buildingFormDiv
	},  document.createElement('div'));	
	document.getElementById("buildDesc2").appendChild(buildDesc.domNode);
	buildDesc.startup();
	
	var  addButton= new dijit.form.Button(
	{ 
		label: "Add Building",
		alt: "Add",
		title: "Add",
		onClick:addBuiding
	}, document.createElement('div'));
        document.getElementById("proceedButton").appendChild(addButton.domNode);
	addButton.startup();
	
}
function addBuiding()
{
	var valid=validateBuildForm();
	if(valid)
	{
		var param="name="+dijit.byId("buildName"+buildingFormDiv).value+"&cat="+dijit.byId("buildcat"+buildingFormDiv).value+"&desc="+dijit.byId("buildDesc"+buildingFormDiv).value+"&long="+document.getElementById("landx").value+"&lat="+document.getElementById("landy").value;
		var builAddRequest=new createObject();
		builAddRequest.open('GET',"/igsg/addBuild/?"+param,true);
		builAddRequest.onreadystatechange=function()
		{
			if(builAddRequest.readyState==4)
			{
				document.getElementById("bAddMsg").innerHTML="<b>"+builAddRequest.responseText;	
				if(builAddRequest.responseText!=null)
				{
					selectedBuilding=dijit.byId("buildName"+buildingFormDiv).value;
					selectedBuildingId=builAddRequest.responseText;
					createAddOfficeForm();
				}
			}
		}
		builAddRequest.send(null);
	}
	
}
function createAddOfficeForm()
{
	//alert(selectedBuilding);
	
	document.getElementById("buildingDiv").innerHTML="";
	document.getElementById("proceedButton").innerHTML="";
	
	document.getElementById("newOfficeDiv").innerHTML="<table width=100% ><tr><td id=buildname2></td><td id=buildname3></td></tr><tr><td id=offName2></td><td id=offName3></td></tr><tr><td id=rank1></td><td id=rank2></td></tr><tr><td id=deptName2></td><td id=deptName3></td></tr><tr><td id=offAddress2></td><td id=offAddress3></td></tr><tr><td id=offPin2></td><td id=offPin3></td></tr><tr><td id=offPhone2></td><td id=offPhone3></td></tr><tr><td id=offFax2></td><td id=offFax3></td></tr><tr><td id=offWeb2></td><td id=offWeb3></td></tr><tr><td id=offEmail2></td><td id=offEmail3></td></tr><tr><td id=offJuri2></td><td id=offJuri3></td></tr><tr><td colspan=2><div id=serviceTableDiv style='border:0px solid #657c9c; '><table><tr><th colspan=2 id=ser2 ></th></tr><tr><td id=ser3></td><td id=addser></td></tr><tr><td id=serList colspan=2></td></tr></table></div></td></tr><tr><td id=desc2></td><td id=desc3></td></tr><table>";
	
	document.getElementById("serviceTableDiv").style.borderWidth="1px";
	document.getElementById("offName2").innerHTML="Office Name";
	var offNameTd=document.getElementById("offName3");
	offNameTd.innerHTML="";
	var offNameTextbox= new dijit.form.TextBox(
	{
		id:"offNames"+createformDiv		
	},  document.createElement('div'));	
	offNameTd.appendChild(offNameTextbox.domNode);
	offNameTextbox.startup();
	
	
	document.getElementById("buildname2").innerHTML="Building Name";
	var buildname=document.getElementById("buildname3");
	buildname.innerHTML="";
	var buildnameTextbox= new dijit.form.TextBox(
	{
		id:"buildname"+createformDiv,
		value:selectedBuilding,
		readOnly:true		
	},  document.createElement('div'));	
	buildname.appendChild(buildnameTextbox.domNode);
	buildnameTextbox.startup();
	
	document.getElementById("rank1").innerHTML="Designation of Head";
	var rankTd=document.getElementById("rank2");
	rankTd.innerHTML="";
	var rankCombobox= new dijit.form.ComboBox(
	{
		id:"rank"+createformDiv,
		store: rankStore,
		searchAttr:"rank"		
	},  document.createElement('div'));	
	rankTd.appendChild(rankCombobox.domNode);
	rankCombobox.startup();
	
	document.getElementById("deptName2").innerHTML="Department";
	var deptTd=document.getElementById("deptName3");
	deptTd.innerHTML="";
	var deptCombobox= new dijit.form.ComboBox(
	{
		id:"depts"+createformDiv,
		store: officeDeptStore,
		searchAttr:"department"		
	},  document.createElement('div'));	
	deptTd.appendChild(deptCombobox.domNode);
	deptCombobox.startup();
	
	document.getElementById("offAddress2").innerHTML="Address";
	var addressTd=document.getElementById("offAddress3");
	addressTd.innerHTML="";
	var addressTextarea= new dijit.form.Textarea(
	{
		id:"address"+createformDiv		
	},  document.createElement('div'));	
	addressTd.appendChild(addressTextarea.domNode);
	addressTextarea.startup();
	
	
			
	
	document.getElementById("offPhone2").innerHTML="Phone";
	var offPhoneTd=document.getElementById("offPhone3");
	offPhoneTd.innerHTML="";
	var offPhoneTextbox= new dijit.form.TextBox(
	{
		id:"offPhones"+createformDiv		
	},  document.createElement('div'));	
	offPhoneTd.appendChild(offPhoneTextbox.domNode);
	offPhoneTextbox.startup();
	
	document.getElementById("offFax2").innerHTML="Fax";
	var offFaxTd=document.getElementById("offFax3");
	offFaxTd.innerHTML="";
	var offFaxTextbox= new dijit.form.TextBox(
	{
		id:"offFaxs"+createformDiv		
	},  document.createElement('div'));	
	offFaxTd.appendChild(offFaxTextbox.domNode);
	offFaxTextbox.startup();
	
	document.getElementById("offWeb2").innerHTML="Web Address";
	var offWebTd=document.getElementById("offWeb3");
	offWebTd.innerHTML="";
	var offWebTextbox= new dijit.form.TextBox(
	{
		id:"offWebs"+createformDiv		
	},  document.createElement('div'));	
	offWebTd.appendChild(offWebTextbox.domNode);
	offWebTextbox.startup();
		
	document.getElementById("offEmail2").innerHTML="Email Address";
	var offEmailTd=document.getElementById("offEmail3");
	offEmailTd.innerHTML="";
	var offEmailTextbox= new dijit.form.TextBox(
	{
		id:"offEmails"+createformDiv		
	},  document.createElement('div'));	
	offEmailTd.appendChild(offEmailTextbox.domNode);
	offEmailTextbox.startup();
	
	
	
	document.getElementById("ser2").innerHTML="Services";
	var serTd=document.getElementById("ser3");
	var serCombobox= new dijit.form.ComboBox(
	{
		id:"services"+createformDiv,
		value:"-- Select and Add Service--",
		store: servicetypeStore,
		searchAttr:"service"
		//onChange:addService		
	},  document.createElement('div'));	
	serTd.appendChild(serCombobox.domNode);
	serCombobox.startup();
	
	var addserButtonTd=document.getElementById("addser");
	addserButtonTd.innerHTML="<a href=# onClick=addService('Add'); style='text-decoration:underline;' ><img src=/giskerala/images/add.png height=20 width=20 border=0 />Add</a> ";
	
	document.getElementById("desc2").innerHTML="Description";
	var desTd=document.getElementById("desc3");
	var descTextarea= new dijit.form.Textarea(
	{
		id:"descri"+createformDiv		
	},  document.createElement('div'));
	desTd.appendChild(descTextarea.domNode);
	descTextarea.startup();
	
	var addsuggnButtonTd=document.getElementById("addsuggbtn2");
	addsuggnButtonTd.innerHTML="";
	var  addsuggnButton= new dijit.form.Button(
	{ 
		id:"add"+createformDiv,
		label: "Add",
		alt: "add",
		title: "add",
		onClick:addNewOffice
	}, document.createElement('div'));
	addsuggnButtonTd.appendChild(addsuggnButton.domNode);
	addsuggnButton.startup();
	
	
}
function addService(type)
{
	var services="";
	if(type=='Add')
	{
		if((dijit.byId("services"+createformDiv).value)!="-- Select and Add Service--")
		{
			serviceArray[serCount]=dijit.byId("services"+createformDiv).value;
			for(var i=0;i<=serCount;i++)
				services+="<tr><td>"+(i+1)+"</td><td>"+serviceArray[i]+"</td><td><img src='/giskerala/images/delete.png' onClick=deleteSer("+i+"); width=15 height=15 /></td></tr>";
			document.getElementById("serList").innerHTML="<table>"+services+"</table>";
			serCount++;
		}
	}
	else
	{
		if((dijit.byId("services1"+editformDiv).value)!="-- Select and Edit Service--")
		{
			serviceArray[serCount]=dijit.byId("services1"+editformDiv).value;
			for(var i=0;i<=serCount;i++)
				services+="<tr><td>"+(i+1)+"</td><td>"+serviceArray[i]+"</td><td><img src='/giskerala/images/delete.png' onClick=deleteSer("+i+"); width=15 height=15 /></td></tr>";
			document.getElementById("serList").innerHTML="<table>"+services+"</table>";
			serCount++;
		}
	}
}
function deleteSer(index)
{
	//alert(index);
	var arrayElement=serviceArray[index]
	for(var i=0; i<serCount;i++ )
     	{ 
        	if(serviceArray[i]==arrayElement)
            	serviceArray.splice(i,1); 
     	 } 
     	 serCount--;
     	 var services="";
     	 for(var i=0;i<serCount;i++)
		services+="<tr><td>"+(i+1)+"</td><td>"+serviceArray[i]+"</td><td><img src='/giskerala/images/delete.png' onClick=deleteSer("+i+"); width=15 height=15 /></td></tr>";
	document.getElementById("serList").innerHTML="<table>"+services+"</table>";
     	 
}

function getplaceLm(value)
{
	document.getElementById("lmName1").innerHTML=value+" Name";
}
var lmAddstore;
function addPlaceLmark()
{
	var valid=validateSuggForm(lmType);
	var estatus=ValidateForm(lmType);
	if( valid==true  && estatus==true)
	{
		var nam,type,user,email,lat,lon,desc,respText;
		nam=dijit.byId("lmNames"+createformDiv).value;
		type=dijit.byId("placeLmarkType"+createformDiv).value;
		if(type=='Landmark')
			type='Land Mark';
		user=dijit.byId("urNames"+createformDiv).value;
		email=dijit.byId("eAddress"+createformDiv).value;
		lat=document.getElementById("landx").value;
		lon=document.getElementById("landy").value;
		desc=dijit.byId("desc"+createformDiv).value;
		var params="name="+nam+"&type="+type+"&user="+user+"&email="+email+"&lat="+lat+"&long="+lon+"&desc="+desc;	//alert(params);	
		var lmAddRequest=new createObject();
		lmAddRequest.open('GET',"/igsg/AddLandMark/?"+params,true);
		lmAddRequest.onreadystatechange=function()
		{
			if(lmAddRequest.readyState==4)
			{
				document.getElementById("addmsg").innerHTML="<b>"+lmAddRequest.responseText+"</b><br><br>Your suggestion is send to Administrator for confirmation";		
				document.getElementById("addsuggbtn").innerHTML="";
				createAddMoreBtn('Place');
				if(lmPoint!=undefined) 
				{
					lmpointMarker.removeMarker(lmPoint);
					lmPoint.destroy();
					lmPoint=null;
				}
				//lmStore=new dojo.data.ItemFileReadStore({url: "/igsg/ListLandMark/"});
				showlist();	
			}
		}
		lmAddRequest.send(null);
	}
	
}
function createAddMoreBtn(type)
{
	var addmoreButtonTd,addmoreButton;
	if(type=='Place')
	{
		addmoreButtonTd=document.getElementById("addMoreBtn1");
		addmoreButton= new dijit.form.Button(
		{ 
			label: "Add Another",
			alt: "add",
			title: "add",
			onClick:addAnotherPlace
		}, document.createElement('div'));
	}
	else if(type=='Office')
	{
		addmoreButtonTd=document.getElementById("addMoreBtn2");
		addmoreButton= new dijit.form.Button(
		{ 
			label: "Add Another",
			alt: "add",
			title: "add",
			onClick:addAnotherOffice
		}, document.createElement('div'));
	}
	addmoreButtonTd.innerHTML="";	
	addmoreButtonTd.appendChild(addmoreButton.domNode);
	addmoreButton.startup();
}
function addAnotherPlace()
{
	getHelp();
	getUserSuggestion();
}
function addAnotherOffice()
{
	getHelp();
	getUserSuggestion();
	dijit.byId("addPlace"+suggDivCount).setSelected(false);
	dijit.byId("addOffice"+suggDivCount).setSelected(true);		
	dijit.byId("suggPane"+suggDivCount).selectChild(dijit.byId("addOffice"+suggDivCount));
}
function addNewOffice()
{
	var valid=validateSuggForm(lmType);
	var services=serviceArray[0];
	for(var i=1;i<serCount;i++)
		services=services+"|"+serviceArray[i];
	if( valid==true )
	{
		var nam,dept,address,pin,phone,fax,web,offemail,juri,user,email,lat,lon,respText,rank,desc;
		
		nam=dijit.byId("offNames"+createformDiv).value;
		rank=dijit.byId("rank"+createformDiv).value;		
		dept=dijit.byId("depts"+createformDiv).value;
		address=dijit.byId("address"+createformDiv).value;		
		phone=dijit.byId("offPhones"+createformDiv).value;
		fax=dijit.byId("offFaxs"+createformDiv).value;
		web=dijit.byId("offWebs"+createformDiv).value;
		offemail=dijit.byId("offEmails"+createformDiv).value;		
		desc=dijit.byId("descri"+createformDiv).value;
		//alert(selectedBuildingId);
		var params="name="+nam+"&build="+selectedBuilding+"&dept="+dept+"&address="+address+"&phone="+phone+"&fax="+fax+"&web="+web+"&offemail="+offemail+"&service="+services+"&rank="+rank+"&desc="+desc+"&e=F"+"&buildid="+selectedBuildingId;
		//alert(params)		;
		var lmAddRequest=new createObject();
		lmAddRequest.open('GET',"/igsg/AddOffice/?"+params,true);
		lmAddRequest.onreadystatechange=function()
		{
			if(lmAddRequest.readyState==4)
			{
				//alert(lmAddRequest.responseText);
				
				if(lmAddRequest.responseText=='Cannot add the office')
				{
					document.getElementById("addmsg2").innerHTML="<b><span style=color:red >"+lmAddRequest.responseText+"</span></b>";
				}	
				else 
				{
					document.getElementById("addmsg2").innerHTML="<b>"+lmAddRequest.responseText+"</b><br><br>Your suggestion is send to Administrator for confirmation";	
					createAddMoreBtn('Office');
					offStore=new dojo.data.ItemFileReadStore({url: "/igsg/ListOffice/"});
					document.getElementById("addsuggbtn2").innerHTML="";
					
				}
				
				if(lmPoint!=undefined) 
				{
					lmpointMarker.removeMarker(lmPoint);
					lmPoint.destroy();
					lmPoint=null;
				}
				//lmStore=new dojo.data.ItemFileReadStore({url: "/igsg/ListLandMark/"});
				showlist();	
			}
		}
		lmAddRequest.send(null);
	}
	
}
function createObject()
{
	var request_type;
        var browser = navigator.appName;
        if(browser == "Microsoft Internet Explorer")
        {
        	request_type = new ActiveXObject("Microsoft.XMLHTTP");
        }
        else    
        { 
        	request_type = new XMLHttpRequest();
        }
        return request_type;
}
function editOffices(id)
{
	var id1,x,y,name1,department,address,rank,build,phone,fax,web,email,descr,service,offid,buildId;
	editformDiv++;
	lmType='Office';
	dijit.byId("suggFields"+suggDivCount).setSelected(false);
	dijit.byId("addOffice"+suggDivCount).setSelected(true);		
	dijit.byId("suggPane"+suggDivCount).selectChild(dijit.byId("addOffice"+suggDivCount));
	document.getElementById("addmsg2").innerHTML="";
	selectList();
	
	document.getElementById("buildingDiv").innerHTML="";
	document.getElementById("proceedButton").innerHTML="";
	
	document.getElementById("newOfficeDiv").innerHTML="<table width=100% ><tr><td id=buildname2></td><td id=buildname3></td></tr><tr><td id=offName2></td><td id=offName3></td></tr><tr><td id=rank1></td><td id=rank2></td></tr><tr><td id=deptName2></td><td id=deptName3></td></tr><tr><td id=offAddress2></td><td id=offAddress3></td></tr><tr><td id=offPin2></td><td id=offPin3></td></tr><tr><td id=offPhone2></td><td id=offPhone3></td></tr><tr><td id=offFax2></td><td id=offFax3></td></tr><tr><td id=offWeb2></td><td id=offWeb3></td></tr><tr><td id=offEmail2></td><td id=offEmail3></td></tr><tr><td id=offJuri2></td><td id=offJuri3></td></tr><tr><td colspan=2><div id=serviceTableDiv style='border:0px solid #657c9c; '><table><tr><th colspan=2 id=ser2 ></th></tr><tr><td id=ser3></td><td id=addser></td></tr><tr><td id=serList colspan=2></td></tr></table></div></td></tr><tr><td id=desc2></td><td id=desc3></td></tr><table><span><input type=hidden id=offId /><input type=hidden id=buildId /></span><span><input type=hidden id=latEdit /></span><span><input type=hidden id=lonEdit /></span>";
	
	var request = offStore.fetch({onComplete:function(items, request)
	{
		for(var i=0;i<items.length;i++)
		{
			id1=offStore.getValue(items[i],"id");
			
			if(id1==id)
			{
				offid=offStore.getValue(items[i],"id");
				name1=offStore.getValue(items[i],"name");
				build=offStore.getValue(items[i],"build");
				//x=offStore.getValue(items[i],"long");
				//y=offStore.getValue(items[i],"lat");
				department=offStore.getValue(items[i],"department");
				address=offStore.getValue(items[i],"address");
				rank=offStore.getValue(items[i],"rank");
				phone=offStore.getValue(items[i],"tele");
				fax=offStore.getValue(items[i],"fax");
				web=offStore.getValue(items[i],"web_address");
				email=offStore.getValue(items[i],"email_address");
				descr=offStore.getValue(items[i],"desc");
				service=offStore.getValue(items[i],"service");
				buildId=offStore.getValue(items[i],"buildid");
			}
			
		}
		//alert(buildId);
		//alert("name----->"+name1);
		//alert("first----->"+offid);
		document.getElementById("offId").value=offid;
		document.getElementById("buildId").value=buildId;
		//document.getElementById("latEdit").value=y;
		//document.getElementById("lonEdit").value=x;
		document.getElementById("serviceTableDiv").style.borderWidth="1px";
		document.getElementById("offName2").innerHTML="Office Name";
		
		var offNameTd=document.getElementById("offName3");
		offNameTd.innerHTML="";
		var offNameTextbox= new dijit.form.TextBox(
		{
			id:"offNames1"+editformDiv,
			value:name1		
		},  document.createElement('div'));	
		offNameTd.appendChild(offNameTextbox.domNode);
		offNameTextbox.startup();
		
		document.getElementById("buildname2").innerHTML="Building Name";
		var buildTd=document.getElementById("buildname3");
		buildTd.innerHTML="";
		var buildText= new dijit.form.TextBox(
		{
			id:"build1"+editformDiv,
			readOnly:true,	
			value:build
		},  document.createElement('div'));	
		buildTd.appendChild(buildText.domNode);
		buildText.startup();
		
		document.getElementById("rank1").innerHTML="Designation of Head";
		var ranktTd=document.getElementById("rank2");
		ranktTd.innerHTML="";
		var rankCombobox= new dijit.form.ComboBox(
		{
			id:"rank1"+editformDiv,
			store: rankStore,
			searchAttr:"rank"	,
			value:rank	
		},  document.createElement('div'));	
		ranktTd.appendChild(rankCombobox.domNode);
		rankCombobox.startup();
		
		document.getElementById("deptName2").innerHTML="Department";
		var deptTd=document.getElementById("deptName3");
		deptTd.innerHTML="";
		var deptCombobox= new dijit.form.ComboBox(
		{
			id:"depts1"+editformDiv,
			store: officeDeptStore,
			searchAttr:"department"	,
			value:department	
		},  document.createElement('div'));	
		deptTd.appendChild(deptCombobox.domNode);
		deptCombobox.startup();
		
		document.getElementById("offAddress2").innerHTML="Address";
		var addressTd=document.getElementById("offAddress3");
		addressTd.innerHTML="";
		var addressTextarea= new dijit.form.Textarea(
		{
			id:"address1"+editformDiv,
			value:address		
		},  document.createElement('div'));	
		addressTd.appendChild(addressTextarea.domNode);
		addressTextarea.startup();
		
		
		
		document.getElementById("offPhone2").innerHTML="Phone";
		var offPhoneTd=document.getElementById("offPhone3");
		offPhoneTd.innerHTML="";
		var offPhoneTextbox= new dijit.form.TextBox(
		{
			id:"offPhones1"+editformDiv,
			value:phone		
		},  document.createElement('div'));	
		offPhoneTd.appendChild(offPhoneTextbox.domNode);
		offPhoneTextbox.startup();
		
		document.getElementById("offFax2").innerHTML="Fax";
		var offFaxTd=document.getElementById("offFax3");
		offFaxTd.innerHTML="";
		var offFaxTextbox= new dijit.form.TextBox(
		{
			id:"offFaxs1"+editformDiv,
			value:fax		
		},  document.createElement('div'));	
		offFaxTd.appendChild(offFaxTextbox.domNode);
		offFaxTextbox.startup();
		
		document.getElementById("offWeb2").innerHTML="Web Address";
		var offWebTd=document.getElementById("offWeb3");
		offWebTd.innerHTML="";
		var offWebTextbox= new dijit.form.TextBox(
		{
			id:"offWebs1"+editformDiv,
			value:web		
		},  document.createElement('div'));	
		offWebTd.appendChild(offWebTextbox.domNode);
		offWebTextbox.startup();
		
		document.getElementById("offEmail2").innerHTML="Email Address";
		var offEmailTd=document.getElementById("offEmail3");
		offEmailTd.innerHTML="";
		var offEmailTextbox= new dijit.form.TextBox(
		{
			id:"offEmails1"+editformDiv,
			value:email		
		},  document.createElement('div'));	
		offEmailTd.appendChild(offEmailTextbox.domNode);
		offEmailTextbox.startup();
		
		
		
		document.getElementById("ser2").innerHTML="Services";
		var serTd=document.getElementById("ser3");
		serTd.innerHTML="";
		var serCombobox= new dijit.form.ComboBox(
		{
			id:"services1"+editformDiv,
			value:"-- Select and Edit Service--",
			store: servicetypeStore,
			searchAttr:"service"
			//onChange:addService		
		},  document.createElement('div'));	
		serTd.appendChild(serCombobox.domNode);
		serCombobox.startup();
		
		var addserButtonTd=document.getElementById("addser");
		addserButtonTd.innerHTML="<a href=# onClick=addService('Edit'); style='text-decoration:underline;' ><img src=/giskerala/images/add.png height=20 width=20 border=0 />Add</a> ";
		
		var services=service.split("|");
		serCount=services.length-1;
		var ser="";
		for(var i=0;i<serCount;i++)
		{
			serviceArray[i]=services[i];
			ser+="<tr><td>"+(i+1)+"</td><td>"+serviceArray[i]+"</td><td><img src='/giskerala/images/delete.png' onClick=deleteSer("+i+"); width=15 height=15 /></td></tr>";
		}
		//alert(ser);
		document.getElementById("serList").innerHTML="<table>"+ser+"</table>";
		
		document.getElementById("desc2").innerHTML="Description";
		var desTd=document.getElementById("desc3");
		desTd.innerHTML="";
		var destextarea= new dijit.form.Textarea(
		{
			id:"desc1"+editformDiv,
			value:descr					
		},  document.createElement('div'));	
		desTd.appendChild(destextarea.domNode);
		destextarea.startup();
		
		
		var addsuggnButtonTd=document.getElementById("addsuggbtn2");
		addsuggnButtonTd.innerHTML="";
		var  addsuggnButton= new dijit.form.Button(
		{ 
			label: "Edit",
			alt: "Edit",
			title: "Edit",
			onClick:EditOffice
		}, document.createElement('div'));
		addsuggnButtonTd.appendChild(addsuggnButton.domNode);
		addsuggnButton.startup();
		
		
	}});
}
function EditOffice()
{
	//var valid=validateSuggForm(lmType);
	var services=serviceArray[0];
	for(var i=1;i<serCount;i++)
		services=services+"|"+serviceArray[i];
	//var estatus1=ValidateForm(lmType,'yours');
	//var estatus2=ValidateForm(lmType,'office');
	//if( valid==true  &&  estatus2==true)
	//{
		var nam,build,dept,address,rank,phone,fax,web,offemail,desc,user,email,lat,lon,respText,id,buildid;
		
		nam=dijit.byId("offNames1"+editformDiv).value;
		build=dijit.byId("build1"+editformDiv).value;
		dept=dijit.byId("depts1"+editformDiv).value;
		address=dijit.byId("address1"+editformDiv).value;
		rank=dijit.byId("rank1"+editformDiv).value;
		phone=dijit.byId("offPhones1"+editformDiv).value;
		fax=dijit.byId("offFaxs1"+editformDiv).value;
		web=dijit.byId("offWebs1"+editformDiv).value;
		offemail=dijit.byId("offEmails1"+editformDiv).value;
		desc=dijit.byId("desc1"+editformDiv).value;
		//user=dijit.byId("urNames"+createformDiv).value;
		//email=dijit.byId("eAddress"+createformDiv).value;
		//lat=document.getElementById("latEdit").value;
		//lon=document.getElementById("lonEdit").value;
		id=document.getElementById("offId").value;
		buildid=document.getElementById("buildId").value;
		//alert(buildid);
		var params="name="+nam+"&build="+build+"&dept="+dept+"&address="+address+"&phone="+phone+"&fax="+fax+"&web="+web+"&offemail="+offemail+"&service="+services+"&rank="+rank+"&desc="+desc+"&e=T&id="+id+"&buildid="+buildid;
		
		//var params="name="+nam+"&rank="+type+"&dept="+dept+"&address="+address+"&pin="+pin+"&phone="+phone+"&fax="+fax+"&web="+web+"&offemail="+offemail+"&juri="+juri+"&service="+services+"&lat="+lat+"&long="+lon+"&id="+id+"&e=T";
		//alert(params)		;
		var lmAddRequest=new createObject();
		lmAddRequest.open('GET',"/igsg/AddOffice/?"+params,true);
		lmAddRequest.onreadystatechange=function()
		{
			if(lmAddRequest.readyState==4)
			{
				
				if(lmAddRequest.responseText=='Cannot add your suggestion')
				{
					document.getElementById("addmsg2").innerHTML="<b><span style=color:red >"+lmAddRequest.responseText+"</span></b>";
				}	
				else 
				{
					document.getElementById("addmsg2").innerHTML="<b>"+lmAddRequest.responseText+"</b><br><br>Your suggestion is send to Administrator for confirmation";	
					createAddMoreBtn('Office');
					showOfficeList();
					document.getElementById("addsuggbtn2").innerHTML="";
					
				}
				
				if(lmPoint!=undefined) 
				{
					lmpointMarker.removeMarker(lmPoint);
					lmPoint.destroy();
					lmPoint=null;
				}
				//lmStore=new dojo.data.ItemFileReadStore({url: "/igsg/ListLandMark/"});
				showlist();	
			}
		}
		lmAddRequest.send(null);
	//}
	
}
function getEditOffice()
{
	dijit.byId("addPlace"+suggDivCount).setSelected(false);
	dijit.byId("suggFields"+suggDivCount).setSelected(true);			
	dijit.byId("suggPane"+suggDivCount).selectChild(dijit.byId("suggFields"+suggDivCount));
}


