﻿$(document).ready(function () {

    /****nav js***
    $('#navigationMenu li .normalMenu').each(function () {

        $(this).before($(this).clone().removeClass().addClass('hoverMenu'));

    });

    $('#navigationMenu li').hover(function () {

        $(this).find('.hoverMenu').stop().animate({ marginTop: '0px' }, 200);

    },

	function () {

	    $(this).find('.hoverMenu').stop().animate({ marginTop: '-63px' }, 200);

	});
    /****nav js end***/

    //toggle boxes
    //Hide (Collapse) the toggle containers on load
    $(".toggle_container").hide();

    //Switch the "Open" and "Close" state per click then slide up/down (depending on open/close state)
    $("h2.trigger").click(function () {
        $(this).toggleClass("active").next().slideToggle("fast");
    });


    $('.backToTop').click(function () {
        $('html, body').animate({ scrollTop: 0 }, 'slow');
        return false;
    });


    //Focus and Blur Text
    $('.itcyInput').focus(function () {
        var currentValue = this.value;
        var defaultText = $('#' + this.id).attr('rel');

        if (currentValue == defaultText) {
            this.value = "";
        }
        else {
            return false;
        }
    });

    //Focus and Blur Text
    $('.itcyInput').blur(function () {
        var currentValue = this.value;
        var defaultText = $('#' + this.id).attr('rel');

        if (currentValue == "") {
            this.value = defaultText;
        }
        else {
            return false;
        }
    });

    //Check opperating system (really made my job harder - thanks a lot Mac.)
    var mac = $.browser.mac(); //returns true or false
    //var safari = $.browser.safari(); //returns true or false
    var firefox = $.browser.firefox(); //returns true or false

    if (mac) {       
        if (firefox) {
            $('head').append('<link rel="stylesheet" href="styles/styles-macFireFox.css" type="text/css" />');
        }
        else {
            //so this is safari and opera and chrome on mac
            $('head').append('<link rel="stylesheet" href="styles/styles-macSafari-Opera-Chrome.css" type="text/css" />');
        }
    }

});

//Focus and Blur Text Boxes
function focusField(obj, shouldBeText) {

    if (obj.value == shouldBeText) {
        obj.value = "";
    }

}
function blurField(obj, replaceValueWithString) {
    if (obj.value == "") {
        obj.value = replaceValueWithString;
    }
}
