/*/***************************************************************************************************************************/// <name>     Altaire | Palo Alto - Common Java Script Library</name>/// <summary>  This JavaScript provides common functions for the menu and other dynamic navigation functionality.</summary>/// <history>///            Konrad Kyc [2008 © Vantagesoft.ca] - 2008-07-13 - Created./// </history>/// <notes>/// </notes>///***************************************************************************************************************************/var floorplanImages = new Array(9);window.onload = InitializeOnLoad;window.onresize = LockWindowSize;///**********************************************************************************/// <name>    Initialize </name>/// <summary> Initialize function that loads immediately when content is downloaded.</summary>///**********************************************************************************function Initialize(){    LockWindowSize();    PageInit();         var tourLink = document.getElementById('hrefTourVideo');        // Change the tour video menu link to a div pop-up. This is to ensure that if the user does not have    // JavaScript enabled, then a static page with the Tour video will be shown.    if(BrowserSupportsModals())    {        tourLink.href = '#TB_inline?height=434&amp;width=730&amp;inlineId=divAltaireTour';        tourLink.setAttribute("target", "");    }    else    {        tourLink.setAttribute("onclick", "javascript:OpenNewWindow('Tour.htm', 752, 452); return false;");    }}///**********************************************************************************/// <name>    InitializeOnLoad </name>/// <summary> Initialize function that loads on PageLoad.</summary>///**********************************************************************************function InitializeOnLoad(){    PageInitOnLoad();}function PageInitOnLoad(){} // Virtual Functionfunction PageInit(){} // Virtual Function///**********************************************************************************/// <name>    LockWindowSize </name>/// <summary> Locks the window size such that the elements do not float off the page.</summary>///**********************************************************************************function LockWindowSize() {    var siteBlock = document.getElementById("divSiteBlock");        if(window.innerWidth < 1220 || document.documentElement.offsetWidth < 1220)    {        siteBlock.className = "FixedSiteBlock";    }    else    {        siteBlock.className = "DynamicSiteBlock";    }}///**********************************************************************************/// <name>    ShowDirections </name>/// <summary> Shows the Directions Modal (that lets the user enter the FROM location).</summary>///**********************************************************************************function ShowDirections(isAltaire){    // If the browser supports the modals, then show the modal for the directions    if(BrowserSupportsModals())    {        tb_show('', '#TB_inline?height=100&amp;width=330&amp;inlineId=divDirectionsInfo', false);    }    else    {        if(isAltaire)        {            // Otherwise open a new window with Google Directions            OpenNewWindow('http://maps.google.com/maps?f=d&hl=en&geocode=&saddr=&daddr=901+San+Antonio+Road,+Palo+Alto,+California+94303', null, null);        }        else        {            // Otherwise open a new window with Google Directions            OpenNewWindow('http://maps.google.com/maps?f=d&hl=en&geocode=&saddr=&daddr=3401+Alma+Street,+Palo+Alto,+California+94306', null, null);        }    }}///**********************************************************************************/// <name>    GetDirections </name>/// <summary> Opens Google Maps with the directions to Altaire Palo Alto, from the///           specified location.</summary>///**********************************************************************************function GetDirections(isKeyPress, isAltaire) {    var showDirections = false;        if(isKeyPress)    {        var pressedKey;                if (window.Event === null) { // ie            pressedKey = event.which;        } else { // mozilla            pressedKey = event.keyCode;        }                // When 'Enter' is pressed from the textbox, show the directions.        if (pressedKey == 13)         {            showDirections = true;  // Enter        }    }    else        showDirections = true;        if(showDirections)    {        var directionsFrom = document.getElementById("txtDirectionsFrom").value;                if(isAltaire)        {            // Open the directions to Altaire Palo Alto in a new window            OpenNewWindow('http://maps.google.com/maps?f=d&hl=en&geocode=&saddr=' + directionsFrom + '&daddr=901+San+Antonio+Road,+Palo+Alto,+California+94303', null, null);                }        else        {            // Open the directions to Offsite Center in a new window            OpenNewWindow('http://maps.google.com/maps?f=d&hl=en&geocode=&saddr=' + directionsFrom + '&daddr=3401+Alma+Street,+Palo+Alto,+California+94306', null, null);        }                // Close the Modal        tb_remove();    }}///**********************************************************************************/// <name>    OpenNewWindow </name>/// <summary> Opens a new window with the specified parameters.</summary>///**********************************************************************************function OpenNewWindow(url, width, height) {    OpenNewWindow(url, width, height, false);}///**********************************************************************************/// <name>    OpenNewWindow </name>/// <summary> Opens a new window with the specified parameters.</summary>///**********************************************************************************function OpenNewWindow(url, width, height, scrollbars) {    if(width != null && width > 0 && height != null && height > 0)    {        if(scrollbars)            window.open(url,'','height=' + height + ',width=' + width + ',scrollbars=yes,status=no,menubar=no,toolbar=no,location=no');        else            window.open(url,'','height=' + height + ',width=' + width + ',status=no,menubar=no,toolbar=no,location=no');    }    else        window.open(url,'','');      }///**********************************************************************************/// <name>    ChangeFloorplan </name>/// <summary> Changes the floorplan for a given.</summary>///**********************************************************************************function ChangeFloorplan(floorplanId, imgId){    ChangeFloorplan(floorplanId, imgId, false);}///**********************************************************************************/// <name>    ChangeFloorplan </name>/// <summary> Changes the floorplan for a given.</summary>///**********************************************************************************function ChangeFloorplan(floorplanId, imgId, isInitialLoad){    floorplanId = floorplanId.toUpperCase();       if (!BrowserSupportsJQuery() || isInitialLoad)    {        document.getElementById(imgId).src = 'Images/Floorplans/Floorplan' + floorplanId + '.gif';    }    else    {        // Change the floorplan image (by fading-out previous and fading-in next)        $("#" + imgId).fadeTo("slow", 0.0, function (){            document.getElementById(imgId).src = 'Images/Floorplans/Floorplan' + floorplanId + '.gif';            setTimeout(function() {$("#" + imgId).fadeTo("slow", 1.0);}, 0);        });        }        document.getElementById(imgId).alt = "Floor Plan " + floorplanId;        switch(floorplanId)    {        case 'POD':            document.title = 'Altaire | Palo Alto - Floorplans - SITE PLAN - Podium Level';            document.getElementById(imgId).alt = "SITE PLAN - Podium";            break;                    case 'A':            document.title = 'Altaire | Palo Alto - Floorplans - PLAN A - 3 Bedroom, 2.5 Bath';            break;        case 'B':            document.title = 'Altaire | Palo Alto - Floorplans - PLAN B - 3 Bedroom, 2.5 Bath';            break;        case 'C':            document.title = 'Altaire | Palo Alto - Floorplans - PLAN C - 3 Bedroom, 2.5 Bath';            break;        case 'D':            document.title = 'Altaire | Palo Alto - Floorplans - PLAN D - 4 Bedroom, 3.5 Bath';            break;        case 'E':            document.title = 'Altaire | Palo Alto - Floorplans - PLAN E - 4 Bedroom, 3.5 Bath';            break;        case 'F':            document.title = 'Altaire | Palo Alto - Floorplans - PLAN F - 3 Bedroom, 3 Bath';            break;        case 'G':            document.title = 'Altaire | Palo Alto - Floorplans - PLAN G - 1 Bedroom, 1 Bath';            break;        case 'H':            document.title = 'Altaire | Palo Alto - Floorplans - PLAN H - 2 Bedroom, 2 Bath';            break;                }        // Clear all styles for the links    document.getElementById("hrefFloorplanPOD").className = "FloorplanLink PrintHidden";    document.getElementById("hrefFloorplanA").className = "FloorplanLink PrintHidden";    document.getElementById("hrefFloorplanB").className = "FloorplanLink PrintHidden";    document.getElementById("hrefFloorplanC").className = "FloorplanLink PrintHidden";    document.getElementById("hrefFloorplanD").className = "FloorplanLink PrintHidden";    document.getElementById("hrefFloorplanE").className = "FloorplanLink PrintHidden";    document.getElementById("hrefFloorplanF").className = "FloorplanLink PrintHidden";    document.getElementById("hrefFloorplanG").className = "FloorplanLink PrintHidden";    document.getElementById("hrefFloorplanH").className = "FloorplanLink PrintHidden";    // Change the style of the corresponding floorplan link    document.getElementById("hrefFloorplan" + floorplanId).className = "FloorplanLink FloorplanLink-on";         // Change the hash so that floorplan can be bookmarked and restored properly (by javascript)    window.location.hash = "Floorplan" + floorplanId;}function PreloadFloorplanImages(){    floorplanImages[0] = new Image(643, 554);     floorplanImages[1] = new Image(643, 554);    floorplanImages[2] = new Image(643, 554);    floorplanImages[3] = new Image(643, 554);    floorplanImages[4] = new Image(643, 554);    floorplanImages[5] = new Image(643, 554);    floorplanImages[6] = new Image(643, 554);    floorplanImages[7] = new Image(643, 554);    floorplanImages[8] = new Image(643, 554);        floorplanImages[0].src = "Images/Floorplans/FloorplanPOD.gif";     floorplanImages[1].src = "Images/Floorplans/FloorplanA.gif";     floorplanImages[2].src = "Images/Floorplans/FloorplanB.gif";     floorplanImages[3].src = "Images/Floorplans/FloorplanC.gif";     floorplanImages[4].src = "Images/Floorplans/FloorplanD.gif";    floorplanImages[5].src = "Images/Floorplans/FloorplanE.gif";    floorplanImages[6].src = "Images/Floorplans/FloorplanF.gif";    floorplanImages[7].src = "Images/Floorplans/FloorplanG.gif";    floorplanImages[8].src = "Images/Floorplans/FloorplanH.gif"; }///**********************************************************************************/// <name>    ClosePopUp </name>/// <summary> Closes the Modal (pop-up).</summary>///**********************************************************************************function ClosePopUp(){        // Close the Modal        tb_remove();}///**********************************************************************************/// <name>    SwitchImage </name>/// <summary> Switches the image for a given object.</summary>///**********************************************************************************function SwitchImage(img, imagePath){    img.src = imagePath;}///**********************************************************************************/// <name>    UseGoogleAnalytics </name>/// <summary> Based on the current host, it determines whether to log statistics.///           This is to ignore staging environments.</summary>///**********************************************************************************function UseGoogleAnalytics(){    return (!(document.location.hostname.toLowerCase() == 'localhost' || document.location.hostname.toLowerCase() == 'www.hutnergroup.com' || document.location.hostname.toLowerCase() == 'hutnergroup.com' || document.location.hostname.toLowerCase() == 'www.konradkyc.com' || document.location.hostname.toLowerCase() == 'konradkyc.com'));}///**********************************************************************************/// <name>    BrowserSupportsModals </name>/// <summary> Determines whether the broswer can support the imitated modal overlays.///           if the browser does not support modals, then a regular pop-up will be///           open.</summary>///**********************************************************************************function BrowserSupportsModals(){    try    {        if(BrowserDetect.browser == "Explorer" && BrowserDetect.majorVersion < 6)            return false;        else if(BrowserDetect.browser == "Firefox" && BrowserDetect.majorVersion < 1)            return false;         else if(BrowserDetect.browser == "Netscape" && BrowserDetect.majorVersion < 6)            return false;        else if(BrowserDetect.browser == "Mozilla" && BrowserDetect.majorVersion < 2)            return false;                else if(BrowserDetect.browser == "Safari" && BrowserDetect.majorVersion < 3)            return false;        else if(BrowserDetect.browser == "Opera" && BrowserDetect.majorVersion < 8)            return false;                                       else        {            // For anything else, return true by default.            return true;        }    }    catch(e)    {        // return false when error occurs        return false;    }}///**********************************************************************************/// <name>    BrowserSupportsJQuery </name>/// <summary> Determines whether the broswer can support the JQuery functionality.///           if the browser does not support JQuery, then features such as animtaion///           will not be initiated.</summary>///**********************************************************************************function BrowserSupportsJQuery(){    try    {        if(BrowserDetect.browser == "Explorer" && BrowserDetect.majorVersion < 6)            return false;        else if(BrowserDetect.browser == "Firefox" && BrowserDetect.majorVersion < 1)            return false;         else if(BrowserDetect.browser == "Netscape" && BrowserDetect.majorVersion < 6)            return false;        else if(BrowserDetect.browser == "Mozilla" && BrowserDetect.majorVersion < 2)            return false;                else if(BrowserDetect.browser == "Safari" && BrowserDetect.majorVersion < 3)            return false;        else if(BrowserDetect.browser == "Opera" && BrowserDetect.majorVersion < 8)            return false;                                       else        {            // For anything else, return true by default.            return true;        }    }    catch(e)    {        // return false when error occurs        return false;    }}///**********************************************************************************/// <name>    Browser Detection </name>/// <summary> Detects which browser the user is using.</summary>/// <credit>  http://www.quirksmode.org/js/detect.html</credit>///**********************************************************************************var BrowserDetect = {	init: function () {		this.browser = this.searchString(this.dataBrowser) || "An unknown browser";		this.version = this.searchVersion(navigator.userAgent)			|| this.searchVersion(navigator.appVersion)			|| "an unknown version";		this.majorVersion = (this.version.toString()).split(".")[0];		this.OS = this.searchString(this.dataOS) || "an unknown OS";	},	searchString: function (data) {		for (var i=0;i<data.length;i++)	{			var dataString = data[i].string;			var dataProp = data[i].prop;			this.versionSearchString = data[i].versionSearch || data[i].identity;			if (dataString) {				if (dataString.indexOf(data[i].subString) != -1)					return data[i].identity;			}			else if (dataProp)				return data[i].identity;		}	},	searchVersion: function (dataString) {		var index = dataString.indexOf(this.versionSearchString);		if (index == -1) return;		return parseFloat(dataString.substring(index+this.versionSearchString.length+1));	},	dataBrowser: [		{ 	string: navigator.userAgent,			subString: "OmniWeb",			versionSearch: "OmniWeb/",			identity: "OmniWeb"		},		{			string: navigator.vendor,			subString: "Apple",			identity: "Safari",			versionSearch: "Version"		},		{			prop: window.opera,			identity: "Opera"		},		{			string: navigator.vendor,			subString: "iCab",			identity: "iCab"		},		{			string: navigator.vendor,			subString: "KDE",			identity: "Konqueror"		},		{			string: navigator.userAgent,			subString: "Firefox",			identity: "Firefox"		},		{			string: navigator.vendor,			subString: "Camino",			identity: "Camino"		},		{		// for newer Netscapes (6+)			string: navigator.userAgent,			subString: "Netscape",			identity: "Netscape"		},		{			string: navigator.userAgent,			subString: "MSIE",			identity: "Explorer",			versionSearch: "MSIE"		},		{			string: navigator.userAgent,			subString: "Gecko",			identity: "Mozilla",			versionSearch: "rv"		},		{ 		// for older Netscapes (4-)			string: navigator.userAgent,			subString: "Mozilla",			identity: "Netscape",			versionSearch: "Mozilla"		}	],	dataOS : [		{			string: navigator.platform,			subString: "Win",			identity: "Windows"		},		{			string: navigator.platform,			subString: "Mac",			identity: "Mac"		},		{			string: navigator.platform,			subString: "Linux",			identity: "Linux"		}	]};BrowserDetect.init();