﻿(function() {
    var po = document.createElement('script'); po.type = 'text/javascript'; po.async = true;
    po.src = 'https://apis.google.com/js/plusone.js';
    var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(po, s);
  })();

$(window).load(function()
{
    $('#slider').nivoSlider({
        effect:'random', // Specify sets like: 'fold,fade,sliceDown'
        slices:15, // For slice animations
        boxCols: 15, // For box animations
        boxRows: 6, // For box animations
        animSpeed:400, // Slide transition speed
        pauseTime:7000, // How long each slide will show
        startSlide:0, // Set starting Slide (0 index)
        directionNav: false,
        pauseOnHover:true
    });
});

$(document).ready(function ()
{
    // Top navigation -- BEGIN
    $(".navigation li .wrapper").mouseover(
            function ()
            {
                if ($(this).find(".hover").children().size() > 0)
                {
                    $(this).find(".hover").delay(300).slideDown("slow");
                }
            }
        );

    $(".navigation li .wrapper").mouseout(
            function (e)
            {
                if ($.contains(this, e.relatedTarget) == false)
                {
                    $(this).find(".hover").stop(true, true);
                    $(this).find(".hover").removeAttr("style");
                    $(this).find(".hover").hide();
                }
            }
        );
    // Top navigation -- END

});

function imageswap(obj, img) 
{
    $(obj).attr("src", img);
}



function checkvoltage()
{
    var Amps = $("#Amps").val();
    var kcheck = $("#kselect").val();
    var volt = $("#Voltage").val();
    var pwfact = $("#pwfactor").val();
    var radio = $("input[name=RadioGroup1]:checked").val();
    var divide = 1;
    // Added below in for if the user changes the phase after it is set by default.
    if (radio == "single_phase")
    { // RadioGroup1[0] = Single phase.
        divide = 1;
    } 
    else
    {
        divide = Math.sqrt(3);
    }

    if (Amps != "" && volt != "")
    {
        $("#kVA").val(Math.round(((Amps * volt * divide) / 1000) * Math.pow(10, 0)) / Math.pow(10, 0));
        $("#kW").val(Math.round(($("#kVA").val() * pwfact) * Math.pow(10, 0)) / Math.pow(10, 0));
    }
}
function voltcheck()
{
    var Amps = $("#Amps").val();
    var kcheck = $("#kselect").val();
    var volt = $("#Voltage").val();
    var pwfact = $("#pwfactor").val();
    var radio = $("input[name=RadioGroup1]:checked").val();
    var divide;
    if (volt < 240)
    {//default to single phase
        $("input[name=RadioGroup1][value=single_phase]").attr("checked", true);
        divide = 1;
    } 
    else
    { //default to three phase
        $("input[name=RadioGroup1][value=three_phase]").attr("checked", true);
        divide = Math.sqrt(3);
    }

    $("#kVA").val(Math.round(((Amps * volt * divide) / 1000) * Math.pow(10, 0)) / Math.pow(10, 0));
    $("#kW").val(Math.round(($("#kVA").val() * pwfact) * Math.pow(10, 0)) / Math.pow(10, 0));
}
function kchecker()
{
    var Amps = $("#Amps").val();
    var kcheck = $("#kselect").val();
    var volt = $("#Voltage").val();
    //var pwfact = $("#pwfactor").val();
    var radio = $("input[name=RadioGroup1]:checked").val();

    var pwfact = 1;
    var divide = 1;
    if (kcheck == "kVA")
    {
        $("#pwfactor").val("1");
        $("#pwfactor").attr("disabled", "disabled");
    } 
    else
    {
        $("#pwfactor").val("0.8");
        $("#pwfactor").attr("disabled", "");
    }

    pwfact = $("#pwfactor").val();
    $("#kVA").val(Math.round(((Amps * volt * divide) / 1000) * Math.pow(10, 0)) / Math.pow(10, 0));
    $("#kW").val(Math.round(($("#kVA").val() * pwfact) * Math.pow(10, 0)) / Math.pow(10, 0));
}

function TestSearchContents()
{
    if ($("input[id*=SearchText]").val() == "Search Our Site")
    {
        $("input[id*=searchErrorMessag]e").show();
        return false;
    }
    $("input[id*=searchErrorMessage]").hide();
    return true;
}
