
	
	var current_slide, slide_width, slide_timer;

	jQuery(document).ready(function() {
	    //if (jQuery('#home-slider').length > 0) {
//	        if (/MSIE (\d+\.\d+);/.test(navigator.userAgent)) {
//	            //	                jQuery('#home-slider-1').cycle({
//	            //	                    fx: 'scrollLeft',
//	            //	                    sync: 0,
//	            //	                    speed: 1000,
//	            //	                    autostop: 1
//	            //	                });
//	            //	                jQuery('#home-slider-2').cycle({
//	            //	                    fx: 'scrollLeft',
//	            //	                    sync: 0,
//	            //	                    speed: 1000,
//	            //	                    autostop: 1,
//	            //	                    delay: 2000,
//	            //	                    end: function() {
//	            //	                        jQuery('#home-slider-flip .flip-back').fadeIn();
//	            //	                    }
//	            //	                });
//	            //	                jQuery('#home-slider-3').cycle({
//	            //	                    fx: 'scrollLeft',
//	            //	                    sync: 0,
//	            //	                    speed: 1000,
//	            //	                    autostop: 1,
//	            //	                    delay: 500
//	            //	                });
//	            jQuery('#home-slider-1-front, #home-slider-2-front, #home-slider-3-front').css('display', 'none');

//	        }
//	        else {
//	            jQuery('#home-slider-1').cycle({
//	                fx: 'curtainX',
//	                sync: 0,
//	                speed: 1000,
//	                autostop: 1,
//	                cleartype: 1
//	            });
//	            jQuery('#home-slider-2').cycle({
//	                fx: 'curtainX',
//	                sync: 0,
//	                speed: 1000,
//	                autostop: 1,
//	                delay: 2000,
//	                cleartype: 1,
//	                end: function() {
//	                    jQuery('#home-slider-flip .flip-back').fadeIn();
//	                }
//	            });
//	            jQuery('#home-slider-3').cycle({
//	                fx: 'curtainX',
//	                sync: 0,
//	                speed: 1000,
//	                autostop: 1,
//	                delay: 500,
//	                cleartype: 1
//	            	            });
//	            //jQuery('#home-slider-1-front, #home-slider-2-front, #home-slider-3-front').css('display', 'none');
//	        }
////	        jQuery('#home-slider-flip .flip-back').click(function() {
////	            jQuery('#home-slider-1').cycle('next');
////	            setTimeout("jQuery('#home-slider-3').cycle('next')", 1000);
////	            setTimeout("jQuery('#home-slider-2').cycle('next')", 2000);
////	            return false;
////	        });

//	    }

	    jQuery.each(jQuery('#left-column ul li'), function(index, value) {
	        if (jQuery(value).find('.product-popup').length > 0) {
	            jQuery(value).hover(function() {
	                var offset = jQuery(this).position();
	                jQuery(this).find('.product-popup').show();
	                jQuery('#nav-connector-line').show().css('left', offset.left + jQuery(this).width() + 'px').css('top', offset.top + 12 + 'px');
	                jQuery(value).children('a:first-child').addClass('selected');
	            }
	            , function() {
	                jQuery(this).find('.product-popup').hide();
	                jQuery('#nav-connector-line').hide();
	                jQuery(value).children('a:first-child').removeClass('selected');
	            });
	        }
	    });

	    if (jQuery('#testimonials-body').length > 0) {
	        if (/MSIE (\d+\.\d+);/.test(navigator.userAgent)) {
	            var ieversion = new Number(RegExp.$1);
	        }
	        else {
	            var ieversion = 0;
	        }
	        if (ieversion < 8) {
	            jQuery('#testimonials-body-content').cycle({
	                fx: 'fade',
	                timeout: 10000,
	                cleartype: 1,
	                pager: '#testimonial-bubbles',
	                after: function() {
	                    jQuery('#testimonials-body-content').css('height', jQuery(this).height());
	                }
	            });
	        }
	        else {
	            jQuery('#testimonials-body-content').css({
	                height: '72px',
	                width: '133px',
	                overflow: 'hidden'
	            });
	        }
	    }

	});


	
	// key events
	Event.observe(document, 'keydown', function(event) {
		switch (event.keyCode) {
			case Event.KEY_ESC:
				if ($('modal'))
					close_modal();
				break;
			default: break;
		}
	});
	
	function show_modal(id) {
		// add the overlay to the window and adjust the height
		var body = $$('body')[0];
		new Insertion.Bottom(body, Builder.node('div', { id: 'modal-overlay' }));
		var overlay = $('modal-overlay');
		
		// add the modal box, browser center, and update the content
		new Insertion.Bottom(body, 
			Builder.node('div', { id: 'modal', style: 'display: none;' }, [
				Builder.node('div', { id: 'modal-inner' }, [
					Builder.node('div', { id: 'modal-content' }).update($(id).innerHTML),
					Builder.node('a', { href: '#', id: 'modal-close', title: 'close', onclick: 'close_modal(); return false;' })
				]),
				Builder.node('div', { id: 'modal-bottom' })
			])
		);
		$('modal').setStyle({
			top: document.viewport.getScrollOffsets()[1] + 100 + 'px',
			left: ((document.viewport.getWidth() - $('modal').getWidth()) / 2) + document.viewport.getScrollOffsets()[0] + 'px'
		}).show();
		
		// give 50px padding below the modal window for aesthetics
		var window_height = get_window_height();
		var overlay_height = (window_height - $('modal').getHeight() < 150) ? $('modal').getHeight() + 150 : window_height;
		
		overlay.setStyle({ height: overlay_height + 'px' });
		overlay.observe('click', function() { close_modal(); });
	}
	function close_modal() {
		$('modal-overlay').remove();
		$('modal').remove();
	}
	
	function get_window_height() {
		// retrieve the height of the document including scrollable area
		var document_height, window_height;
		
		if (window.innerHeight && window.scrollMaxY) document_height = window.innerHeight + window.scrollMaxY;
		else if (document.body.scrollHeight > document.body.offsetHeight) document_height = document.body.scrollHeight;
		else document_height = document.body.offsetHeight;
		
		if (self.innerHeight) window_height = self.innerHeight;
		else if (document.documentElement && document.documentElement.clientHeight) window_height = document.documentElement.clientHeight;
		else if (document.body) window_height = document.body.clientHeight;
		
		return (document_height < window_height) ? window_height : document_height;
	}
