﻿var PropertytabControlID;
function doOpen() {
	if (document.getElementById("divOptions").style.display == 'block')
		document.getElementById("divOptions").style.display = 'none';

	if (document.getElementById("divOptions").style.display == 'none')
		document.getElementById("divOptions").style.display = 'block';
}
function box_flip(boxid) {
	var box_id = boxid;

	if (document.getElementById(box_id).style.display == 'none') {
		box_open(box_id);
	} else {
		box_close(box_id);
	}
}
function box_open(b_id) {
	document.getElementById(b_id).style.display = 'block';
}

function box_close(b_id) {
	document.getElementById(b_id).style.display = 'none';
}

function iFrameHeight() {

	var h = 0;
	if (!document.all) {
		h = document.getElementById('prodetFrame').contentDocument.height;
		document.getElementById('prodetFrame').style.height = h + 100 + 'px';
	} else if (document.all) {
		h = document.frames('prodetFrame').document.body.scrollHeight;
		document.all.prodetFrame.style.height = h + 600 + 'px';
	}
}
function ChangeLotSqft(SaleTypeDiv, LotSqftDiv, ddlPropertyType) {
	if (document.getElementById(ddlPropertyType).value == 'M') {
		document.getElementById(LotSqftDiv).style.display = 'none';
	}
	else {
		document.getElementById(LotSqftDiv).style.display = 'block';
	}
	if (document.getElementById(ddlPropertyType).value == 'R') {
		document.getElementById(SaleTypeDiv).style.display = 'none';
	}
	else {
		document.getElementById(SaleTypeDiv).style.display = 'block';
	}
}
function ChangeBedroom(MinBedrooms, MaxBedrooms, LblBedrooms) {
	var MinBed, MaxBed, LblBed;
	MinBed = document.getElementById(MinBedrooms).value;
	MaxBed = document.getElementById(MaxBedrooms).value;
	LblBed = document.getElementById(LblBedrooms);
	LblBed.className = 'greensmalltext';
	if (MinBed == 0 && MaxBed == 0)
		LblBed.innerHTML = 'No Preference';
	else if (MinBed == MaxBed)
		LblBed.innerHTML = MinBed + ' bedroom(s) only';
	else if (MinBed > 0 && MaxBed == 0)
		LblBed.innerHTML = MinBed + ' bedroom(s) and above';
	else if (MinBed == 0 && MaxBed > 0)
		LblBed.innerHTML = 'Upto ' + MaxBed + ' bedroom(s)';
	else if (MinBed > MaxBed) {
		LblBed.innerHTML = 'Please select a valid range. Eg: 2 to 4';
		LblBed.className = 'redsmalltext';
	}
	else if (MinBed > 0 && MaxBed > 0)
		LblBed.innerHTML = 'Between ' + MinBed + ' and ' + MaxBed + ' bedroom(s)';
}
function ChangeBathroom(MinBathrooms, MaxBathrooms, LblBathrooms) {
	var MinBath, MaxBath, LblBath;
	MinBath = document.getElementById(MinBathrooms).value;
	MaxBath = document.getElementById(MaxBathrooms).value;
	LblBath = document.getElementById(LblBathrooms);
	LblBath.className = 'greensmalltext';
	if (MinBath == 0 && MaxBath == 0)
		LblBath.innerHTML = 'No Preference';
	else if (MinBath == MaxBath)
		LblBath.innerHTML = MinBath + ' bathroom(s) only';
	else if (MinBath > 0 && MaxBath == 0)
		LblBath.innerHTML = MinBath + ' bathroom(s) and above';
	else if (MinBath == 0 && MaxBath > 0)
		LblBath.innerHTML = 'Upto ' + MaxBath + ' bathroom(s)';
	else if (MinBath > MaxBath) {
		LblBath.innerHTML = 'Please select a valid range. Eg: 2 to 4';
		LblBath.className = 'redsmalltext';
	}
	else if (MinBath > 0 && MaxBath > 0)
		LblBath.innerHTML = 'Between ' + MinBath + ' and ' + MaxBath + ' bathroom(s)';
}
function ChangeSqft(MinSqfts, MaxSqfts, LblSqfts) {
	var MinSqft, MaxSqft, LblSqft;
	MinSqft = document.getElementById(MinSqfts).value;
	MaxSqft = document.getElementById(MaxSqfts).value;
	LblSqft = document.getElementById(LblSqfts);
	LblSqft.className = 'greensmalltext';
	if (MinSqft == 0 && MaxSqft == 0)
		LblSqft.innerHTML = 'No Preference';
	else if (MinSqft == MaxSqft)
		LblSqft.innerHTML = MinSqft + ' Sq. Ft. only';
	else if (MinSqft > 0 && MaxSqft == 0)
		LblSqft.innerHTML = MinSqft + ' Sq. Ft.  and above';
	else if (MinSqft == 0 && MaxSqft > 0)
		LblSqft.innerHTML = 'Upto ' + MaxSqft + ' Sq. Ft.';
	else if (MinSqft > MaxSqft) {
		LblSqft.innerHTML = 'Please select a valid range. Eg: 2 to 4';
		LblSqft.className = 'redsmalltext';
	}
	else if (MinSqft > 0 && MaxSqft > 0)
		LblSqft.innerHTML = 'Between ' + MinSqft + ' and ' + MaxSqft + ' Sq. Ft.';
}

function SetActiveTab(tabControl, tabNumber, url) {

	// var tabContainer = document.getElementById(tabControl).value
	var tabContainer = $find(tabControl);
	if (tabContainer != undefined && tabContainer != null) {
		tabContainer.set_activeTabIndex(tabNumber);
		document.getElementById("prodetFrame").src = url;
		//var cntr= document.getElementById("ltrDetailMsg").style.visibility == "hidden"; 
		document.getElementById("tcSecond_tpDetail_ltrDetailMsg").style.display = "none";

		iFrameHeight();
	}
}
function SetActiveTabPrperty(tabControl, tabNumber, url) {
	// var tabContainer = document.getElementById(tabControl).value
	var tabContainer = $find(tabControl);
	if (tabContainer != undefined && tabContainer != null) {
		tabContainer.set_activeTabIndex(tabNumber);

		document.getElementById("prodetFrame").src = url;
		iFrameHeight();

	}
}

function SetPropertyDetailActiveTab(tabControl, tabNumber, url) {
	//alert(tabControl);
	var tabContainer = $find(tabControl);
	if (tabContainer != undefined && tabContainer != null) {
		/*tabContainer.set_activeTabIndex(tabNumber);*/
		document.getElementById("prodetFrame").src = url;
		document.getElementById("tcSecond_tpDetail_ltrDetailMsg").style.display = "none";
		iFrameHeight();
	}
}
function ActivePropertyDetailTabHitesh(tchitesh) {

	if (tchitesh != undefined && tchitesh != null) {
		tchitesh.set_activeTabIndex(1);
		iFrameHeight();
	}
}
function ActivePropertyDetailTab() {
	var tabContainer = $find(PropertytabControlID);
	if (tabContainer != undefined && tabContainer != null) {
		tabContainer.set_activeTabIndex(1);
		iFrameHeight();
	}
}
function ActiveMapTab(tabControl, tabNumber) {
	var tabContainer = $find(tabControl);
	if (tabContainer != undefined && tabContainer != null) {
		tabContainer.set_activeTabIndex(tabNumber);
		iFrameHeight();
	}
}

function showSearchResultTab(tabControl, tabNumber) {
	var tabContainer = $find(tabControl);
	if (tabContainer != undefined && tabContainer != null) {
		tabContainer.set_activeTabIndex(tabNumber);
	}
}

function showmemarkerexclusive(add, lat, lon, mapid, imgpath, shadowpath, tabControl, detailpath) {

	PropertytabControlID = tabControl;
	//SetPropertyDetailActiveTab(tabControl,1,detailpath);
	//gmap = document.getElementById('subgurim_AitMap');
	tabContainer = $find(tabControl);
	if (tabContainer != undefined && tabContainer != null) {
		tabContainer.set_activeTabIndex(1);
		/*tabContainer.get_tabs()[1].set_enabled( false );*/
	}

	var point = new GLatLng(lat, lon);

	var myIcon = new GIcon();
	myIcon.image = imgpath;
	myIcon.shadow = shadowpath;
	myIcon.iconSize = new GSize(20, 34);
	myIcon.shadowSize = new GSize(37, 34);
	myIcon.iconAnchor = new GPoint(10, 34);
	myIcon.infoWindowAnchor = new GPoint(10, 0);


	var marker = new GMarker(point, myIcon);
	subgurim_AitMap.addOverlay(marker);
	marker.openInfoWindowHtml(add);
	subgurim_AitMap.setCenter(point, 10);
	//marker.showInfoWindow();

}
function showmemarker(add, lat, lon, mapid, imgpath, shadowpath, tabControl, detailpath) {

	PropertytabControlID = tabControl;
	SetPropertyDetailActiveTab(tabControl, 1, detailpath);
	//gmap = document.getElementById('subgurim_AitMap');
	tabContainer = $find(tabControl);
	if (tabContainer != undefined && tabContainer != null) {
		tabContainer.set_activeTabIndex(0);
		/*tabContainer.get_tabs()[1].set_enabled( false );*/
	}

	var point = new GLatLng(lat, lon);

	var myIcon = new GIcon();
	myIcon.image = imgpath;
	myIcon.shadow = shadowpath;
	myIcon.iconSize = new GSize(20, 34);
	myIcon.shadowSize = new GSize(37, 34);
	myIcon.iconAnchor = new GPoint(10, 34);
	myIcon.infoWindowAnchor = new GPoint(10, 0);


	var marker = new GMarker(point, myIcon);
	subgurim_AitMap.addOverlay(marker);
	marker.openInfoWindowHtml(add);
	//subgurim_AitMap.setCenter(point, 10);

	//marker.showInfoWindow();

}

function showcenter(bounds) {
	subgurim_AitMap.setCenter(bounds.getCenter(), subgurim_AitMap.getBoundsZoomLevel(bounds));
}
