﻿$(document).ready(Setup);

function Setup() {
    SetUpBsLink();
    inputReseter($('.login-form input.username'), 'Username');
    inputReseter($('.login-form input.password'), 'Password');
}


function SetUpBsLink() {
    document.getElementById('blue').onmouseover = BSLinkOver;
    document.getElementById('switch').onmouseover = BSLinkOver;

    document.getElementById('blue').onmouseout = BSLinkOut;
    document.getElementById('switch').onmouseout = BSLinkOut;
}

function BSLinkOver() {
    document.getElementById('blue').style.color = '#00479C';
    document.getElementById('switch').style.color = '#FF9933';
}

function BSLinkOut() {
    document.getElementById('blue').style.color = '';
    document.getElementById('switch').style.color = '';
}

function SetUpAboutNav() {
    $('.about-nav').hover(AboutOver, AboutOut);
}

function AboutOver(about_element) {
    new_src = $(about_element.currentTarget).children('img').attr('src').replace('-off.png', '-on.png');
    $(about_element.currentTarget).children('img').attr('src', new_src);
}

function AboutOut(about_element) {
    new_src = $(about_element.currentTarget).children('img').attr('src').replace('-on.png', '-off.png');
    $(about_element.currentTarget).children('img').attr('src', new_src);
}

function SetAboutSelected(num) {
    about_element = $($('.about-nav')[num]);
    
    //Set the image to 'on'
    new_src = about_element.children('img').attr('src').replace('-off.png', '-on.png');
    about_element.children('img').attr('src', new_src);

    //Remove the mouseover
    about_element.unbind('mouseenter').unbind('mouseleave');
}

function EmailPage() {
    mail_str = "mailto:?subject=Check this out: " + document.title;
    mail_str += "&body=" + document.title;
    mail_str += ". Check it out here: " + location.href;
    location.href = mail_str;
}

function inputReseter(jqObj, iniVal) {
    $(jqObj).focus(function () {
        value = $(this).val();
        if (value == iniVal) {
            $(this).val('');
        } else {
            // user has ented input, do nothing
        }
    });
    $(jqObj).blur(function () {
        if ($(this).val() === '') {
            $(this).val(iniVal);
        } else {
            // user has ented input, do nothing
        }
    });
}
