
	var specStrArray = new Array();
	var groupCount = new Array();
	var textArray = new Array();
	var strArrays = new Array();
	var strArray = new Array();
	var array = new Array();
	
	var ProjectType = "Apartment";
	var bigWidth = 650;
	var unitCount = 0;
	var spec = null;
	var counter = 0;
	var floors = 0;
	var count1 = 0;
	var count = 0;
	var divWidth = 250;
	var ctr = 0;
	var req;
	var proj;
	
	var noOfBlocks = 0;
	var floorName = "Floor";
	
	var unitNameArray = new Array();
	var unitTypeArray = new Array();
	var areaInSqFeetArray = new Array();
	var landInfoArray = new Array();
	var startingPriceArray = new Array();
	var unitThumbImageArray = new Array();
	var unitStatusArray = new Array();
	var ratePerUnitAreaArray = new Array();
	var floorNoArray = new Array();
	var noOfUnitsInFloorArray = new Array();
	var blocksArray = new Array();
	var blockArray = new Array();

	function startAction(){
		queryString = '' + this.location;
		
  		queryString = queryString.substring((queryString.indexOf('?')) + 1);
		projectId = queryString.substring((queryString.indexOf('=')) + 1);
		
		queryString = queryString.substring((queryString.indexOf('&')) + 1);
		var divName = queryString.substring((queryString.indexOf('=')) + 1);

		var tabName = "subtab_1";
		if(divName != "summeryDiv"){
			tabName = "subtab_5";
		}
		sendURL(projectId);
		showHideDivs(divName,tabName);
	}
	
    function  sendURL(projectId){
        projectId = projectId.substring(0,(projectId.indexOf('&')));
        var timeStamp = new Date();
        timeStamp = timeStamp.getTime();
        callRemoteURL(globalURL+"getDetailXML.action?projectId=" + projectId , processData);
    }

	function  getBirdsEyeView(){
		projectId = projectId.substring(0,(projectId.indexOf('&')));
		if(projectId != ""){
			timeStamp = new Date();
			timeStamp = timeStamp.getTime();
			callRemoteURL(globalURL+"getAllPhotos.action?ProjectId=" + projectId + "&albums=Birdview&ts=" + timeStamp, BirdEyeView);
		}
	}

	
	function  BirdEyeView(){
		if (req.readyState == 4) {
      		if (req.status == 200) {
      			birdCount = 0;
 				refreshContentDiv("AlbumItem", "Caption");
				refreshContentDiv("AlbumItem", "Resource");
			} 
		}
	}
	
	var birdViewArray = new Array();
	function refreshContentDiv(parentTag, divTag) {
		var divName = document.getElementById("birdsViewDiv");
		var divElement = document.getElementById("birdsView");
		var listArray = parseXMLtoArrayValue(parentTag, divTag);
		
		var len = listArray.length;
		if(len > 0){
			for(i=0; i<len; i++){
				birdViewArray[birdCount] = listArray[i];
				birdCount++;
			}
			str = "";
			for(i=0; i<len; i++){
				if(birdViewArray[i+len] != undefined ){
					url = escape(birdViewArray[i+len]);
					str += "<span  style='width:150px;text-align:left;float:left;'><a href='#' onclick=\"unitImgPopUp('"+url+"');\" <span><img src='images/bullet3.gif' height='13' width='14' border='0'/>" + birdViewArray[i] + "</a></span>";
				}
			}
			divName.style.display = "block";
			divElement.innerHTML = str;
		}
	}
	
	function getAvailabiliityChart(){
		timeStamp = new Date();
		timeStamp = timeStamp.getTime();
		callRemoteURL(globalURL+"getAvailabilityCharts.action?ts=" + timeStamp, refreshAvailCharts);
	}
	
	function refreshAvailCharts(){
		if (req.readyState == 4) {
      		if (req.status == 200) {
				getValueFromXMLToArray();
				refreshBlockDiv("blocksDiv",blocksArray[0]);
						
				if(ProjectType == "Villa"){
					document.getElementById('unitDetails').style.width="155px";
					document.getElementById('layoutMap').style.display="block";
				}else{
					document.getElementById('unitDetails').style.width=divWidth+"px";
					document.getElementById('apartmentLayoutMap').style.display="block";
				}
		
				refreshAvailabilityDiv("unitDetails", blocksArray[0]);
			//	ShowEmail("Project", "Status","ShowMailDiv");
				getBirdsEyeView();
			} 
		}

	}
	
	function processData() {		
		if (req.readyState == 4) {
      		if (req.status == 200) {
				setValueInVarialbe();	
				refreshDivs("Project", "Id", "projectIdDiv");
				refreshDivs("Project", "Name", "projectDiv");
				refreshDivs("Project", "Address", "addressDiv");
				refreshDivs("Project", "Description", "descriptionDiv");
				refreshDivs("Project", "StatutoryCharges", "StatutoryChargesDiv");
				refreshDivs("Project", "StatutoryCharges", "StatutoryChargesP");
				
				refreshImagelocationmap("LocationMap", "Map","locationDiv");
				if(ProjectType == "Villa"){				
					refreshLayoutMap("Project", "LayoutMap","layoutMap");
				}else{
					refreshLayoutMap("Project", "LayoutMap","apartmentLayoutMap");
				}

				refreshImage("Project", "Thumb","elevationDiv", 190, 140);
				refreshLogoImage("Project", "Logo","logoDiv", 110, 80);				
				refreshGlanceDivs("Addition", "Description");
				
				refreshDivisions("NoGroupItems", null,"additionalInfoDesc");
				refreshDivisions("GroupName", null,"additionalInfoName");
				refreshDivisions("GroupItemDesc", null,"additionalInfoDesc");
				
				refreshFeaturesDivs("Amenity", null,"amenityDiv");
				refreshFeaturesDivs("Highlight", null,"highlightsDiv");
				
				refreshSpecDivs("Specific", "Name","specification");
				refreshSpecDivs("Specific", "Description","specification");
				
				refreshUnitTypesDivs("Type","Name","unitTypeDiv");
				refreshUnitTypesDivs("Type","UnitTypeThumbImage","unitTypeDiv");
				
				getAvailabiliityChart();				
			} 
		}
	}


	function getValueFromXMLToArray() {		

		parseXMLtoArrayValue("Unit", "NoOfUnitsInFloor");
		if(textArray[0] != undefined){
			noOfUnitsInFloorArray = textArray;
		}

		parseXMLtoArrayValue("Unit","UnitName");
		if(textArray[0] != undefined){
			unitNameArray = textArray;
		}		
		parseXMLtoArrayValue("Unit", "UnitType");
		if(textArray[0] != undefined){
			unitTypeArray = textArray;
		}		
		parseXMLtoArrayValue("Unit", "AreaInSqFeet");
		if(textArray[0] != undefined){
			areaInSqFeetArray = textArray;
		}		
		parseXMLtoArrayValue("Unit", "LandInfo");
		if(textArray[0] != undefined){
			landInfoArray = textArray;
		}		
		parseXMLtoArrayValue("Unit", "StartingPrice");
		if(textArray[0] != undefined){
			startingPriceArray = textArray;
		}		
		parseXMLtoArrayValue("Unit", "UnitThumbImage");
		if(textArray[0] != undefined){
			unitThumbImageArray = textArray;
		}		
		parseXMLtoArrayValue("Unit", "UnitStatus");
		if(textArray[0] != undefined){
			unitStatusArray = textArray;
		}		
		parseXMLtoArrayValue("Unit", "RatePerUnitArea");
		if(textArray[0] != undefined){
			ratePerUnitAreaArray = textArray;
		}		
		parseXMLtoArrayValue("Unit", "FloorNo");
		if(textArray[0] != undefined){
			floorNoArray = textArray;
		}		
		parseXMLtoArrayValue("Unit","NameBlock");
		if(textArray[0] != undefined){
			blocksArray = textArray;
		}

		parseXMLtoArray("BlockName",null);
		if(textArray[0] != undefined){
			blockArray = textArray;
		}
	}


	function refreshAvailabilityDiv(divId, blockName) {
		if(blockName != undefined){
			var divElement = document.getElementById(divId);
			var str = "";
			noOfUnits = unitNameArray.length;
			floors = 0;
			for(i=0; i<noOfUnits; i++){			
				if(blocksArray[i] == blockName){
					var color = "available";
					if(unitStatusArray[i] == "Sold"){
						color = "sold";
					}else if(unitStatusArray[i] == "Blocked"){
						color = "blocked";
					}

					if(ProjectType == "Villa"){
															
						var area = (landInfoArray[i] == "N/A") ? "" : " (" +landInfoArray[i]+ ")";
						var rate = (ratePerUnitAreaArray[i] == "N/A") ? "" : " @ " +ratePerUnitAreaArray[i]+ "/-<br/>";
						var sqft = (areaInSqFeetArray[i] == 0) ? "" : "<br/>" +areaInSqFeetArray[i] + " Sqft" + rate + area ;
						var price = (startingPriceArray[i] == 0) ? "" : "<br/>Price " + startingPriceArray[i];
						url = escape(unitThumbImageArray[i]);
						
						proj = (unitTypeArray[i]  == "N/A") ? " (" + unitTypeArray[i] + ")" : "( <a href='#' onclick=\"unitImgPopUp('"+url+"');\")>"+ unitTypeArray[i] +"</a> )";
						str += "<div id='statusVilla'><div class="+color+"><b>" 
							+ unitNameArray[i] + "</b> " + proj + "<br/><span>" + unitStatusArray[i] 
							+ "</span>"+ sqft + price +"</div></div><br/>";
					}else{
		
						var fCount = floorNoArray[i];
						divWidth = noOfUnitsInFloorArray[i] * 130 + 4 * noOfUnitsInFloorArray[i] + 130;
		
						if(bigWidth  > divWidth){
							divWidth = bigWidth;
						}else{
							bigWidth = divWidth;
						}
						
						var rate = (ratePerUnitAreaArray[i] == "N/A") ? "" : " @ " +ratePerUnitAreaArray[i]+ "/-";
						var sqft = (areaInSqFeetArray[i] == 0) ? "" : areaInSqFeetArray[i] +" Sqft" + rate;
						var price = (startingPriceArray[i] == 0) ? "" : "Price " + startingPriceArray[i];
						url = escape(unitThumbImageArray[i]);
						
						proj = (unitTypeArray[i]  == "N/A") ? " (" + unitTypeArray[i] + ")" : "( <a href='#' onclick=\"unitImgPopUp('"+url+"');\")>"+ unitTypeArray[i] +"</a> )";
						
						if(floors != fCount){
							floors = fCount;
							if(str != ""){
								str += "</div></div><div style='width:"+divWidth+"px;'><img scr='images/spacer.gif' width='100%' height='1'/></div>";
							}
							floorName = (fCount != 0) ? "Floor : " + fCount : "Ground Floor";
							str += "<div style='float:left; width:"+divWidth +"px;'><div id='status'><div class='floor'><br/><br/><b>" 
								+ floorName + "</b></div></div>";
								
							str += "<div id='status'><div class="+color+"><b>" 
								+ unitNameArray[i] +"</b> " + proj + "<br/><span>"+ unitStatusArray[i] +"</span><br/>" 
								+ sqft +"<br/>"+ price +"</div></div>";
							
						}else{
							str += "<div id='status'><div class="+color+"><b>" 
								+ unitNameArray[i] + "</b>" + proj + "<br/><span>"+ unitStatusArray[i] +"</span><br/>" 
								+ sqft +"<br/>"+ price +"</div></div>";
						}
					}
				}
			}
			divElement.innerHTML = str;
		}
	}


	function refreshUnitTypesDivs(parentTag, divTag,  divId) {		
		parseXMLtoArrayValue(parentTag, divTag);
		var divElement = document.getElementById(divId);

		if(textArray[0]==undefined){
			divElement.innerHTML="";
		}
		else{
			if(textArray.length > 0){	
				
				var str = "";
				for(i=0; i<textArray.length; i++){
					strArrays[counter] = textArray[i];
					counter++;
				}
				
				for(i=0; i<strArrays.length; i++){
					if(strArrays[i+textArray.length ] != undefined ){
						url = escape(strArrays[i+textArray.length]);
						str += "<span  style='padding-bottom:5px;float:left;'><a href='#' onclick=\"unitImgPopUp('"+url+"');\" <span><img src='images/bullet2.gif' height='10' width='14' border='0'/>" + strArrays[i] + "</a></span>";
					}
				}
				
				divElement.innerHTML = str;
				
			}else{
				divElement.innerHTML = "<p><img src='images/bullet.gif' height='10' width='14' border='0'/>  <b>" + textArray[0] + "</b>";
			}
		}
	}
	
	function refreshBlockDiv(divId, selBlock) {
		var divElement = document.getElementById(divId);
		var str = "";
		var fontStyle = "normal";
		if(blockArray.length > 1){				
			for(i=0; i<blockArray.length; i++){
				fontStyle = (blockArray[i] == selBlock) ? "bold" : "normal";
				str += "<span  style='width:110px;text-decoration:none;font-weight: "+fontStyle+";'><a href='#' style='text-decoration:none;color:#006D5A;' onclick=\"showByBlock('"+blockArray[i]+"');\"><img src='images/bullet4.gif' height='10' width='14' border='0'/>" + blockArray[i] + "</a></span>";
			}				
			divElement.innerHTML = str;
		}
	}
	
	function showByBlock(blockName) {
		refreshAvailabilityDiv("unitDetails", blockName);
		refreshBlockDiv("blocksDiv",blockName);
	}	

	function refreshFeaturesDivs(parentTag, divTag,  divId) {		
		parseXMLtoArrayValue(parentTag, divTag);
		var divElement = document.getElementById(divId);

		if(textArray[0]==undefined){
			divElement.innerHTML="";
		}
		else{
			if(textArray.length > 1){	
				var str = "";		
				for(i=0; i<textArray.length; i++){
					str += "<img src='images/bullet.gif' height='10' width='14' border='0'/>  " + textArray[i] + "<br/>";
				}
				divElement.innerHTML = str;
			}else{
				divElement.innerHTML = "<p><img src='images/bullet.gif' height='10' width='14' border='0'/>  " + textArray[0];
			}
		}
	}

	function refreshSpecDivs(parentTag, divTag,  divId) {
		parseXMLtoArrayValue(parentTag, divTag);
		var divElement = document.getElementById(divId);
		if(textArray[0]==undefined){
			divElement.innerHTML="";
		}
		else{
			if(textArray.length > 1){			
				var str = "";
				
				for(i=0; i<textArray.length; i++){
					specStrArray[count] = textArray[i];
					count++;
				}
				for(i=0; i<specStrArray.length; i++){
					if(specStrArray[i+textArray.length] != undefined ){
						str += "<p><img src='images/bullet.gif' height='10' width='14' border='0'/> <b>" + specStrArray[i] + "</b><p><img src='images/spacer.gif' height='12' width='30' border='0'/>" + specStrArray[i+textArray.length]+"<br><br>";
					}
				}
				
				divElement.innerHTML = str;
			}else{
				if(spec == null){
					spec = "<img src='images/bullet.gif' height='10' width='14' border='0'/> <b>" + textArray[0];
				}else{
					divElement.innerHTML = spec + "</b><p><img src='images/spacer.gif' height='12' width='30' border='0'/>" + textArray[0];
				}
			}
		}
	}

	function refreshDivs(parentTag, divTag,  divId) {		
		parseXMLtoArrayValue(parentTag, divTag);
		var divElement = document.getElementById(divId);
		if(textArray[0] == undefined){
			divElement.innerHTML="";
		}
		else{
			divElement.innerHTML = (textArray[0] == "N/A") ? "" : textArray[0];
		}
	}
	function ShowEmail(parentTag, divTag,  divId) {	
		parseXMLtoArrayValue(parentTag, divTag);
		var divElement = document.getElementById(divId);
		if(textArray[0] != undefined){		
			if(textArray[0] != "New"){
				divElement.style.display="none";				
			}else{
				divElement.style.display="block";	
			}
		}
	}

	
	function setValueInVarialbe(){
		parseXMLtoArrayValue("Project", "ProjectType");
		if(textArray[0] != undefined){
			ProjectType = textArray[0];
		}
		parseXMLtoArrayValue("Blocks", "NoOfBlocks");
		if(textArray[0] != undefined){
			noOfBlocks = textArray[0];
		}
	}
	
	function refreshGlanceDivs(parentTag, divTag){
		parseXMLtoArrayValue(parentTag, divTag);
		var typeSpan = document.getElementById("projType");
		var locSpan = document.getElementById("projLoc");

		if(textArray[0] != undefined){
			typeSpan.innerHTML = textArray[0];
		}
		if(textArray[1] != undefined){
			locSpan.innerHTML = textArray[1];
		}
	}

	
	function refreshDivisions(parentTag, divTag,  divId) {		
		parseXMLtoArrayValue(parentTag, divTag);
		
		var divElement = document.getElementById(divId);

		if(textArray.length > 0){			
			var str = "";
			for(i=0; i<textArray.length; i++){
				if(groupCount[0] != null){
					array[ctr] = textArray[i];
					ctr++;
				}
			}
			if(groupCount[0] == null){
				groupCount = textArray;
			}
			
			var no = array.length - textArray.length;
			for(i=0; i<no; i++){
				if(array[i] != undefined ){
					str += "<p><img src='images/bullet.gif' height='10' width='14' border='0'/> <b>" + array[i] + "</b>" ;
					for(j=0; j<groupCount[i]; j++){
						str += "<p><img src='images/spacer.gif' height='12' width='30' border='0'/>" + textArray[count1]+"<br>";
						count1++;
					}
				}
			}
			divElement.innerHTML = str;
		}
	} 
	
	function refreshImage(parentTag, divTag,  divId, width, height) {	
		parseXMLtoArrayValue(parentTag, divTag);
		var divElement= document.getElementById(divId);
		url = escape(textArray[0]);
		divElement.innerHTML="<a href='#' onclick=\"unitImgPopUp('"+url+"');\"><img src=\""+textArray[0] +"\"  width='"+width+"' height='"+height+"' border='0'/></a>";
	} 
	
	function refreshLogoImage(parentTag, divTag,  divId, width, height) {	
		parseXMLtoArrayValue(parentTag, divTag);
		var divElement= document.getElementById(divId);
		divElement.innerHTML="<img src=\""+textArray[0] +"\"  width='"+width+"' height='"+height+"' border='0'/>";
	} 

	
	function refreshLayoutMap(parentTag, divTag,  divId) {	
		parseXMLtoArrayValue(parentTag, divTag);
		var divElement= document.getElementById(divId);
		if(textArray[0] != undefined && textArray[0] != "images/spacer.gif"){
			url = escape(textArray[0]);
			divElement.innerHTML="<a href='#' onclick=\"unitImgPopUp('"+url+"');\"><img src=\""+textArray[0] +"\" alt='' title='Click to view Enlarged Image' border='0' width='600' height='900' /></a>";
		}
		else{
			divElement.innerHTML = "";
		}
	} 


	function refreshImagelocationmap(parentTag, divTag,  divId) {		
		parseXMLtoArrayValue(parentTag, divTag);
		var divElement= document.getElementById(divId);
		
		if(textArray[0] != undefined){
			url = escape(textArray[0]);
			divElement.innerHTML="<a href='#' onclick=\"unitImgPopUp('"+url+"');\"><img src=\""+textArray[0] +"\" alt='' title='Click to view Enlarged Image' height='600' width='800' border='0'/></a>";
		}
		else{
			divElement.innerHTML = "";
		}

	} 
	
	function showHideDivs(divName,selectedTab){

		var summery = document.getElementById("summeryDiv");
		var amenity = document.getElementById("featuresDiv");
		var spec = document.getElementById("specDiv");
		var loc = document.getElementById("locationMapDiv");
		var avail = document.getElementById("availDiv");
		var selectedDiv = document.getElementById(divName);
	
		var subtab1 = document.getElementById("subtab_1");
		var subtab2 = document.getElementById("subtab_2");
		var subtab3 = document.getElementById("subtab_3");
		var subtab4 = document.getElementById("subtab_4");
		var subtab5 = document.getElementById("subtab_5");
		var selectedSubTab = document.getElementById(selectedTab);

		summery.style.display = "none";
		amenity.style.display = "none";
		spec.style.display = "none";
		loc.style.display = "none";
		avail.style.display = "none";
		selectedDiv.style.display = "block";
		
		subtab1.style.display = "none";
		subtab2.style.display = "none";
		subtab3.style.display = "none";
		subtab4.style.display = "none";
		subtab5.style.display = "none";
		selectedSubTab.style.display = "block";

	}

    function emailPopUp(url){
        window.open(url,'popupWindow','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,copyhistory=no,width=400,height=320,screenX=1000,screenY=100,top=250,left=220');
    }


