/* begin Page */
/* Created by Artisteer v3.1.0.46558 */
// css helper
(function($) {
    var data = [
        {str:navigator.userAgent,sub:'Chrome',ver:'Chrome',name:'chrome'},
        {str:navigator.vendor,sub:'Apple',ver:'Version',name:'safari'},
        {prop:window.opera,ver:'Opera',name:'opera'},
        {str:navigator.userAgent,sub:'Firefox',ver:'Firefox',name:'firefox'},
        {str:navigator.userAgent,sub:'MSIE',ver:'MSIE',name:'ie'}];
    for (var n=0;n<data.length;n++)	{
        if ((data[n].str && (data[n].str.indexOf(data[n].sub) != -1)) || data[n].prop) {
            var v = function(s){var i=s.indexOf(data[n].ver);return (i!=-1)?parseInt(s.substring(i+data[n].ver.length+1)):'';};
            $('html').addClass(data[n].name+' '+data[n].name+v(navigator.userAgent) || v(navigator.appVersion)); break;			
        }
    }
})(jQuery);
/* end Page */

/* begin Menu */
jQuery(function () {
    jQuery('ul.rd-hmenu a[href=#]').click(function () { return false; });
    if (!jQuery.browser.msie || parseInt(jQuery.browser.version) > 6) return;
    jQuery.each(jQuery('ul.rd-hmenu li'), function(i, val) {
        val.j = jQuery(val);
        val.UL = val.j.children('ul:first');
        if (val.UL.length == 0) return;
        val.A = val.j.children('a:first');
        this.onmouseenter = function() {
            this.j.addClass('rd-hmenuhover');
            this.UL.addClass('rd-hmenuhoverUL');
            this.A.addClass('rd-hmenuhoverA');
        };
        this.onmouseleave = function() {
            this.j.removeClass('rd-hmenuhover');
            this.UL.removeClass('rd-hmenuhoverUL');
            this.A.removeClass('rd-hmenuhoverA');
        };
    });
});
/* end Menu */

/* begin MenuSubItem */
jQuery(function () {
    jQuery("ul.rd-hmenu ul li").hover(function () { jQuery(this).prev().children("a").addClass("rd-hmenu-before-hovered"); }, 
        function () { jQuery(this).prev().children("a").removeClass("rd-hmenu-before-hovered"); });
});

jQuery(function () {
    if (!jQuery.browser.msie) return;
    var ieVersion = parseInt(jQuery.browser.version);
    if (ieVersion > 7) return;

    /* Fix width of submenu items.
    * The width of submenu item calculated incorrectly in IE6-7. IE6 has wider items, IE7 display items like stairs.
    */
    jQuery.each(jQuery("ul.rd-hmenu ul"), function () {
        var maxSubitemWidth = 0;
        var submenu = jQuery(this);
        var subitem = null;
        jQuery.each(submenu.children("li").children("a"), function () {
            subitem = jQuery(this);
            var subitemWidth = subitem.outerWidth();
            if (maxSubitemWidth < subitemWidth)
                maxSubitemWidth = subitemWidth;
        });
        if (subitem != null) {
            var subitemBorderLeft = parseInt(subitem.css("border-left-width"), 10) || 0;
            var subitemBorderRight = parseInt(subitem.css("border-right-width"), 10) || 0;
            var subitemPaddingLeft = parseInt(subitem.css("padding-left"), 10) || 0;
            var subitemPaddingRight = parseInt(subitem.css("padding-right"), 10) || 0;
            maxSubitemWidth -= subitemBorderLeft + subitemBorderRight + subitemPaddingLeft + subitemPaddingRight;
            submenu.children("li").children("a").css("width", maxSubitemWidth + "px");
        }
    });

    if (ieVersion > 6) return;
    jQuery("ul.rd-hmenu ul>li:first-child>a").css("border-top-width", "1px");
});
/* end MenuSubItem */

/* begin Layout */
jQuery(function () {
     var c = jQuery('div.rd-content');
    if (c.length !== 1) return;
    var s = c.parent().children('.rd-layout-cell:not(.rd-content)');


    if (jQuery.browser.msie && parseInt(jQuery.browser.version) < 8) {
        jQuery(window).bind('resize', function() {
            var w = 0;
            c.hide();
            s.each(function() { w += this.clientWidth; });
            c.w = c.parent().width(); c.css('width', c.w - w + 'px');
            c.show();
        });
    }

    jQuery(window).trigger('resize');
});/* end Layout */

/* begin Button */
function artButtonSetup(className) {
    jQuery.each(jQuery("a." + className + ", button." + className + ", input." + className), function (i, val) {
        var b = jQuery(val);
        if (!b.parent().hasClass('rd-button-wrapper')) {
            if (b.is('input')) b.val(b.val().replace(/^\s*/, '')).css('zoom', '1');
            if (!b.hasClass('rd-button')) b.addClass('rd-button');
            jQuery("<span class='rd-button-wrapper'><span class='rd-button-l'> </span><span class='rd-button-r'> </span></span>").insertBefore(b).append(b);
            if (b.hasClass('active')) b.parent().addClass('active');
        }
        b.mouseover(function () { jQuery(this).parent().addClass("hover"); });
        b.mouseout(function () { var b = jQuery(this); b.parent().removeClass("hover"); if (!b.hasClass('active')) b.parent().removeClass('active'); });
        b.mousedown(function () { var b = jQuery(this); b.parent().removeClass("hover"); if (!b.hasClass('active')) b.parent().addClass('active'); });
        b.mouseup(function () { var b = jQuery(this); if (!b.hasClass('active')) b.parent().removeClass('active'); });
    });
}
jQuery(function() { artButtonSetup("rd-button"); });

/* end Button */

/* begin VMenu */
jQuery(function() {
    if (!jQuery('html').hasClass('ie7')) return;
    jQuery('ul.rd-vmenu li:not(:first-child),ul.rd-vmenu li li li:first-child,ul.rd-vmenu>li>ul').each(function () { jQuery(this).append('<div class="rd-vmenu-separator"> </div><div class="rd-vmenu-separator-bg"> </div>'); });
});


/* end VMenu */



jQuery(function () {
    artButtonSetup("button");
});

/* Code below added by Dan Schaefer of Ruysdael Design, 2/7/2012 */
var loveLeft, loveTop, loveWidth, loveHeight;
var playLeft, playTop, playWidth, playHeight;
var workLeft, workTop, workWidth, workHeight;
var thriveLeft, thriveTop, thriveWidth, thriveHeight;
var whose_alive = 'none';
var love_top  = 31;
var thrive_left = 682;
var thrive_top  = 9;
var work_left = 180;
var work_top = 5;
var play_left = 520;
var play_top = 53;
var tHeaderEvent;
var timerHeaderRunning = false;
var fadeHeaderUpTime = 1000;
var holdHeaderTime = 1500; // milliseconds to hold
var cycleHeaderTime = 20000;
jQuery(function() {
	jQuery('div.rd-header img.header-graphic').each(function(index, element) {
        jQuery(element).fadeTo(0,0).css('display','none');
    });
	startHeaderTimer();
});

//
    function headerTick() {
	stopHeaderTimer();
	switch(whose_alive) {
		case 'none':
			jQuery('#love-graphic').css('width',loveWidth).
			css('height',loveHeight).
			css('left',loveLeft).
			css('top',loveTop);
			jQuery('#play-graphic').css('width',playWidth).
			css('height',playHeight).
			css('left',playLeft).
			css('top',playTop);
			jQuery('#work-graphic').css('width',workWidth).
			css('height',workHeight).
			css('left',workLeft).
			css('top',workTop).
			fadeTo(fadeHeaderUpTime,1);
			jQuery('#thrive-graphic').css('width',thriveWidth).
			css('height',thriveHeight).
			css('left',thriveLeft).
			css('top',thriveTop);
			whose_alive = 'work';
			startHeaderTimer(holdHeaderTime);
			break;
		case 'work':
			jQuery('#love-graphic').fadeTo(fadeHeaderUpTime,1);
			whose_alive = 'love';
			startHeaderTimer(holdHeaderTime);
			break;
		case 'love':
			jQuery('#play-graphic').fadeTo(fadeHeaderUpTime,1);
			whose_alive = 'play';
			startHeaderTimer(holdHeaderTime);
			break;
		case 'play':
			jQuery('#thrive-graphic').fadeTo(fadeHeaderUpTime,1);
			whose_alive = 'thrive';
			startHeaderTimer(cycleHeaderTime);
			break;
		case 'thrive':
			// sample measurements before everything blows up, allowing us to
			// reset them back to their original 
			loveWidth = jQuery('#love-graphic').css('width');
			loveHeight = jQuery('#love-graphic').css('height');
			loveLeft = jQuery('#love-graphic').css('left');
			loveTop = jQuery('#love-graphic').css('top');
			playWidth = jQuery('#play-graphic').css('width');
			playHeight = jQuery('#play-graphic').css('height');
			playLeft = jQuery('#play-graphic').css('left');
			playTop = jQuery('#play-graphic').css('top');
			workWidth = jQuery('#work-graphic').css('width');
			workHeight = jQuery('#work-graphic').css('height');
			workLeft = jQuery('#work-graphic').css('left');
			workTop = jQuery('#work-graphic').css('top');
			thriveWidth = jQuery('#thrive-graphic').css('width');
			thriveHeight = jQuery('#thrive-graphic').css('height');
			thriveLeft = jQuery('#thrive-graphic').css('left');
			thriveTop = jQuery('#thrive-graphic').css('top');
			jQuery('.header-graphic').each(function() {
				var position = jQuery(this).position();
				jQuery(this)
				.css({
					top: position.top,
					left: position.left})
				.animate ({
					opacity: 'hide',
					width: jQuery(this).width() * 5,
					height: jQuery(this).height() * 5,
					top: position.top - (jQuery(this).height() * 5 / 2),
					left: position.left - (jQuery(this).width() * 5 / 2)
				},'normal');
			});
			whose_alive = 'none';
			startHeaderTimer(holdHeaderTime);
	}
}
//
function startHeaderTimer(runTime) {
	if (!timerHeaderRunning) {
		tHeaderEvent = setTimeout("headerTick()",runTime);
		//tHeaderEvent = setTimeout('headerTick()',holdHeaderTime);
		timerHeaderRunning = true;
	}
}
//
function stopHeaderTimer() {
	if (timerHeaderRunning) {
		clearTimeout(tHeaderEvent);
		timerHeaderRunning = false;
	}
}


