<!--
/*
These common javascript function are used by Youngatart.ca 

compiled by Jeff Shields Jan 12, 2009


*/
/*querystring.js - Contains functions to extract querystring parameters from URL
The parameters are loaded into the associative array queryString[].*/
function DisplayQueryStr(){
	//In open JavaScript (not inside a function), define the array
	var queryString = new Array();
	// and then pull the querystyring parameters from the URL.
	// The search property of the window location returns the query string.
	// The method substring(1) removes the first character (the question mark).
	// The split function then copies the parameters into an array called "parms"
	var parameters = window.location.search.substring(1).split('&');
	// For each element in the array, find the equal sign that separates the parameter
	// name from the parameter value.  If there is one, divide the expression into
	// the parameter name
	for (var i=0; i<parameters.length; i++) {
	    var pos = parameters[i].indexOf('=');
	    // If there is an equal sign, separate the parameter into the name and value,
	    // and store it into the queryString array.
	    if (pos > 0) {
	        var paramname = parameters[i].substring(0,pos);
	        var paramval = parameters[i].substring(pos+1);
	        queryString[paramname] = unescape(paramval.replace(/\+/g,' '));
	    } else {
	        //special value when there is a querystring parameter with no value
	        queryString[parameters[i]]="" 
	    }
	}
	document.write ("<b>Query String Parameters:</b><ol style='margin-top:0;'>")
	for (paramname in queryString) {
	    document.write ("<li>" + paramname + " = " + queryString[paramname]);
	}
	document.write ("</ol>")
	
	if (queryString['full_name']) {
	    document.write ('Thank you, ' + queryString["full_name"] + ' for your inquiry. ' +  
	        'We will follow-up by contacting you at ' + queryString["email"]);
	} else {
	    document.write ('This box is active only when there is a querystring parameter named "full_name"');
	}
}


window.onload=montre;
function montre(id) {
// used for showing hidden menus
var d = document.getElementById(id);
	for (var i = 0; i<=10; i++) {
		if (document.getElementById('smenu'+i)) {document.getElementById('smenu'+i).style.display='none';}
	}
if (d) {d.style.display='block';}
}

function newWin (title,url) { //v1.0
//"toolbar=yes,location=no,scrollbars,status,"
  var avHeight = parseInt(screen.availHeight);
  var avWidth = parseInt(screen.availWidth); 
  
  var aStr =  "left=20,top=20,width=" + (avWidth - 60) + ",height=" + (avHeight - 200) ;
	
	var myWin = window.open(url, title, "toolbar=yes,location=no,scrollbars,status,menubar=yes,resizable," + aStr ); 
	myWin.focus();
}

function openMap (title,url) { //v1.0
	var myWin = window.open(url, title, "toolbar=no,location=no,status,menubar=no,width=700,height=600"); 
	myWin.focus();
}

function getmap(city,address,postal) { //v1.0
	var str = "http://www.mapquest.ca/maps/map.adp?formtype=search&countryid=41&addtohistory=&country=CA&state=BC"; 
	
    str += "&address="+address+"&city="+city+"&zipcode="+postal;
    
    str += "&zoom=7&submit=Get+Map";
    location.href = str; 
}


/*
<!-- This script and many more are available free online at -->
<!-- The JavaScript Source!! http://javascript.internet.com -->

<!-- Begin sets message depending on the date
*/
var days = new Array();
var msgs = new Array();

// fixed date messages
days[0] = "January 1, 2009";
msgs[0] = "Happy New Year!";

days[1] = "February 14, 2008";
msgs[1] = "Happy Valentine's Day!";

days[2] = "March 17, 2009";
msgs[2] = "St. Patrick's Day!";

days[3] = "April 1, 2009";
msgs[3] = "April Fool's Day!";

days[4] = "May 1, 2009";
msgs[4] = "May Day!";

days[5] = "May 5, 2009";
msgs[5] = "Cinco de Mayo!";

days[6] = "July 1, 2009";
msgs[6] = "Happy Canada Day!";

days[7] = "July 4, 2009";
msgs[7] = "Independence Day!";

days[8] = "October 31, 2009";
msgs[8] = "Halloween!";

days[9] = "November 11, 2009";
msgs[9] = "Remembrance Day!";

days[10] = "December 25, 2009";
msgs[10] = "Merry Christmas!";

days[11] = "December 26, 2009";
msgs[11] = "Boxing Day!";

// days that change each year
days[12] = "March 21, 2009";
msgs[12] = "First day of Spring!";

days[13] = "April 10, 2009";
msgs[13] = "Good Friday!";

days[14] = "April 13, 2009";
msgs[14] = "Happy Easter!";

days[15] = "May 10, 2009";
msgs[15] = "Happy Mother's Day!";

days[16] = "May 18, 2009";
msgs[16] = "Victoria Day!";

days[17] = "June 21, 2009";
msgs[17] = "Happy Father's Day!";

days[18] = "June 21, 2009";
msgs[18] = "First day of Summer!";

days[19] = "August 3, 2009";
msgs[19] = "Civic Holiday";

days[20] = "September 7, 2009";
msgs[20] = "Labour Day!";

days[21] = "September 22, 2009";
msgs[21] = "First Day of Autumn!";

days[22] = "October 12, 2009";
msgs[22] = "Happy Thanksgiving!";

days[23] = "November 26, 2009";
msgs[23] = "Happy US Thanksgiving!";

days[24] = "December 21, 2009";
msgs[24] = "First Day of Winter!";


var months = new Array("", 
"January", "February", "March", "April", "May", "June",
"July", "August", "September", "October", "November", "December"
);

var today = new Date(); // today
var mon = months[today.getMonth() + 1]; // month
var day = today.getDate(); // day
var year = y2k(today.getYear()); // year

function dateMsg() {
for (i = 0; i < days.length; i++) {
	tempdate = new Date(days[i]);
	tempmonth = months[tempdate.getMonth() + 1];
	tempday = tempdate.getDate();
	tempyear = y2k(tempdate.getYear());

    if (year == tempyear && mon == tempmonth && day == tempday)
		return(days[i] + "<br>" + msgs[i]); // returns day message
   }
return(mon + " " + day + ", " + year ); // returns default
}

// Y2K Fix Function
function y2k(year) {
	if (year < 2000)		
	year = year + 1900;
return year;
}

/* 
	by Paul@YellowPencil.com and Scott@YellowPencil.com
	feel free to delete all comments except for the above credit
*/

// Initialize Scripts - is this a browser that understands DOM?

function scriptInit() {
if (!document.getElementById) {
	return;
	}
}


// Set up Event Listener - the script that allows us to use the addEvent call below

function addEvent(elm, evType, fn, useCapture) {
	if (elm.addEventListener) {
	elm.addEventListener(evType, fn, useCapture);
	return true;
	} else if (elm.attachEvent) {
	var r = elm.attachEvent('on' + evType, fn);
	return r;
	} else {
	elm['on' + evType] = fn;
	}
}

// Start Column Script
function setTall() {
	if (document.getElementById) {
		// the divs array contains references to each column's div element.  
		// Replace 'center' 'right' and 'left' with your own.  
		// Or remove the last one entirely if you've got 2 columns.  Or add another if you've got 4!
		var divs = new Array(document.getElementById('sidebar'), document.getElementById('content'));
		
		// Let's determine the maximum height out of all columns specified
		var maxHeight = 0;
		for (var i = 0; i < divs.length; i++) {
			if (divs[i].offsetHeight > maxHeight) maxHeight = divs[i].offsetHeight;
		}
		
		// Let's set all columns to that maximum height
		for (var i = 0; i < divs.length; i++) {
			divs[i].style.height = maxHeight + 'px';

			// Now, if the browser's in standards-compliant mode, the height property
			// sets the height excluding padding, so we figure the padding out by subtracting the
			// old maxHeight from the new offsetHeight, and compensate!  So it works in Safari AND in IE 5.x
			if (divs[i].offsetHeight > maxHeight) {
				divs[i].style.height = (maxHeight - (divs[i].offsetHeight - maxHeight)) + 'px';
			}
		}
	}
}


// For convenience...
Date.prototype.format = function (mask, utc) {
	return dateFormat(this, mask, utc);
};
String.prototype.trim = function() {
	return this.replace(/^\s+|\s+$/g,"");
}
String.prototype.ltrim = function() {
	return this.replace(/^\s+/,"");
}
String.prototype.rtrim = function() {
	return this.replace(/\s+$/,"");
}


function trim(stringToTrim) {
	return stringToTrim.replace(/^\s+|\s+$/g,"");
}
function ltrim(stringToTrim) {
	return stringToTrim.replace(/^\s+/,"");
}
function rtrim(stringToTrim) {
	return stringToTrim.replace(/\s+$/,"");
}
function convertToMoney(num){
	return num.toFixed(2)
}

/*
 * Date Format 1.2.2
 * (c) 2007-2008 Steven Levithan <stevenlevithan.com>
 * MIT license
 * Includes enhancements by Scott Trenda <scott.trenda.net> and Kris Kowal <cixar.com/~kris.kowal/>
 *
 * Accepts a date, a mask, or a date and a mask.
 * Returns a formatted version of the given date.
 * The date defaults to the current date/time.
 * The mask defaults to dateFormat.masks.default.
 */
var dateFormat = function () {
	var	token = /d{1,4}|m{1,4}|yy(?:yy)?|([HhMsTt])\1?|[LloSZ]|"[^"]*"|'[^']*'/g,
		timezone = /\b(?:[PMCEA][SDP]T|(?:Pacific|Mountain|Central|Eastern|Atlantic) (?:Standard|Daylight|Prevailing) Time|(?:GMT|UTC)(?:[-+]\d{4})?)\b/g,
		timezoneClip = /[^-+\dA-Z]/g,
		pad = function (val, len) {
			val = String(val);
			len = len || 2;
			while (val.length < len) val = "0" + val;
			return val;
		};

	// Regexes and supporting functions are cached through closure
	return function (date, mask, utc) {
		var dF = dateFormat;

		// You can't provide utc if you skip other args (use the "UTC:" mask prefix)
		if (arguments.length == 1 && (typeof date == "string" || date instanceof String) && !/\d/.test(date)) {
			mask = date;
			date = undefined;
		}

		// Passing date through Date applies Date.parse, if necessary
		date = date ? new Date(date) : new Date();
		if (isNaN(date)) throw new SyntaxError("invalid date");

		mask = String(dF.masks[mask] || mask || dF.masks["default"]);

		// Allow setting the utc argument via the mask
		if (mask.slice(0, 4) == "UTC:") {
			mask = mask.slice(4);
			utc = true;
		}

		var	_ = utc ? "getUTC" : "get",
			d = date[_ + "Date"](),
			D = date[_ + "Day"](),
			m = date[_ + "Month"](),
			y = date[_ + "FullYear"](),
			H = date[_ + "Hours"](),
			M = date[_ + "Minutes"](),
			s = date[_ + "Seconds"](),
			L = date[_ + "Milliseconds"](),
			o = utc ? 0 : date.getTimezoneOffset(),
			flags = {
				d:    d,
				dd:   pad(d),
				ddd:  dF.i18n.dayNames[D],
				dddd: dF.i18n.dayNames[D + 7],
				m:    m + 1,
				mm:   pad(m + 1),
				mmm:  dF.i18n.monthNames[m],
				mmmm: dF.i18n.monthNames[m + 12],
				yy:   String(y).slice(2),
				yyyy: y,
				h:    H % 12 || 12,
				hh:   pad(H % 12 || 12),
				H:    H,
				HH:   pad(H),
				M:    M,
				MM:   pad(M),
				s:    s,
				ss:   pad(s),
				l:    pad(L, 3),
				L:    pad(L > 99 ? Math.round(L / 10) : L),
				t:    H < 12 ? "a"  : "p",
				tt:   H < 12 ? "am" : "pm",
				T:    H < 12 ? "A"  : "P",
				TT:   H < 12 ? "AM" : "PM",
				Z:    utc ? "UTC" : (String(date).match(timezone) || [""]).pop().replace(timezoneClip, ""),
				o:    (o > 0 ? "-" : "+") + pad(Math.floor(Math.abs(o) / 60) * 100 + Math.abs(o) % 60, 4),
				S:    ["th", "st", "nd", "rd"][d % 10 > 3 ? 0 : (d % 100 - d % 10 != 10) * d % 10]
			};

		return mask.replace(token, function ($0) {
			return $0 in flags ? flags[$0] : $0.slice(1, $0.length - 1);
		});
	};
}();

// Some common format strings
dateFormat.masks = {
	"default":      "ddd mmm dd yyyy HH:MM:ss",
	shortDate:      "m/d/yy",
	mediumDate:     "mmm d, yyyy",
	longDate:       "mmmm d, yyyy",
	fullDate:       "dddd, mmmm d, yyyy",
	shortTime:      "h:MM TT",
	mediumTime:     "h:MM:ss TT",
	longTime:       "h:MM:ss TT Z",
	isoDate:        "yyyy-mm-dd",
	isoTime:        "HH:MM:ss",
	isoDateTime:    "yyyy-mm-dd'T'HH:MM:ss",
	isoUtcDateTime: "UTC:yyyy-mm-dd'T'HH:MM:ss'Z'"
};

// Internationalization strings
dateFormat.i18n = {
	dayNames: [
		"Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat",
		"Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"
	],
	monthNames: [
		"Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec",
		"January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"
	]
};

/*
	Fire Events - you can add other scripts here and call them using the following method.  
	This one balances the columns when the page loads, and again when the window is resized
	Some have asked about users changing text size, because this script won't fire and your page can look weird.  If you were resizing text via a script, we could run this script when the user calls that script.  However, if you're relying on browser methods for text resizing, I'm not aware of a method to watch for that kind of an event.  If someone smarter than me knows of one, please let me know!  If you don't understand what I mean, then pretend I didn't say anything...
*/

addEvent(window, 'load', setTall, false);
addEvent(window, 'resize', setTall, false);


//-->

