﻿/// <reference path="jquery-vsdoc.js" />
//*************************************************************************************
// File     : vsjc_functions.js
// Requires : jquery.js (version 1.3.2+)
// Author   : Kyle Weems (ksw)
// Origin   : mindfly.com
// Created  : Jan 18, 2010
// Modified : Jun 10, 2010
//*************************************************************************************

$(document).ready(function() {
    // featureSlider();
    BrainGnat.slideshow.panelSlide('#rotator .slider li', '#rotator .controls li', 720, 0);
    smartMenu();
    signupFocus();
    pseudoMenuHover();
});

function pseudoMenuHover(){
    $('#menu li').mouseover(function(){$(this).addClass('over');});
    $('#menu li').mouseout(function(){$(this).removeClass('over');});
}

function smartMenu() {
    $('#menu > li').mouseenter(function() {
        var w = 0;
        if ($(this).children('ul').length < 1) {
            $(this).addClass('childless');
        } else {
            var tallest = 0;
            for (i = 0; i < $(this).children('ul').children('li').length; i++) {
                var current = $(this).children('ul').children('li:eq(' + i + ')')
                w = w + current.outerWidth();
                if (current.height() > tallest) {
                    tallest = current.height();
                }
            }
            $(this).children('ul').css('width', w + 'px');
            $(this).children('ul').children('li').css('height', tallest + 'px');
            adjustMenu($(this).children('ul'));
        }
    });
}

function adjustMenu(e) {
    var left = e.parent().position().left;
    if (e.outerWidth() + left > $('#header').width()) {
        e.css('margin-left', "-"+((e.outerWidth() + left + 20) - $('#header').width()) + 'px');
    }
}

function signupFocus() {
    $('#ea').focus(function() { if ($(this).attr('value') == 'email address') { $(this).attr('value', ''); $(this).css('color', 'rgba(100, 148, 132, 1)'); } });
    $('#ea').blur(function() { if ($(this).attr('value') == '') { $(this).attr('value', 'email address');  $(this).css('color', 'rgba(100, 148, 132, 0.49)'); } });
}