﻿// Setup global Vars

//Add the startup code to the page
window.addEvent('domready', function() {



    $$("#CallMeBackFormButtonID").each(function(e, i, a) {
        e.addEvent("mouseover", function() {
        e.setProperty("class", "CallMeBackFormButtonRollover");
        });


        e.addEvent("mouseleave", function() {
            e.setProperty("class", "CallMeBackFormButton");
        });
    });
    $('CallMeBackName').addEvent("focus", function() {
        if ($('CallMeBackName').getProperty('value') == "Name *") {
            $('CallMeBackName').setProperty('value', "");
        }
    });

    $('CallMeBackName').addEvent("blur", function() {
        if ($('CallMeBackName').getProperty('value') == "") {
            $('CallMeBackName').setProperty('value', "Name *");
        }
    });


    $('CallMeBackCompany').addEvent("focus", function() {
        if ($('CallMeBackCompany').getProperty('value') == "Company *") {
            $('CallMeBackCompany').setProperty('value', "");
        }
    });

    $('CallMeBackCompany').addEvent("blur", function() {
        if ($('CallMeBackCompany').getProperty('value') == "") {
            $('CallMeBackCompany').setProperty('value', "Company *");
        }
    });



    $('CallMeBackPhone').addEvent("focus", function() {
        if ($('CallMeBackPhone').getProperty('value') == "Phone *") {
            $('CallMeBackPhone').setProperty('value', "");
        }
    });

    $('CallMeBackPhone').addEvent("blur", function() {
        if ($('CallMeBackPhone').getProperty('value') == "") {
            $('CallMeBackPhone').setProperty('value', "Phone *");
        }
    });

    $('CallMeBackEmail').addEvent("focus", function() {
        if ($('CallMeBackEmail').getProperty('value') == "Email *") {
            $('CallMeBackEmail').setProperty('value', "");
        }
    });

    $('CallMeBackEmail').addEvent("blur", function() {
        if ($('CallMeBackEmail').getProperty('value') == "") {
            $('CallMeBackEmail').setProperty('value', "Email *");
        }
    });



    $('CallMeBackFormID').addEvent("submit", function() {

        var msg = "";

        if (($('CallMeBackEmail').getProperty('value').length == 0) ||
        $('CallMeBackEmail').getProperty('value') == "Email *") {
            msg += "Please enter email address \n";
            $('CallMeBackEmail').focus();
            $('CallMeBackEmail').morph({ "background-color": ["#FF0000", "#e6e7e8"] })
        }

        if (($('CallMeBackPhone').getProperty('value').length == 0) ||
        $('CallMeBackPhone').getProperty('value') == "Phone *") {
            msg += "Please enter phone number \n";
            $('CallMeBackPhone').focus();
            $('CallMeBackPhone').morph({ "background-color": ["#FF0000", "#e6e7e8"] })
        }

        if (($('CallMeBackCompany').getProperty('value').length == 0) ||
        $('CallMeBackCompany').getProperty('value') == "Company *") {
            msg += "Please enter company name \n";
            $('CallMeBackCompany').focus();
            $('CallMeBackCompany').morph({ "background-color": ["#FF0000", "#e6e7e8"] })
        }

        if (($('CallMeBackName').getProperty('value').length == 0) ||
        $('CallMeBackName').getProperty('value') == "Name *") {
            msg += "Please enter your Name \n";
            $('CallMeBackName').focus();
            $('CallMeBackName').morph({ "background-color": ["#FF0000", "#e6e7e8"] })
        }


        if (msg.length > 0) {
            return false;
        }

        return true;
    });
});

