<!-- Begin
var JSDir = '/js/';
var Now = new Date();
var minYear = 1988;
var maxYear = Now.getFullYear()+1;
var pngBug = ((navigator.userAgent.indexOf("Gecko") != -1))
	? false
	: true;
var domBug = ((navigator.userAgent.indexOf("Gecko") != -1) || (navigator.appVersion.indexOf("MSIE 7") != -1))
	? false
	: true;

/* --------------------------------------------------
 WINDOW FUNCTIONS, METHODS
-------------------------------------------------- */
Object.extend(window,  {
	onerror: function(desc,page,line,chr){
		return true;
	},
	width: function(){
		return (navigator.appVersion.indexOf('MSIE')>0) ? document.body.clientWidth : window.innerWidth ;
	},
	height: function(){
		return (navigator.appVersion.indexOf('MSIE')>0) ? document.body.clientHeight : window.innerHeight ;
	},
	getDimensions: function(){
		return {
			width: window.width(),
			height: window.height()
		};
	},
	getPageScroll: function(){
		var yScroll;
		if (self.pageYOffset) {
			yScroll = self.pageYOffset;
		} else if (document.documentElement && document.documentElement.scrollTop){	 // Explorer 6 Strict
			yScroll = document.documentElement.scrollTop;
		} else if (document.body) {// all other Explorers
			yScroll = document.body.scrollTop;
		};
		arrayPageScroll = new Array('',yScroll)
		return arrayPageScroll;
	},
	getPageSize: function(){
		var xScroll, yScroll;

		if (window.innerHeight && window.scrollMaxY) {
			xScroll = document.body.scrollWidth;
			yScroll = window.innerHeight + window.scrollMaxY;
		} else if (document.body.scrollHeight > document.body.offsetHeight){ // all but Explorer Mac
			xScroll = document.body.scrollWidth;
			yScroll = document.body.scrollHeight;
		} else { // Explorer Mac...would also work in Explorer 6 Strict, Mozilla and Safari
			xScroll = document.body.offsetWidth;
			yScroll = document.body.offsetHeight;
		};

		var windowWidth, windowHeight;
		if (self.innerHeight) {	// all except Explorer
			windowWidth = self.innerWidth;
			windowHeight = self.innerHeight;
		} else if (document.documentElement && document.documentElement.clientHeight) { // Explorer 6 Strict Mode
			windowWidth = document.documentElement.clientWidth;
			windowHeight = document.documentElement.clientHeight;
		} else if (document.body) { // other Explorers
			windowWidth = document.body.clientWidth;
			windowHeight = document.body.clientHeight;
		};

		// for small pages with total height less then height of the viewport
		if(yScroll < windowHeight){
			pageHeight = windowHeight;
		} else {
			pageHeight = yScroll;
		};

		// for small pages with total width less then width of the viewport
		if(xScroll < windowWidth){
			pageWidth = windowWidth;
		} else {
			pageWidth = xScroll;
		};

		arrayPageSize = new Array(pageWidth,pageHeight,windowWidth,windowHeight)
		return arrayPageSize;
	},

	fullscreen: function(){
		self.moveTo(0,0);self.resizeTo(screen.availWidth,screen.availHeight);
	}
});

/* --------------------------------------------------
 DOCUMENT FUNCTIONS, METHODS
-------------------------------------------------- */
Object.extend(document,  {
	initialize: function(){
		this.loaded = true;
	},

	getMouse: function(e){
		if( !e ) { e = window.event; }
		if( !e || ( typeof( e.pageX ) != 'number' && typeof( e.clientX ) != 'number' ) ) { return [ 0, 0 ]; }
		if( typeof( e.pageX ) == 'number' ) {
			this.mouseX = e.pageX;
			this.mouseY = e.pageY;
		} else {
			this.mouseX = e.clientX;
			this.mouseY = e.clientY;
			if(
				!(
					( window.navigator.userAgent.indexOf( 'Opera' ) + 1 )
					|| ( window.ScriptEngine && ScriptEngine().indexOf( 'InScript' ) + 1 )
					|| window.navigator.vendor == 'KDE'
				)
			) {
				if( document.documentElement && ( document.documentElement.scrollTop || document.documentElement.scrollLeft ) ) {
					this.mouseX += document.documentElement.scrollLeft;
					this.mouseY += document.documentElement.scrollTop;
				} else if( document.body && ( document.body.scrollTop || document.body.scrollLeft ) ) {
					this.mouseX += document.body.scrollLeft;
					this.mouseY += document.body.scrollTop;
				}
			}
		}
		return [ this.mouseX, this.mouseY ];
	}
});

if(!Prototype.Browser.IE) document.captureEvents(Event.MOUSEMOVE);
document.onmousemove = document.getMouse;

/* --------------------------------------------------
 STRING FUNCTIONS, METHODS
-------------------------------------------------- */
Object.extend(String, {
	nbsp: '\u00a0'
});

Object.extend(String.prototype, {
	trim: function(){
		return this.replace(/^\s+|\s+$/g, '');
	},

	urlencode: function(){
		return this.replace(/[\ ]/gi, '%20').replace(/[\!]/gi, '%21').replace(/[\#]/gi, '%23').replace(/[\$]/gi, '%24');replace(/[\%]/gi, '%25').replace(/[\&]/gi, '%26').replace(/[\+]/gi, '%2B').replace(/[\,]/gi, '%2C').replace(/[\/]/gi, '%2F').replace(/[\:]/gi, '%3A').replace(/[\;]/gi, '%3B').replace(/[\<]/gi, '%3C').replace(/[\=]/gi, '%3D').replace(/[\>]/gi, '%3E').replace(/[\?]/gi, '%3F').replace(/[\@]/gi, '%40').replace(/[\[]/gi, '%5B').replace(/[\/]/gi, '%5C').replace(/[\]]/gi, '%5D').replace(/[\^]/gi, '%5E').replace(/[\`]/gi, '%60').replace(/[\{]/gi, '%7B').replace(/[\|]/gi, '%7C').replace(/[\}]/gi, '%7D').replace(/[\~]/gi, '%7E');
	},

	urldecode: function(){
		return this.replace(/[\ ]/gi, '');
	},

	nl2br: function(){
		return this.replace(/\r|\n|\r\n/g, '<br>');
	},

	humanbytes: function(){
		var size = parseInt(this, 10);
		var p=0;
		var xlat = ['B','kB','MB','GB','TB'];
		while(size >= 1024){
			p++;
			size/=1024;
		};
		return (Math.ceil(size*100)/100)+' '+xlat[p];
	},

	replaceAll: function(pcFrom, pcTo){
		var i = this.indexOf(pcFrom);
		var c = this;
		while (i > -1){
			c = c.replace(pcFrom, pcTo);
			i = c.indexOf(pcFrom);
		}
		return c;
	},

	linkify: function(){
		return this.replace(/[A-Za-z]+:\/\/[A-Za-z0-9-_]+\.[A-Za-z0-9-_:%&\?\/.=#]+/g, function(m) {
			return m.link(m);
		});
	},

	unicodeentities: function(){
		return this.replace(/\%u(\d{4})/gi, '&#x$1;');
	},

	cleanurl: function(){
		var string = this.toLowerCase();
		string = string.replace(/[\ ]/gi, '_').replace(/[\&]/gi, '_').replace(/[\/]/gi, '_').replace(/[\,]/gi, '_');
		var i = 0;
		while(string.indexOf('__') != -1 && ++i < 10){
			string = string.replace('__','_');
		};
		return string;
	}
});


/* --------------------------------------------------
 EVENT FUNCTIONS, METHODS
-------------------------------------------------- */
Object.extend(Event, {
	KEY_SHIFT:    16,
	KEY_CTRL:     17,
	KEY_ALT:      18,
	KEY_SPACE:    32
});


/* --------------------------------------------------
 DOM FUNCTIONS, METHODS
-------------------------------------------------- */
//element offset
offSet = function(element){
	if($(element)) element = $(element);
	var curleft = curtop = 0;
	if (element.offsetParent) {
		do {
			curleft += element.offsetLeft;
			curtop += element.offsetTop;
		} while (element = element.offsetParent);
		return [curleft,curtop];
	};
};

//createElement
domCE = function(elementType, subType){
	//return $(document.createElement(elementType));
	var element = document.createElement(elementType);
	if(typeof subType != 'undefined') element.type = subType;
	return $(document.createDocumentFragment().appendChild(element));
};
//removeElement
domRE = function(element){
	if($(element)) element = $(element);
	try{
		p = element.parentNode;
		p.removeChild(element);
		return p;
	}catch(e){};
};
//createTextNode
domCTN = function(string){
	//return $(document.createTextNode(string));
	return $(document.createDocumentFragment().appendChild(document.createTextNode(string)));
};
//remove child nodes
domRCN = function(element){
	if($(element)) element = $(element);
	while(element.childNodes.length > 0){
		element.removeChild(element.firstChild);
	};
	return element;
};
//insertBefore
domIB = function(child, reference){
	return reference.parentNode.domIB(child, reference);
};
//insertAfter
domIA = function(child, reference){
	return reference.parentNode.domIA(child, reference);
};

Element.addMethods({
	//disable element
	disable: function(element){
		if($(element)) element = $(element);
		element.domSA({ 'disabled': 'disabled' });
		return element;
	},
	disableSelector: function(element, selectors){
		if($(element)) element = $(element);
		element.getElementsBySelector(selectors).each(function(selector){
			selector.disable();
		});
		return element;
	},

	//enable element
	enable: function(element){
		if($(element)) element = $(element);
		element.domRA('disabled');
		return element;
	},
	enableSelector: function(element, selectors){
		if($(element)) element = $(element);
		element.getElementsBySelector(selectors).each(function(selector){
			selector.enable();
		});
		return element;
	},

	//element offset
	offSet: function(element){
		if($(element)) element = $(element);
		var curleft = curtop = 0;
		if (element.offsetParent) {
			do {
				curleft += element.offsetLeft;
				curtop += element.offsetTop;
			} while (element = element.offsetParent);
			return [curleft,curtop];
		};
	},

	//createElement
	domCE: function(element, elementType, subType){
		if($(element)) element = $(element);
		element.domAC(domCE(elementType, subType));
		return element;
	},
	//createTextNode
	domCTN: function(element, string){
		if($(element)) element = $(element);
		element.domAC(domCTN(string));
		return element;
	},
	//createHTMLTextNode
	domCHTN: function(element, string){
		if($(element)) element = $(element);
		element.domAC(theText = domCE('span'));
		theText.replace(string);
		return element;
	},
	//appendChild(ren)
	domAC: function(element, child){
		if($(element)) element = $(element);
		switch(typeof(child)){
			case 'function':
				element.domAC(child(element));
				break;
			case 'object':
				if(typeof(child.each) != 'undefined'){
					child.each(function(child){ element.domAC(child); });
				}else{
					//element.appendChild(child);
					fragment = document.createDocumentFragment();
					fragment.appendChild(child);
					element.appendChild(fragment);
				};
				break;
		};
		return element;
	},
	//prependChild(ren)
	domPC: function(element, child){
		if($(element)) element = $(element);
		switch(typeof(child)){
			case 'function':
				element.domPC(child(element));
				break;
			case 'object':
				if(typeof(child.each) != 'undefined'){
					child.each(function(child){ element.domPC(child); });
				}else{
					element.insertBefore(child, element.firstChild);
				};
				break;
		};
		return element;
	},
	//setAttribute
	domSA: function(element, attributeArray){
		if($(element)) element = $(element);
		var keys = Object.keys(attributeArray);
		var values = Object.values(attributeArray);
		for(i=0;i<keys.length;i++){
			if(keys[i] == 'className' && !Prototype.Browser.IE){
				//element.setAttribute('class', values[i]);
				element.className = values[i];
			}else if(keys[i] == 'className' && (navigator.appVersion.indexOf("MSIE 8") != -1)){
				element.setAttribute('class', values[i]);
			}else if(keys[i] == 'checked' && (values[i] == 'checked') && !Prototype.Browser.IE){
				element.defaultChecked = true;
			}else{
				switch(typeof(values[i])){
					case 'function':
						eval('element.'+keys[i]+' = '+values[i]);
						break;
					case 'string':
					default:
						element.setAttribute(keys[i], values[i]);
						break;
				};
			};
		};
		return element;
	},
	//removeAttribute
	domRA: function(element, attribute){
		element = $(element);
		if(typeof eval('element.'+attribute.toLowerCase()) == 'function'){
			eval('element.'+attribute.toLowerCase()+' = null;');
		};
		element.removeAttribute(attribute);
		element.removeAttribute(attribute.toLowerCase());
		return element;
	},
	//className
	domCN: function(element, className){
		if($(element)) element = $(element);
		element.className = className;
		return element;
	},
	//className(s)
	domCNs: function(element, classNameOut, classNameOver){
		element = $(element);
		element.className = classNameOut;
		element.onmouseover = function(){ this.className = classNameOver+' '+classNameOut; };
		element.onmouseout = function(){ this.className = classNameOut; };
		return element;
	},
	//remove/replace childNodes
	domRCN: function(element, child){
		if($(element)) element = $(element);
		while(element.childNodes[0])
			element.removeChild(element.childNodes[0]);
		if(child)
			element.domAC(child);
		return element;
	},
 	//tooltip
	domTT: function(element, child){
		if($(element)) element = $(element);
		if($(child)) child = $(child);
		new Tooltip(element, child);
		return element;
	},
	//insertBefore
	domIB: function(element, child, reference){
		if($(element)) element = $(element);
		if(typeof(reference) == 'undefined'){
			parent = element.parentNode;
			reference = element;
		}else{
			parent = element;
		}
		parent.insertBefore(child, reference);
		return element;
	},
	//insertAfter
	domIA: function(element, child, reference){
		if($(element)) element = $(element);
		if(typeof(reference) == 'undefined'){
			parent = element.parentNode;
			reference = element;
		}else{
			parent = element;
		};
		if(typeof(reference.next()) == 'undefined'){
			parent.domAC(child);
		}else{
			parent.domIB(child, reference.next());
		};
		return element;
	},

	insertAtCursor: function(element, string) {
		if($(element)) element = $(element);
		//IE support
		if (document.selection) {
			element.focus();
			sel = document.selection.createRange();
			sel.text = string;
		}
		//MOZILLA/NETSCAPE support
		else if (element.selectionStart || element.selectionStart == '0') {
			var startPos = element.selectionStart;
			var endPos = element.selectionEnd;
			element.value = element.value.substring(0, startPos)
				+ string
				+ element.value.substring(endPos, element.value.length);
		} else {
			element.value += string;
		}
	}
});

Null = Class.create();
Object.extend(Null.prototype, {
	initialize: function() {
		return null;
	}
});

/* --------------------------------------------------
 SOCIAL WEB
-------------------------------------------------- */
SocialWeb = Class.create();
Object.extend(SocialWeb.prototype, {
	initialize: function(element, url, title){
		this.element = element;
		this.url = url;
		this.location = escape(document.location.toString());
		this.title = escape(document.title.toString());

		this.element.domAC(
			domCE('h5').domCTN('Bookmark & Share')
		).domAC(
			this.unorderedList = domCE('ul')
		);

		this.addIC(
			'Google',
			'http://www.google.com/bookmarks/mark?op=edit&output=popup&bkmk='+this.location+'&title='+this.title,
			'ic_google_bmarks'
		);

		this.addIC(
			'Yahoo',
			'http://myweb2.search.yahoo.com/myresults/bookmarklet?t='+this.title+'&u='+this.location,
			'ic_yahoo_myweb'
		);
		this.addIC(
			'LIVE (MSN)',
			'https://favorites.live.com/quickadd.aspx?marklet=1&mkt=utf-8&url='+document.location+'&title='+this.title,
			'ic_windows_live'
		);
		this.addIC(
			'Facebook',
			'http://www.facebook.com/share.php?u='+this.location,
			'ic_facebook'
		);
		this.addIC(
			'Netscape',
			'http://www.netscape.com/submit/?U='+this.location,
			'ic_netscape'
		);
		this.addIC(
			'Delicious',
			'http://del.icio.us/post?url='+this.location+'&title='+this.title,
			'ic_delicious'
		);
		this.addIC(
			'Ma.gnolia',
			'http://ma.gnolia.com/bookmarklet/add?url='+this.location+'&title='+this.title,
			'ic_magnolia'
		);
		this.addIC(
			'Stumble Upon',
			'http://www.stumbleupon.com/submit?url='+this.location+'&title='+this.title,
			'ic_stumbleupon'
		);
		this.addIC(
			'Reddit',
			'http://reddit.com/submit?url='+this.location+'&title='+this.title,
			'ic_reddit'
		);
		this.addIC(
			'Wists',
			'http://wists.com/r.php?c=&r='+this.location+'&title='+this.title,
			'ic_wists'
		);
		this.addIC(
			'The Things I Want',
			'http://www.thethingsiwant.com/wishing/addtolist_s.php4?type=fromsite&URL='+this.location+'&Desc='+this.title,
			'ic_thethingsiwant'
		);
		this.addIC(
			'This Next',
			'http://www.thisnext.com/pick/new/submit/sociable/?url='+this.location,
			'ic_thisnext'
		);
		this.addIC(
			'Furl',
			'http://www.furl.net/storeIt.jsp?u='+this.location+'&t='+this.title,
			'ic_furl'
		);
	},

	addIC: function(icTitle, icHref, icClass){
		this.unorderedList.domAC(
			domCE('li').domAC(
				domCE('a').domSA({
					href: icHref,
					className: icClass,
					title: icTitle,
					target: '_blank',
					rel: 'nofollow'
				}).domAC(
					domCE('span').domCTN(icTitle)
				)
			)
		);
	},

	urlencode: function(string){
		return string.replace(/[\ ]/gi, '%20').replace(/[\!]/gi, '%21').replace(/[\#]/gi, '%23').replace(/[\$]/gi, '%24');replace(/[\%]/gi, '%25').replace(/[\&]/gi, '%26').replace(/[\+]/gi, '%2B').replace(/[\,]/gi, '%2C').replace(/[\/]/gi, '%2F').replace(/[\:]/gi, '%3A').replace(/[\;]/gi, '%3B').replace(/[\<]/gi, '%3C').replace(/[\=]/gi, '%3D').replace(/[\>]/gi, '%3E').replace(/[\?]/gi, '%3F').replace(/[\@]/gi, '%40').replace(/[\[]/gi, '%5B').replace(/[\/]/gi, '%5C').replace(/[\]]/gi, '%5D').replace(/[\^]/gi, '%5E').replace(/[\`]/gi, '%60').replace(/[\{]/gi, '%7B').replace(/[\|]/gi, '%7C').replace(/[\}]/gi, '%7D').replace(/[\~]/gi, '%7E');
	}
});

if(typeof $('socialWeb') != 'undefined'){
	YAHOO.util.Event.onDOMReady(function(){
		new SocialWeb($('socialWeb'), 'http://ifar.ca', 'Fortin Electronic Systems');
	});
};

/* --------------------------------------------------
 COUNTDOWN
-------------------------------------------------- */
CountDown = Class.create();
Object.extend(CountDown.prototype, {
	initialize: function (element, date, onStart, onFinish) {
		this.element = element;
		this.date = new Date(date);
		this.onStart = onStart;
		this.onFinish = onFinish;
		this.ticker = setInterval(this.tick.bind(this), 250);
		this.values = {
			days:[],
			hours:[],
			minutes:[],
			seconds:[]
		};

		this.element.domRCN();
		this.element.domSA({
			className: 'countdown'
		}).domAC(
			this.elementDays0 = domCE('img').domSA({
				src: '/images/countdown_overlay.png',
				className: 'digit'
			})
		).domAC(
			this.elementDays1 = domCE('img').domSA({
				src: '/images/countdown_overlay.png',
				className: 'digit'
			})
		).domAC(
			this.elementDays2 = domCE('img').domSA({
				src: '/images/countdown_overlay.png',
				className: 'digit'
			})
		).domAC(
			domCE('img').domSA({
				src: '/images/countdown_divider.png'
			})
		).domAC(
			this.elementHours0 = domCE('img').domSA({
				src: '/images/countdown_overlay.png',
				className: 'digit'
			})
		).domAC(
			this.elementHours1 = domCE('img').domSA({
				src: '/images/countdown_overlay.png',
				className: 'digit'
			})
		).domAC(
			domCE('img').domSA({
				src: '/images/countdown_divider.png'
			})
		).domAC(
			this.elementMinutes0 = domCE('img').domSA({
				src: '/images/countdown_overlay.png',
				className: 'digit'
			})
		).domAC(
			this.elementMinutes1 = domCE('img').domSA({
				src: '/images/countdown_overlay.png',
				className: 'digit'
			})
		).domAC(
			domCE('img').domSA({
				src: '/images/countdown_divider.png'
			})
		).domAC(
			this.elementSeconds0 = domCE('img').domSA({
				src: '/images/countdown_overlay.png',
				className: 'digit'
			})
		).domAC(
			this.elementSeconds1 = domCE('img').domSA({
				src: '/images/countdown_overlay.png',
				className: 'digit'
			})
		)
	},

	tick: function(){
		this.now = new Date();

		if(this.now > this.date){
			clearInterval(this.ticker);
			this.onFinish();
			return;
		};

		if(!this.started){
			this.onStart();
			this.started = true;
		}

		this.days = Math.floor((this.date - this.now) / 1000 / 60 / 60 / 24);
		this.hours = Math.floor((this.date - this.now) / 1000 / 60 / 60 - (24 * this.days));
		this.minutes = Math.floor((this.date - this.now) / 1000 /60 - (24 * 60 * this.days) - (60 * this.hours));
		this.seconds = Math.floor((this.date - this.now) / 1000 - (24 * 60 * 60 * this.days) - (60 * 60 * this.hours) - (60 * this.minutes));

		this.data = {
			days: [
				Math.floor(this.days/100),
				Math.floor((this.days%100)/10),
				(this.days%10)
			],

			hours: [
				Math.floor(this.hours/10),
				(this.hours%10)
			],

			minutes: [
				Math.floor(this.minutes/10),
				(this.minutes%10)
			],

			seconds: [
				Math.floor(this.seconds/10),
				(this.seconds%10)
			]
		}


		if(this.data.days[0] != this.values.days[0]) this.scroll(this.elementDays0, this.data.days[0], 9);
		if(this.data.days[1] != this.values.days[1]) this.scroll(this.elementDays1, this.data.days[1], 9);
		if(this.data.days[2] != this.values.days[2]) this.scroll(this.elementDays2, this.data.days[2], 9);

		if(this.data.hours[0] != this.values.hours[0]) this.scroll(this.elementHours0, this.data.hours[0], 2);
		if(this.data.hours[1] != this.values.hours[1]) this.scroll(this.elementHours1, this.data.hours[1], ((this.data.hours[0] == 2) ? 3 : 9));

		if(this.data.minutes[0] != this.values.minutes[0]) this.scroll(this.elementMinutes0, this.data.minutes[0], 5);
		if(this.data.minutes[1] != this.values.minutes[1]) this.scroll(this.elementMinutes1, this.data.minutes[1], 9);

		if(this.data.seconds[0] != this.values.seconds[0]) this.scroll(this.elementSeconds0, this.data.seconds[0], 5);
		if(this.data.seconds[1] != this.values.seconds[1]) this.scroll(this.elementSeconds1, this.data.seconds[1], 9);

		this.values = this.data;
	},

	scroll: function(element, num, msb){
		var offset = Math.round(((num + 1) * 51) - 51);
		if(num == msb){
			var reset = Math.round(((num + 2) * 51) - 51);
			element.setStyle({
				backgroundPosition: '0px -'+reset+'px',
				bottom: reset+'px'
			});
		};
		this.animation = new YAHOO.util.Anim(element, {
			bottom: { to: offset }
		}, 0.25, YAHOO.util.Easing.easeBoth);
		this.animation.onTween.subscribe(function(type, args){
			this.setStyle({
				backgroundPosition: '0px -'+this.getStyle('bottom')
			});
		}.bind(element));
		this.animation.animate();
	}
});

// End -->
