﻿function createMarker(point, number, popText, iconUrl) {
	var baseIcon = new GIcon();
	//baseIcon.shadow = 'http://maps.google.com/mapfiles/kml/pal4/icon27s.png';
	baseIcon.iconSize = new GSize(20, 24);
	//baseIcon.shadowSize = new GSize(45, 42); 
	baseIcon.iconAnchor = new GPoint(9, 34);
	baseIcon.infoWindowAnchor = new GPoint(9, 2);
	//baseIcon.infoShadowAnchor = new GPoint(18, 25);
	baseIcon.infoShadowAnchor = new GPoint(5, 5);

	var icon = new GIcon(baseIcon);
	//icon.image = 'http://www.validsafe.com/merchant-trust-seal-images/house-icon.gif';
	icon.image = iconUrl;

	var marker = new GMarker(point, icon);
	GEvent.addListener(marker, 'click', function () {
		var infoTabs = [
        new GInfoWindowTab('Listing', popText)];
		//,
		//new GInfoWindowTab('Description', descText) 
		marker.openInfoWindowTabsHtml(infoTabs);
	});
	return marker;
}

function createMarkerLarge(point, number, popText, iconUrl) {
	var baseIcon = new GIcon();
	//baseIcon.shadow = 'http://maps.google.com/mapfiles/kml/pal4/icon27s.png';
	baseIcon.iconSize = new GSize(20, 34);
	//baseIcon.shadowSize = new GSize(45, 42); 
	baseIcon.iconAnchor = new GPoint(9, 34);
	baseIcon.infoWindowAnchor = new GPoint(9, 2);
	//baseIcon.infoShadowAnchor = new GPoint(18, 25);
	baseIcon.infoShadowAnchor = new GPoint(5, 5);

	var icon = new GIcon(baseIcon);
	//icon.image = 'http://www.validsafe.com/merchant-trust-seal-images/house-icon.gif';
	icon.image = iconUrl;

	var marker = new GMarker(point, icon);
	GEvent.addListener(marker, 'click', function () {
		var infoTabs = [
		new GInfoWindowTab('Listing', popText)];
		//,
		//new GInfoWindowTab('Description', descText) 
		marker.openInfoWindowTabsHtml(infoTabs);
	});
	return marker;
}

function createMarkerWithSize(point, number, popText, iconUrl, iLen, iWid) {
	var baseIcon = new GIcon();
	//baseIcon.shadow = 'http://maps.google.com/mapfiles/kml/pal4/icon27s.png';
	baseIcon.iconSize = new GSize(iLen, iWid);
	//baseIcon.shadowSize = new GSize(45, 42); 
	baseIcon.iconAnchor = new GPoint(9, 34);
	baseIcon.infoWindowAnchor = new GPoint(9, 2);
	//baseIcon.infoShadowAnchor = new GPoint(18, 25);
	baseIcon.infoShadowAnchor = new GPoint(5, 5);

	var icon = new GIcon(baseIcon);
	//icon.image = 'http://www.validsafe.com/merchant-trust-seal-images/house-icon.gif';
	icon.image = iconUrl;


	var marker = new GMarker(point, icon);
	GEvent.addListener(marker, 'click', function () {
		var infoTabs = [
        new GInfoWindowTab('Listing', popText)];
		//,
		//new GInfoWindowTab('Description', descText) 
		marker.openInfoWindowTabsHtml(infoTabs);
	});
	return marker;
}

//var point = new GLatLng(40.74155,-73.982133);
//map.addOverlay(createMarker(point, '1','zzz','AAA'));

function addOnloadEvent(fnc) {
	if (typeof window.addEventListener != "undefined")
		window.addEventListener("load", fnc, false);
	else if (typeof window.attachEvent != "undefined") {
		window.attachEvent("onload", fnc);
	}
	else {
		if (window.onload != null) {
			var oldOnload = window.onload;
			window.onload = function (e) {
				oldOnload(e);
				window[fnc]();
			};
		}
		else
			window.onload = fnc;
	}
}

function saveRemoveApartment(obj, id) {
	var mee = this;

	var u = '/PropertySearch/SaveRemoveApartment.aspx?data=' + obj.innerHTML + '&id=' + id;

	$.post(u, { 'name': this.innerHTML, 'apartment_id': id }, function (data) {

		//$(".saveRemoveLink").corner();
		if (data == "EXPIRED") window.location = "/my-account/login.do?id=" + id;
		obj.innerHTML = data;
		//window.location = "/my-account/login.do?id=" + id;
	});
}

function MM_openBrWindow(theURL, winName, features) { //v2.0
	window.open(theURL, winName, features);
}

function CheckIsIE() {
	if (navigator.appName.toUpperCase() == 'MICROSOFT INTERNET EXPLORER') {
		return true;
	}
	else {
		return false;
	}
}

function PrintThisPage() {
	if (CheckIsIE() == true) {
		document.ifWorkspace.focus();
		document.ifWorkspace.print();
	}
	else {
		window.frames['ifWorkspace'].focus();
		window.frames['ifWorkspace'].print();
	}
}

function PrintThisWholePage() {
	window.print();
}

function sendmail() {
	var to = "";
	var subj = "ArdorNY.com - Best Real Estate Source in New York City!";
	var body = "Hi, just visited this page at www.ardorny.com and wanted to share it with you, take a look: ";
	var url = window.location.href;
	parent.location.href = 'mailto:' + to + '?subject=' + subj + ' &body=' + body + url;
}

function fitMap(map, points) {
	var bounds = new GLatLngBounds();
	for (var i = 0; i < points.length; i++) {
		bounds.extend(points[i]);
	}
	map.setZoom(map.getBoundsZoomLevel(bounds));
	map.setCenter(bounds.getCenter());
}


function ClearValidators() {
	if (typeof (Page_Validators) != "undefined") {
		for (var i = 0; i < Page_Validators.length; i++) {
			var validator = Page_Validators[i];
			validator.isvalid = true;
			ValidatorUpdateDisplay(validator);
		}
	}
}

function escaped(check) {
	var retval="";
	var j=0;
	for (var i = 0; i < check.length; i++) {
		retval += check[i];
		if (i % 4 == 0) {
			retval += j++;
		}
	}
	return retval;
}

$(document).ready(function () {
    $(".makeEmail").each(function (data, value) {

        //var h = $(this).text();
        var h = $(value).html();
        //("AAA");
        $(value).html("<a href='mailto:" + h + "'>" + h + "</a>");
        //o.html("AAA");
    });
});
