﻿    // Validates empty strings
    function ValidateEmpty(source, arguments)
    {
        if (arguments.Value == '')
            arguments.IsValid = false;
        else
            arguments.IsValid = true;            
    }





    // Validates e-mail addresses
    function CheckEmail(source,arguments)
    {
        var reg = new RegExp("\\w+([-+.']\\w+)*@\\w+([-.]\\w+)*\\.\\w+([-.]\\w+)*");

        if (reg.test(arguments.Value) == true){
            arguments.IsValid = true;
        }else{
            arguments.IsValid = false;
        }
    }
    




    // Validates contact us drop down
    function ValidateDropDown(source,arguments)
    {
        if (arguments.Value == '-')
            arguments.IsValid = false;
        else
            arguments.IsValid = true;
    }





    // Validates text box length
    function ValidateLength(source,arguments)
    {
        if (arguments.Value.length > source.MaximumLength){
            arguments.IsValid = false;
        }else{
            arguments.IsValid = true;
        }
    }





    
    function CheckContent(source,arguments)
    {
        var reg = new RegExp("[^\\w\\s.\"@',&/?-]");

        if (reg.test(arguments.Value) == true){
            arguments.IsValid = false;
        }else{
            arguments.IsValid = true;
        }
    }





    
    function CheckString(source,arguments)
    {
        var reg = new RegExp("[^\\w\\s.\",'-]");

        if (reg.test(arguments.Value) == true){
            arguments.IsValid = false;
        }else{
            arguments.IsValid = true;
        }
    }
    
    
    
    
    
        
    /*  provide a radio button element and it unselects the other 
        radio button withing the group provided excluding the one passed */
    function radioButtonSelector(radioButton, groupName)
    {
        var objItem = radioButton.children;
        var objRadioButton = (radioButton.type=="radio") ? radioButton : radioButton.children.item[0];
        var blnState=objRadioButton.checked;

        for(i=0; i<objRadioButton.form.elements.length; i++) {

            var radioElement = objRadioButton.form.elements[i];

            if (radioElement.type=="radio" && radioElement.name.indexOf(groupName) != -1) {

                radioElement.checked = false;
            }
        }
        
        objRadioButton.checked = blnState;
    }

