//
// Gestion SANDALWOOD Management Canada
//
// written by Patrick Irie
// Patrick Irie Phototography & New Media
//
// Copyright 2004, 2005, 2006, 2007, 2008, 2009 Sandalwood Management Canada Co.
// ALL RIGHTS RESERVED.
//
// July 12, 2010
// ver 1.10.14
//
//
//
///////////////////////////////////////////////////////////////////////////////////


// 
// client definable variables
//

// Feedback Subject Lines
var feedbackSubjEn = 'Website feedback';   // can be set for automatic email titles for 'Your Opinion' button
var feedbackSubjFr = 'Opinion du site web';


var broURL = "Properties/Juillet2010.pdf";

var defaultMallOpp = "455";
var defaultOfficeOpp = "420";




//
// global variable definitions
//

browserName = navigator.appName;

menuButtons = new Array("home", "aboutus", "ourteam", "contactus", "opinion");

var isCD = 0;


//
// global functions
//


function initButtons(color, language) {

	for (x=0; x < menuButtons.length; x++) {

		eval('b_' + menuButtons[x] + '_Over = new Image();');
		eval('b_' + menuButtons[x] + '_Over.src = "' + color + 'b_' + language + '_' + menuButtons[x] + '_on.gif"');

		eval('b_' + menuButtons[x] + '_Leave = new Image();');
		eval('b_' + menuButtons[x] + '_Leave.src = "' + color + 'b_' + language + '_' + menuButtons[x] + '_over.gif"');

		eval('b_' + menuButtons[x] + '_Active = new Image();');
		eval('b_' + menuButtons[x] + '_Active.src = "' + color + 'b_' + language + '_' + menuButtons[x] + '_off.gif"');

	}

	b_language_Over = new Image();
	eval('b_language_Over.src = "' + color + 'b_' + language + '_language_Over.gif"');

}



function buildMenu(color, language, currentpage) {

		initButtons(color, language);
		var LC = (language == "En") ? "_Fr" : "_En";

		document.write("<table border=0 width=862 cellspacing=0 cellpadding=0>");
		document.write("	<tr>");
		document.write("		<td width=750 align=left valign=top>");
		if (currentpage == "home")
			document.write("			<A nohref onMouseOver=\"window.status=''; return true;\" onMouseOut=\"window.status=''; return true;\"><img width=99 height=14 src=\"" + color + "b_" + language + "_home_on.gif\" border=0></A>&nbsp;");
		else
			document.write("			<A href=\"home_" + language + ".htm\" onMouseOver=\"bRoll('" + color + "', 'home', '" + language + "', 'over'); window.status=''; return true;\" onMouseOut=\"bRoll('" + color + "', 'home', '" + language + "', 'off'); window.status=''; return true;\"><img name=\"home\" width=99 height=14 src=\"" + color + "b_" + language + "_home_off.gif\" border=0></A>&nbsp;");

		if (currentpage == "aboutus")
			document.write("			<A nohref onMouseOver=\"window.status=''; return true;\" onMouseOut=\"window.status=''; return true;\"><img width=99 height=14 src=\"" + color + "b_" + language + "_aboutus_on.gif\" border=0></A>&nbsp;");
		else
			document.write("			<A href=\"aboutus_" + language + ".htm\" onMouseOver=\"bRoll('" + color + "', 'aboutus', '" + language + "', 'over'); window.status=''; return true;\" onMouseOut=\"bRoll('" + color + "', 'aboutus', '" + language + "', 'off'); window.status=''; return true;\"><img name=\"aboutus\" width=99 height=14 src=\"" + color + "b_" + language + "_aboutus_off.gif\" border=0></A>&nbsp;");

		if (currentpage == "ourteam")
			document.write("			<A nohref onMouseOver=\"window.status=''; return true;\" onMouseOut=\"window.status=''; return true;\"><img width=99 height=14 src=\"" + color + "b_" + language + "_ourteam_on.gif\" border=0></A>&nbsp;");
		else
			document.write("			<A href=\"ourteam_" + language + ".htm\" onMouseOver=\"bRoll('" + color + "', 'ourteam', '" + language + "', 'over'); window.status=''; return true;\" onMouseOut=\"bRoll('" + color + "', 'ourteam', '" + language + "', 'off'); window.status=''; return true;\"><img name=\"ourteam\" width=99 height=14 src=\"" + color + "b_" + language + "_ourteam_off.gif\" border=0></A>&nbsp;");

		if (currentpage == "contactus")
			document.write("			<A nohref onMouseOver=\"window.status=''; return true;\" onMouseOut=\"window.status=''; return true;\"><img width=99 height=14 src=\"" + color + "b_" + language + "_contactus_on.gif\" border=0></A>&nbsp;");
		else
			document.write("			<A href=\"contactus_" + language + ".htm\" onMouseOver=\"bRoll('" + color + "', 'contactus', '" + language + "', 'over'); window.status=''; return true;\" onMouseOut=\"bRoll('" + color + "', 'contactus', '" + language + "', 'off'); window.status=''; return true;\"><img name=\"contactus\" width=99 height=14 src=\"" + color + "b_" + language + "_contactus_off.gif\" border=0></A>&nbsp;");

		document.write("			&nbsp;<A href=\"mailto:opinion@sandalwoodmgt.com?subject=" + (language == 'En' ? feedbackSubjEn : feedbackSubjFr) + (isCD == 1 ? ' (CDROM)' : '') +  "\" onMouseOver=\"bRoll('" + color + "', 'opinion', '" + language + "', 'over'); window.status=''; return true;\" onMouseOut=\"bRoll('" + color + "', 'opinion', '" + language + "', 'off'); window.status=''; return true;\"><img name=\"opinion\" width=99 height=14 src=\"" + color + "b_" + language + "_opinion_off.gif\" border=0></A>");
		document.write("		</td>");
		document.write("		<td align=right valign=top>");
		document.write("			<A href=\"" + currentpage + LC + ".htm\" onMouseOver=\"bRoll('" + color + "', 'language', '" + language + "', 'over'); window.status=''; return true;\" onMouseOut=\"bRoll('" + color + "', 'language', '" + language + "', 'off'); window.status=''; return true;\"><img name=\"language\" width=99 height=14 src=\"" + color + "b_" + language + "_language_off.gif\" border=0></A>");
		document.write("		</td>");
		document.write("	<tr>");
		document.write("</table>");
		document.write("<br>");
		if(language == "En")
			document.write("<span style=\"font-family:Arial, Helvetica, sans-serif; font-size:7pt; letter-spacing:.01em; color:#505050\">&copy;2009 Copyright Sandalwood Management.  All Rights Reserved.</span>");
		else
			document.write("<span style=\"font-family:Arial, Helvetica, sans-serif; font-size:7pt; letter-spacing:.01em; color:#505050\">&copy;2009 Copyright Gestion Sandalwood. Tous droits réservés.</span>");


}





function buildSmaps(language) {

locList = new Array("QC", "401", "402", "403", "404", "405", "406", "407", "408", "409", "410", "411", "412", "413", "414", "415", "416", "417", "418", "428", "429", "430", "431", "432", "433", "436", "447", "448", "449", "450", "454", "455");

	var loadSmap = (language == "En") ? "Properties/Smap_load.gif" : "Properties/Smap_load_Fr.gif";

	for (x=0; x < locList.length; x++) {

		document.write("			<div id='Smap_" + locList[x] + "' style='position:absolute; top:24; margin-left:429; z-index:3; visibility:hidden;'>");
		document.write("				<img width=217 height=226 lowsrc='" + loadSmap + "' src='Properties/Smap_" + locList[x] + ".gif'>");
		document.write("			</div>");
	}

}




function buildAList() {

locList = new Array("401", "402", "403", "404", "405", "406", "407", "408", "409", "410", "411", "412", "413", "414", "415", "416", "417", "418", "428", "429", "430", "431", "432", "433", "436", "447", "448", "449", "450", "454", "455");

addressList = new Array("1094, boul. des Chutes<br>Beauport, QC",
			"1700, rue Sherbrooke<br>Magog, QC",
			"1971, rue Bilodeau<br>Plessisville, QC",
			"4000, boul. du Jardin<br>Charlesbourg, QC",
			"6700, rue St-Georges<br>Lévis, QC",
			"1100, boul. de la Chaudière<br>Cap-Rouge, QC",
			"10516, boul. Ste-Anne<br>Sainte-Anne-de-Beaupré, QC",
			"9550, boul. de l'Ormière<br>Québec, QC",
			"333, Côte Joyeuse<br>St-Raymond, QC",
			"161, route 230 ouest<br>La Pocatière, QC",
			"175, rue Principale<br>Cowansville, QC",
			"25, route 138<br>Forestville, QC",
			"2000, boul. Louis-Fréchette<br>Nicolet, QC",
			"3856, boul. Taschereau<br>Greenfield Park, QC",
			"250, rue Fiset<br>Sorel, QC",
			"8245, boul. Taschereau<br>Brossard, QC",
			"340, rue Belvédère<br>Sherbrooke, QC",
			"7500, boul. Les Galeries d'Anjou<br>Anjou, QC",
			"500, avenue Daigneault<br>Chandler, QC",
			"39-2, Montée Sandy Beach<br>Gaspé, QC",
			"705, avenue du Pont Nord<br>Alma, QC",
			"1324, boul. Talbot<br>Chicoutimi, QC",
			"3460, boul. St-François<br>Jonquière, QC",
			"1221, boul. Marcotte<br>Roberval, QC",
			"270-284, Elgar<br>Ile-des-S&#156;urs, QC",
			"40, Place du Commerce<br>Ile-des-S&#156;urs, QC",
			"375, boul. De Comporté<br>La Malbaie, QC",
			"130, route Racette<br>Saint-Augustin-de-Desmaures, QC",
			"170, boul. Laurier Est<br>Laurier-Station, QC",
			"1950, boul. Labelle<br>St-Jérôme, QC",
			"475 boul. Jutras Est<br>Victoriaville, QC"
			);

	for (x=0; x < locList.length; x++) {

		document.write("			<div id='A_" + locList[x] + "' style='position:absolute; top:270; margin-left:420; width:217; z-index:3; text-align:right; visibility:hidden;'>");
		document.write("				<p>" + addressList[x] + "</p>");
		document.write("			</div>");
	}

}





// build maps for office props
//
function buildOmaps() {

locList = new Array("420", "421", "422", "423", "424", "425", "426", "427", "434", "435", "437", "438", "439", "440", "441", "442", "443", "444", "445", "446", "451", "452", "453", "454", "455");

	for (x=0; x < locList.length; x++) {
	
		document.write('		<div id="map' + locList[x] + '" style="position:absolute; right:0; top:150; width:114; visibility:hidden;">');
		document.write('			<img align=top width=114 height=125 src="Properties/map_' + locList[x] + '.gif"> </div>');
	}

}





// Arrows
//
function aRoll(request, state) {
	if(slides > 1)
		document [request].src = "Properties/b_" + request + "_" + state + ".gif";
}




// menu buttons
//
function bRoll(set, request, language, state) {

	switch(state) {
		case "on":
			document [request].src = set + "b_" + language + "_" + request + "_on.gif";
			break;

		case "over":
			document [request].src = set + "b_" + language + "_" + request + "_over.gif";
			break;

		case "off":
			document [request].src = set + "b_" + language + "_" + request + "_off.gif";
			break;

		// unused
		//case "click":
		//	document [request].src = set + "b_" + language + "_" + request + "_click.gif";
		//	break;
	}

}



// Properties rollover (Smap)
//
function pRoll(locID, state) {

	switch(state) {
		case "over":
			document.getElementById('Smap_'+locID).style.visibility='visible';
			document.getElementById('A_'+locID).style.visibility='visible';

		break;


		case "off":
			if(selectedRegion) {
				document.getElementById('Smap_'+locID).style.visibility='hidden';
				if(selectedRegion != "AL" && selectedRegion != "OldMtl")
					selRegS = "QC";
				else
					selRegS = selectedRegion;

				document.getElementById('Smap_'+selRegS).style.visibility='visible';
			} else
				document.getElementById('Smap_'+locID).style.visibility='hidden';

			document.getElementById('A_'+locID).style.visibility='hidden';

		break;
	}

}



// Region (properties) rollover (Cmap, base Smap and list)
// mall
//
function rRoll(obj, state, region) {

	switch(state) {
		case "over":
			if (browserName == "Microsoft Internet Explorer")
				obj.style.cursor='hand';
			else
				obj.style.cursor='pointer';

			obj.style.color='#E20A16';

			if(selectedRegion) {

				selRegC = SelRegS = "QC"; // post alberta & oldmtl kludge

				document.getElementById('Smap_'+selRegS).style.visibility='hidden';
				document.getElementById('Cmap_'+selRegC).style.visibility='hidden';
			}

			_region = (region =="OldMtl") ? region : "QC";

			document.getElementById('Smap_'+_region).style.visibility='visible';

			regC = "QC";  // post Alberta kludge

			document.getElementById('Cmap_'+regC).style.visibility='visible';

			break;


		case "click":
			if(activeItem)
				activeItem.style.color='#000000';

			document.getElementById('Cmap_QC').style.visibility='hidden'; // replacement kludge (post Alberta)
			
			document.getElementById('QCList').style.visibility='hidden';
			document.getElementById('MtlEList').style.visibility='hidden';
			document.getElementById('SLSJList').style.visibility='hidden';
			document.getElementById('GaspList').style.visibility='hidden';

			document.getElementById(region + 'List').style.visibility='visible';

			selectedRegion = region;
			activeItem = obj;

			break;


		case "out":
			if (region != selectedRegion)
				obj.style.color='#000000';

			selRegC = selRegS = "QC";  // post alberta & oldmtl kludge

			regC = _region = "QC";

			if(selectedRegion && region!=selectedRegion) {
				document.getElementById('Smap_'+_region).style.visibility='hidden';
				document.getElementById('Smap_'+selRegS).style.visibility='visible';
				document.getElementById('Cmap_'+regC).style.visibility='hidden';
				document.getElementById('Cmap_'+selRegC).style.visibility='visible';
			} else if(selectedRegion) {
				document.getElementById('Smap_'+selRegS).style.visibility='visible';
				document.getElementById('Cmap_'+selRegC).style.visibility='visible';
			} else {
				document.getElementById('Smap_'+_region).style.visibility='hidden';
				document.getElementById('Cmap_'+regC).style.visibility='hidden';
			}

			break;

	}

}





// office region roll
//
function orRoll(obj, state, region) {

	switch(state) {
		case "over":
			if (browserName == "Microsoft Internet Explorer")
				obj.style.cursor='hand';
			else
				obj.style.cursor='pointer';

			obj.style.color='#E20A16';

			if(selectedRegion)
				document.getElementById('regMap' + selectedRegion).style.visibility='hidden';
				
			document.getElementById('regMap' + region).style.visibility='visible';

			break;


		case "click":
			if(selectedRegion == region) break;
			
			if(selectedRegion) {
				activeItem.style.color='#FFFFFF';
				document.getElementById('propList' + selectedRegion).style.visibility='hidden';
			}

			document.getElementById('propList' + region).style.visibility='visible';

			

			selectedRegion = region;
			activeItem = obj;

			break;


		case "out":
			if (region != selectedRegion) {
				obj.style.color='#FFFFFF';
				document.getElementById('regMap' + region).style.visibility='hidden';
			}
			
			if(selectedRegion)
				document.getElementById('regMap' + selectedRegion).style.visibility='visible';

			break;

	}

}



// office prop roll
//
function opRoll(obj, state, prop) {

	switch(state) {
		case "over":
			if (browserName == "Microsoft Internet Explorer")
				obj.style.cursor='hand';
			else
				obj.style.cursor='pointer';

			obj.style.color='#E20A16';

			document.getElementById('map' + prop).style.visibility='visible';
			
			break;


		case "out":
			obj.style.color='#FFFFFF';
			
			document.getElementById('map' + prop).style.visibility='hidden';

			break;

	}

}








// view buttons
//
function vRoll(request, language, state) {

	switch(state) {
		case "over":
			document [request].src = "b_" + language + "_view_over.gif";
			break;

		case "off":
			document [request].src = "b_" + language + "_view_off.gif";
			break;

		case "click":
			document [request].src = "b_" + language + "_view_click.gif";
			break;
	}

}



function randSplash() {

	var splashList = new Array("mall_band_1.jpg", "mall_band_2.jpg", "mall_band_3.jpg", "mall_band_4.jpg", "office_band_1.jpg", "office_band_2.jpg", "office_band_3.jpg", "office_band_4.jpg");
	var rand = Math.round(Math.random()*(splashList.length-1));

	document.write("<img width=862 height=219 src=\"Corporate/" + splashList[rand] + "\" border=0>");

}



function buildCounter(language) {
	if(language == "En")
		document.write('<img name="slideCount" width=28 height=35 border=0 src="Properties/1.gif"><img width=23 height=35 border=0 src="Properties/of.gif"><img name="slideTotal" width=28 height=35 border=0 src="Properties/' + slides + '.gif">');
	else
		document.write('<img name="slideCount" width=28 height=35 border=0 src="Properties/1.gif"><img width=23 height=35 border=0 src="Properties/de.gif"><img name="slideTotal" width=28 height=35 border=0 src="Properties/' + slides + '.gif">');
}




function buildCounterOffices(language) {
	if(language == "En")
		document.write('<img name="slideCount" width=23 height=21 border=0 src="Properties/1b.gif"><img width=21 height=21 border=0 src="Properties/ofb.gif"><img name="slideTotal" width=23 border=0 height=21 src="Properties/' + slides + 'b.gif">');
	else
		document.write('<img name="slideCount" width=23 height=21 border=0 src="Properties/1b.gif"><img width=21 height=21 border=0 src="Properties/deb.gif"><img name="slideTotal" width=23 height=21 border=0 src="Properties/' + slides + 'b.gif">');
}




function spawnPopupWin(type, locID, language, Xsize, Ysize, SPECIAL) {

	if (browserName == "Netscape") {
		xPos = window.screenX + 100;
		yPos = window.screenY + 100;
	} else {
		xPos = window.screenLeft + 100;
		yPos = window.screenTop + 50;
	}

	switch(language) {
		case "En":
			if(type == "f")
				window.open('Properties/floorplan.htm?' + locID + '&' + SPECIAL, '_floorplan', 'resizable=no, scrollbars=no, toolbar=no, location=no, directories=no, status=no, width=' + Xsize + ', height=' + Ysize + ', menubar=no, top=' + yPos + ', left=' + xPos);
				
			else if(type == "d")
				window.open('Properties/demographm.htm?' + locID + '&' + SPECIAL, '_demograph', 'resizable=no, scrollbars=no, toolbar=no, location=no, directories=no, status=no, width=' + Xsize + ', height=' + Ysize + ', menubar=no, top=' + yPos + ', left=' + xPos);
						
			else if(type == "p") 
				window.open('Properties/demograph.htm?' + locID, '_profile', 'resizable=no, scrollbars=no, toolbar=no, location=no, directories=no, status=no, width=' + Xsize + ', height=' + Ysize + ', menubar=no, top=' + yPos + ', left=' + xPos);
				
			else if(type == "photo") 
				window.open('Properties/photo.htm?' + locID, '_photo', 'resizable=no, scrollbars=no, toolbar=no, location=no, directories=no, status=no, width=' + Xsize + ', height=' + Ysize + ', menubar=no, top=' + yPos + ', left=' + xPos);
			
			else if(type == "m") 
				window.open('Properties/officemap.htm?' + locID + '&' + SPECIAL, '_map', 'resizable=no, scrollbars=no, toolbar=no, location=no, directories=no, status=no, width=' + Xsize + ', height=' + Ysize + ', menubar=no, top=' + yPos + ', left=' + xPos);
						
			else
				document.write('Type defition error occured in function spawnPopupWin()');
			break;

		case "Fr":
			if(type == "f")
				window.open('Properties/floorplan-f.htm?' + locID + '&' + SPECIAL, '_floorplan', 'resizable=no, scrollbars=no, toolbar=no, location=no, directories=no, status=no, width=' + Xsize + ', height=' + Ysize + ', menubar=no, top=' + yPos + ', left=' + xPos);

			else if(type == "d") 
				window.open('Properties/demographm-f.htm?' + locID + '&' + SPECIAL, '_demograph', 'resizable=no, scrollbars=no, toolbar=no, location=no, directories=no, status=no, width=' + Xsize + ', height=' + Ysize + ', menubar=no, top=' + yPos + ', left=' + xPos);

			else if(type == "p") 
				window.open('Properties/demograph-f.htm?' + locID, '_profile', 'resizable=no, scrollbars=no, toolbar=no, location=no, directories=no, status=no, width=' + Xsize + ', height=' + Ysize + ', menubar=no, top=' + yPos + ', left=' + xPos);

			else if(type == "photo") 
				window.open('Properties/photo-f.htm?' + locID, '_photo', 'resizable=no, scrollbars=no, toolbar=no, location=no, directories=no, status=no, width=' + Xsize + ', height=' + Ysize + ', menubar=no, top=' + yPos + ', left=' + xPos);
			
			else if(type == "m") 
				window.open('Properties/officemap-f.htm?' + locID + '&' + SPECIAL, '_map', 'resizable=no, scrollbars=no, toolbar=no, location=no, directories=no, status=no, width=' + Xsize + ', height=' + Ysize + ', menubar=no, top=' + yPos + ', left=' + xPos);

			else
				document.write('Type defition error occured in function spawnPopupWin()');
			break;
	}

}



function spawnMapWin(_URL) {

	if (browserName == "Netscape") {
		xPos = window.screenX + 25;
		yPos = window.screenY + 25;
	} else {
		xPos = window.screenLeft + 40;
		yPos = window.screenTop - 60;
	}


	window.open(_URL, '_mapquest', 'resizable=yes, scrollbars=yes, width=800, height=700, top=' + yPos + ', left=' + xPos);

}






function slideshow(dir, locID, set)	{

	if(dir == "+") {
		count++;
		if(count > slides)
			count = 1;
	} else {
		count--;
		if(count == "0")
			count = slides;
	}

	document.slidePic.src = "Properties/" + locID + "/pic" + count + ".jpg";

	if(set)
		document.slideCount.src = "Properties/" + count + set + ".gif";
	else
		document.slideCount.src = "Properties/" + count + ".gif";

}



function spawnSummary(file) {
	
	if(file !="select")
		self.location = ('docs/' + file);

}




function spawnOppWin(locID, language) {

	if (browserName == "Netscape") {
		xPos = window.screenX + 60;
		yPos = window.screenY + 120;
	} else {
		xPos = window.screenLeft + 50;
		yPos = window.screenTop + 5;
	}

	if(language == "Fr") lang = "f";
	else lang = 'e';

	window.open('Flash/' + locID + '_' + lang + '.html', '_opportunity', 'resizable=no, scrollbars=no, status=no, toolbar=no, width=890, height=549, top=' + yPos + ', left=' + xPos);

}




